From 36b7c68111723244edc222dfb5ab58b9da1d3585 Mon Sep 17 00:00:00 2001 From: Christian Hopps Date: Sat, 20 Apr 2024 04:31:03 -0400 Subject: [PATCH] tests: improve coverage no need to modify source/build dir - by using symlinks in the rundir (/tmp) into the source/build directory we avoid needing to copy the *.gcda stat files into the source/build dir. Signed-off-by: Christian Hopps --- tests/topotests/conftest.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/topotests/conftest.py b/tests/topotests/conftest.py index c6f038b7f6..a2315138cc 100755 --- a/tests/topotests/conftest.py +++ b/tests/topotests/conftest.py @@ -496,7 +496,7 @@ def setup_coverage(config): os.environ["GCOV_PREFIX"] = str(gcdadir) if is_main_runner(): - commander.cmd_raises(f"find {bdir} -name '*.gc??' -exec chmod o+rw {{}} +") + commander.cmd_raises(f"find {bdir} -name '*.gc??' -exec chmod o+r {{}} +") commander.cmd_raises(f"mkdir -p {gcdadir}") commander.cmd_raises(f"chown -R root:frr {gcdadir}") commander.cmd_raises(f"chmod 2775 {gcdadir}") @@ -767,18 +767,25 @@ def coverage_finish(terminalreporter, config): bdir = Path(os.environ["FRR_BUILD_DIR"]) gcdadir = Path(os.environ["GCOV_PREFIX"]) - # Get the data files into the build directory - logger.info("Copying gcda files from '%s' to '%s'", gcdadir, bdir) - user = os.environ.get("SUDO_USER", os.environ["USER"]) - commander.cmd_raises(f"chmod -R ugo+r {gcdadir}") + logger.info("Creating .gcno ssymlink from '%s' to '%s'", gcdadir, bdir) commander.cmd_raises( - f"tar -C {gcdadir} -cf - . | su {user} -c 'tar -C {bdir} -xf -'" + f"cd {gcdadir}; bdir={bdir}" + + """ +for f in $(find . -name '*.gcda'); do + f=${f#./}; + f=${f%.gcda}.gcno; + ln -fs $bdir/$f $f; + touch -h -r $bdir/$f $f; + echo $f; +done""" ) # Get the results into a summary file data_file = rundir / "coverage.info" logger.info("Gathering coverage data into: %s", data_file) - commander.cmd_raises(f"lcov --directory {bdir} --capture --output-file {data_file}") + commander.cmd_raises( + f"lcov --directory {gcdadir} --capture --output-file {data_file}" + ) # Get coverage info filtered to a specific set of files report_file = rundir / "coverage.info" -- 2.39.5