• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5import logging
6import os
7
8from autotest_lib.client.bin import utils
9from autotest_lib.client.common_lib import file_utils
10from autotest_lib.client.cros import chrome_binary_test
11from autotest_lib.client.cros.video import helper_logger
12
13
14DOWNLOAD_BASE = ('http://commondatastorage.googleapis.com'
15                 '/chromiumos-test-assets-public/')
16BINARY = 'video_decode_accelerator_unittest'
17
18class video_VDASanity(chrome_binary_test.ChromeBinaryTest):
19    """
20    VDA sanity autotest runs binary video_decode_accelerator_unittest on a list
21    of videos.
22    """
23    version = 1
24
25    @helper_logger.video_log_wrapper
26    @chrome_binary_test.nuke_chrome
27    def run_once(self, test_cases):
28        for (path, width, height, frame_num, frag_num, profile) in test_cases:
29            video_path = os.path.join(self.bindir, 'video.download')
30            test_video_data = '%s:%d:%d:%d:%d:%d:%d:%d' % (
31                video_path, width, height, frame_num, frag_num, 0, 0, profile)
32            try:
33                self._download_video(path, video_path)
34                self._run_test_case(test_video_data)
35            finally:
36                self._remove_if_exists(video_path)
37
38    def _download_video(self, download_path, local_file):
39        url = DOWNLOAD_BASE + download_path
40        logging.info('Downloading "%s" to "%s"', url, local_file)
41        file_utils.download_file(url, local_file)
42
43    def _run_test_case(self, test_video_data):
44        cmd_line_list = [
45            '--test_video_data="%s"' % test_video_data,
46            '--gtest_filter=VideoDecodeAcceleratorTest.NoCrash',
47            helper_logger.chrome_vmodule_flag(),
48            '--ozone-platform=gbm',
49        ]
50        cmd_line = ' '.join(cmd_line_list)
51        self.run_chrome_test_binary(BINARY, cmd_line)
52
53    def _remove_if_exists(self, filepath):
54        try:
55            os.remove(filepath)
56        except OSError:
57            pass
58