示例#1
0
    def run_once(self):
        """
        Open browser, and affect brightness using  up and down functions.

        @raises: error.TestFail if brightness keys (F6/F7) did not work.

        """
        # Check for internal_display
        if not graphics_utils.has_internal_display():
            raise error.TestNAError('Test can not proceed on '
                                    'devices without internal display.')
        with chrome.Chrome():
            logging.info("Increasing the initial brightness to max without "
                         "verifying brightness.")
            # Not using command to set max brightness because
            # the brightness button stays at the current level
            # only irrespective of the command
            self.test_brightness_up(verify_brightness=False)
            # Actual test starts from here.
            self.test_brightness_down(verify_brightness=True)
            self.test_brightness_up(verify_brightness=True)
示例#2
0
 def run_once(self):
     """Sets up a router, connects to it, pings it, and repeats."""
     client_mac = self.context.client.wifi_mac
     for router_conf, client_conf in self._configurations:
         if router_conf.is_11ac:
             router_caps = self.context.router.capabilities
             if site_linux_system.LinuxSystem.CAPABILITY_VHT not in \
                     router_caps:
                 raise error.TestNAError('Router does not have AC support')
         self.context.configure(router_conf)
         self.context.capture_host.start_capture(
             router_conf.frequency,
             ht_type=router_conf.ht_packet_capture_mode)
         client_conf.ssid = self.context.router.get_ssid()
         assoc_result = self.context.assert_connect_wifi(client_conf)
         if client_conf.expect_failure:
             logging.info('Skipping ping because we expected this '
                          'attempt to fail.')
         else:
             with self.context.client.assert_no_disconnects():
                 self.context.assert_ping_from_dut()
             if self.context.router.detect_client_deauth(client_mac):
                 raise error.TestFail(
                     'Client de-authenticated during the test')
             self.context.client.shill.disconnect(client_conf.ssid)
             times_dict = {
                 'Discovery': assoc_result.discovery_time,
                 'Association': assoc_result.association_time,
                 'Configuration': assoc_result.configuration_time
             }
             for key in times_dict.keys():
                 self.output_perf_value(
                     description=key,
                     value=times_dict[key],
                     units='seconds',
                     higher_is_better=False,
                     graph=router_conf.perf_loggable_description)
         self.context.client.shill.delete_entries_for_ssid(client_conf.ssid)
         self.context.router.deconfig()
         self.context.capture_host.stop_capture()
    def run_once(self, host, full_payload=True, job_repo_url=None):
        """
        Trys an autoupdate during ChromeOS OOBE without a deadline.

        @param host: The DUT that we are running on.
        @param full_payload: True for a full payload. False for delta.
        @param job_repo_url: Used for debugging locally. This is used to figure
                             out the current build and the devserver to use.
                             The test will read this from a host argument
                             when run in the lab.

        """
        self._host = host

        # veyron_rialto is a medical device with a different OOBE that auto
        # completes so this test is not valid on that device.
        if 'veyron_rialto' in self._host.get_board():
            raise error.TestNAError('Rialto has a custom OOBE. Skipping test.')

        update_url = self.get_update_url_for_test(job_repo_url,
                                                  full_payload=full_payload,
                                                  critical_update=False)
        logging.info('Update url: %s', update_url)

        # Call client test to start the OOBE update.
        client_at = autotest.Autotest(self._host)
        client_at.run_test('autoupdate_StartOOBEUpdate',
                           image_url=update_url,
                           full_payload=full_payload,
                           critical_update=False)

        # Ensure that the update failed as expected.
        err_msg = 'finished OmahaRequestAction with code ' \
                  'ErrorCode::kNonCriticalUpdateInOOBE'
        output = self._host.run('cat /var/log/update_engine.log | grep "%s"' %
                                err_msg,
                                ignore_status=True).exit_status
        if output != 0:
            raise error.TestFail('Update did not fail with '
                                 'kNonCriticalUpdateInOOBE')
 def __init__(self,
              router,
              frame_type,
              channel,
              ssid_prefix=None,
              num_bss=None,
              frame_count=None,
              delay=None,
              dest_addr=None,
              probe_resp_footer=None,
              instance=0):
     """
     @param router: LinuxRouter object router to send frames from.
     @param frame_type: int management frame type.
     @param channel: int targeted channel.
     @param ssid_prefix: string SSID prefix for BSSes in the frames.
     @param num_bss: int number of BSSes configured for sending frames.
     @param frame_count: int number of frames to send, frame_count of 0
             implies infinite number of frames.
     @param delay: int delay in between frames in milliseconds.
     @param dest_addr: MAC address of the destination address (DA).
     @param probe_resp_footer: footer bytes for probe responses.
     @param instance: int hostapd instance on router to send frames from.
     """
     if router.board == "panther":
         raise error.TestNAError('Panther router does not support manual '
                                 'beacon frame generation')
     self._router = router
     self._channel = channel
     self._frame_type = frame_type
     self._ssid_prefix = ssid_prefix
     self._num_bss = num_bss
     self._frame_count = frame_count
     self._delay = delay
     self._dest_addr = dest_addr
     self._probe_resp_footer = probe_resp_footer
     self._ap_interface = router.hostapd_instances[instance].interface
     self._injection_interface = None
     self._pid = None
    def run_once(self, host, suspend_count, reset_type):
        """Verify deep sleep after suspending for the given number of cycles

        The test either suspends to s3 or reboots the device depending on
        reset_type. There are two valid reset types: mem and reboot. The test
        will make sure that the device is off or in s3 long enough to ensure
        Cr50 should be able to enter deep sleep. At the end of the test, it
        checks that Cr50 entered deep sleep the same number of times it
        suspended.

        @param host: the host object representing the DUT.
        @param suspend_count: The number of cycles to suspend or reboot the
                device.
        @param reset_type: a str with the cycle type: 'mem' or 'reboot'
        """
        if self.MIN_SUSPEND + self.MIN_RESUME < self.SLEEP_DELAY:
            logging.info(
                'Minimum suspend-resume cycle is %ds. This is '
                'shorter than the Cr50 idle timeout. Cr50 may not '
                'enter deep sleep every cycle',
                self.MIN_SUSPEND + self.MIN_RESUME)
        if not suspend_count:
            raise error.TestFail('Need to provide non-zero suspend_count')

        # Clear the deep sleep count
        logging.info('Clear Cr50 deep sleep count')
        self.cr50.clear_deep_sleep_count()

        if reset_type == 'reboot':
            self.run_reboots(suspend_count)
        elif reset_type == 'mem':
            self.run_suspend_resume(host, suspend_count)
        else:
            raise error.TestNAError(
                'Invalid reset_type. Use "mem" or "reboot"')

        # Cr50 should enter deep sleep once per suspend cycle if deep sleep is
        # supported
        self.check_cr50_state(suspend_count, self.original_cr50_version)
