diff --git a/vndk/tools/header-checker/tests/gen_all.py b/vndk/tools/header-checker/tests/gen_all.py index 9bb62e9a8..474b7228a 100755 --- a/vndk/tools/header-checker/tests/gen_all.py +++ b/vndk/tools/header-checker/tests/gen_all.py @@ -9,25 +9,18 @@ import_path = os.path.abspath(os.path.join(import_path, 'utils')) sys.path.insert(1, import_path) from utils import run_header_abi_dumper -from utils import copy_reference_dump_content from module import Module +from test import INPUT_DIR +from test import EXPECTED_DIR +from test import make_and_copy_reference_dumps -SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) -INPUT_DIR = os.path.join(SCRIPT_DIR, 'input') -EXPECTED_DIR = os.path.join(SCRIPT_DIR, 'expected') -REFERENCE_DUMP_DIR = os.path.join(SCRIPT_DIR, 'reference_dumps') FILE_EXTENSIONS = ['h', 'hpp', 'hxx', 'cpp', 'cc', 'c'] -def make_and_copy_reference_dumps(module, default_cflags=[], - reference_dump_dir=REFERENCE_DUMP_DIR): - lsdump_content = module.make_dump(default_cflags) - return copy_reference_dump_content(module.get_dump_name(), lsdump_content, - reference_dump_dir, '', module.arch) def main(): patt = re.compile( - '^.*\\.(?:' + \ - '|'.join('(?:' + re.escape(ext) + ')' for ext in FILE_EXTENSIONS) + \ + '^.*\\.(?:' + + '|'.join('(?:' + re.escape(ext) + ')' for ext in FILE_EXTENSIONS) + ')$') input_dir_prefix_len = len(INPUT_DIR) + 1 for base, dirnames, filenames in os.walk(INPUT_DIR): @@ -48,9 +41,10 @@ def main(): f.write(output_content) modules = Module.get_test_modules() for module in modules: - make_and_copy_reference_dumps(module) + print('Created abi dump at', make_and_copy_reference_dumps(module)) return 0 + if __name__ == '__main__': sys.exit(main()) diff --git a/vndk/tools/header-checker/tests/module.py b/vndk/tools/header-checker/tests/module.py index 8ef024612..a3ae37946 100755 --- a/vndk/tools/header-checker/tests/module.py +++ b/vndk/tools/header-checker/tests/module.py @@ -11,26 +11,25 @@ sys.path.insert(1, import_path) from utils import run_header_abi_dumper from utils import run_header_abi_dumper_on_file from utils import run_header_abi_linker -from utils import TARGET_ARCHS from utils import SOURCE_ABI_DUMP_EXT SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) -INPUT_DIR = os.path.join(SCRIPT_DIR, 'input') -EXPECTED_DIR = os.path.join(SCRIPT_DIR, 'expected') -REF_DUMP_DIR = os.path.join(SCRIPT_DIR, 'reference_dumps') ARCH_TARGET_CFLAGS = { - 'arm': ['-target', 'arm-linux-androideabi'], - 'arm64': ['-target', 'aarch64-linux-android'], - 'x86': ['-target', 'i386-linux-androideabi'], - 'x86_64': ['-target', 'x86_64-linux-android'], - 'mips': ['-target', 'mips-linux-androideabi'], - 'mips64': ['-target', 'mips64-linux-android'], + 'arm': ('-target', 'arm-linux-androideabi'), + 'arm64': ('-target', 'aarch64-linux-android'), + 'x86': ('-target', 'i386-linux-androideabi'), + 'x86_64': ('-target', 'x86_64-linux-android'), + 'mips': ('-target', 'mips-linux-androideabi'), + 'mips64': ('-target', 'mips64-linux-android'), } +TARGET_ARCHES = ['arm', 'arm64', 'x86', 'x86_64', 'mips', 'mips64'] + def relative_to_abs_path(relative_path): return os.path.join(SCRIPT_DIR, relative_path) + def relative_to_abs_path_list(relative_path_list): abs_paths = [] for relative_path in relative_path_list: @@ -42,17 +41,16 @@ class Module(object): def __init__(self, name, arch, cflags, export_include_dirs): self.name = name self.arch = arch - self.cflags = cflags - self.arch_cflags = [''] - if self.arch != '': - self.arch_cflags = ARCH_TARGET_CFLAGS.get(self.arch) - self.export_include_dirs = relative_to_abs_path_list(export_include_dirs) + self.cflags = tuple(cflags) + self.arch_cflags = ARCH_TARGET_CFLAGS.get(self.arch, tuple()) + self.export_include_dirs = relative_to_abs_path_list( + export_include_dirs) def get_dump_name(self): """Returns the module name followed by file extension.""" raise NotImplementedError() - def make_dump(self, default_cflags): + def make_dump(self): """Returns the dump content as a string.""" raise NotImplementedError() @@ -61,8 +59,10 @@ class Module(object): raise NotImplementedError() def mutate_for_all_arches(self): + if self.arch: + return [self] modules = [] - for target_arch in TARGET_ARCHS: + for target_arch in TARGET_ARCHES: modules.append(self.mutate_for_arch(target_arch)) return modules @@ -70,13 +70,12 @@ class Module(object): def get_test_modules(): modules = [] for module in TEST_MODULES.values(): - if module.arch == '': - modules += module.mutate_for_all_arches() + modules += module.mutate_for_all_arches() return modules @staticmethod - def get_test_module_by_name(name): - return TEST_MODULES.get(name) + def get_test_modules_by_name(name): + return TEST_MODULES.get(name).mutate_for_all_arches() class SdumpModule(Module): @@ -90,7 +89,7 @@ class SdumpModule(Module): def get_dump_name(self): return self.name + '.sdump' - def make_dump(self, default_cflags): + def make_dump(self): return run_header_abi_dumper( self.src, remove_absolute_paths=True, cflags=self.cflags, export_include_dirs=self.export_include_dirs, @@ -102,8 +101,8 @@ class SdumpModule(Module): class LsdumpModule(Module): - def __init__(self, name, arch, srcs, version_script, cflags, - export_include_dirs, api, dumper_flags=tuple(), + def __init__(self, name, srcs, version_script, export_include_dirs, + cflags=tuple(), arch='', api='current', dumper_flags=tuple(), linker_flags=tuple()): super(LsdumpModule, self).__init__(name, arch, cflags, export_include_dirs) @@ -116,28 +115,28 @@ class LsdumpModule(Module): def get_dump_name(self): return self.name + SOURCE_ABI_DUMP_EXT - def make_dump(self, default_cflags): - """ For each source file, produce a .sdump file, and link them to form - an lsump file""" + def make_dump(self): + """For each source file, produce a .sdump file, and link them to form + an lsump file.""" dumps_to_link = [] with tempfile.TemporaryDirectory() as tmp: output_lsdump = os.path.join(tmp, self.get_dump_name()) for src in self.srcs: - output_path = os.path.join(tmp, os.path.basename(src)) + '.sdump' + output_path = os.path.join(tmp, + os.path.basename(src) + '.sdump') dumps_to_link.append(output_path) run_header_abi_dumper_on_file( src, output_path, self.export_include_dirs, - self.cflags + self.arch_cflags + default_cflags, + self.cflags + self.arch_cflags, self.dumper_flags) return run_header_abi_linker(output_lsdump, dumps_to_link, self.version_script, self.api, self.arch, self.linker_flags) def mutate_for_arch(self, target_arch): - return LsdumpModule(self.name, target_arch, self.srcs, - self.version_script, self.cflags, - self.export_include_dirs, self.api, - self.dumper_flags, self.linker_flags) + return LsdumpModule(self.name, self.srcs, self.version_script, + self.export_include_dirs, self.cflags, target_arch, + self.api, self.dumper_flags, self.linker_flags) TEST_MODULES = [ @@ -159,9 +158,6 @@ TEST_MODULES = [ ], version_script='integration/c_and_cpp/map.txt', export_include_dirs=['integration/c_and_cpp/include'], - cflags=[], - arch='', - api='current', ), LsdumpModule( name='libc_and_cpp_with_opaque_ptr_a', @@ -172,8 +168,6 @@ TEST_MODULES = [ version_script='integration/c_and_cpp/map.txt', export_include_dirs=['integration/c_and_cpp/include'], cflags=['-DOPAQUE_STRUCT_A=1'], - arch='', - api='current', ), LsdumpModule( name='libc_and_cpp_with_opaque_ptr_b', @@ -184,8 +178,6 @@ TEST_MODULES = [ version_script='integration/c_and_cpp/map.txt', export_include_dirs=['integration/c_and_cpp/include'], cflags=['-DOPAQUE_STRUCT_B=1'], - arch='', - api='current', ), LsdumpModule( name='libc_and_cpp_with_unused_struct', @@ -196,8 +188,6 @@ TEST_MODULES = [ version_script='integration/c_and_cpp/map.txt', export_include_dirs=['integration/c_and_cpp/include'], cflags=['-DINCLUDE_UNUSED_STRUCTS=1'], - arch='', - api='current', ), LsdumpModule( name='libc_and_cpp_with_unused_cstruct', @@ -208,8 +198,6 @@ TEST_MODULES = [ version_script='integration/c_and_cpp/map.txt', export_include_dirs=['integration/c_and_cpp/include'], cflags=['-DINCLUDE_UNUSED_STRUCTS=1', '-DMAKE_UNUSED_STRUCT_C=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp', @@ -220,9 +208,6 @@ TEST_MODULES = [ ], version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], - cflags=[], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_odr', @@ -234,8 +219,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DTEST_ODR'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_add_function', @@ -247,8 +230,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map_add_function.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_ADD_FUNCTION=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_add_function_and_unexported_elf', @@ -272,9 +253,6 @@ TEST_MODULES = [ ], version_script='integration/cpp/gold/map_add_function.txt', export_include_dirs=['integration/cpp/gold/include'], - cflags=[], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_change_function_access', @@ -286,8 +264,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_CHANGE_FUNCTION_ACCESS=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_add_global_variable', @@ -299,8 +275,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map_added_globvar.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_ADD_GLOBVAR=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_add_global_variable_private', @@ -312,8 +286,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map_added_globvar.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_ADD_GLOBVAR=1', '-DGOLDEN_ADD_GLOBVAR_PRIVATE'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_return_type_diff', @@ -325,8 +297,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_RETURN_TYPE_DIFF=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_parameter_type_diff', @@ -338,8 +308,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map_parameter_type_diff.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_PARAMETER_TYPE_DIFF=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_vtable_diff', @@ -351,8 +319,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_VTABLE_DIFF=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_member_diff', @@ -364,8 +330,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_MEMBER_DIFF=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_member_fake_diff', @@ -377,8 +341,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_MEMBER_FAKE_DIFF=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_member_cv_diff', @@ -390,8 +352,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_MEMBER_CV_DIFF=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_change_member_access', @@ -403,8 +363,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_CHANGE_MEMBER_ACCESS=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_member_integral_type_diff', @@ -416,8 +374,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_MEMBER_INTEGRAL_TYPE_DIFF=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_enum_diff', @@ -429,8 +385,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_ENUM_DIFF=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_enum_extended', @@ -442,8 +396,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_ENUM_EXTENSION=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_unreferenced_elf_symbol_removed', @@ -454,18 +406,12 @@ TEST_MODULES = [ ], version_script='integration/cpp/gold/map_elf_symbol_removed.txt', export_include_dirs=['integration/cpp/gold/include'], - cflags=[], - arch='', - api='current', ), LsdumpModule( name='libreproducability', srcs=['integration/c_and_cpp/reproducability.c'], version_script='integration/c_and_cpp/repro_map.txt', export_include_dirs=['integration/c_and_cpp/include'], - cflags=[], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_member_name_changed', @@ -477,8 +423,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_CHANGE_MEMBER_NAME_SAME_OFFSET=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_function_pointer', @@ -490,8 +434,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_FUNCTION_POINTER=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_function_pointer_parameter_added', @@ -504,8 +446,6 @@ TEST_MODULES = [ export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_FUNCTION_POINTER_ADD_PARAM=1', '-DGOLDEN_FUNCTION_POINTER=1'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_internal_public_struct', @@ -518,8 +458,6 @@ TEST_MODULES = [ export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_WITH_INTERNAL_STRUCT', '-DGOLDEN_WITH_PUBLIC_INTERNAL_STRUCT'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_internal_private_struct', @@ -531,8 +469,6 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_WITH_INTERNAL_STRUCT'], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_inheritance_type_changed', @@ -544,17 +480,12 @@ TEST_MODULES = [ version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], cflags=['-DGOLDEN_CHANGE_INHERITANCE_TYPE'], - arch='', - api='current', ), LsdumpModule( name='libpure_virtual_function', srcs=['integration/cpp/pure_virtual/pure_virtual_function.cpp'], export_include_dirs=['integration/cpp/pure_virtual/include'], version_script='', - cflags=[], - arch='', - api='current', ), LsdumpModule( name='libgolden_cpp_json', @@ -565,9 +496,6 @@ TEST_MODULES = [ ], version_script='integration/cpp/gold/map.txt', export_include_dirs=['integration/cpp/gold/include'], - cflags=[], - arch='', - api='current', dumper_flags=['-output-format', 'Json'], linker_flags=['-input-format', 'Json', '-output-format', 'Json'] ), diff --git a/vndk/tools/header-checker/tests/test.py b/vndk/tools/header-checker/tests/test.py index bef8e74de..71d626087 100755 --- a/vndk/tools/header-checker/tests/test.py +++ b/vndk/tools/header-checker/tests/test.py @@ -9,11 +9,9 @@ import_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) import_path = os.path.abspath(os.path.join(import_path, 'utils')) sys.path.insert(1, import_path) -from utils import ( - AOSP_DIR, SOURCE_ABI_DUMP_EXT, TARGET_ARCHS, read_output_content, - run_abi_diff, run_header_abi_dumper) +from utils import (AOSP_DIR, read_output_content, run_abi_diff, + run_header_abi_dumper) from module import Module -from gen_all import make_and_copy_reference_dumps SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) @@ -22,11 +20,37 @@ EXPECTED_DIR = os.path.join(SCRIPT_DIR, 'expected') REF_DUMP_DIR = os.path.join(SCRIPT_DIR, 'reference_dumps') -class MyTest(unittest.TestCase): +def make_and_copy_reference_dumps(module, reference_dump_dir=REF_DUMP_DIR): + output_content = module.make_dump() + + dump_dir = os.path.join(reference_dump_dir, module.arch) + os.makedirs(dump_dir, exist_ok=True) + + dump_path = os.path.join(dump_dir, module.get_dump_name()) + with open(dump_path, 'w') as f: + f.write(output_content) + + return dump_path + + +class HeaderCheckerTest(unittest.TestCase): @classmethod def setUpClass(cls): cls.maxDiff = None + def setUp(self): + self.tmp_dir = None + + def tearDown(self): + if self.tmp_dir: + self.tmp_dir.cleanup() + self.tmp_dir = None + + def get_tmp_dir(self): + if not self.tmp_dir: + self.tmp_dir = tempfile.TemporaryDirectory() + return self.tmp_dir.name + def run_and_compare(self, input_path, expected_path, cflags=[]): with open(expected_path, 'r') as f: expected_output = f.read() @@ -53,43 +77,43 @@ class MyTest(unittest.TestCase): def prepare_and_run_abi_diff(self, old_ref_dump_path, new_ref_dump_path, target_arch, expected_return_code, flags=[]): self.run_and_compare_abi_diff(old_ref_dump_path, new_ref_dump_path, - 'test', target_arch, expected_return_code, - flags) + 'test', target_arch, + expected_return_code, flags) - def create_ref_dump(self, module_bare, dir_name, target_arch): - module = module_bare.mutate_for_arch(target_arch) - return make_and_copy_reference_dumps(module, [], dir_name) - - def get_or_create_ref_dump(self, name, target_arch, dir_name, create): - module = Module.get_test_module_by_name(name) - if create == True: - return self.create_ref_dump(module, dir_name, target_arch) - return os.path.join(REF_DUMP_DIR, target_arch, module.get_dump_name()) + def get_or_create_ref_dump(self, module, create): + if create: + return make_and_copy_reference_dumps(module, self.get_tmp_dir()) + return os.path.join(REF_DUMP_DIR, module.arch, module.get_dump_name()) def prepare_and_run_abi_diff_all_archs(self, old_lib, new_lib, expected_return_code, flags=[], create_old=False, create_new=True): - with tempfile.TemporaryDirectory() as tmp: - for target_arch in TARGET_ARCHS: - old_ref_dump_path = self.get_or_create_ref_dump( - old_lib, target_arch, tmp, create_old) - new_ref_dump_path = self.get_or_create_ref_dump( - new_lib, target_arch, tmp, create_new) - self.prepare_and_run_abi_diff( - old_ref_dump_path, new_ref_dump_path, target_arch, - expected_return_code, flags) + old_modules = Module.get_test_modules_by_name(old_lib) + new_modules = Module.get_test_modules_by_name(new_lib) + self.assertEqual(len(old_modules), len(new_modules)) - def prepare_and_absolute_diff_all_archs(self, old_lib, new_lib, - flags=[], create=True): - with tempfile.TemporaryDirectory() as tmp: - for target_arch in TARGET_ARCHS: - old_ref_dump_path = self.get_or_create_ref_dump( - old_lib, target_arch, tmp, False) - new_ref_dump_path = self.get_or_create_ref_dump( - new_lib, target_arch, tmp, create) - self.assertEqual( - read_output_content(old_ref_dump_path, AOSP_DIR), - read_output_content(new_ref_dump_path, AOSP_DIR)) + for old_module, new_module in zip(old_modules, new_modules): + self.assertEqual(old_module.arch, new_module.arch) + old_ref_dump_path = self.get_or_create_ref_dump(old_module, + create_old) + new_ref_dump_path = self.get_or_create_ref_dump(new_module, + create_new) + self.prepare_and_run_abi_diff( + old_ref_dump_path, new_ref_dump_path, new_module.arch, + expected_return_code, flags) + + def prepare_and_absolute_diff_all_archs(self, old_lib, new_lib): + old_modules = Module.get_test_modules_by_name(old_lib) + new_modules = Module.get_test_modules_by_name(new_lib) + self.assertEqual(len(old_modules), len(new_modules)) + + for old_module, new_module in zip(old_modules, new_modules): + self.assertEqual(old_module.arch, new_module.arch) + old_ref_dump_path = self.get_or_create_ref_dump(old_module, False) + new_ref_dump_path = self.get_or_create_ref_dump(new_module, True) + self.assertEqual( + read_output_content(old_ref_dump_path, AOSP_DIR), + read_output_content(new_ref_dump_path, AOSP_DIR)) def test_example1_cpp(self): self.run_and_compare_name_cpp('example1.cpp') @@ -168,7 +192,8 @@ class MyTest(unittest.TestCase): def test_libgolden_cpp_add_function_and_elf_symbol(self): self.prepare_and_run_abi_diff_all_archs( - "libgolden_cpp", "libgolden_cpp_add_function_and_unexported_elf", 4) + "libgolden_cpp", "libgolden_cpp_add_function_and_unexported_elf", + 4) def test_libgolden_cpp_fabricated_function_ast_removed_diff(self): self.prepare_and_run_abi_diff_all_archs( @@ -244,7 +269,8 @@ class MyTest(unittest.TestCase): def test_libgolden_cpp_member_function_pointer_changed(self): self.prepare_and_run_abi_diff_all_archs( "libgolden_cpp_function_pointer", - "libgolden_cpp_function_pointer_parameter_added", 8, [], True, True) + "libgolden_cpp_function_pointer_parameter_added", 8, [], + True, True) def test_libgolden_cpp_internal_struct_access_upgraded(self): self.prepare_and_run_abi_diff_all_archs( diff --git a/vndk/tools/header-checker/utils/utils.py b/vndk/tools/header-checker/utils/utils.py index 88982afd6..842e99ce4 100644 --- a/vndk/tools/header-checker/utils/utils.py +++ b/vndk/tools/header-checker/utils/utils.py @@ -19,7 +19,8 @@ except KeyError: BUILTIN_HEADERS_DIR = ( os.path.join(AOSP_DIR, 'bionic', 'libc', 'include'), os.path.join(AOSP_DIR, 'external', 'libcxx', 'include'), - os.path.join(AOSP_DIR, 'prebuilts', 'clang-tools', 'linux-x86', 'clang-headers'), + os.path.join(AOSP_DIR, 'prebuilts', 'clang-tools', 'linux-x86', + 'clang-headers'), ) EXPORTED_HEADERS_DIR = ( @@ -38,8 +39,6 @@ DEFAULT_CFLAGS = ['-std=gnu99'] DEFAULT_HEADER_FLAGS = ["-dump-function-declarations"] DEFAULT_FORMAT = 'ProtobufTextFormat' -TARGET_ARCHS = ['arm', 'arm64', 'x86', 'x86_64', 'mips', 'mips64'] - def get_reference_dump_dir(reference_dump_dir_stem, reference_dump_dir_insertion, lib_arch): @@ -78,21 +77,6 @@ def copy_reference_dump(lib_path, reference_dump_dir, compress): return reference_dump_path -def copy_reference_dump_content(file_name, output_content, - reference_dump_dir_stem, - reference_dump_dir_insertion, lib_arch): - reference_dump_dir = get_reference_dump_dir(reference_dump_dir_stem, - reference_dump_dir_insertion, - lib_arch) - reference_dump_path = os.path.join(reference_dump_dir, file_name) - os.makedirs(os.path.dirname(reference_dump_path), exist_ok=True) - with open(reference_dump_path, 'w') as f: - f.write(output_content) - - print('Created abi dump at', reference_dump_path) - return reference_dump_path - - def read_output_content(output_path, replace_str): with open(output_path, 'r') as f: return f.read().replace(replace_str, '') @@ -115,7 +99,7 @@ def run_header_abi_dumper_on_file(input_path, output_path, export_include_dirs=tuple(), cflags=tuple(), flags=tuple()): input_ext = os.path.splitext(input_path)[1] - cmd = ['header-abi-dumper', '-o', output_path, input_path,] + cmd = ['header-abi-dumper', '-o', output_path, input_path] for dir in export_include_dirs: cmd += ['-I', dir] cmd += flags @@ -188,15 +172,15 @@ def find_lib_lsdumps(target_arch, target_arch_variant, cpu_variant = '_' + target_cpu_variant arch_variant = '_' + target_arch_variant arch_lsdump_paths = [] - if target_cpu_variant == 'generic' or target_cpu_variant is None or\ - target_cpu_variant == '': + if (target_cpu_variant == 'generic' or target_cpu_variant is None or + target_cpu_variant == ''): cpu_variant = '' - if target_arch_variant == target_arch or target_arch_variant is None or\ - target_arch_variant == '': + if (target_arch_variant == target_arch or target_arch_variant is None or + target_arch_variant == ''): arch_variant = '' - target_dir = 'android_' + target_arch + arch_variant +\ - cpu_variant + core_or_vendor_shared_str + target_dir = ('android_' + target_arch + arch_variant + + cpu_variant + core_or_vendor_shared_str) for key in lsdump_paths: if libs and key not in libs: continue @@ -245,7 +229,7 @@ def get_build_vars_for_product(names, product=None): out, err = proc.communicate() if proc.returncode != 0: - print ("error: %s" % err.decode('utf-8'), file=sys.stderr) + print("error: %s" % err.decode('utf-8'), file=sys.stderr) return None build_vars = out.decode('utf-8').strip().splitlines()