def test_webrtc(self, local_path, gather_result): """ Runs the webrtc test with and without hardware acceleration. @param local_path: the path to the video file. @param gather_result: a function to run and return the test result after chrome opens. The input parameter of the funciton is Autotest chrome instance. @return a dictionary that contains test the result. """ keyvals = {} EXTRA_BROWSER_ARGS.append(FAKE_FILE_ARG % local_path) with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS +\ [helper_logger.chrome_vmodule_flag()], arc_mode=self.arc_mode, init_network_controller=True) as cr: # On daisy, Chrome freezes about 30 seconds after login because of # TPM error. See http://crbug.com/588579. if utils.get_board() == 'daisy': logging.warning('Delay 30s for issue 588579 on daisy') time.sleep(30) # Open WebRTC loopback page and start the loopback. self.start_loopback(cr) result = gather_result(cr) # Check if decode is hardware accelerated. if histogram_verifier.is_bucket_present( cr, constants.RTC_INIT_HISTOGRAM, constants.RTC_VIDEO_INIT_BUCKET): keyvals[WEBRTC_WITH_HW_ACCELERATION] = result else: logging.info("Can not use hardware decoding.") keyvals[WEBRTC_WITHOUT_HW_ACCELERATION] = result return keyvals # Start chrome with disabled video hardware decode flag. with chrome.Chrome(extra_browser_args= DISABLE_ACCELERATED_VIDEO_DECODE_BROWSER_ARGS + EXTRA_BROWSER_ARGS, arc_mode=self.arc_mode, init_network_controller=True) as cr: if utils.get_board() == 'daisy': logging.warning('Delay 30s for issue 588579 on daisy') time.sleep(30) # Open the webrtc loopback page and start the loopback. self.start_loopback(cr) result = gather_result(cr) # Make sure decode is not hardware accelerated. if histogram_verifier.is_bucket_present( cr, constants.RTC_INIT_HISTOGRAM, constants.RTC_VIDEO_INIT_BUCKET): raise error.TestError('HW decode should not be used.') keyvals[WEBRTC_WITHOUT_HW_ACCELERATION] = result return keyvals
def supports_bluetooth(self): """Return True if this device has Bluetooth capabilities; else False.""" device = utils.get_board() if device in self._INVALID_BOARDS: logging.info('%s does not have Bluetooth.', device) return False return True
def run_once(self, arc_mode=None): # If we are in arc_mode, do not report failures to perf dashboard. if arc_mode: self._test_failure_report_enable = False self.add_failures('graphics_Idle') with chrome.Chrome(logged_in=True, arc_mode=arc_mode) as cr: # The New Tab Page contains the Google doodle which can cause # arbitrary side effects. Hide it by going to a neutral page. if not cr.browser.tabs: cr.browser.tabs.New() tab = cr.browser.tabs[0] tab.Navigate('chrome://version') # Try to protect against runaway previous tests. if not utils.wait_for_idle_cpu(60.0, 0.1): logging.warning('Could not get idle CPU before running tests.') self._gpu_type = utils.get_gpu_family() self._cpu_type = utils.get_cpu_soc_family() self._board = utils.get_board() errors = '' errors += self.verify_graphics_dvfs() errors += self.verify_graphics_fbc() errors += self.verify_graphics_psr() errors += self.verify_graphics_gem_idle() errors += self.verify_graphics_i915_min_clock() errors += self.verify_graphics_rc6() errors += self.verify_lvds_downclock() errors += self.verify_short_blanking() if errors: raise error.TestFail('Failed: %s' % errors) self.remove_failures('graphics_Idle')
def alsa_rms_test_setup(): """Setup for alsa_rms_test. Different boards/chipsets have different set of mixer controls. Even controls that have the same name on different boards might have different capabilities. The following is a general idea to setup a given class of boards, and some specialized setup for certain boards. """ card_id = alsa_utils.get_first_soundcard_with_control('Mic Jack', 'Mic') arch = utils.get_arch() board = utils.get_board() uses_max98090 = os.path.exists('/sys/module/snd_soc_max98090') if board in ['daisy_spring', 'daisy_skate']: # The MIC controls of the boards do not support dB syntax. alsa_utils.mixer_cmd(card_id, 'sset Headphone ' + _DEFAULT_ALSA_MAX_VOLUME) alsa_utils.mixer_cmd(card_id, 'sset MIC1 ' + _DEFAULT_ALSA_MAX_VOLUME) alsa_utils.mixer_cmd(card_id, 'sset MIC2 ' + _DEFAULT_ALSA_MAX_VOLUME) elif arch in ['armv7l', 'aarch64'] or uses_max98090: # ARM platforms or Intel platforms that uses max98090 codec driver. alsa_utils.mixer_cmd(card_id, 'sset Headphone ' + _DEFAULT_ALSA_MAX_VOLUME) alsa_utils.mixer_cmd(card_id, 'sset MIC1 ' + _DEFAULT_ALSA_CAPTURE_GAIN) alsa_utils.mixer_cmd(card_id, 'sset MIC2 ' + _DEFAULT_ALSA_CAPTURE_GAIN) else: # The rest of Intel platforms. alsa_utils.mixer_cmd(card_id, 'sset Master ' + _DEFAULT_ALSA_MAX_VOLUME) alsa_utils.mixer_cmd(card_id, 'sset Capture ' + _DEFAULT_ALSA_CAPTURE_GAIN)
def verify_graphics_fbc(self): """ On systems which support FBC, check that we can get into FBC; idle before doing so, and retry every second for 20 seconds.""" logging.info('Running verify_graphics_fbc') # Link's FBC is disabled (crbug.com/338588). # TODO(marcheu): remove this when/if we fix this bug. board = utils.get_board() if board == 'link': return '' # Machines which don't have a monitor can't get FBC. if utils.has_no_monitor(): return '' if (self._gpu_type == 'haswell' or self._gpu_type == 'ivybridge' or self._gpu_type == 'sandybridge'): tries = 0 found = False param_path = self.get_valid_path(FBC_PATHS) if not param_path: return 'FBC_PATHS not found.' while not found and tries < 20: time.sleep(1) with open(param_path, 'r') as fbc_info_file: for line in fbc_info_file: if re.search('FBC enabled', line): found = True break tries += 1 if not found: return self.handle_error('Did not see FBC enabled. ', param_path) return ''
def run_once(self): if utils.get_board() not in ['samus', 'gandof']: raise error.TestNAError( 'Trying to run PSR tests on unsupported board.') psr_enabled = self._is_psr_enabled() if (not psr_enabled and graphics_utils.call_xrandr('--output eDP1 --set psr on')): error.TestFail('Unable to enable PSR via xrandr.') # Start chrome in full screen mode so that there is no blinking cursor # or ticking clock on the screen. with chrome.Chrome(logged_in=False, extra_browser_args=['--kiosk']): # Sample the PSR performance count from debugfs and wait for 20s. # At the end of 20s, re-sample the PSR performance count. The time # spent in PSR should be close to (20s - <vblankoffdelay>). sleep_time_milliseconds = 20 * 1000 min_occupancy = 0.9 * (sleep_time_milliseconds - self._get_vblank_timeout()) perf_count_old = self._get_perf_count() time.sleep(sleep_time_milliseconds / 1000) perf_count_new = self._get_perf_count() occupancy_time = perf_count_new - perf_count_old if occupancy_time < min_occupancy: raise error.TestFail( 'PSR occupancy time %dms less than expected.' % occupancy_time) # Disable PSR if it was not enabled to begin with. if (not psr_enabled and graphics_utils.call_xrandr('--output eDP1 --set psr off')): raise error.TestWarn('Unable to disable PSR via xrandr.')
def verify_graphics_psr(self): """ On systems which support PSR, check that we can get into PSR; idle before doing so, and retry every second for 20 seconds.""" logging.info('Running verify_graphics_psr') board = utils.get_board() if board != 'samus': return '' tries = 0 found = False param_path = self.get_valid_path(PSR_PATHS) if not param_path: return 'PSR_PATHS not found.' while not found and tries < 20: time.sleep(1) with open(param_path, 'r') as fbc_info_file: for line in fbc_info_file: match = re.search(r'Performance_Counter: (.*)', line) if match and int(match.group(1)) > 0: found = True break tries += 1 if not found: return self.handle_error('Did not see PSR enabled. ', param_path) return ''
def run_once(self, arc_mode=None): # If we are in arc_mode, do not report failures to perf dashboard. if arc_mode: self._test_failure_report_enable = False # We use kiosk mode to make sure Chrome is idle. self.add_failures('Graphics_Idle') with chrome.Chrome(logged_in=False, extra_browser_args=['--kiosk'], arc_mode=arc_mode): # Try to protect against runaway previous tests. if not utils.wait_for_idle_cpu(20.0, 0.1): logging.warning('Could not get idle CPU before running tests.') self._gpu_type = utils.get_gpu_family() self._cpu_type = utils.get_cpu_soc_family() self._board = utils.get_board() errors = '' errors += self.verify_graphics_dvfs() errors += self.verify_graphics_fbc() errors += self.verify_graphics_psr() errors += self.verify_graphics_gem_idle() errors += self.verify_graphics_i915_min_clock() errors += self.verify_graphics_rc6() errors += self.verify_lvds_downclock() errors += self.verify_short_blanking() if errors: raise error.TestFail('Failed: %s' % errors) self.remove_failures('Graphics_Idle')
def run_once(self, to_test): """Run alsa_api_test binary and verify its result. Checks the source code of alsa_api_test in audiotest repo for detail. @param to_test: support these test items: move: Checks snd_pcm_forward API. fill: Checks snd_pcm_mmap_begin API. drop: Checks snd_pcm_drop API. """ # Skip test_drop on boards that do not implement snd_pcm_drop # correctly, as it cannot pass. board = utils.get_board().lower() if to_test == 'drop' and board in self._BOARDS_WITHOUT_DROP_SUPPORT: logging.info('Skipping test_drop for unsupported board: %s', board) return self._cardnames = alsa_utils.get_soundcard_names() self._devices = [] self._find_sound_devices() method_name = '_test_' + to_test method = getattr(self, method_name) for card_index, device_index in self._devices: device = 'hw:%s,%s' % (card_index, device_index) method(device)
def _skip_hcd(self): """Skips HCD controlling on some boards.""" board = utils.get_board() if board in self._SKIP_HCD_BLACKLIST: logging.info('Skip HCD controlling on board %s', board) return True return False
def run_once(self, check_link_speed=()): # Use rootdev to find the underlying block device even if the # system booted to /dev/dm-0. device = site_utils.get_root_device() # Check the device is fixed def IsFixed(dev): sysfs_path = '/sys/block/%s/removable' % dev return (os.path.exists(sysfs_path) and open(sysfs_path).read().strip() == '0') alpha_re = re.compile(r'^/dev/([a-zA-Z]+)$') alnum_re = re.compile(r'^/dev/([a-zA-Z]+[0-9]+)$') dev = alpha_re.findall(device) + alnum_re.findall(device) if len(dev) != 1 or not IsFixed(dev[0]): raise error.TestFail('The main disk %s is not fixed' % dev) # If it is an mmcblk device, then it is SSD. # Else run hdparm to check for SSD. if re.search("mmcblk", device): return hdparm = utils.run('/sbin/hdparm -I %s' % device) # Check if device is a SSD match = re.search(r'Nominal Media Rotation Rate: (.+)$', hdparm.stdout, re.MULTILINE) if match and match.group(1): if match.group(1) != 'Solid State Device': if utils.get_board() in self.boards_with_hdd: return raise error.TestFail('The main disk is not a SSD, ' 'Rotation Rate: %s' % match.group(1)) else: raise error.TestFail('Rotation Rate not reported from the device, ' 'unable to ensure it is a SSD') # Check if SSD is > 8GB in size match = re.search("device size with M = 1000\*1000: (.+) MBytes", hdparm.stdout, re.MULTILINE) if match and match.group(1): size = int(match.group(1)) self.write_perf_keyval({"mb_ssd_device_size": size}) else: raise error.TestFail('Device size info missing from the device') # Check supported link speed. # # check_link_speed is an empty tuple by default, which does not perform # link speed checking. You can run the test while specifying # check_link_speed=('1.5Gb/s', '3.0Gb/s') to check the 2 signaling # speeds are both supported. for link_speed in check_link_speed: if not re.search(r'Gen. signaling speed \(%s\)' % link_speed, hdparm.stdout, re.MULTILINE): raise error.TestFail('Link speed %s not supported' % link_speed)
def NoDeviceFailure(self, forgive_flaky, message): """ No WiFi device found. Forgiveable in some suites, for some boards. """ board = utils.get_board() if forgive_flaky and board in self.EXCEPTION_BOARDS: return error.TestWarn('Exception (%s): %s' % (board, message)) else: return error.TestFail(message)
def warmup(self): if self.perf_cmd == 'record -b': uarch = utils.get_intel_cpu_uarch() if uarch not in INTEL_LBR_UARCHS: raise error.TestNAError('Unsupported microarchitecture.') unsupported_boards = ['gizmo'] board = utils.get_board() if board in unsupported_boards: raise error.TestNAError('Unsupported board')
def _skip_device(self, card_device): """Skips devices on some boards. @param card_device: A tuple of (card index, device index). @returns: True if the device should be skipped. False otherwise. """ return card_device in self._DEVICES_TO_BE_SKIPPED.get( utils.get_board().lower(), [])
def run_once(self): """Entry point of this test.""" if not self.supports_bluetooth(): return self._device = utils.get_board() if self._device in self._REFERENCE_ONLY: return self.poll_adapter_presence() self._check_id()
def run_once(self, width, height, mask_points=None, logged_in=None): self.width = width self.height = height self.logged_in = logged_in self.mask_points = mask_points if utils.get_board() != 'link': logging.info('This test should only be run on link so exiting.') return self.run_screenshot_comparison_test()
def _create_dut_info_dict(self, power_rails): """Create a dictionary that contain information of the DUT. Args: power_rails: list of measured power rails Returns: DUT info dictionary """ board = utils.get_board() platform = utils.get_platform() if not platform.startswith(board): board += '_' + platform if power_utils.has_hammer(): board += '_hammer' dut_info_dict = { 'board': board, 'version': { 'hw': utils.get_hardware_revision(), 'milestone': lsbrelease_utils.get_chromeos_release_milestone(), 'os': lsbrelease_utils.get_chromeos_release_version(), 'channel': lsbrelease_utils.get_chromeos_channel(), 'firmware': utils.get_firmware_version(), 'ec': utils.get_ec_version(), 'kernel': utils.get_kernel_version(), }, 'sku': { 'cpu': utils.get_cpu_name(), 'memory_size': utils.get_mem_total_gb(), 'storage_size': utils.get_disk_size_gb(utils.get_root_device()), 'display_resolution': utils.get_screen_resolution(), }, 'ina': { 'version': 0, 'ina': power_rails, }, 'note': self._note, } if power_utils.has_battery(): status = power_status.get_status() if status.battery: # Round the battery size to nearest tenth because it is # fluctuated for platform without battery nominal voltage data. dut_info_dict['sku']['battery_size'] = round( status.battery[0].energy_full_design, 1) dut_info_dict['sku']['battery_shutdown_percent'] = \ power_utils.get_low_battery_shutdown_percent() return dut_info_dict
def _check_for_errors(self): """Find and identify suspend errors. Return True iff we should retry.""" warning_regex = re.compile(r' kernel: \[.*WARNING:') abort_regex = re.compile( r' kernel: \[.*Freezing of tasks abort' r'| powerd_suspend\[.*Cancel suspend at kernel' r'| kernel: \[.*PM: Wakeup pending, aborting suspend') # rsyslogd can put this out of order with dmesg, so track in variable fail_regex = re.compile(r'powerd_suspend\[\d+\]: Error') failed = False # TODO(scottz): warning_monitor crosbug.com/38092 for i in xrange(len(self._logs)): line = self._logs[i] if warning_regex.search(line): # match the source file from the WARNING line, and the # actual error text by peeking one or two lines below that src = cros_logging.strip_timestamp(line) text = cros_logging.strip_timestamp(self._logs[i + 1]) + '\n' \ + cros_logging.strip_timestamp(self._logs[i + 2]) for p1, p2 in sys_power.KernelError.WHITELIST: if re.search(p1, src) and re.search(p2, text): logging.info('Whitelisted KernelError: %s', src) break else: raise sys_power.KernelError("%s\n%s" % (src, text)) if abort_regex.search(line): wake_source = 'unknown' match = re.search(r'last active wakeup source: (.*)$', '\n'.join(self._logs[i - 5:i + 3]), re.MULTILINE) if match: wake_source = match.group(1) driver = self._identify_driver(wake_source) for b, w in sys_power.SpuriousWakeupError.S0_WHITELIST: if (re.search(b, utils.get_board()) and re.search(w, wake_source)): logging.warning( 'Whitelisted spurious wake before ' 'S3: %s | %s', wake_source, driver) return True if "rtc" in driver: raise sys_power.SuspendTimeout('System took too ' 'long to suspend.') raise sys_power.SpuriousWakeupError('Spurious wake ' 'before S3: %s | %s' % (wake_source, driver)) if fail_regex.search(line): failed = True if failed: raise sys_power.SuspendFailure('Unidentified problem.') return False
def _verify_roles(self): """Verify that POWERD_ROLE was set on devices as expected.""" # TODO(chromium:410968): Consider moving this to USE flags instead of # listing devices here. boards_with_touchscreen = ['link', 'samus'] boards_maybe_touchscreen = [ 'rambi', 'peppy', 'glimmer', 'clapper', 'nyan_big', 'nyan_blaze', 'expresso' ] boards_chromebox = [ 'beltino', 'guado', 'mccloud', 'panther', 'rikku', 'stumpy', 'tidus', 'tricky', 'zako' ] boards_aio = ['nyan_kitty', 'tiny', 'anglar', 'monroe'] expect_keyboard = None expect_touchpad = None expect_touchscreen = None board = utils.get_board() if board in boards_chromebox or board in boards_aio: expect_keyboard = [0] expect_touchpad = [0] else: expect_keyboard = [1] expect_touchpad = [1] if board in boards_with_touchscreen: expect_touchscreen = [1] elif board in boards_maybe_touchscreen: expect_touchscreen = [0, 1] else: expect_touchscreen = [0] expected_num_per_role = [ ('internal_keyboard', expect_keyboard), ('internal_touchpad', expect_touchpad), ('internal_touchscreen', expect_touchscreen), ] for role, expected_num in expected_num_per_role: num = len(self.devices_with_role[role]) if num not in expected_num: self.errors += 1 logging.error( 'POWERD_ROLE=%s is present %d times, expected ' 'one of %s', role, num, repr(expected_num)) if len(self.devices_with_role['external_input']) != 0: logging.warn('%d external input devices detected', len(self.devices_with_role['external_input']))
def run_once(self): board = utils.get_board().lower() snd_control = len(glob.glob(_SND_DEV_DIR + _SND_DEFAULT_MASK)) if board in self._NO_AUDIO_DEVICE_LIST: if snd_control: raise error.TestError( '%s is not supposed to have sound control!' % board) else: return record = board not in self._NO_RECORDER_BOARDS_LIST playback = board not in self._NO_PLAYBACK_BOARDS_LIST self.check_sound_files(playback, record) self.check_device_list(playback, record)
def verify_lvds_downclock(self): """On systems which support LVDS downclock, checks the kernel log for a message that an LVDS downclock mode has been added.""" logging.info('Running verify_lvds_downclock') board = utils.get_board() if not (board == 'alex' or board == 'lumpy' or board == 'stout'): return '' # Get the downclock message from the logs. reader = cros_logging.LogReader() reader.set_start_by_reboot(-1) if not reader.can_find('Adding LVDS downclock mode'): return self.handle_error('LVDS downclock quirk not applied. ') return ''
def _create_powerlog_dict(self, raw_measurement): """Create powerlog dictionary from raw measurement data Data format in go/power-dashboard-data Args: raw_measurement: dictionary contains raw measurement data. Returns: A dictionary of powerlog. """ powerlog_dict = { 'format_version': 2, 'timestamp': time.time(), 'test': self._testname, 'dut': { 'board': utils.get_board(), 'version': { 'hw': utils.get_hardware_revision(), 'milestone': lsbrelease_utils.get_chromeos_release_milestone(), 'os': lsbrelease_utils.get_chromeos_release_version(), 'channel': lsbrelease_utils.get_chromeos_channel(), 'firmware': utils.get_firmware_version(), 'ec': utils.get_ec_version(), 'kernel': utils.get_kernel_version(), }, 'sku': { 'cpu': utils.get_cpu_name(), 'memory_size': utils.get_mem_total_gb(), 'storage_size': utils.get_disk_size_gb(utils.get_root_device()), 'display_resolution': utils.get_screen_resolution(), }, 'ina': { 'version': 0, 'ina': raw_measurement['data'].keys() }, 'note': '' }, 'power': raw_measurement } if power_utils.has_battery(): # Round the battery size to nearest tenth because it is fluctuated # for platform without battery norminal voltage data. powerlog_dict['dut']['sku']['battery_size'] = round( power_status.get_status().battery[0].energy_full_design, 1) powerlog_dict['dut']['sku']['battery_shutdown_percent'] = \ power_utils.get_low_battery_shutdown_percent() return powerlog_dict
def initialize(self): super(graphics_WebGLAquarium, self).initialize() self.sampler_lock = threading.Lock() # TODO: Create samplers for other platforms (e.g. x86). if utils.get_board().lower() in ['daisy', 'daisy_spring']: # Enable ExynosSampler on Exynos platforms. The sampler looks for # exynos-drm page flip states: 'wait_kds', 'rendered', 'prepared', # and 'flipped' in kernel debugfs. # Sample 3-second durtaion for every 5 seconds. self.kernel_sampler = sampler.ExynosSampler(period=5, duration=3) self.kernel_sampler.sampler_callback = self.exynos_sampler_callback self.kernel_sampler.output_flip_stats = ( self.exynos_output_flip_stats)
def _hwclock_ts(self, not_before, retries=3): """Read the RTC resume timestamp saved by powerd_suspend.""" for retry in xrange(retries + 1): early_wakeup = False if os.path.exists(self.HWCLOCK_FILE): # TODO(crbug.com/733773): Still fragile see bug. match = re.search(r'(.+)(\.\d+)[+-]\d+:?\d+$', utils.read_file(self.HWCLOCK_FILE), re.DOTALL) if match: timeval = time.strptime(match.group(1), "%Y-%m-%d %H:%M:%S") seconds = time.mktime(timeval) seconds += float(match.group(2)) logging.debug('RTC resume timestamp read: %f', seconds) if seconds >= not_before: return seconds early_wakeup = True time.sleep(0.05 * retry) if early_wakeup: logging.debug('Early wakeup, dumping eventlog if it exists:\n') elog = utils.system_output('mosys eventlog list | tail -n %d' % self._RELEVANT_EVENTLOG_LINES, ignore_status=True) wake_elog = (['unknown'] + re.findall(r'Wake Source.*', elog))[-1] for line in reversed(self._logs): match = re.search(r'PM1_STS: WAK.*', line) if match: wake_syslog = match.group(0) break else: wake_syslog = 'unknown' for b, e, s in sys_power.SpuriousWakeupError.S3_WHITELIST: if (re.search(b, utils.get_board()) and re.search(e, wake_elog) and re.search(s, wake_syslog)): logging.warning('Whitelisted spurious wake in S3: %s | %s', wake_elog, wake_syslog) return None raise sys_power.SpuriousWakeupError( 'Spurious wake in S3: %s | %s' % (wake_elog, wake_syslog)) if self._get_board() in ['lumpy', 'stumpy', 'kiev']: logging.debug( 'RTC read failure (crosbug/36004), dumping nvram:\n' + utils.system_output('mosys nvram dump', ignore_status=True)) return None raise error.TestError('Broken RTC timestamp: ' + utils.read_file(self.HWCLOCK_FILE))
def run_once(self): """ Check that udev variables are assigned correctly by udev rules. In particular, verifies that powerd tags are set correctly. """ logging.debug('Board: %s', utils.get_board()) self._get_roles() self._dump_roles() self._dump_udev_attrs() self.errors = 0 self._verify_roles() if self.errors != 0: raise error.TestFail('Verification of udev variables failed; see ' 'logs for details')
def run_once(self): """ Collect a perf callchain profile and check the detailed perf report. """ # Waiting on ARM/perf support if not utils.get_current_kernel_arch().startswith('x86'): return # These boards are not supported unsupported_boards = ['gizmo'] board = utils.get_board() if board in unsupported_boards: return try: graph = os.path.join(self.srcdir, 'graph') perf_file_path = os.tempnam() perf_record_args = [ 'perf', 'record', '-e', 'cycles', '-g', '-o', perf_file_path, '--', graph ] perf_report_args = ['perf', 'report', '-D', '-i', perf_file_path] try: subprocess.check_output(perf_record_args, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as cmd_error: raise error.TestFail( "Running command [%s] failed: %s" % (' '.join(perf_record_args), cmd_error.output)) # Make sure the file still exists. if not os.path.isfile(perf_file_path): raise error.TestFail('Could not find perf output file: ' + perf_file_path) p = subprocess.Popen(perf_report_args, stdout=subprocess.PIPE) result = self.report_has_callchain_length_at_least(p.stdout, 3) for _ in p.stdout: pass p.wait() finally: os.remove(perf_file_path) if not result: raise error.TestFail('Callchain not found')
def run_once(self): # Mono and stereo capturing should work fine @ 44.1KHz and 48KHz. if utils.get_board().lower() not in EXCLUSION_BOARDS: # Verify recording using ALSA utils. channels = alsa_utils.get_card_preferred_record_channels() if channels is None: channels = [1, 2] for c in channels: self.verify_alsa_capture(c, 44100) self.verify_alsa_capture(c, 48000) # Verify recording of CRAS. self.verify_cras_capture(1, 44100) self.verify_cras_capture(1, 48000) self.verify_cras_capture(2, 48000) self.verify_cras_capture(2, 44100)
def run_once(self, duration=1, output_node="INTERNAL_SPEAKER"): """Run aplay and verify its output is as expected. @param duration: The duration to run aplay in seconds. @param output_node: The type of output device to test. It should be INTERNAL_SPEAKER or HEADPHONE. """ # Check CRAS server is alive. If not, restart it and wait a second to # get server ready. if utils.get_service_pid('cras') == 0: logging.debug("CRAS server is down. Restart it.") utils.start_service('cras', ignore_status=True) time.sleep(1) # Skip test if there is no internal speaker on the board. if output_node == "INTERNAL_SPEAKER": board_type = utils.get_board_type() board_name = utils.get_board() if not audio_spec.has_internal_speaker(board_type, board_name): logging.debug("No internal speaker. Skipping the test.") return cras_utils.set_single_selected_output_node(output_node) cras_device_type = cras_utils.get_selected_output_device_type() logging.debug("Selected output device type=%s", cras_device_type) if cras_device_type != output_node: raise error.TestFail("Fail to select output device.") cras_device_name = cras_utils.get_selected_output_device_name() logging.debug("Selected output device name=%s", cras_device_name) if cras_device_name is None: raise error.TestFail("Fail to get selected output device.") alsa_device_name = alsa_utils.convert_device_name(cras_device_name) # Stop CRAS to make sure the audio device won't be occupied. utils.stop_service('cras', ignore_status=True) try: _check_play(alsa_device_name, duration, APLAY_EXPECTED) finally: #Restart CRAS utils.start_service('cras', ignore_status=True)
def initialize(self): self._board = utils.get_board() self._cpu_type = utils.get_cpu_soc_family() self._gpu_type = utils.get_gpu_family() # deqp may depend on libraries that are present only on test images. # Those libraries are installed in /usr/local. self._env = os.environ.copy() old_ld_path = self._env.get('LD_LIBRARY_PATH', '') if old_ld_path: self._env[ 'LD_LIBRARY_PATH'] = '/usr/local/lib:/usr/local/lib64:' + old_ld_path else: self._env['LD_LIBRARY_PATH'] = '/usr/local/lib:/usr/local/lib64' # Determine which executable should be run. Right now never egl. major, minor = graphics_utils.get_gles_version() logging.info('Found gles%d.%d.', major, minor) if major is None or minor is None: raise error.TestFail( 'Failed: Could not get gles version information (%d, %d).' % (major, minor)) if major >= 2: self._can_run_executables.append('gles2/deqp-gles2') if major >= 3: self._can_run_executables.append('gles3/deqp-gles3') if major > 3 or minor >= 1: self._can_run_executables.append('gles31/deqp-gles31') # If libvulkan is installed, then assume the board supports vulkan. has_libvulkan = False for libdir in ('/usr/lib', '/usr/lib64', '/usr/local/lib', '/usr/local/lib64'): if os.path.exists(os.path.join(libdir, 'libvulkan.so')): has_libvulkan = True if (has_libvulkan and os.path.exists( '/usr/local/deqp/external/vulkancts/modules/vulkan/deqp-vk')): self._can_run_executables.append( 'external/vulkancts/modules/vulkan/deqp-vk') self._services = service_stopper.ServiceStopper(['ui', 'powerd']) # Valid choices are fbo and pbuffer. The latter avoids dEQP assumptions. self._surface = 'pbuffer'
def _generate_tags(self, testname): """ Generate tags for the current test run @param testname the name of the current test @return an array of tags """ # get chrome version version_string = utils.system_output(constants.CHROME_VERSION_COMMAND, ignore_status=True) version_string = utils.parse_chrome_version(version_string)[0] return { 'testname': testname, 'chromeos_version': utils.get_chromeos_release_version(), 'chrome_version': version_string, 'board': utils.get_board(), 'date': datetime.date.today().strftime("%m/%d/%y"), }