Files
android_development/vndk/tools/header-checker/tests/gen_all.py
Jayant Chowdhary 7cc00996e5 Fix map key in header-abi-diff while extracting user defined types.
The key being added to respective maps which facilitate diffing of
unreferenced user defined types was earlier the linker set key. The
unique id should be used instead. This is because linker set keys for C
and C++ types can be the same, but their unique id's cannot. Thus,
having linker set keys as a key leaves open the possibility of false
type aliasing, whereas the unique id does not.

Test: python3 tests/test.py

Test: python3 tests/test.py \
      MyTest.test_libc_and_cpp_with_unused_struct_and_libc_and_cpp_with_unused_cstruct;
      before this change, this test fails; after this change, the test
      passes.

Change-Id: I91816167a48308a8c812d01e0a09e9bb70c60b50
2018-02-07 13:04:30 -08:00

58 lines
2.0 KiB
Python
Executable File

#!/usr/bin/env python3
import os
import re
import sys
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 run_header_abi_dumper
from utils import copy_reference_dump_content
from module import Module
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_lsdump(default_cflags)
return copy_reference_dump_content(module.get_name(), lsdump_content,
reference_dump_dir, '',
module.get_arch())
def main():
patt = re.compile(
'^.*\\.(?:' + \
'|'.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):
for filename in filenames:
if not patt.match(filename):
print('ignore:', filename)
continue
input_path = os.path.join(base, filename)
input_rel_path = input_path[input_dir_prefix_len:]
output_path = os.path.join(EXPECTED_DIR, input_rel_path)
print('generating', output_path, '...')
output_content = run_header_abi_dumper(input_path, True)
os.makedirs(os.path.dirname(output_path), exist_ok=True)
with open(output_path, 'w') as f:
f.write(output_content)
modules = Module.get_test_modules()
for module in modules:
make_and_copy_reference_dumps(module)
return 0
if __name__ == '__main__':
sys.exit(main())