From 77fd179707f2bd9616b10a2e36b9a5b9f51641f3 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Fri, 27 Sep 2024 19:17:41 +0800 Subject: [PATCH] ANDROID: Fix gcno mappings - The gcno mapping files can map virtual device modules' gcno files. create-tracefile.py no longer needs to omit them. - The script extracts coverage data to out/coverage/kunit. The old data affect the results and should be cleared. Test: common/tools/testing/android/bin/kunit.sh --gcov Bug: 358439710 Change-Id: Ia97db8085327c80564f9688fa24fe8b8bb0af249 Signed-off-by: Hsin-Yi Chen --- tools/testing/android/bin/create-tracefile.py | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/tools/testing/android/bin/create-tracefile.py b/tools/testing/android/bin/create-tracefile.py index cdc6391af768..47233fb636a9 100755 --- a/tools/testing/android/bin/create-tracefile.py +++ b/tools/testing/android/bin/create-tracefile.py @@ -44,14 +44,6 @@ EXCLUDED_FILES = [ "*/security/selinux/flask.h", ] -# TODO(b/330365583) These gcno files are not currently preserved. -OMITTED_GCNO_FILES = [ - "common-modules/virtual-device/v4l2loopback/v4l2loopback.gcno", - "common-modules/virtual-device/goldfish_drivers/goldfish_sync.gcno", - "common-modules/virtual-device/goldfish_drivers/goldfish_pipe.gcno", - "common-modules/virtual-device/goldfish_drivers/goldfish_address_space.gcno", -] - def create_llvm_gcov_sh( llvm_cov_filename: str, @@ -161,15 +153,6 @@ def correct_symlinks_in_directory(directory: str, prefix_mappings: {}) -> None: for root, _, files in os.walk(directory): for filename in files: filepath = os.path.join(root, filename) - - # TODO(b/330365583) These gcno files aren't preserved and can't be used. - if any( - ommitted_filename in filepath - for ommitted_filename in OMITTED_GCNO_FILES - ): - os.remove(filepath) - continue - if os.path.islink(filepath): if not update_symlink_from_mapping(filepath, prefix_mappings): logging.error( @@ -332,7 +315,9 @@ def unpack_gcov_tar(file_path: str, output_dir: str) -> str: ) test_dest_dir = os.path.join(output_dir, testname) - os.makedirs(test_dest_dir, exist_ok=True) + if os.path.exists(test_dest_dir): + shutil.rmtree(test_dest_dir) + os.makedirs(test_dest_dir) shutil.unpack_archive(file_path, test_dest_dir, "tar") return test_dest_dir