1 #!/usr/bin/env python 2 # 3 # Copyright (C) 2017 The Android Open Source Project 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 # 17 18 import logging 19 import time 20 21 from vts.runners.host import asserts 22 from vts.runners.host import keys 23 from vts.runners.host import test_runner 24 from vts.testcases.template.hal_hidl_gtest import hal_hidl_gtest 25 import VtsHalMediaOmxV1_0TestCase as omx_test_case 26 27 28 class VtsHalMediaOmxV1_0Host(hal_hidl_gtest.HidlHalGTest): 29 """Host test class to run the Media_Omx HAL.""" 30 31 COMPONENT_TEST = "ComponentHidlTest" 32 AUDIO_ENC_TEST = "AudioEncHidlTest" 33 AUDIO_DEC_TEST = "AudioDecHidlTest" 34 VIDEO_ENC_TEST = "VideoEncHidlTest" 35 VIDEO_DEC_TEST = "VideoDecHidlTest" 36 37 # Roles we want to test. 38 whitelist_roles = ["audio_encoder.aac", 39 "audio_encoder.amrnb", 40 "audio_encoder.amrwb", 41 "audio_encoder.flac", 42 "audio_decoder.aac", 43 "audio_decoder.amrnb", 44 "audio_decoder.amrwb", 45 "audio_decoder.flac", 46 "audio_decoder.g711alaw", 47 "audio_decoder.g711mlaw", 48 "audio_decoder.gsm", 49 "audio_decoder.mp3", 50 "audio_decoder.opus", 51 "audio_decoder.raw", 52 "audio_decoder.vorbis", 53 "video_encoder.avc", 54 "video_encoder.h263", 55 "video_encoder.mpeg4", 56 "video_encoder.vp8", 57 "video_encoder.vp9", 58 "video_decoder.avc", 59 "video_decoder.h263", 60 "video_decoder.hevc", 61 "video_decoder.mpeg4", 62 "video_decoder.vp8", 63 "video_decoder.vp9"] 64 65 def CreateTestCases(self): 66 """Get all registered test components and create test case objects.""" 67 # Init the IOmx hal. 68 self._dut.hal.InitHidlHal( 69 target_type="media_omx", 70 target_basepaths=self._dut.libPaths, 71 target_version=1.0, 72 target_package="android.hardware.media.omx", 73 target_component_name="IOmx", 74 bits=64 if self._dut.is64Bit else 32) 75 76 # Call listNodes to get all registered components. 77 self.vtypes = self._dut.hal.media_omx.GetHidlTypeInterface("types") 78 status, nodeList = self._dut.hal.media_omx.listNodes() 79 asserts.assertEqual(self.vtypes.Status.OK, status) 80 81 self.components = {} 82 for node in nodeList: 83 self.components[node['mName']] = node['mRoles'] 84 85 super(VtsHalMediaOmxV1_0Host, self).CreateTestCases() 86 87 # @Override 88 def CreateTestCase(self, path, tag=''): 89 """Create a list of VtsHalMediaOmxV1_0testCase objects. 90 91 For each target side gtest test case, create a set of new test cases 92 argumented with different component and role values. 93 94 Args: 95 path: string, absolute path of a gtest binary on device 96 tag: string, a tag that will be appended to the end of test name 97 98 Returns: 99 A list of VtsHalMediaOmxV1_0TestCase objects 100 """ 101 gtest_cases = super(VtsHalMediaOmxV1_0Host, self).CreateTestCase(path, 102 tag) 103 test_cases = [] 104 105 for gtest_case in gtest_cases: 106 test_suite = gtest_case.full_name 107 for component, roles in self.components.iteritems(): 108 for role in roles: 109 if not self.COMPONENT_TEST in test_suite and not role in self.whitelist_roles: 110 continue 111 if self.AUDIO_ENC_TEST in test_suite and not "audio_encoder" in role: 112 continue 113 if self.AUDIO_DEC_TEST in test_suite and not "audio_decoder" in role: 114 continue 115 if self.VIDEO_ENC_TEST in test_suite and not "video_encoder" in role: 116 continue 117 if self.VIDEO_DEC_TEST in test_suite and not "video_decoder" in role: 118 continue 119 test_name = component + '_' + role 120 # TODO (zhuoyao): get instance name using lshal. 121 instance_name = "default" 122 test_case = omx_test_case.VtsHalMediaOmxV1_0TestCase( 123 component, role, instance_name, test_suite, test_name, 124 path, tag) 125 test_cases.append(test_case) 126 logging.info("num of test_testcases: %s", len(test_cases)) 127 return test_cases 128 129 130 if __name__ == "__main__": 131 test_runner.main() 132