示例#6
0
    def run_once(self, host):
        """Runs the platform_CryptohomeLECredentialManager test across a reboot.
        """
        try:
            pinweaver_client.GetLog(host)
        except pinweaver_client.PinWeaverNotAvailableError:
            logging.info('PinWeaver not supported!')
            raise error.TestNAError('PinWeaver is not available')

        autotest.Autotest(host).run_test(
            'platform_CryptohomeLECredentialManager',
            pre_reboot=True,
            check_client_result=True)

        host.reboot()

        autotest.Autotest(host).run_test(
            'platform_CryptohomeLECredentialManager',
            pre_reboot=False,
            check_client_result=True)

        logging.info('Tests passed!')
    def initialize(self):
        # Check if the kernel supports cpu hotplug
        if utils.running_config():
            utils.check_for_kernel_feature('HOTPLUG_CPU')

        # Check cpu nums, if equals 1, quit.
        if utils.count_cpus() == 1:
            e_msg = 'Single CPU online detected, test not supported.'
            raise error.TestNAError(e_msg)

        # Have a simple and quick check first, FIX me please.
        utils.system('dmesg -c > /dev/null')
        for cpu in utils.cpu_online_map():
            if os.path.isfile('/sys/devices/system/cpu/cpu%s/online' % cpu):
                utils.system(
                    'echo 0 > /sys/devices/system/cpu/cpu%s/online' % cpu, 1)
                utils.system('dmesg -c')
                time.sleep(3)
                utils.system(
                    'echo 1 > /sys/devices/system/cpu/cpu%s/online' % cpu, 1)
                utils.system('dmesg -c')
                time.sleep(3)
示例#8
0
    def initialize(self, host, cmdline_args, dev_path='', full_args={}):
        # Restore the original image, rlz code, and board id during cleanup.
        super(firmware_Cr50GetName, self).initialize(host,
                                                     cmdline_args,
                                                     full_args,
                                                     restore_cr50_state=True,
                                                     cr50_dev_path=dev_path)

        if not self.host.path_exists(self.GET_NAME_SCRIPT):
            raise error.TestNAError('Device does not have "cr50-get-name"')

        # Update to the dev image so we can erase the board id after we set it.
        # This test is verifying cr50-get-name, so it is ok if cr50 is running a
        # dev image.
        self.cr50_update(self.get_saved_cr50_dev_path())

        # Stop trunksd so it wont interfere with the update
        cr50_utils.StopTrunksd(self.host)

        # Get the current cr50 update messages. The test will keep track of the
        # last message and separate the current output from actual test results.
        self.get_result()
    def run_once(self, host, plug_status, test_mirrored=False):

        # Check for chromebook type devices
        if not host.get_board_type() == 'CHROMEBOOK':
            raise error.TestNAError('DUT is not Chromebook. Test Skipped')
        self.host = host
        self.test_mirrored = test_mirrored
        self.errors = list()

        # Check the servo object
        if self.host.servo is None:
            raise error.TestError('Invalid servo object found on the host.')

        factory = remote_facade_factory.RemoteFacadeFactory(host)
        display_facade = factory.create_display_facade()
        chameleon_board = host.chameleon

        chameleon_board.reset()
        finder = chameleon_port_finder.ChameleonVideoInputFinder(
            chameleon_board, display_facade)
        for chameleon_port in finder.iterate_all_ports():
            self.run_test_on_port(chameleon_port, display_facade, plug_status)
    def run_once(self, host=None):
        self.client = host

        # Skip the test if the TPM is unavailable.
        tpm_status = tpm_utils.TPMStatus(self.client)
        if 'Enabled' not in tpm_status:
            raise error.TestError('Error obtaining TPM enabled state. Status '
                                  'returned by cryptohome: ' + str(tpm_status))
        if not tpm_status['Enabled']:
            raise error.TestNAError("TPM is not enabled")

        # Clear the TPM, so that the client test is able to obtain the TPM owner
        # password.
        tpm_utils.ClearTPMOwnerRequest(self.client, wait_for_ready=True)

        # Run the client test which executes the Cr50VirtualNVRam test.
        autotest.Autotest(self.client).run_test('firmware_Cr50VirtualNVRam',
                                                check_client_result=True)

        # Clean the TPM up, so that the TPM state set by the firmware
        # tests doesn't affect subsequent tests.
        tpm_utils.ClearTPMOwnerRequest(self.client)
    def run_once(self, dev_mode=False):
        if not self.faft_client.system.has_host():
            raise error.TestNAError(
                'DUT is not Android device.  Skipping test')

        self.faft_client.host.run_shell_command('adb reboot bootloader')
        # make sure that DUT goes offline first
        self.switcher.wait_for_client_offline()
        self.switcher.wait_for_client_fastboot()

        if not self.in_fastboot_mode():
            raise error.TestFail("DUT not in fastboot mode!")

        # try rebooting into OS
        logging.info("Testing fastboot reboot")
        self.faft_client.host.run_shell_command('fastboot reboot')
        # make sure that DUT goes offline first
        self.switcher.wait_for_client_offline()
        self.switcher.wait_for_client()

        # now reboot into fastboot again
        self.faft_client.host.run_shell_command('adb reboot bootloader')
        # make sure that DUT goes offline first
        self.switcher.wait_for_client_offline()
        self.switcher.wait_for_client_fastboot()
        if not self.in_fastboot_mode():
            raise error.TestFail("DUT not in fastboot mode!")

        logging.info("Testing fastboot reboot-bootloader")
        self.faft_client.host.run_shell_command('fastboot reboot-bootloader')
        # make sure that DUT goes offline first
        self.switcher.wait_for_client_offline()
        self.switcher.wait_for_client_fastboot()
        if not self.in_fastboot_mode():
            raise error.TestFail("DUT not in fastboot mode!")

        self.faft_client.host.run_shell_command('fastboot continue')
        self.switcher.wait_for_client()
