def _run_test_case(self, name, test_video_data, frame_num, rendering_fps): # Get frame delivery time, decode as fast as possible. test_log_file = self._results_file(name, 'no_rendering', OUTPUT_LOG) cmd_line_list = [ '--test_video_data="%s"' % test_video_data, '--gtest_filter=DecodeVariations/*/0', '--disable_rendering', '--output_log="%s"' % test_log_file, '--ozone-platform=gbm', helper_logger.chrome_vmodule_flag(), ] cmd_line = ' '.join(cmd_line_list) self.run_chrome_test_binary(BINARY, cmd_line) frame_delivery_times = self._load_frame_delivery_times(test_log_file) if len(frame_delivery_times) != frame_num: raise error.TestError( "frames number mismatch - expected: %d, got: %d" % (frame_num, len(frame_delivery_times))) self._analyze_frame_delivery_times(name, frame_delivery_times) # Get frame drop rate & CPU usage, decode at the specified fps test_log_file = self._results_file(name, 'with_rendering', OUTPUT_LOG) time_log_file = self._results_file(name, 'with_rendering', TIME_LOG) cmd_line_list = [ '--test_video_data="%s"' % test_video_data, '--gtest_filter=DecodeVariations/*/0', '--rendering_warm_up=%d' % RENDERING_WARM_UP_ITERS, '--rendering_fps=%s' % rendering_fps, '--output_log="%s"' % test_log_file, '--ozone-platform=gbm', helper_logger.chrome_vmodule_flag(), ] cmd_line = ' '.join(cmd_line_list) time_cmd = ('%s -f "%s" -o "%s" ' % (TIME_BINARY, TIME_OUTPUT_FORMAT, time_log_file)) self.run_chrome_test_binary(BINARY, cmd_line, prefix=time_cmd) frame_delivery_times = self._load_frame_delivery_times(test_log_file) self._analyze_frame_drop_rate(name, frame_delivery_times, rendering_fps) self._analyze_cpu_usage(name, time_log_file) # Get decode time median. test_log_file = self._results_file(name, 'decode_time', OUTPUT_LOG) cmd_line_list = [ '--test_video_data="%s"' % test_video_data, '--gtest_filter=*TestDecodeTimeMedian', '--output_log="%s"' % test_log_file, '--ozone-platform=gbm', helper_logger.chrome_vmodule_flag(), ] cmd_line = ' '.join(cmd_line_list) self.run_chrome_test_binary(BINARY, cmd_line) line = open(test_log_file, 'r').read() m = RE_DECODE_TIME_MEDIAN.match(line) assert m, 'invalid format: %s' % line decode_time = int(m.group(1)) self._logperf(name, KEY_DECODE_TIME_50, decode_time, UNIT_MICROSECOND)
def run_once(self, codec, fps, video_file): """ Report cpu usage and frame processing time with HW and SW encode. Use MediaRecorder to record a videos with HW encode and SW encode, and report the frame processing time and CPU usage of both. @param codec: a string indicating the codec used to encode video stream, ex. 'h264'. @param fps: an integer specifying FPS of the fake input video stream. @param video_file: a string specifying the name of the video file to be used as fake input video stream. """ # Download test video. url = DOWNLOAD_BASE + video_file local_path = os.path.join(self.bindir, video_file) file_utils.download_file(url, local_path) fake_file_arg = (FAKE_FILE_ARG % local_path) fake_stream_arg = (FAKE_STREAM_ARG % fps) processing_time_sw = 0 processing_time_hw = 0 cpu_usage_sw = 0 cpu_usage_hw = 0 with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS + [fake_file_arg, fake_stream_arg] + DISABLE_HW_ENCODE_ARGS + [helper_logger.chrome_vmodule_flag()], init_network_controller=True) as cr: (processing_time_sw, cpu_usage_sw) = self.get_record_performance(cr, codec, False) self.output_perf_value(description=(SW_PREFIX + FRAME_PROCESSING_TIME), value=processing_time_sw, units=TIME_UNIT, higher_is_better=False) self.output_perf_value(description=(SW_PREFIX + CPU_USAGE), value=cpu_usage_sw, units=PERCENT, higher_is_better=False) with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS + [fake_file_arg, fake_stream_arg] + [helper_logger.chrome_vmodule_flag()], init_network_controller=True) as cr: (processing_time_hw, cpu_usage_hw) = self.get_record_performance(cr, codec, True) self.output_perf_value(description=(HW_PREFIX + FRAME_PROCESSING_TIME), value=processing_time_hw, units=TIME_UNIT, higher_is_better=False) self.output_perf_value(description=(HW_PREFIX + CPU_USAGE), value=cpu_usage_hw, units=PERCENT, higher_is_better=False) log = 'sw processing_time=%f cpu=%d hw processing_time=%f cpu=%d' % ( processing_time_sw, cpu_usage_sw, processing_time_hw, cpu_usage_hw) logging.info(log)
def _run_test_case(self, test_name, test_stream_data): """ Runs a VEA unit test. @param test_name: Name of this test case. @param test_stream_data: Parameter to --test_stream_data in vea_unittest. """ # Get FPS. test_log_file = self._get_result_filename(test_name, 'fullspeed', TEST_LOG_SUFFIX) vea_args = [ '--gtest_filter=EncoderPerf/*/0', '--test_stream_data=%s' % test_stream_data, '--output_log="%s"' % test_log_file, helper_logger.chrome_vmodule_flag(), '--ozone-platform=gbm'] self.run_chrome_test_binary(VEA_BINARY, ' '.join(vea_args)) self._analyze_fps(test_name, test_log_file) # Get CPU usage and encode latency under specified frame rate. test_log_file = self._get_result_filename(test_name, 'fixedspeed', TEST_LOG_SUFFIX) time_log_file = self._get_result_filename(test_name, 'fixedspeed', TIME_LOG_SUFFIX) vea_args = [ '--gtest_filter=SimpleEncode/*/0', '--test_stream_data=%s' % test_stream_data, '--run_at_fps', '--measure_latency', '--output_log="%s"' % test_log_file, helper_logger.chrome_vmodule_flag(), '--ozone-platform=gbm'] time_cmd = ('%s -f "%s" -o "%s" ' % (TIME_BINARY, TIME_OUTPUT_FORMAT, time_log_file)) self.run_chrome_test_binary(VEA_BINARY, ' '.join(vea_args), prefix=time_cmd) self._analyze_encode_latency(test_name, test_log_file) self._analyze_cpu_usage(test_name, time_log_file) # TODO(pbos): Measure quality at more bitrates. # Generate SSIM/PSNR scores (objective quality metrics). test_log_file = self._get_result_filename(test_name, 'quality', TEST_LOG_SUFFIX) frame_stats_file = self._get_result_filename(test_name, 'quality', FRAME_STATS_SUFFIX) vea_args = [ '--gtest_filter=SimpleEncode/*/0', '--test_stream_data=%s' % test_stream_data, '--frame_stats="%s"' % frame_stats_file, '--output_log="%s"' % test_log_file, helper_logger.chrome_vmodule_flag(), '--ozone-platform=gbm'] self.run_chrome_test_binary(VEA_BINARY, ' '.join(vea_args)) self._analyze_frame_stats(test_name, frame_stats_file)
def run_once(self, codec): """ Tests whether VEA works by verifying histogram after MediaRecorder records a video. """ with chrome.Chrome( extra_browser_args=EXTRA_BROWSER_ARGS +\ [helper_logger.chrome_vmodule_flag()], init_network_controller=True) as cr: cr.browser.platform.SetHTTPServerDirectories(self.bindir) self.tab = cr.browser.tabs.New() self.tab.Navigate( cr.browser.platform.http_server.UrlOf( os.path.join(self.bindir, 'loopback_mediarecorder.html'))) self.tab.WaitForDocumentReadyStateToBeComplete() self.tab.EvaluateJavaScript(JS_INVOCATION % codec) if not self.is_test_completed(): logging.error('%s did not complete', test_name) raise error.TestFail('Failed %s' % test_name) # Waits for histogram updated for the test video. histogram_verifier.verify(cr, MEDIA_RECORDER_HW_ENC_USED, MEDIA_RECORDER_HW_ENC_USED_BUCKET) # Verify no GPU error happens. if histogram_verifier.is_histogram_present(cr, MEDIA_RECORDER_ERROR): logging.info( histogram_verifier.get_histogram(cr, MEDIA_RECORDER_ERROR)) raise error.TestError('GPU Video Encoder Error.')
def run_once(self, test_cases): """ Runs JpegEncodeAcceleratorTest.SimpleEncode on the device and reports latency values for HW and SW. """ for (image_path, width, height) in test_cases: url = DOWNLOAD_BASE + image_path file_name = os.path.basename(image_path) input_path = os.path.join(self.bindir, file_name) file_utils.download_file(url, input_path) test_name = ('%s_%dx%d' % (file_name, width, height)) output_path = os.path.join(self.tmpdir, TEST_LOG) cmd_line_list = [helper_logger.chrome_vmodule_flag()] + [ '--gtest_filter=JpegEncodeAcceleratorTest.SimpleEncode', ('--output_log=%s' % output_path), ('--repeat=%d' % REPEAT_TIMES), ('--yuv_filenames="%s:%dx%d"' % (input_path, width, height)) ] cmd_line = ' '.join(cmd_line_list) try: self.run_chrome_test_binary(self.binary, cmd_line) self.report_perf_results(test_name, output_path) except Exception as last_error: # Log the error and continue to the next test case. logging.exception(last_error) finally: self.remove_if_exists(input_path) self.remove_if_exists(output_path)
def run_once(self, codec, is_switchres, video): """Tests whether video seek works by random seeks forward and backward. @param codec: the codec to be tested, ex. 'vp8', 'vp9', 'h264'. @param is_switchres: bool, True if using switch resolution video. @param video: Sample video file to be seeked in Chrome. """ if self.is_skipping_test(codec, is_switchres): logging.info('Skipping test run on this board.') return # return immediately to pass this test with chrome.Chrome( extra_browser_args=helper_logger.chrome_vmodule_flag(), init_network_controller=True) as cr: cr.browser.platform.SetHTTPServerDirectories(self.bindir) tab = cr.browser.tabs[0] tab.Navigate( cr.browser.platform.http_server.UrlOf( os.path.join(self.bindir, 'video.html'))) tab.WaitForDocumentReadyStateToBeComplete() tab.EvaluateJavaScript('loadSourceAndRunSeekTest("%s")' % video) def get_seek_test_status(): seek_test_status = tab.EvaluateJavaScript( 'getSeekTestStatus()') logging.info('Seeking: %s', seek_test_status) return seek_test_status utils.poll_for_condition( lambda: get_seek_test_status() == 'pass', exception=error.TestError('Seek test is stuck and timeout'), timeout=WAIT_TIMEOUT_S, sleep_interval=1)
def run_once(self, video_file): """Tests whether Chrome reloads video after reloading the tab. @param video_file: fullpath to video to play. """ with chrome.Chrome( extra_browser_args=helper_logger.chrome_vmodule_flag(), init_network_controller=True) as cr: shutil.copy2(constants.VIDEO_HTML_FILEPATH, self.bindir) cr.browser.platform.SetHTTPServerDirectories(self.bindir) tab = cr.browser.tabs[0] html_fullpath = os.path.join(self.bindir, 'video.html') url = cr.browser.platform.http_server.UrlOf(html_fullpath) player = native_html5_player.NativeHtml5Player( tab, full_url=url, video_id='video', video_src_path=video_file, event_timeout=30) player.load_video() player.play() player.verify_video_can_play(5) player.reload_page() player.load_video() player.play() player.verify_video_can_play(5)
def _get_vea_unittest_args(self, test_stream_data, test_log_file): vea_args = [ '--test_stream_data=%s' % test_stream_data, '--output_log="%s"' % test_log_file, '--ozone-platform=gbm', helper_logger.chrome_vmodule_flag() ] return vea_args
def run_once(self, subtest_name): """Main runner for the test. @param subtest_name: The name of the test to run, given below. """ extension_paths = [] if self.DISABLE_COOKIES: # To stop the system from erasing the previous profile, enable: # options.dont_override_profile = True extension_path = os.path.join(os.path.dirname(__file__), 'files/cookie-disabler') extension_paths.append(extension_path) with chrome.Chrome( extra_browser_args=helper_logger.chrome_vmodule_flag(), extension_paths=extension_paths) as cr: self.initialize_test(cr, self.TEST_PAGE) if subtest_name is 'playing': self.perform_playing_test() elif subtest_name is 'pausing': self.perform_pausing_test() elif subtest_name is 'resuming': self.perform_resuming_test() elif subtest_name is 'seeking': self.perform_seeking_test() elif subtest_name is 'frame_drop': self.perform_frame_drop_test() elif subtest_name is 'ending': self.perform_ending_test() elif subtest_name is 'last_second': self.perform_last_second_test()
def launch_recorder_test(self, test_name): """Launch a recorder test. @param test_name: Name of test to run. """ with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS +\ [helper_logger.chrome_vmodule_flag()], init_network_controller=True) as cr: cr.browser.platform.SetHTTPServerDirectories(self.bindir) self.tab = cr.browser.tabs[0] self.tab.Navigate( cr.browser.platform.http_server.UrlOf( os.path.join(self.bindir, 'loopback_mediarecorder.html'))) self.tab.WaitForDocumentReadyStateToBeComplete() self.tab.EvaluateJavaScript(test_name + "();") if not self.is_test_completed(): logging.error('%s did not complete', test_name) raise error.TestFail('Failed %s' % (test_name)) try: result = self.tab.EvaluateJavaScript('result;') except: logging.error('Cannot retrieve results from javascript') raise error.TestFail('Failed %s' % (test_name)) if result != 'PASS': raise error.TestFail('Failed %s, got %s' % (test_name, result))
def run_once(self, video_name, histogram_name, histogram_bucket_val, capability): if self.is_skipping_test(): raise error.TestNAError('Skipping test run on this board.') if not device_capability.DeviceCapability().have_capability( capability): logging.warning("Missing Capability: %s" % capability) return # Download test video. url = DOWNLOAD_BASE + video_name local_path = os.path.join(self.bindir, video_name) file_utils.download_file(url, local_path) # Start chrome with test flags. EXTRA_BROWSER_ARGS.append(FAKE_FILE_ARG % local_path) EXTRA_BROWSER_ARGS.append(helper_logger.chrome_vmodule_flag()) with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS, init_network_controller=True) as cr: histogram_differ = histogram_verifier.HistogramDiffer( cr, histogram_name) # Open WebRTC loopback page. cr.browser.platform.SetHTTPServerDirectories(self.bindir) self.start_loopback(cr) # Make sure decode is hardware accelerated. histogram_verifier.expect_sole_bucket(histogram_differ, histogram_bucket_val, histogram_bucket_val)
def run_once(self, codec, capability): """ Tests whether VEA works by verifying histogram after MediaRecorder records a video. """ device_capability.DeviceCapability().ensure_capability(capability) with chrome.Chrome( extra_browser_args=EXTRA_BROWSER_ARGS +\ [helper_logger.chrome_vmodule_flag()], init_network_controller=True) as cr: hw_enc_used_differ = histogram_verifier.HistogramDiffer( cr, MEDIA_RECORDER_HW_ENC_USED) recorder_error_differ = histogram_verifier.HistogramDiffer( cr, MEDIA_RECORDER_ERROR) cr.browser.platform.SetHTTPServerDirectories(self.bindir) self.tab = cr.browser.tabs.New() self.tab.Navigate(cr.browser.platform.http_server.UrlOf( os.path.join(self.bindir, 'loopback_mediarecorder.html'))) self.tab.WaitForDocumentReadyStateToBeComplete() self.tab.EvaluateJavaScript(JS_INVOCATION % codec) if not self.is_test_completed(): logging.error('%s did not complete', test_name) raise error.TestFail('Failed %s' % test_name) histogram_verifier.expect_sole_bucket( hw_enc_used_differ, MEDIA_RECORDER_HW_ENC_USED_BUCKET, 'HW encoder used (1)') has_error, diff_error = histogram_verifier.poll_histogram_grow( recorder_error_differ) if has_error: raise error.TestError( 'GPU Video Encoder Error. Histogram diff: %r' % diff_error)
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 run_once(self): """Runs the test.""" self.board = utils.get_current_board() with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS +\ [helper_logger.chrome_vmodule_flag()], init_network_controller=True) as cr: self.start_getusermedia(cr) self.print_perf_results()
def run_once(self): """Runs the test.""" with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS +\ [helper_logger.chrome_vmodule_flag()], init_network_controller=True) as cr: self.start_getusermedia(cr) self.wait_test_completed(SHORT_TIMEOUT_IN_SECS) self.verify_successful()
def run_once(self, element_type='video'): """Runs the test.""" with chrome.Chrome(extra_browser_args = EXTRA_BROWSER_ARGS + \ [helper_logger.chrome_vmodule_flag()], init_network_controller = True) as cr: self.start_test(cr, element_type) self.wait_test_completed(TIMEOUT) self.print_result()
def _run_test_case(self, test_video_data): cmd_line_list = [ '--test_video_data="%s"' % test_video_data, '--gtest_filter=VideoDecodeAcceleratorTest.NoCrash', helper_logger.chrome_vmodule_flag(), '--ozone-platform=gbm', ] cmd_line = ' '.join(cmd_line_list) self.run_chrome_test_binary(BINARY, cmd_line)
def run_once(self, in_cloud, streams, profile, gtest_filter=None): """Runs video_encode_accelerator_unittest on the streams. @param in_cloud: Input file needs to be downloaded first. @param streams: The test streams for video_encode_accelerator_unittest. @param profile: The profile to encode into. @param gtest_filter: test case filter. @raises error.TestFail for video_encode_accelerator_unittest failures. """ last_test_failure = None for path, width, height, bit_rate in streams: if in_cloud: input_path = os.path.join(self.tmpdir, path.split('/')[-1]) _download_video(path, input_path) else: input_path = os.path.join(self.cr_source_dir, path) output_path = os.path.join(self.tmpdir, '%s.out' % input_path.split('/')[-1]) cmd_line_list = [] cmd_line_list.append( '--test_stream_data="%s:%s:%s:%s:%s:%s"' % (input_path, width, height, profile, output_path, bit_rate)) cmd_line_list.append(helper_logger.chrome_vmodule_flag()) cmd_line_list.append('--ozone-platform=gbm') # Command line |gtest_filter| can override get_filter_option(). predefined_filter = self.get_filter_option(profile, (width, height)) if gtest_filter and predefined_filter: logging.warning('predefined gtest filter is suppressed: %s', predefined_filter) applied_filter = gtest_filter else: applied_filter = predefined_filter if applied_filter: cmd_line_list.append('--gtest_filter="%s"' % applied_filter) cmd_line = ' '.join(cmd_line_list) try: self.run_chrome_test_binary(BINARY, cmd_line, as_chronos=False) except error.TestFail as test_failure: # Continue to run the remaining test streams and raise # the last failure after finishing all streams. logging.exception('error while encoding %s', input_path) last_test_failure = test_failure finally: # Remove the downloaded video if in_cloud: _remove_if_exists(input_path) _remove_if_exists(output_path) if last_test_failure: raise last_test_failure
def test_playback(self, local_path, gather_result): """ Runs the video playback 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 = {} with chrome.Chrome( extra_browser_args=helper_logger.chrome_vmodule_flag(), arc_mode=self.arc_mode, init_network_controller=True) as cr: # crbug/753292 - enforce the idle checks after login if not utils.wait_for_idle_cpu(WAIT_FOR_IDLE_CPU_TIMEOUT, CPU_IDLE_USAGE): logging.warning('Could not get idle CPU post login.') if not utils.wait_for_cool_machine(): logging.warning('Could not get cold machine post login.') # Open the video playback page and start playing. self.start_playback(cr, local_path) result = gather_result(cr) # Check if decode is hardware accelerated. if histogram_verifier.is_bucket_present( cr, constants.MEDIA_GVD_INIT_STATUS, constants.MEDIA_GVD_BUCKET): keyvals[PLAYBACK_WITH_HW_ACCELERATION] = result else: logging.info("Can not use hardware decoding.") keyvals[PLAYBACK_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, arc_mode=self.arc_mode, init_network_controller=True) as cr: # Open the video playback page and start playing. self.start_playback(cr, local_path) result = gather_result(cr) # Make sure decode is not hardware accelerated. if histogram_verifier.is_bucket_present( cr, constants.MEDIA_GVD_INIT_STATUS, constants.MEDIA_GVD_BUCKET): raise error.TestError( 'Video decode acceleration should not be working.') keyvals[PLAYBACK_WITHOUT_HW_ACCELERATION] = result return keyvals
def run_once(self): # TODO(scottz): Remove this when crbug.com/220147 is fixed. dut_board = utils.get_current_board() if dut_board == 'x86-mario': raise error.TestNAError('This test is not available on %s' % dut_board) with chrome.Chrome( extra_browser_args=helper_logger.chrome_vmodule_flag(), init_network_controller=True) as cr: self.run_video_tests(cr.browser)
def run_once(self, video_codec): """Runs the video_WebRtcPeerConnectionWithCamera test. @param video_codec: video codec to use. """ with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS +\ [helper_logger.chrome_vmodule_flag()], init_network_controller=True) as cr: self.start_loopback(cr, video_codec) self.wait_test_completed(TIMEOUT) self.print_loopback_result(video_codec)
def run_once(self, video_file, arc_mode=False): """ Tests whether the requested video is playable @param video_file: Sample video file to be played in Chrome. """ blacklist = [ # (board, arc_mode) # None means don't care ('x86-mario', None), ('x86-zgb', None), # The result on elm and oak is flaky in arc mode. # TODO(wuchengli): remove them once crbug.com/679864 is fixed. ('elm', True), ('oak', True) ] dut_board = utils.get_current_board() for (blacklist_board, blacklist_arc_mode) in blacklist: if blacklist_board == dut_board: if blacklist_arc_mode is None or blacklist_arc_mode == arc_mode: logging.info("Skipping test run on this board.") return break if arc_mode: arc_mode_str = arc_common.ARC_MODE_ENABLED else: arc_mode_str = arc_common.ARC_MODE_DISABLED with chrome.Chrome( extra_browser_args=helper_logger.chrome_vmodule_flag(), arc_mode=arc_mode_str, init_network_controller=True) as cr: shutil.copy2(constants.VIDEO_HTML_FILEPATH, self.bindir) video_path = os.path.join(constants.CROS_VIDEO_DIR, 'files', video_file) shutil.copy2(video_path, self.bindir) cr.browser.platform.SetHTTPServerDirectories(self.bindir) tab = cr.browser.tabs.New() html_fullpath = os.path.join(self.bindir, 'video.html') url = cr.browser.platform.http_server.UrlOf(html_fullpath) player = native_html5_player.NativeHtml5Player( tab, full_url=url, video_id='video', video_src_path=video_file, event_timeout=120) player.load_video() player.play() player.verify_video_can_play(constants.PLAYBACK_TEST_TIME_S)
def run_once(self, subtest_name): with chrome.Chrome( extra_browser_args=helper_logger.chrome_vmodule_flag()) as cr: self.init(cr, self.PLAYER_PAGE) try: # The control file passes in a test name, which is the name of # the test to run, prepended with 'test_'. function_to_call = getattr(self, 'test_' + subtest_name) function_to_call() except AttributeError: # Just in case the input test name was mistyped in the control # file. raise error.TestFail('No function named: test_' + subtest_name)
def run_once(self, capability): """ Runs jpeg_decode_accelerator_unittest on the device. @param capability: Capability required for executing this test. @param gtest_filter: test case filter. @raises: error.TestFail for jpeg_decode_accelerator_unittest failures. """ device_capability.DeviceCapability().ensure_capability(capability) logging.debug('Starting video_JpegDecodeAccelerator') cmd_line = helper_logger.chrome_vmodule_flag() self.run_chrome_test_binary(self.binary, cmd_line)
def start_decode(self, gtest_filter): """ Start jpeg decode process. @param gtest_filter: gtest_filter argument. """ logging.debug('Starting video_JpegDecodeAccelerator %s', gtest_filter) cmd_line_list = [helper_logger.chrome_vmodule_flag()] cmd_line_list.append('--gtest_filter="%s"' % gtest_filter) cmd_line_list.append('--perf_decode_times=%d' % self.perf_jpeg_decode_times) cmd_line = ' '.join(cmd_line_list) self.run_chrome_test_binary(self.binary, cmd_line)
def run_once(self, videos, capability, import_mode=False, use_cr_source_dir=True): """ Runs video_decode_accelerator_unittest on the videos. @param videos: The test videos for video_decode_accelerator_unittest. @param use_cr_source_dir: Videos are under chrome source directory. @param gtest_filter: test case filter. @raises: error.TestFail for video_decode_accelerator_unittest failures. """ device_capability.DeviceCapability().ensure_capability(capability) logging.debug('Starting video_VideoDecodeAccelerator: %s', videos) if use_cr_source_dir: path = os.path.join(self.cr_source_dir, 'media', 'test', 'data', '') else: path = '' last_test_failure = None for video in videos: cmd_line_list = ['--test_video_data="%s%s"' % (path, video)] # While thumbnail test fails, write thumbnail image to results # directory so that it will be accessible to host and packed # along with test logs. cmd_line_list.append('--thumbnail_output_dir="%s"' % self.resultsdir) cmd_line_list.append(helper_logger.chrome_vmodule_flag()) cmd_line_list.append('--ozone-platform=gbm') if import_mode: cmd_line_list.append('--test_import') cmd_line_list.append('--frame_validator=check') cmd_line = ' '.join(cmd_line_list) try: self.run_chrome_test_binary(self.binary, cmd_line) except error.TestFail as test_failure: # Continue to run the remaining test videos and raise # the last failure after finishing all videos. logging.error('%s: %s', video, test_failure.message) last_test_failure = test_failure if last_test_failure: raise last_test_failure
def run_once(self, gtest_filter=None): """ Runs jpeg_decode_accelerator_unittest on the device. @param gtest_filter: test case filter. @raises: error.TestFail for jpeg_decode_accelerator_unittest failures. """ logging.debug('Starting video_JpegDecodeAccelerator') cmd_line_list = [helper_logger.chrome_vmodule_flag()] if gtest_filter: cmd_line_list.append('--gtest_filter="%s"' % gtest_filter) cmd_line = ' '.join(cmd_line_list) self.run_chrome_test_binary(self.binary, cmd_line)
def run_once(self): """Runs the audio_WebRtcAudioLoopback test.""" # Record a sample of "silence" to use as a noise profile. noise_file = os.path.join(self.resultsdir, 'cras_noise.wav') cras_utils.capture(noise_file, duration=1) # Create a file for the audio recording. recorded_file = os.path.join(self.resultsdir, 'cras_recorded.wav') self.wait_for_active_stream_count(0) with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS +\ [helper_logger.chrome_vmodule_flag()], init_network_controller=True) as cr: self.start_test(cr, recorded_file) self.wait_test_completed(TIMEOUT) self.print_result(recorded_file, noise_file)
def run_once(self, video_file, video_len, capability): """Verify VDA and playback for the video_file. @param video_file: test video file. @param video_len : test video file length. """ device_capability.DeviceCapability().ensure_capability(capability) with chrome.Chrome( extra_browser_args=helper_logger.chrome_vmodule_flag(), init_network_controller=True) as cr: init_status_differ = histogram_verifier.HistogramDiffer( cr, constants.MEDIA_GVD_INIT_STATUS) shutil.copy2(constants.VIDEO_HTML_FILEPATH, self.bindir) cr.browser.platform.SetHTTPServerDirectories(self.bindir) tab1 = cr.browser.tabs[0] html_fullpath = os.path.join(self.bindir, 'video.html') url = cr.browser.platform.http_server.UrlOf(html_fullpath) logging.info("full url is %s", url) player = native_html5_player.NativeHtml5Player( tab1, full_url=url, video_id='video', video_src_path=video_file, event_timeout=120) player.load_video() player.play() # Verify the video playback. for i in range(1, video_len / 2): if (player.paused() or player.ended()): raise error.TestError('Video either stopped or ended.') time.sleep(1) # Verify that video ends successfully. utils.poll_for_condition( lambda: player.ended(), timeout=video_len, exception=error.TestError('Video did not end successfully'), sleep_interval=1) # Make sure decode is hardware accelerated. histogram_verifier.expect_sole_bucket(init_status_differ, constants.MEDIA_GVD_BUCKET, 'OK (0)')
def run_once(self, codec, is_switchres, video, capability): """Tests whether video seek works by random seeks forward and backward. @param codec: the codec to be tested, ex. 'vp8', 'vp9', 'h264'. @param is_switchres: bool, True if using switch resolution video. @param video: Sample video file to be seeked in Chrome. @param capability: The capability required for executing the test. """ if self.is_skipping_test(codec, is_switchres): logging.info('Skipping test run on this board.') return # return immediately to pass this test device_capability.DeviceCapability().ensure_capability(capability) with chrome.Chrome( extra_browser_args=helper_logger.chrome_vmodule_flag(), init_network_controller=True) as cr: cr.browser.platform.SetHTTPServerDirectories(self.bindir) tab = cr.browser.tabs[0] tab.Navigate( cr.browser.platform.http_server.UrlOf( os.path.join(self.bindir, 'video.html'))) tab.WaitForDocumentReadyStateToBeComplete() tab.EvaluateJavaScript('loadSourceAndRunSeekTest("%s")' % video) def get_seek_test_status(): seek_test_status = tab.EvaluateJavaScript( 'getSeekTestStatus()') logging.info('Seeking: %s', seek_test_status) return seek_test_status # Wait until we get the 'pass' status, meaning the test has been # successful. Also timeout and fail the test if we stay on the same # seek for more than WAIT_TIMEOUT_S. cur_status = get_seek_test_status() while True: utils.poll_for_condition( lambda: get_seek_test_status() != cur_status, exception=error.TestError( 'Seek test is stuck and timeout'), timeout=WAIT_TIMEOUT_S, sleep_interval=1) cur_status = get_seek_test_status() if cur_status == 'pass': break