From 29092604b2b12c4d1c2475a755460c128e938cad Mon Sep 17 00:00:00 2001 From: Jayant Chowdhary Date: Tue, 21 Nov 2017 08:48:13 -0800 Subject: [PATCH 1/3] Fix how header-checker tests run. Previously, the tests mainly exercised header-abi-diff. After this change, checked-in reference dumps are compared with generated dumps. This allows us to: - get header-abi-dumper and header-abi-linker involved in testing better. - Know about any incompatbile message format changes made inadvertently. Test: tests/test.py; all tests pass. Change-Id: I7c7ba0811e6c08c6194a0a11616680279e7a0e1d --- vndk/tools/header-checker/tests/gen_all.py | 8 +-- vndk/tools/header-checker/tests/module.py | 20 ++++++-- vndk/tools/header-checker/tests/test.py | 58 +++++++++++++++------- vndk/tools/header-checker/utils/utils.py | 4 +- 4 files changed, 62 insertions(+), 28 deletions(-) diff --git a/vndk/tools/header-checker/tests/gen_all.py b/vndk/tools/header-checker/tests/gen_all.py index 7adf03b59..b0b3ed61e 100755 --- a/vndk/tools/header-checker/tests/gen_all.py +++ b/vndk/tools/header-checker/tests/gen_all.py @@ -21,10 +21,12 @@ DEFAULT_CFLAGS = ['-x', 'c++', '-std=c++11'] FILE_EXTENSIONS = ['h', 'hpp', 'hxx', 'cpp', 'cc', 'c'] -def make_and_copy_reference_dumps(module, default_cflags): +def make_and_copy_reference_dumps(module, default_cflags, + reference_dump_dir=REFERENCE_DUMP_DIR): lsdump_content = module.make_lsdump(default_cflags) - copy_reference_dump_content(module.get_name(), lsdump_content, - REFERENCE_DUMP_DIR, '', module.get_arch()) + return copy_reference_dump_content(module.get_name(), lsdump_content, + reference_dump_dir, '', + module.get_arch()) def main(): patt = re.compile( diff --git a/vndk/tools/header-checker/tests/module.py b/vndk/tools/header-checker/tests/module.py index af58dfbfb..68baa011d 100755 --- a/vndk/tools/header-checker/tests/module.py +++ b/vndk/tools/header-checker/tests/module.py @@ -84,27 +84,35 @@ class Module(object): self.version_script, self.api, self.arch) @staticmethod - def mutate_module_for_all_arches(module): - modules = [] + def mutate_module_for_arch(module, target_arch): name = module.get_name() srcs = module.get_srcs() version_script = module.get_version_script() cflags = module.get_cflags() export_include_dirs = module.get_export_include_dirs() api = module.get_api() + return Module(name, target_arch, srcs, version_script, cflags, + export_include_dirs, api) + + @staticmethod + def mutate_module_for_all_arches(module): + modules = [] for target_arch in TARGET_ARCHS: - modules.append(Module(name, target_arch, srcs, version_script, - cflags, export_include_dirs, api)) + modules.append(Module.mutate_module_for_arch(module, target_arch)) return modules @staticmethod def get_test_modules(): modules = [] - for module in TEST_MODULES: + for module in TEST_MODULES.values(): if module.get_arch() == '': modules += Module.mutate_module_for_all_arches(module) return modules + @staticmethod + def get_test_module_by_name(name): + return TEST_MODULES[name] + TEST_MODULES = [ Module( name = 'libc_and_cpp', @@ -309,3 +317,5 @@ TEST_MODULES = [ api = 'current', ), ] + +TEST_MODULES = { m.name: m for m in TEST_MODULES } diff --git a/vndk/tools/header-checker/tests/test.py b/vndk/tools/header-checker/tests/test.py index 72753ce71..73eaa15bb 100755 --- a/vndk/tools/header-checker/tests/test.py +++ b/vndk/tools/header-checker/tests/test.py @@ -3,6 +3,7 @@ import os import unittest import sys +import tempfile import_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) import_path = os.path.abspath(os.path.join(import_path, 'utils')) @@ -14,8 +15,9 @@ from utils import SOURCE_ABI_DUMP_EXT from utils import TARGET_ARCHS from utils import get_build_var from utils import make_library -from utils import find_lib_lsdump from module import Module +from gen_all import make_and_copy_reference_dumps +from gen_all import DEFAULT_CFLAGS SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) INPUT_DIR = os.path.join(SCRIPT_DIR, 'input') @@ -27,6 +29,12 @@ class MyTest(unittest.TestCase): def setUpClass(cls): cls.maxDiff = None + def get_reference_dump_path(self, name, target_arch): + ref_dump_dir = os.path.join(REF_DUMP_DIR, target_arch) + ref_dump_path = os.path.join(ref_dump_dir, + name + SOURCE_ABI_DUMP_EXT) + return ref_dump_path + def run_and_compare(self, input_path, expected_path, cflags=[]): with open(expected_path, 'r') as f: expected_output = f.read() @@ -47,27 +55,40 @@ class MyTest(unittest.TestCase): def run_and_compare_abi_diff(self, old_dump, new_dump, lib, arch, expected_return_code, flags=[]) : - actual_output = run_abi_diff(old_dump, new_dump, arch, lib, flags) - self.assertEqual(actual_output, expected_return_code) + actual_output = run_abi_diff(old_dump, new_dump, arch, lib, flags) + self.assertEqual(actual_output, expected_return_code) - def prepare_and_run_abi_diff(self, old_lib, new_lib, + def prepare_and_run_abi_diff(self, old_ref_dump_path, new_ref_dump_path, target_arch, expected_return_code, flags=[]): - ref_dump_dir = os.path.join(REF_DUMP_DIR, target_arch) - old_ref_dump_path = os.path.join(ref_dump_dir, - old_lib + SOURCE_ABI_DUMP_EXT) - - new_ref_dump_path = os.path.join(ref_dump_dir, - new_lib + SOURCE_ABI_DUMP_EXT) - self.run_and_compare_abi_diff(old_ref_dump_path, new_ref_dump_path, - new_lib, target_arch, - expected_return_code, flags) + 'test', target_arch, expected_return_code, + flags) + + def create_ref_dump(self, name, dir_name, target_arch): + module_bare = Module.get_test_module_by_name(name) + module = Module.mutate_module_for_arch(module_bare, target_arch) + return make_and_copy_reference_dumps(module, DEFAULT_CFLAGS, + dir_name) + + def get_or_create_ref_dump(self, name, target_arch, dir_name, create): + if create == True: + return self.create_ref_dump(name, dir_name, target_arch) + return self.get_reference_dump_path(name, target_arch) def prepare_and_run_abi_diff_all_archs(self, old_lib, new_lib, - expected_return_code, flags=[]): - for target_arch in TARGET_ARCHS: - self.prepare_and_run_abi_diff(old_lib, new_lib, target_arch, - expected_return_code, flags) + expected_return_code, 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.prepare_and_run_abi_diff(old_ref_dump_path, + new_ref_dump_path, target_arch, + expected_return_code, flags) def test_func_decl_no_args(self): self.run_and_compare_name_c_cpp('func_decl_no_args.h') @@ -157,7 +178,8 @@ class MyTest(unittest.TestCase): def test_libgolden_cpp_fabricated_function_ast_removed_diff(self): self.prepare_and_run_abi_diff_all_archs( - "libgolden_cpp_fabricated_function_ast_removed", "libgolden_cpp", 0) + "libgolden_cpp_fabricated_function_ast_removed", "libgolden_cpp", 0, + [], False) def test_libgolden_cpp_member_fake_diff(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 fd4141325..58053f13e 100644 --- a/vndk/tools/header-checker/utils/utils.py +++ b/vndk/tools/header-checker/utils/utils.py @@ -43,7 +43,7 @@ def copy_reference_dump(lib_path, reference_dump_dir_stem, with open(reference_dump_path, 'w') as f: f.write(output_content) print('Created abi dump at ', reference_dump_path) - return 1 + return reference_dump_path def copy_reference_dump_content(lib_name, output_content, reference_dump_dir_stem, @@ -57,7 +57,7 @@ def copy_reference_dump_content(lib_name, output_content, with open(reference_dump_path, 'w') as f: f.write(output_content) print('Created abi dump at ', reference_dump_path) - return 1 + return reference_dump_path def read_output_content(output_path, replace_str): with open(output_path, 'r') as f: From c18ded4bb00b18a3e41496e33f3a1810318aac21 Mon Sep 17 00:00:00 2001 From: Jayant Chowdhary Date: Tue, 21 Nov 2017 11:06:02 -0800 Subject: [PATCH 2/3] Make create_reference_dumps.py faster. Since we now build and install all vndk libraries,regardless of dependencies, we may just look for all files with the extension '.lsdump' for TARGET_ARCH and TARGET_2ND_ARCH, and copy them to the given reference dump directory. Test: utils/create_reference_dumps.py --version current -ref-dump-dir creates reference dumps at Change-Id: Ic9db57b00614b3e8dc18d8e56eab4bd87df1723c --- .../utils/create_reference_dumps.py | 43 ++++++------------- vndk/tools/header-checker/utils/utils.py | 40 ++++++++++------- 2 files changed, 37 insertions(+), 46 deletions(-) diff --git a/vndk/tools/header-checker/utils/create_reference_dumps.py b/vndk/tools/header-checker/utils/create_reference_dumps.py index 770f125d3..b3f7cb2d9 100755 --- a/vndk/tools/header-checker/utils/create_reference_dumps.py +++ b/vndk/tools/header-checker/utils/create_reference_dumps.py @@ -5,12 +5,8 @@ import re import sys import argparse -from utils import make_library -from utils import find_lib_lsdump -from utils import get_build_var -from utils import AOSP_DIR -from utils import read_output_content -from utils import copy_reference_dump +from utils import (make_library, find_lib_lsdumps, get_build_var, AOSP_DIR, + read_output_content, copy_reference_dumps) class Target(object): def __init__(self, has_2nd): @@ -20,27 +16,19 @@ class Target(object): self.cpu_variant = \ get_build_var('TARGET{}_CPU_VARIANT'.format(extra)) -def get_vndk_libs(vndk_list_path): - with open(vndk_list_path, 'r') as f: - return f.read().splitlines() - -def create_source_abi_reference_dumps(soong_dir, vndk_libs, args): +def create_source_abi_reference_dumps(soong_dir, args): ref_dump_dir_stem = os.path.join(args.ref_dump_dir, args.version) ref_dump_dir_insertion = 'source-based' num_libs_copied = 0 - for vndk_lib in vndk_libs: - if args.make_libs: - make_library(vndk_lib) - for target in [Target(True), Target(False)]: - arch_lsdump_path = find_lib_lsdump(vndk_lib, target.arch, - target.arch_variant, - target.cpu_variant) - # Copy the contents of the lsdump into it's corresponding - # reference directory. - num_libs_copied += copy_reference_dump(arch_lsdump_path, - ref_dump_dir_stem, - ref_dump_dir_insertion, - target.arch) + for target in [Target(True), Target(False)]: + arch_lsdump_paths = find_lib_lsdumps(target.arch, target.arch_variant, + target.cpu_variant, soong_dir) + # Copy the contents of the lsdump into it's corresponding + # reference directory. + num_libs_copied += copy_reference_dumps(arch_lsdump_paths, + ref_dump_dir_stem, + ref_dump_dir_insertion, + target.arch) return num_libs_copied @@ -48,17 +36,12 @@ def main(): # Parse command line options. parser = argparse.ArgumentParser() parser.add_argument('--version', help='VNDK version') - parser.add_argument('--vndk-list', help='file containing list of vndk \ - libraries') parser.add_argument('-ref-dump-dir', help='directory to copy reference abi \ dumps into') - parser.add_argument('-make-libs', action ="store_true", default = False, - help='make libraries before copying dumps') args = parser.parse_args() num_processed = 0 soong_dir = os.path.join(AOSP_DIR, 'out', 'soong', '.intermediates') - num_processed += create_source_abi_reference_dumps(soong_dir,\ - get_vndk_libs(args.vndk_list), args) + num_processed += create_source_abi_reference_dumps(soong_dir, args) print() print('msg: Processed', num_processed, 'libraries') if __name__ == '__main__': diff --git a/vndk/tools/header-checker/utils/utils.py b/vndk/tools/header-checker/utils/utils.py index 58053f13e..83cd8ee87 100644 --- a/vndk/tools/header-checker/utils/utils.py +++ b/vndk/tools/header-checker/utils/utils.py @@ -18,24 +18,32 @@ EXPORTED_HEADERS_DIR = ( 'tests'), ) -SOURCE_ABI_DUMP_EXT = ".so.lsdump" +SO_EXT = '.so' +SOURCE_ABI_DUMP_EXT_END = '.lsdump' +SOURCE_ABI_DUMP_EXT = SO_EXT + SOURCE_ABI_DUMP_EXT_END TARGET_ARCHS = ['arm', 'arm64', 'x86', 'x86_64', 'mips', 'mips64'] def get_reference_dump_dir(reference_dump_dir_stem, - reference_dump_dir_insertion, lib_arch): + reference_dump_dir_insertion, lib_arch): reference_dump_dir = os.path.join(reference_dump_dir_stem, lib_arch) reference_dump_dir = os.path.join(reference_dump_dir, reference_dump_dir_insertion) return reference_dump_dir -def copy_reference_dump(lib_path, reference_dump_dir_stem, - reference_dump_dir_insertion, lib_arch): - if lib_path is None: - return 0 - reference_dump_dir = get_reference_dump_dir(reference_dump_dir_stem, + +def copy_reference_dumps(lib_paths, reference_dir_stem, + reference_dump_dir_insertion, lib_arch): + reference_dump_dir = get_reference_dump_dir(reference_dir_stem, reference_dump_dir_insertion, lib_arch) + num_created = 0 + for lib_path in lib_paths: + copy_reference_dump(lib_path, reference_dump_dir) + num_created += 1 + return num_created + +def copy_reference_dump(lib_path, reference_dump_dir): reference_dump_path = os.path.join(reference_dump_dir, os.path.basename(lib_path)) os.makedirs(os.path.dirname(reference_dump_path), exist_ok=True) @@ -104,14 +112,14 @@ def make_library(lib_name): make_cmd = ['make', '-j', lib_name] subprocess.check_call(make_cmd, cwd=AOSP_DIR) -def find_lib_lsdump(lib_name, target_arch, target_arch_variant, - target_cpu_variant): +def find_lib_lsdumps(target_arch, target_arch_variant, + target_cpu_variant, soong_dir): """ Find the lsdump corresponding to lib_name for the given arch parameters if it exists""" assert 'ANDROID_PRODUCT_OUT' in os.environ cpu_variant = '_' + target_cpu_variant arch_variant = '_' + target_arch_variant - + lsdump_paths = [] if target_cpu_variant == 'generic' or target_cpu_variant is None or\ target_cpu_variant == '': cpu_variant = '' @@ -120,16 +128,16 @@ def find_lib_lsdump(lib_name, target_arch, target_arch_variant, arch_variant = '' target_dir = 'android_' + target_arch + arch_variant +\ - cpu_variant + '_shared_core' - soong_dir = os.path.join(AOSP_DIR, 'out', 'soong', '.intermediates') - expected_lsdump_name = lib_name + SOURCE_ABI_DUMP_EXT + cpu_variant + '_vendor_shared' for base, dirnames, filenames in os.walk(soong_dir): for filename in filenames: - if filename == expected_lsdump_name: + name, ext = os.path.splitext(filename) + sofile, soext = os.path.splitext(name) + if ext == SOURCE_ABI_DUMP_EXT_END and soext == SO_EXT : path = os.path.join(base, filename) if target_dir in os.path.dirname(path): - return path - return None + lsdump_paths.append(path) + return lsdump_paths def run_abi_diff(old_test_dump_path, new_test_dump_path, arch, lib_name, flags=[]): From a668261e85ef18ea2c35c57f25401a7a0c0fdb60 Mon Sep 17 00:00:00 2001 From: Jayant Chowdhary Date: Mon, 4 Dec 2017 18:19:04 -0800 Subject: [PATCH 3/3] Fix missing setter for RecordKind. The record kind (struct, class or union) was not being set while converting from protobuf to IR. Test: tests/test.py, all tests pass. Without the change, the default kind of a C record would have shown up as class_kind. Change-Id: I507581211a6d30c2c51414c6fab6413eece6b458 --- .../include/ir_representation_protobuf.h | 19 +++++++++++ .../src/ir_representation_protobuf.cpp | 2 ++ vndk/tools/header-checker/tests/module.py | 10 ++++++ .../arm/libreproducability.so.lsdump | 34 +++++++++++++++++++ .../arm64/libreproducability.so.lsdump | 34 +++++++++++++++++++ .../mips/libreproducability.so.lsdump | 34 +++++++++++++++++++ .../mips64/libreproducability.so.lsdump | 34 +++++++++++++++++++ .../x86/libreproducability.so.lsdump | 34 +++++++++++++++++++ .../x86_64/libreproducability.so.lsdump | 34 +++++++++++++++++++ vndk/tools/header-checker/tests/test.py | 20 +++++++++++ 10 files changed, 255 insertions(+) create mode 100644 vndk/tools/header-checker/tests/reference_dumps/arm/libreproducability.so.lsdump create mode 100644 vndk/tools/header-checker/tests/reference_dumps/arm64/libreproducability.so.lsdump create mode 100644 vndk/tools/header-checker/tests/reference_dumps/mips/libreproducability.so.lsdump create mode 100644 vndk/tools/header-checker/tests/reference_dumps/mips64/libreproducability.so.lsdump create mode 100644 vndk/tools/header-checker/tests/reference_dumps/x86/libreproducability.so.lsdump create mode 100644 vndk/tools/header-checker/tests/reference_dumps/x86_64/libreproducability.so.lsdump diff --git a/vndk/tools/header-checker/header-abi-util/include/ir_representation_protobuf.h b/vndk/tools/header-checker/header-abi-util/include/ir_representation_protobuf.h index 9325b09a6..b34255b51 100644 --- a/vndk/tools/header-checker/header-abi-util/include/ir_representation_protobuf.h +++ b/vndk/tools/header-checker/header-abi-util/include/ir_representation_protobuf.h @@ -88,6 +88,25 @@ inline abi_dump::RecordKind RecordKindIRToProtobuf( assert(false); } +inline RecordTypeIR::RecordKind RecordKindProtobufToIR( + abi_dump::RecordKind kind) { + switch (kind) { + case abi_dump::RecordKind::struct_kind: + return RecordTypeIR::struct_kind; + + case abi_dump::RecordKind::class_kind: + return RecordTypeIR::class_kind; + + case abi_dump::RecordKind::union_kind: + return RecordTypeIR::union_kind; + + default: + return RecordTypeIR::struct_kind; + } + // Should not be reached + assert(false); +} + inline abi_dump::VTableComponent::Kind VTableComponentKindIRToProtobuf( VTableComponentIR::Kind kind) { switch (kind) { diff --git a/vndk/tools/header-checker/header-abi-util/src/ir_representation_protobuf.cpp b/vndk/tools/header-checker/header-abi-util/src/ir_representation_protobuf.cpp index 3b3e9c91e..f526aa73b 100644 --- a/vndk/tools/header-checker/header-abi-util/src/ir_representation_protobuf.cpp +++ b/vndk/tools/header-checker/header-abi-util/src/ir_representation_protobuf.cpp @@ -154,6 +154,8 @@ RecordTypeIR ProtobufTextFormatToIRReader::RecordTypeProtobufToIR( // Base Specifiers record_type_ir.SetCXXBaseSpecifiers(RecordCXXBaseSpecifiersProtobufToIR( record_type_protobuf.base_specifiers())); + record_type_ir.SetRecordKind( + RecordKindProtobufToIR(record_type_protobuf.record_kind())); return record_type_ir; } diff --git a/vndk/tools/header-checker/tests/module.py b/vndk/tools/header-checker/tests/module.py index 68baa011d..d878175cb 100755 --- a/vndk/tools/header-checker/tests/module.py +++ b/vndk/tools/header-checker/tests/module.py @@ -316,6 +316,16 @@ TEST_MODULES = [ arch = '', api = 'current', ), + Module( + 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', + ), ] TEST_MODULES = { m.name: m for m in TEST_MODULES } diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm/libreproducability.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm/libreproducability.so.lsdump new file mode 100644 index 000000000..35d36134a --- /dev/null +++ b/vndk/tools/header-checker/tests/reference_dumps/arm/libreproducability.so.lsdump @@ -0,0 +1,34 @@ +record_types { + type_info { + name: "ShouldRepro" + size: 4 + alignment: 4 + referenced_type: "ShouldRepro" + source_file: "/development/vndk/tools/header-checker/tests/integration/c_and_cpp/include/reproducability_c.h" + linker_set_key: "ShouldRepro" + } + fields { + referenced_type: "int" + field_offset: 0 + field_name: "a" + access: public_access + } + access: public_access + is_anonymous: true + record_kind: struct_kind +} +builtin_types { + type_info { + name: "int" + size: 4 + alignment: 4 + referenced_type: "int" + source_file: "" + linker_set_key: "int" + } + is_unsigned: false + is_integral: true +} +elf_functions { + name: "repro" +} diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm64/libreproducability.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm64/libreproducability.so.lsdump new file mode 100644 index 000000000..35d36134a --- /dev/null +++ b/vndk/tools/header-checker/tests/reference_dumps/arm64/libreproducability.so.lsdump @@ -0,0 +1,34 @@ +record_types { + type_info { + name: "ShouldRepro" + size: 4 + alignment: 4 + referenced_type: "ShouldRepro" + source_file: "/development/vndk/tools/header-checker/tests/integration/c_and_cpp/include/reproducability_c.h" + linker_set_key: "ShouldRepro" + } + fields { + referenced_type: "int" + field_offset: 0 + field_name: "a" + access: public_access + } + access: public_access + is_anonymous: true + record_kind: struct_kind +} +builtin_types { + type_info { + name: "int" + size: 4 + alignment: 4 + referenced_type: "int" + source_file: "" + linker_set_key: "int" + } + is_unsigned: false + is_integral: true +} +elf_functions { + name: "repro" +} diff --git a/vndk/tools/header-checker/tests/reference_dumps/mips/libreproducability.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips/libreproducability.so.lsdump new file mode 100644 index 000000000..35d36134a --- /dev/null +++ b/vndk/tools/header-checker/tests/reference_dumps/mips/libreproducability.so.lsdump @@ -0,0 +1,34 @@ +record_types { + type_info { + name: "ShouldRepro" + size: 4 + alignment: 4 + referenced_type: "ShouldRepro" + source_file: "/development/vndk/tools/header-checker/tests/integration/c_and_cpp/include/reproducability_c.h" + linker_set_key: "ShouldRepro" + } + fields { + referenced_type: "int" + field_offset: 0 + field_name: "a" + access: public_access + } + access: public_access + is_anonymous: true + record_kind: struct_kind +} +builtin_types { + type_info { + name: "int" + size: 4 + alignment: 4 + referenced_type: "int" + source_file: "" + linker_set_key: "int" + } + is_unsigned: false + is_integral: true +} +elf_functions { + name: "repro" +} diff --git a/vndk/tools/header-checker/tests/reference_dumps/mips64/libreproducability.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips64/libreproducability.so.lsdump new file mode 100644 index 000000000..35d36134a --- /dev/null +++ b/vndk/tools/header-checker/tests/reference_dumps/mips64/libreproducability.so.lsdump @@ -0,0 +1,34 @@ +record_types { + type_info { + name: "ShouldRepro" + size: 4 + alignment: 4 + referenced_type: "ShouldRepro" + source_file: "/development/vndk/tools/header-checker/tests/integration/c_and_cpp/include/reproducability_c.h" + linker_set_key: "ShouldRepro" + } + fields { + referenced_type: "int" + field_offset: 0 + field_name: "a" + access: public_access + } + access: public_access + is_anonymous: true + record_kind: struct_kind +} +builtin_types { + type_info { + name: "int" + size: 4 + alignment: 4 + referenced_type: "int" + source_file: "" + linker_set_key: "int" + } + is_unsigned: false + is_integral: true +} +elf_functions { + name: "repro" +} diff --git a/vndk/tools/header-checker/tests/reference_dumps/x86/libreproducability.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86/libreproducability.so.lsdump new file mode 100644 index 000000000..35d36134a --- /dev/null +++ b/vndk/tools/header-checker/tests/reference_dumps/x86/libreproducability.so.lsdump @@ -0,0 +1,34 @@ +record_types { + type_info { + name: "ShouldRepro" + size: 4 + alignment: 4 + referenced_type: "ShouldRepro" + source_file: "/development/vndk/tools/header-checker/tests/integration/c_and_cpp/include/reproducability_c.h" + linker_set_key: "ShouldRepro" + } + fields { + referenced_type: "int" + field_offset: 0 + field_name: "a" + access: public_access + } + access: public_access + is_anonymous: true + record_kind: struct_kind +} +builtin_types { + type_info { + name: "int" + size: 4 + alignment: 4 + referenced_type: "int" + source_file: "" + linker_set_key: "int" + } + is_unsigned: false + is_integral: true +} +elf_functions { + name: "repro" +} diff --git a/vndk/tools/header-checker/tests/reference_dumps/x86_64/libreproducability.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86_64/libreproducability.so.lsdump new file mode 100644 index 000000000..35d36134a --- /dev/null +++ b/vndk/tools/header-checker/tests/reference_dumps/x86_64/libreproducability.so.lsdump @@ -0,0 +1,34 @@ +record_types { + type_info { + name: "ShouldRepro" + size: 4 + alignment: 4 + referenced_type: "ShouldRepro" + source_file: "/development/vndk/tools/header-checker/tests/integration/c_and_cpp/include/reproducability_c.h" + linker_set_key: "ShouldRepro" + } + fields { + referenced_type: "int" + field_offset: 0 + field_name: "a" + access: public_access + } + access: public_access + is_anonymous: true + record_kind: struct_kind +} +builtin_types { + type_info { + name: "int" + size: 4 + alignment: 4 + referenced_type: "int" + source_file: "" + linker_set_key: "int" + } + is_unsigned: false + is_integral: true +} +elf_functions { + name: "repro" +} diff --git a/vndk/tools/header-checker/tests/test.py b/vndk/tools/header-checker/tests/test.py index 73eaa15bb..e18b9d0f0 100755 --- a/vndk/tools/header-checker/tests/test.py +++ b/vndk/tools/header-checker/tests/test.py @@ -9,12 +9,14 @@ 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 read_output_content from utils import run_header_abi_dumper from utils import run_abi_diff from utils import SOURCE_ABI_DUMP_EXT from utils import TARGET_ARCHS from utils import get_build_var from utils import make_library +from utils import AOSP_DIR from module import Module from gen_all import make_and_copy_reference_dumps from gen_all import DEFAULT_CFLAGS @@ -90,6 +92,20 @@ class MyTest(unittest.TestCase): new_ref_dump_path, target_arch, expected_return_code, flags) + 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)) + def test_func_decl_no_args(self): self.run_and_compare_name_c_cpp('func_decl_no_args.h') @@ -198,6 +214,10 @@ class MyTest(unittest.TestCase): "libgolden_cpp", "libgolden_cpp_unreferenced_elf_symbol_removed", 16) + def test_libreproducability(self): + self.prepare_and_absolute_diff_all_archs("libreproducability", + "libreproducability") + if __name__ == '__main__': unittest.main()