blob: 8cc91f7eec0486b97e97711fcb66fb888fc905e2 [file] [log] [blame]
Zhuoyao Zhang8bbefd72018-03-29 15:14:13 -07001#!/usr/bin/env python
2#
3# Copyright 2018 - 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#
17import argparse
18import os
19import sys
20
21from build.vts_spec_parser import VtsSpecParser
22from configure.test_case_creator import TestCaseCreator
23"""Regenerate test configures for all hal adapter tests.
24
25Usage:
26 python update_hal_adapter_tests.py [-h] cts_hal_mapping_dir
27"""
28
29
30def main():
31 build_top = os.getenv('ANDROID_BUILD_TOP')
32 if not build_top:
33 print('Error: Missing ANDROID_BUILD_TOP env variable. Please run '
34 '\'. build/envsetup.sh; lunch <build target>\' Exiting...')
35 sys.exit(1)
36
37 parser = argparse.ArgumentParser(
38 description='Update vts hal adapter tests.')
39 parser.add_argument(
40 'cts_hal_mapping_dir',
41 help='Directory that stores cts_hal_mapping files.')
42 args = parser.parse_args()
43
44 vts_spec_parser = VtsSpecParser()
45 hal_list = vts_spec_parser.HalNamesAndVersions()
46
47 for hal_name, hal_version in hal_list:
48 hal_package_name = 'android.hardware.' + hal_name + '@' + hal_version
49 major_version, minor_version = hal_version.split('.')
50 if int(minor_version) > 0:
51 lower_version = major_version + '.' + str(int(minor_version) - 1)
52 if (hal_name, lower_version) in hal_list:
53 test_case_creater = TestCaseCreator(vts_spec_parser,
54 hal_package_name)
55 test_case_creater.LaunchTestCase(
56 test_type='adapter',
57 mapping_dir_path=args.cts_hal_mapping_dir)
58
59
60if __name__ == '__main__':
61 main()