| # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| """Test to verify formats availability for hardware offload. |
| """ |
| import logging, os |
| from autotest_lib.client.bin import test, utils |
| from autotest_lib.client.common_lib import error |
| |
| try: |
| import v4l2 |
| except ImportError: |
| # v4l2 module is generated by setup. It will fail when setup runs and succeed |
| # when run_once runs. |
| pass |
| |
| class audiovideo_Formats(test.test): |
| """Test class to verify formats availability for hardware offload. |
| """ |
| version = 1 |
| preserve_srcdir = False |
| DAISY_VIDEO_DEC = "/dev/mfc-dec" |
| DAISY_CAPTURE_FORMATS = ["VM12", "NM12"] |
| DAISY_OUTPUT_FORMATS = ["H264", "VP80"] |
| # Values in the dictionary are three-element tuples: |
| # (the video device, capture formats list, output formats list) |
| FORMATS_DICT = {"DAISY": (DAISY_VIDEO_DEC, |
| DAISY_CAPTURE_FORMATS, |
| DAISY_OUTPUT_FORMATS), |
| "SNOW": (DAISY_VIDEO_DEC, # SNOW=DAISY |
| DAISY_CAPTURE_FORMATS, |
| DAISY_OUTPUT_FORMATS)} |
| |
| def setup(self): |
| os.chdir(self.srcdir) |
| utils.make() |
| |
| def run_once(self): |
| """Tests whether the supported image formats are expected. |
| """ |
| item = self.FORMATS_DICT.get(utils.get_board()) |
| if item: |
| device = item[0] |
| expected_capture_formats = set(item[1]) |
| expected_output_formats = set(item[2]) |
| capture_formats = set(v4l2.enum_capture_formats(device)) |
| output_formats = set(v4l2.enum_output_formats(device)) |
| logging.info("Capture formats=%s", capture_formats) |
| logging.info("Output formats=%s", output_formats) |
| if not (expected_capture_formats <= capture_formats): |
| raise error.TestFail("Missing capture formats: (%s)" % |
| ", ".join(expected_capture_formats - capture_formats)) |
| if not (expected_output_formats <= output_formats): |
| raise error.TestFail("Missing output formats: (%s)" % |
| ", ".join(expected_output_formats - output_formats)) |