blob: 733254ad3a9a8a4ed5a95f8853fc88708cf5c373 [file] [log] [blame]
Zhuoyao Zhanga7035872017-02-20 16:06:02 -08001#!/usr/bin/env python
2#
3# Copyright 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
18import argparse
19import os
20import re
21import sys
22
23from configure.test_case_creator import TestCaseCreator
24from build.vts_spec_parser import VtsSpecParser
25"""Regenerate test configures for all existing tests.
26
27Usage:
28 python update_hal_tests.py
29"""
30
31
32def GetTimeOut(configure_path):
33 """Get the timeout settings from the original configure.
34
35 Args:
36 configure_path: path of the original configure file.
37
38 Returns:
39 timeout values.
40 """
41 time_out = "1m"
42 configure_file = open(configure_path, "r")
43 for line in configure_file.readlines():
44 if "test-timeout" in line:
45 temp = line[(line.find("value") + 7):]
46 time_out = temp[0:temp.find('"')]
47 break
48 return time_out
49
50
51def GetDisableRunTime(configure_path):
52 """Get the stop runtime settings from the original configure.
53
54 Args:
55 configure_path: path of the original configure file.
56
57 Returns:
58 Settings about whether to stop runtime before test.
59 """
60 disable_runtime = False
61 configure_file = open(configure_path, "r")
62 for line in configure_file.readlines():
63 if "binary-test-disable-framework" in line:
64 disable_runtime = True
65 break
66 return disable_runtime
67
68
69test_categories = {
70 'target': ('target/AndroidTest.xml', 'target', False),
71 'target_profiling': ('target_profiling/AndroidTest.xml', 'target', True),
72 'host': ('host/AndroidTest.xml', 'host', False),
73 'host_profiling': ('host_profiling/AndroidTest.xml', 'host', True),
74}
75
76
77def main():
78 build_top = os.getenv('ANDROID_BUILD_TOP')
79 if not build_top:
80 print('Error: Missing ANDROID_BUILD_TOP env variable. Please run '
81 '\'. build/envsetup.sh; lunch <build target>\' Exiting...')
82 sys.exit(1)
83
84 vts_spec_parser = VtsSpecParser()
85 hal_list = vts_spec_parser.HalNamesAndVersions()
86
87 for hal_name, hal_version in hal_list:
88 hal_package_name = 'android.hardware.' + hal_name + '@' + hal_version
89 test_case_creater = TestCaseCreator(vts_spec_parser, hal_package_name)
90 hal_path = hal_name.replace(".", "/")
91 hal_version_str = 'V' + hal_version.replace('.', '_')
92 hal_test_path = os.path.join(build_top, 'test/vts-testcase/hal',
93 hal_path, hal_version_str)
94
95 for test_categry, configure in test_categories.iteritems():
96 print test_categry
97 print configure
98 test_configure_path = os.path.join(hal_test_path, configure[0])
99 if os.path.exists(test_configure_path):
100 time_out = GetTimeOut(test_configure_path)
101 stop_runtime = GetDisableRunTime(test_configure_path)
102 test_case_creater.LaunchTestCase(
103 configure[1],
104 time_out=time_out,
105 is_profiling=configure[2],
106 stop_runtime=stop_runtime,
107 update_only=True)
108
109
110if __name__ == '__main__':
111 main()