示例#12
0
    def _check_sysfs(self, host):
        # First check that we are on a suitable DUT which offers the ability to
        # disable the idle state
        arch = host.run_output('uname -m')
        if arch != 'aarch64':
            # Idle states differ between CPU architectures, so this test would
            # need further development to support other platforms.
            raise error.TestNAError('Test only supports Arm aarch64 CPUs')
        if not host.path_exists(DISABLE_PATH.format(0, 1)):
            logging.error('sysfs path absent: cannot disable idle state')
            raise error.TestError('Cannot disable idle state')

        # Identify available idle states. state0 is running state; other states
        # should be disabled when disabling idle.
        self.states = []
        state_dirs = host.run_output(
            'ls -1 /sys/devices/system/cpu/cpu0/cpuidle/')
        for state in state_dirs.split('\n'):
            if re.match('state[1-9][0-9]*$', state):
                # Look for dirnames like 'state1' (but exclude 'state0')
                self.states.append(int(state[5:]))
        logging.info('Found idle states: {}'.format(self.states))

        self.cpu_count = int(host.run_output('nproc --all'))
        logging.info('Found {} cpus'.format(self.cpu_count))
        logging.info('Idle enabled = {}'.format(self._is_idle_enabled(host)))

        # From this point on we expect the test to be able to run, so we will
        # need to ensure that the idle state is restored when the test exits
        self._cleanup_required = True
        self._enable_idle(host, False)
        if self._is_idle_enabled(host):
            logging.error('Failed to disable idle state')
            raise error.TestError('Cannot disable idle state')
        self._enable_idle(host, True)
        if not self._is_idle_enabled(host):
            logging.error('Failed to re-enable idle state')
            raise error.TestError('Cannot disable idle state')
    def run_once(self, host, loop_count):
        self.host = host
        dut_type = host.get_board_type()
        if dut_type != 'CHROMEBOOK':
            raise error.TestNAError('This test is not supported on %s' %
                                    dut_type)
        self.autotest_client = autotest.Autotest(self.host)

        # Start as powered on
        if self.host.has_power():
            self.host.power_on()
        else:
            raise error.TestError('No RPM is setup to device')

        # Check if DUT has lid.
        self.has_lid = True
        if self.host.servo.get('lid_open') == 'not_applicable':
            self.has_lid = False
        else:
            # Check if lid_open control is good.
            self.host.servo.lid_open()
            if self.host.servo.get('lid_open') != 'yes':
                self.has_lid = False

        # Login to device
        self.action_login()

        pdu_connected = True
        for i in xrange(loop_count):
            logging.info('--- Iteration %d', (i + 1))

            # Discharging state
            expected = ('no', 'Disconnected', 'Discharging')
            self.switch_power_and_verify(False, expected)

            # Charging state - it could be any of the three below
            expected = ('yes', 'AC', '(Charging|Fully charged)')
            self.switch_power_and_verify(True, expected)
    def hostap_configure(self, configuration, multi_interface=None):
        """Build up a hostapd configuration file and start hostapd.

        Also setup a local server if this router supports them.

        @param configuration HosetapConfig object.
        @param multi_interface bool True iff multiple interfaces allowed.

        """
        if multi_interface is None and (self.hostapd_instances or
                                        self.station_instances):
            self.deconfig()
        if configuration.is_11ac:
            router_caps = self.get_capabilities()
            if site_linux_system.LinuxSystem.CAPABILITY_VHT not in router_caps:
                raise error.TestNAError('Router does not have AC support')

        self.start_hostapd(configuration)
        interface = self.hostapd_instances[-1].interface
        self.iw_runner.set_tx_power(interface, 'auto')
        self.set_beacon_footer(interface, configuration.beacon_footer)
        self.start_local_server(interface)
        logging.info('AP configured.')
