• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (C) 2020 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17import logging
18import sys
19
20import xml.etree.ElementTree as ET
21
22VTS_TO_VTS_CORE_MAPPING = {
23    "VtsHalCameraProviderV2_5Target": ["VtsHalCameraProviderV2_4TargetTest"],
24    "VtsKernelLiblpTest": ["vts_core_liblp_test"],
25    "VtsFastbootVerification": ["FastbootVerifyUserspaceTest"],
26    "VtsKernelMemInfoTest": ["vts_core_meminfo_test"],
27    "VtsKernelQtaguidTest": ["vts_test_binary_qtaguid_module"],
28    "VtsTrebleFrameworkVintfTest": ["vts_treble_vintf_framework_test"],
29    "VtsKernelLibdmTest": ["vts_libdm_test"],
30    "VtsGsiBootTest": ["vts_gsi_boot_test"],
31    "VtsHalBaseV1_0TargetTest": ["vts_ibase_test"],
32    "VtsKernelLibcutilsTest": ["KernelLibcutilsTest"],
33    "VtsKernelNetBpfTest": ["bpf_module_test"],
34    "VtsSecurityAvb": ["vts_security_avb_test"],
35    "VtsKernelBinderTest": ["binderSafeInterfaceTest",
36                            "binderLibTest",
37                            "binderDriverInterfaceTest",
38                            "memunreachable_binder_test"],
39    "VtsKernelTunTest": ["vts_kernel_tun_test"],
40    "VtsTrebleVendorVintfTest": ["vts_treble_vintf_vendor_test"],
41}
42
43IGNORED_MODULES = ["VtsKernelHwBinder"]
44
45def usage():
46    """Prints usage and exits."""
47    print("Arguments Error: Please specify the test_result file of "
48          "vts and vts-core.")
49    print "Usage: <this script> <test_result_of_vts> <test_result_of_vts_core>"
50    print "       e.g. python compare_vts_core_result.py vts_test_result.xml vts_core_test_result.xml"
51    exit(-1)
52
53def _get_all_modules_name_from_xml(result_file):
54    """Get all modules name from a test_result file.
55
56    Args:
57        restul_file: The path of a test result file.
58
59    Returns:
60        A set of all test module names.
61    """
62    xml_tree = ET.parse(result_file)
63    xml_root = xml_tree.getroot()
64    all_modules = set()
65    for elem in xml_root.iter(tag="Module"):
66        all_modules.add(elem.attrib['name'])
67    return all_modules
68
69def _compare_vts_and_vts_core_module(vts_modules, vts_core_modules):
70    """Compare vts and vts-core module names.
71
72    Args:
73        vts_modules: All modules names of vts.
74        vts_core_modules: All modules name of vts-core.
75
76    Returns:
77        A set of the modules that in the vts but not in the vts-core.
78    """
79    module_name_convert_keys = VTS_TO_VTS_CORE_MAPPING.keys()
80    not_converted_modules = []
81    for vts_module_name in vts_modules:
82        vts_core_module_names = [vts_module_name]
83        if vts_module_name in module_name_convert_keys:
84            vts_core_module_names = VTS_TO_VTS_CORE_MAPPING[vts_module_name]
85        for necessary_module_name in vts_core_module_names:
86            if necessary_module_name not in vts_core_modules:
87                Hal_test_name = necessary_module_name + "Test"
88                if Hal_test_name not in vts_core_modules:
89                    if vts_module_name not in IGNORED_MODULES:
90                        not_converted_modules.append(vts_module_name)
91                        break
92    return sorted(not_converted_modules)
93
94def compare_vts_and_vts_core_result_file(vts_result_file, vts_core_result_file):
95    """Compare the test result file of vts and vts-core.
96
97    Args:
98        vts_result_file: The path of the test result file of vts.
99        vts_core_result_file: The path of the test result file of vts-core.
100
101    Returns:
102        A set of the modules that in the vts but not in the vts-core.
103    """
104    vts_modules = _get_all_modules_name_from_xml(vts_result_file)
105    vts_core_modules = _get_all_modules_name_from_xml(vts_core_result_file)
106    not_converted_modules = _compare_vts_and_vts_core_module(vts_modules, vts_core_modules)
107    for module in not_converted_modules:
108        print module
109
110def main(argv):
111    """Entry point of atest script.
112
113    Args:
114        argv: A list of arguments.
115    """
116    if len(argv) != 3:
117        usage()
118    compare_vts_and_vts_core_result_file(argv[1], argv[2])
119
120if __name__ == '__main__':
121    main(sys.argv)
122