Home | History | Annotate | Download | only in video_VDASanity
      1 # Copyright 2017 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import logging
      6 import os
      7 
      8 from autotest_lib.client.bin import utils
      9 from autotest_lib.client.common_lib import file_utils
     10 from autotest_lib.client.cros import chrome_binary_test
     11 from autotest_lib.client.cros.video import device_capability
     12 from autotest_lib.client.cros.video import helper_logger
     13 
     14 
     15 DOWNLOAD_BASE = ('http://commondatastorage.googleapis.com'
     16                  '/chromiumos-test-assets-public/')
     17 BINARY = 'video_decode_accelerator_unittest'
     18 
     19 class video_VDASanity(chrome_binary_test.ChromeBinaryTest):
     20     """
     21     VDA sanity autotest runs binary video_decode_accelerator_unittest on a list
     22     of videos.
     23     """
     24     version = 1
     25 
     26     @helper_logger.video_log_wrapper
     27     @chrome_binary_test.nuke_chrome
     28     def run_once(self, test_cases, capability):
     29         device_capability.DeviceCapability().ensure_capability(capability)
     30         for (path, width, height, frame_num, frag_num, profile) in test_cases:
     31             video_path = os.path.join(self.bindir, 'video.download')
     32             test_video_data = '%s:%d:%d:%d:%d:%d:%d:%d' % (
     33                 video_path, width, height, frame_num, frag_num, 0, 0, profile)
     34             try:
     35                 self._download_video(path, video_path)
     36                 self._run_test_case(test_video_data)
     37             finally:
     38                 self._remove_if_exists(video_path)
     39 
     40     def _download_video(self, download_path, local_file):
     41         url = DOWNLOAD_BASE + download_path
     42         logging.info('Downloading "%s" to "%s"', url, local_file)
     43         file_utils.download_file(url, local_file)
     44 
     45     def _run_test_case(self, test_video_data):
     46         cmd_line_list = [
     47             '--test_video_data="%s"' % test_video_data,
     48             '--gtest_filter=VideoDecodeAcceleratorTest.NoCrash',
     49             helper_logger.chrome_vmodule_flag(),
     50             '--ozone-platform=gbm',
     51         ]
     52         cmd_line = ' '.join(cmd_line_list)
     53         self.run_chrome_test_binary(BINARY, cmd_line)
     54 
     55     def _remove_if_exists(self, filepath):
     56         try:
     57             os.remove(filepath)
     58         except OSError:
     59             pass
     60