示例#15
0
    def run_once(self):
        # TODO(victoryang): make this test run on both x86 and arm
        if not self.check_ec_capability(['x86', 'lid']):
            raise error.TestNAError(
                "Nothing needs to be tested on this device")

        logging.info("Suspend and wake by power button.")
        self.suspend()
        self.switcher.wait_for_client_offline()
        self.servo.power_normal_press()
        self.switcher.wait_for_client()

        logging.info("Suspend and wake by lid switch.")
        self.suspend()
        self.switcher.wait_for_client_offline()
        self.servo.set('lid_open', 'no')
        time.sleep(self.LID_DELAY)
        self.servo.set('lid_open', 'yes')
        self.switcher.wait_for_client()

        logging.info("EC hibernate and wake by power button.")
        self.hibernate_and_wake_by_power_button()
        self.switcher.wait_for_client()
    def run_once(self):
        if not self.check_ec_capability():
            raise error.TestNAError(
                "Nothing needs to be tested on this device")

        logging.info("Shutdown when powerd is still running and wake from S5 "
                     "with short power button press.")

        if self.servo.is_localhost():
            self.check_state(self.debounce_power_button)
        self.switcher.mode_aware_reboot(
            'custom', lambda: self.shutdown_and_wake(
                self.POWER_BUTTON_POWERD_DURATION, self.SHORT_WAKE_DELAY, self.
                POWER_BUTTON_SHORT_POWER_ON_DURATION))

        logging.info("Shutdown when powerd is stopped and wake from G3 "
                     "with short power button press.")
        self.kill_powerd()
        self.switcher.mode_aware_reboot(
            'custom', lambda: self.shutdown_and_wake(
                self.POWER_BUTTON_NO_POWERD_DURATION, self.LONG_WAKE_DELAY,
                self.POWER_BUTTON_SHORT_POWER_ON_DURATION))

        logging.info("Shutdown when powerd is still running and wake from G3 "
                     "with long power button press.")
        self.switcher.mode_aware_reboot(
            'custom', lambda: self.shutdown_and_wake(
                self.POWER_BUTTON_POWERD_DURATION, self.LONG_WAKE_DELAY, self.
                POWER_BUTTON_LONG_POWER_ON_DURATION))

        logging.info("Shutdown when powerd is stopped and wake from S5 "
                     "with long power button press.")
        self.kill_powerd()
        self.switcher.mode_aware_reboot(
            'custom', lambda: self.shutdown_and_wake(
                self.POWER_BUTTON_NO_POWERD_DURATION, self.SHORT_WAKE_DELAY,
                self.POWER_BUTTON_LONG_POWER_ON_DURATION))
示例#17
0
    def run_once(self, host):
        router_hostname = site_linux_router.build_router_hostname(
            client_hostname=host.hostname,
            router_hostname=self._router_hostname_from_cmdline)
        router_host = hosts.create_host(router_hostname)
        board = router_host.get_board().split(':', 1)[1]  # Remove 'board:'
        desired = self.STABLE_VERSIONS.get(board, None)
        if desired is None:
            raise error.TestFail('No stable version found for for router with '
                                 'board=%s.' % board)

        logging.info(
            'Checking whether router is at the latest '
            'stable version: %s', desired.release_version)
        current_release_version = self.get_release_version(router_host)
        if desired.release_version == current_release_version:
            raise error.TestNAError('%s is already at latest version %s.' %
                                    (router_hostname, desired.release_version))

        logging.info('Updating %s to image %s from %s', router_hostname,
                     desired.release_version, current_release_version)
        logging.info('Staging artifacts.')
        try:
            ds = dev_server.ImageServer.resolve(desired.builder_version,
                                                router_hostname)
            ds.stage_artifacts(desired.builder_version,
                               ['full_payload', 'stateful'])
        except dev_server.DevServerException as e:
            logging.error(e)
            raise error.TestFail(str(e))

        url = self.get_update_url(ds.url(), desired.builder_version)
        try:
            router_host.machine_install(force_update=True, update_url=url)
        except error.InstallError as e:
            logging.error(e)
            raise error.TestFail(str(e))
示例#18
0
    def _run_standalone(self, group):
        os.chdir(self.XFS_TESTS_PATH)
        logging.debug("Environment variables: %s", os.environ)
        output = utils.system_output('bash ./check -E %s -g %s' %
                                     (self.XFS_EXCLUDE_FILENAME, group),
                                     ignore_status=True,
                                     retain_output=True)
        lines = output.split('\n')
        result_line = lines[-2]

        if self.NA_RE.match(result_line):
            raise error.TestNAError('Test dependency failed, no tests run')

        elif self.FAILED_RE.match(result_line):
            failures_line = re.match(r'Failures: (?P<tests>.*)', lines[-3])
            if failures_line:
                test_failures = failures_line.group('tests')
                tests = test_failures.split(' ')
                for test in tests:
                    result_full = os.path.join('results',
                                               '.'.join([test, 'full']))
                    result_full_loc = os.path.join(self.XFS_TESTS_PATH,
                                                   result_full)
                    if os.path.isfile(result_full_loc):
                        test_name = test.replace('/', '_')
                        shutil.copyfile(
                            result_full_loc,
                            os.path.join(self.resultsdir,
                                         '%s.full' % test_name))
            raise error.TestError('%s. Check debug logs for complete '
                                  'test output' % result_line)

        elif self.PASSED_RE.match(result_line):
            return
        else:
            raise error.TestError('Could not assert success or failure, '
                                  'assuming failure. Please check debug logs')
示例#19
0
    def run_once(self, host, client_autotest):
        """This test verify that user should get default brightness
        after rebooting the device with maximum brigntness level.
        """
        if host.has_internal_display() is None:
            raise error.TestNAError('Test can not processed on '
                                    'devices without internal display')
        self.is_freon_build(host)
        autotest_client = autotest.Autotest(host)
        host.reboot()
        autotest_client.run_test(client_autotest, exit_without_logout=True)

        initial_bright = self.backlight_control(self.GET_BRIGHTNESS_FLAG, host)

        if initial_bright < 10.0 or initial_bright > 90.0:
            raise error.TestFail('Default brightness level is out '
                                 'of scope(10% - 90%): %f' % (initial_bright))

        self.backlight_control('%s=0' % (self.SET_BRIGHTNESS_FLAG), host)
        if not self.backlight_control(self.GET_BRIGHTNESS_FLAG, host) == 0:
            raise error.TestFail('Not able to change the brightness '
                                 'to minum(0%) level')
        self.backlight_control('%s=100' % (self.SET_BRIGHTNESS_FLAG), host)
        if not self.backlight_control(self.GET_BRIGHTNESS_FLAG, host) == 100:
            raise error.TestFail('Not able to change the brightness '
                                 'to maximum(100%) level')

        host.reboot()
        autotest_client.run_test(client_autotest, exit_without_logout=True)
        bright_after_reboot = self.backlight_control(self.GET_BRIGHTNESS_FLAG,
                                                     host)
        if not initial_bright == bright_after_reboot:
            raise error.TestFail('Not able to reset default brightness\n'
                                 'Previous boot default brightness: %f\n'
                                 'Current boot default brightness: %f' %
                                 (initial_bright, bright_after_reboot))
    def initialize(self,
                   host,
                   value,
                   force=False,
                   is_test_na=False,
                   repair=False):
        """Initialize.

        @param host: The host object to update to |value|.
        @param value: String of the image we want to install on the host.
        @param force: not used by initialize.
        @param is_test_na: boolean, if True, will simply skip the test
                           and emit TestNAError. The control file
                           determines whether the test should be skipped
                           and passes the decision via this argument. Note
                           we can't raise TestNAError in control file as it won't
                           be caught and handled properly.
        @param repair: not used by initialize.
        """
        if is_test_na:
            raise error.TestNAError('Provisioning not applicable.')
        # We check value in initialize so that it fails faster.
        if not (value or repair):
            raise error.TestFail('No build version specified.')
示例#21
0
    def run_once(self, host, ping_timeout=30, logged_in=True):
        self._host = host
        if 'veyron_rialto' in self._host.get_board():
            raise error.TestNAError('Skipping test on rialto device.')

        self._check_rlz_brand_code()

        # Clear TPM owner so we have no users on DUT.
        tpm_utils.ClearTPMOwnerRequest(self._host)

        # Setup DUT to send rlz ping after a short timeout.
        self._set_vpd_values()
        self._make_rootfs_writable()
        self._reduce_rlz_ping_delay(ping_timeout)
        self._host.reboot()

        # Login, do a Google search, check for CAF event in RLZ Data file.
        client_at = autotest.Autotest(self._host)
        client_at.run_test(self._CLIENT_TEST,
                           ping_timeout=ping_timeout,
                           logged_in=logged_in)
        client_at._check_client_test_result(self._host, self._CLIENT_TEST)

        self._check_rlz_vpd_settings_post_ping()
示例#22
0
    def get_reset_driver(self):
        DRIVER_LIST = [
            self.DriverReset(
                supported=self.mwifiex_reset_exists,
                do_reset=self.mwifiex_reset,
                need_reboot=lambda: not self.mwifiex_reset_exists(),
            ),
            self.DriverReset(
                supported=self.ath10k_reset_exists,
                do_reset=self.ath10k_reset,
                need_reboot=lambda: not self.ath10k_reset_exists(),
            ),
            self.DriverReset(
                supported=self.iwlwifi_reset_exists,
                do_reset=self.iwlwifi_reset,
                need_reboot=lambda: not self.iwlwifi_reset_exists(),
            ),
        ]

        for driver in DRIVER_LIST:
            if driver.supported():
                return driver
        else:
            raise error.TestNAError('DUT does not support device reset')
    def run_upstart_tests(self):
        """
        Run some sanity tests for cupsd and the upstart-socket-bridge
        socket-activation.
        """
        if not upstart.has_service('cupsd'):
            raise error.TestNAError('No cupsd service found')

        upstart.ensure_running('upstart-socket-bridge')

        if not self.wait_for_path_exists(self._CUPS_SOCK_PATH):
            raise error.TestFail('Missing CUPS socket: %s', self._CUPS_SOCK_PATH)

        # Make sure CUPS is stopped, so we can test on-demand launch.
        if upstart.is_running('cupsd'):
            upstart.stop_job('cupsd')

        self.check_cups_is_responding()

        # Now try stopping socket bridge, to see it clean up its files.
        upstart.stop_job('upstart-socket-bridge')
        upstart.stop_job('cupsd')

        if os.path.exists(self._CUPS_SOCK_PATH):
            raise error.TestFail('CUPS socket was not cleaned up: %s', self._CUPS_SOCK_PATH)

        # Create dummy file, to see if upstart-socket-bridge will clear it out
        # properly.
        utils.system('touch %s' % self._CUPS_SOCK_PATH)

        upstart.restart_job('upstart-socket-bridge')

        if not os.path.exists(self._CUPS_SOCK_PATH):
            raise error.TestFail('Missing CUPS socket: %s', self._CUPS_SOCK_PATH)

        self.check_cups_is_responding()
示例#24
0
    def update_device(self, device_host):
        """Update router and pcap associated with host.

        @param device_host: router / pcap host object
        @param device_board: router / pcap board name

        """
        device_board = device_host.get_board().split(':', 1)[1]
        desired = self.STABLE_VERSIONS.get(device_board, None)
        if desired is None:
            raise error.TestFail(
                'No stable version found for %s with board=%s.' %
                (device_host.hostname, device_board))

        logging.info('Checking whether %s is at the latest stable version: %s',
                     device_host.hostname, desired.release_version)
        current_release_version = self.get_release_version(device_host)
        if desired.release_version == current_release_version:
            raise error.TestNAError(
                '%s is already at latest version %s.' %
                (device_host.hostname, desired.release_version))

        logging.info('Updating %s to image %s from %s', device_host.hostname,
                     desired.release_version, current_release_version)
        logging.info('Staging artifacts.')
        try:
            ds = dev_server.ImageServer.resolve(desired.builder_version,
                                                device_host.hostname)
            ds.stage_artifacts(desired.builder_version,
                               ['full_payload', 'stateful'])
        except dev_server.DevServerException as e:
            logging.error(e)
            raise error.TestFail(str(e))

        url = self.get_update_url(ds.url(), desired.builder_version)
        autoupdater.ChromiumOSUpdater(url, host=device_host).run_update()
    def __enter__(self):
        status = power_status.get_status()

        # We expect the DUT is powered by battery now. But this is not always
        # true due to other bugs. Disable this test temporarily as workaround.
        # TODO(johnylin): remove this workaround after AC control is stable
        #                 crbug.com/914211
        if status.on_ac():
            logging.warning('Still powered by AC. Skip this test')
            raise error.TestNAError('Unable to disable AC.')
        # Verify that we are running on battery and the battery is sufficiently
        # charged.
        status.assert_battery_state(BATTERY_INITIAL_CHARGED_MIN)

        self._backlight = power_utils.Backlight()
        self._backlight.set_default()

        self._service_stopper = service_stopper.ServiceStopper(
            service_stopper.ServiceStopper.POWER_DRAW_SERVICES)
        self._service_stopper.stop_services()

        self._system_power = power_status.SystemPower(status.battery_path)
        self._power_logger = power_status.PowerLogger([self._system_power])
        return self
示例#26
0
    def run_once(self):
        """Test body."""
        client_caps = self.context.client.capabilities
        if site_linux_system.LinuxSystem.CAPABILITY_TDLS not in client_caps:
            raise error.TestNAError('DUT is incapable of TDLS')
        router_caps = self.context.router.capabilities
        if site_linux_system.LinuxSystem.CAPABILITY_TDLS not in router_caps:
            raise error.TestNAError('Router is incapable of TDLS')

        # Configure the AP.
        frequency = 2412
        self.context.configure(
            hostap_config.HostapConfig(frequency=frequency, force_wmm=True))
        router_ssid = self.context.router.get_ssid()

        # Connect the DUT to the AP.
        self.context.assert_connect_wifi(
            xmlrpc_datatypes.AssociationParameters(ssid=router_ssid))

        # Connect a client instance to the AP so the DUT has a peer to which
        # it can send TDLS traffic.
        self.context.router.add_connected_peer()

        # Test for TDLS connectivity to the peer, using the IP address.
        # We expect the first attempt to fail since the client does not
        # have the IP address of the peer in its ARP cache.
        peer_ip = self.context.router.local_peer_ip_address(0)
        link_state = self.context.client.query_tdls_link(peer_ip)
        if link_state is not False:
            raise error.TestError('First query of TDLS link succeeded: %r' %
                                  link_state)

        # Wait a reasonable time for the ARP triggered by the first TDLS
        # command to succeed.
        time.sleep(1)

        # A second attempt should succeed, since by now the ARP cache should
        # be populated.  However at this time there should be no link.
        link_state = self.context.client.query_tdls_link(peer_ip)
        if link_state != 'Nonexistent':
            raise error.TestError(
                'DUT does not report a missing TDLS link: %r' % link_state)

        # Perform TDLS discover and check the status after waiting for response.
        self.context.client.discover_tdls_link(peer_ip)
        try:
            utils.poll_for_condition(lambda:
                                     (self.context.client.query_tdls_link(
                                         peer_ip) == 'Disconnected'),
                                     timeout=1)
        except utils.TimeoutError:
            link_state = self.context.client.query_tdls_link(peer_ip)
            logging.error('DUT does not report TDLS link is disconnected: %r',
                          link_state)

        # Ping from DUT to the associated peer without TDLS.
        self.ping_and_check_for_tdls(frequency, expected=False)

        # Ping from DUT to the associated peer with TDLS.
        self.context.client.establish_tdls_link(peer_ip)
        self.ping_and_check_for_tdls(frequency, expected=True)

        # Ensure that the DUT reports the TDLS link as being active.
        # Use the MAC address to ensure we can perform TDLS requests
        # against either IP or MAC addresses.
        peer_mac = self.context.router.local_peer_mac_address()
        link_state = self.context.client.query_tdls_link(peer_mac)
        if link_state != 'Connected':
            raise error.TestError(
                'DUT does not report TDLS link is active: %r' % link_state)
    def run_once(self, host, test_mirrored=False, testcase_spec=None,
                 repeat_count=3, suspend_time_range=(5,7)):
        if test_mirrored and not host.get_board_type() == 'CHROMEBOOK':
            raise error.TestNAError('DUT is not Chromebook. Test Skipped')

        if testcase_spec is None:
            testcase_spec = self.DEFAULT_TESTCASE_SPEC

        test_name = "%s_%dx%d" % testcase_spec
        _, width, height = testcase_spec
        test_resolution = (width, height)

        if not edid.is_edid_supported(host, testcase_spec[1], testcase_spec[2]):
            raise error.TestFail('Error: EDID is not supported by the platform'
                    ': %s', test_name)

        edid_path = os.path.join(self.bindir, 'test_data', 'edids', test_name)

        factory = remote_facade_factory.RemoteFacadeFactory(host)
        display_facade = factory.create_display_facade()
        chameleon_board = host.chameleon

        chameleon_board.setup_and_reset(self.outputdir)
        finder = chameleon_port_finder.ChameleonVideoInputFinder(
                chameleon_board, display_facade)
        for chameleon_port in finder.iterate_all_ports():
            screen_test = chameleon_screen_test.ChameleonScreenTest(
                    chameleon_port, display_facade, self.outputdir)

            logging.info('Use EDID: %s', test_name)
            with chameleon_port.use_edid_file(edid_path):
                # Keep the original connector name, for later comparison.
                expected_connector = utils.wait_for_value_changed(
                        display_facade.get_external_connector_name,
                        old_value=False)
                logging.info('See the display on DUT: %s', expected_connector)

                if not expected_connector:
                    raise error.TestFail('Error: Failed to see external display'
                            ' (chameleon) from DUT: %s', test_name)

                logging.info('Set mirrored: %s', test_mirrored)
                display_facade.set_mirrored(test_mirrored)
                logging.info('Repeat %d times Suspend and resume', repeat_count)

                count = repeat_count
                while count > 0:
                    count -= 1
                    if test_mirrored:
                        # magic sleep to make nyan_big wake up in mirrored mode
                        # TODO: find root cause
                        time.sleep(6)
                    suspend_time = random.randint(*suspend_time_range)
                    logging.info('Going to suspend, for %d seconds...',
                                 suspend_time)
                    display_facade.suspend_resume(suspend_time)
                    logging.info('Resumed back')

                    message = screen_test.check_external_display_connected(
                            expected_connector)
                    if not message:
                        message = screen_test.test_screen_with_image(
                                test_resolution, test_mirrored)
                    if message:
                        raise error.TestFail(message)
示例#28
0
    def run_once(self):
        if not self.faft_config.has_lid:
            logging.info('This test does nothing on devices without lid.')
            return

        if self.faft_config.fw_bypasser_type != 'ctrl_d_bypasser':
            raise error.TestNAError("This test is only valid on devices with "
                                    "screens.")

        if self.faft_config.chrome_ec and not self.check_ec_capability(['lid'
                                                                        ]):
            raise error.TestNAError("TEST IT MANUALLY! ChromeEC can't control "
                                    "lid on the device %s" %
                                    self.faft_config.platform)

        logging.info("Expected dev mode and reboot. "
                     "When the next DEVELOPER SCREEN shown, close lid "
                     "to make DUT shutdown.")
        self.check_state((self.checkers.crossystem_checker, {
            'devsw_boot': '1',
            'mainfw_type': 'developer',
        }))
        self.switcher.mode_aware_reboot(wait_for_dut_up=False)
        self.run_shutdown_process(
            self.wait_fw_screen_and_close_lid,
            pre_power_action=self.servo.lid_open,
            post_power_action=self.switcher.bypass_dev_mode)
        self.switcher.wait_for_client()

        logging.info("Reboot. When the developer screen shown, press "
                     "enter key to trigger either TO_NORM screen (new) or "
                     "RECOVERY INSERT screen (old). Then close lid to "
                     "make DUT shutdown.")
        self.check_state((self.checkers.crossystem_checker, {
            'devsw_boot': '1',
            'mainfw_type': 'developer',
        }))
        self.switcher.mode_aware_reboot(wait_for_dut_up=False)
        self.run_shutdown_process(
            self.wait_second_screen_and_close_lid,
            pre_power_action=self.servo.lid_open,
            post_power_action=self.switcher.bypass_dev_mode,
            shutdown_timeout=self.SHORT_SHUTDOWN_CONFIRMATION_PERIOD)
        self.switcher.wait_for_client()

        logging.info("Request recovery boot. When the RECOVERY INSERT "
                     "screen shows, close lid to make DUT shutdown.")
        self.check_state((self.checkers.crossystem_checker, {
            'devsw_boot': '1',
            'mainfw_type': 'developer',
        }))
        self.faft_client.system.request_recovery_boot()
        self.switcher.mode_aware_reboot(wait_for_dut_up=False)
        self.run_shutdown_process(
            self.wait_longer_fw_screen_and_close_lid,
            pre_power_action=self.servo.lid_open,
            post_power_action=self.switcher.bypass_dev_mode,
            shutdown_timeout=self.SHORT_SHUTDOWN_CONFIRMATION_PERIOD)
        self.switcher.wait_for_client()

        logging.info("Request recovery boot again. When the recovery "
                     "insert screen shows, insert a corrupted USB and trigger "
                     "a YUCK SCREEN. Then close lid to make DUT shutdown.")
        self.check_state((self.checkers.crossystem_checker, {
            'devsw_boot': '1',
            'mainfw_type': 'developer',
        }))
        self.faft_client.system.request_recovery_boot()
        self.switcher.mode_aware_reboot(wait_for_dut_up=False)
        self.run_shutdown_process(
            self.wait_yuck_screen_and_close_lid,
            pre_power_action=self.servo.lid_open,
            post_power_action=self.switcher.bypass_dev_mode,
            shutdown_timeout=self.SHORT_SHUTDOWN_CONFIRMATION_PERIOD)
        self.switcher.wait_for_client()

        logging.info("Switch back to normal mode.")
        self.check_state((self.checkers.crossystem_checker, {
            'devsw_boot': '1',
            'mainfw_type': 'developer',
        }))
        self.switcher.reboot_to_mode(to_mode='normal')

        logging.info("Expected normal mode and request recovery boot. "
                     "Because an USB stick is inserted, a RECOVERY REMOVE "
                     "screen shows. Close lid to make DUT shutdown.")
        self.check_state((self.checkers.crossystem_checker, {
            'devsw_boot': '0',
            'mainfw_type': 'normal',
        }))
        self.faft_client.system.request_recovery_boot()
        self.switcher.mode_aware_reboot(wait_for_dut_up=False)
        self.run_shutdown_process(
            self.wait_longer_fw_screen_and_close_lid,
            pre_power_action=self.servo.lid_open,
            run_power_action=False,
            shutdown_timeout=self.SHORT_SHUTDOWN_CONFIRMATION_PERIOD)
        self.switcher.wait_for_client()
        self.check_state((self.checkers.crossystem_checker, {
            'devsw_boot': '0',
            'mainfw_type': 'normal',
        }))
示例#29
0
    def attenuator(self):
        """@return attenuator object (e.g. a BeagleBone)."""
        if self._attenuator is None:
            raise error.TestNAError('No attenuator available in this setup.')

        return self._attenuator
    def run_once(self, host, test_mirrored=False, resolution_list=None):
        if not host.get_board_type() == 'CHROMEBOOK':
            raise error.TestNAError('DUT is not Chromebook. Test Skipped')
        if resolution_list is None:
            resolution_list = self.DEFAULT_RESOLUTION_LIST
        factory = remote_facade_factory.RemoteFacadeFactory(host)
        display_facade = factory.create_display_facade()
        chameleon_board = host.chameleon

        chameleon_board.reset()
        finder = chameleon_port_finder.ChameleonVideoInputFinder(
                chameleon_board, display_facade)

        errors = []
        for chameleon_port in finder.iterate_all_ports():
            screen_test = chameleon_screen_test.ChameleonScreenTest(
                    chameleon_port, display_facade, self.outputdir)
            chameleon_port_name = chameleon_port.get_connector_type()
            logging.info('Detected %s chameleon port.', chameleon_port_name)
            for interface, width, height in resolution_list:
                if not chameleon_port_name.startswith(interface):
                    continue
                test_resolution = (width, height)
                test_name = "%s_%dx%d" % ((interface,) + test_resolution)

                if not edid.is_edid_supported(host, interface, width, height):
                    logging.info('Skip unsupported EDID: %s', test_name)
                    continue
                edid_path = os.path.join(self.bindir, 'test_data', 'edids',
                                    test_name)

                logging.info('Use EDID: %s', test_name)

                with chameleon_port.use_edid_file(edid_path):
                    index = utils.wait_for_value_changed(
                            display_facade.get_first_external_display_index,
                            old_value=False)
                    if not index:
                        raise error.TestFail("No external display is found.")

                    # In mirror mode only display index is '0', as external
                    # is treated same as internal(single resolution applies)
                    if test_mirrored:
                        index = 0
                    logging.info('Set mirrored: %s', test_mirrored)
                    display_facade.set_mirrored(test_mirrored)
                    settings_resolution_list = (
                            display_facade.get_available_resolutions(index))
                    if len(settings_resolution_list) == 0:
                        raise error.TestFail("No resolution list is found.")
                    logging.info('External display %d: %d resolutions found.',
                                index, len(settings_resolution_list))

                    for r in settings_resolution_list:
                        # FIXME: send a keystroke to keep display on.
                        # This is to work around a problem where the display may be
                        # turned off if the test has run for a long time (e.g.,
                        # greater than 15 min). When the display is off,
                        # set_resolution() will fail.
                        display_facade.hide_cursor()

                        logging.info('Set resolution to %dx%d', *r)
                        display_facade.set_resolution(index, *r)
                        time.sleep(self.RESOLUTION_CHANGE_TIME)

                        chameleon_port.wait_video_input_stable()
                        screen_test.test_screen_with_image(r, test_mirrored, errors)

            if errors:
                raise error.TestFail('; '.join(set(errors)))