]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests/shell: set valgrind's "--vgdb-prefix=" to orignal TMPDIR
authorThomas Haller <thaller@redhat.com>
Fri, 8 Sep 2023 14:25:31 +0000 (16:25 +0200)
committerFlorian Westphal <fw@strlen.de>
Sat, 9 Sep 2023 14:32:52 +0000 (16:32 +0200)
"test-wrapper.sh" sets TMPDIR="$NFT_TEST_TESTTMPDIR". That is useful, so
that temporary files of the tests are placed inside the test result
data.

Sometimes tests miss to delete those files, which would result in piling
up /tmp/tmp.XXXXXXXXXX files. By setting $TMPDIR, those files are
clearly related to the test run that created them, and can be deleted
together.

However, valgrind likes to create files like
"vgdb-pipe-from-vgdb-to-68-by-thom-on-???"  inside $TMPDIR. These are
pipes, so if you run `grep -R ^ /tmp/nft-test.latest` while
the test is still running (to inspect the results), then the process
hands reading from the pipe.

Instead, tell valgrind to put those files in the original TMPDIR. For
that purpose, export NFT_TEST_TMPDIR_ORIG from "run-tests.sh".

Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
tests/shell/helpers/nft-valgrind-wrapper.sh
tests/shell/run-tests.sh

index ad8cc74bc781a321b9353d2324aed0ed1a186ea4..6125dd0f30897530ab2bd52bd7bf3322169f179c 100755 (executable)
@@ -12,6 +12,7 @@ libtool \
                --show-leak-kinds=all \
                --num-callers=100 \
                --error-exitcode=122 \
+               --vgdb-prefix="$NFT_TEST_TMPDIR_ORIG/vgdb-pipe-nft-test-$SUFFIX" \
                $NFT_TEST_VALGRIND_OPTS \
                "$NFT_REAL" \
                "$@" \
index c622c150950000d34a7e3df2b4e3417131e5df9f..5931b20e164500638da6a145fdc3e4d61415506f 100755 (executable)
@@ -257,6 +257,11 @@ START_TIME="$(cut -d ' ' -f1 /proc/uptime)"
 
 _TMPDIR="${TMPDIR:-/tmp}"
 
+# Export the orignal TMPDIR for the tests. "test-wrapper.sh" sets TMPDIR to
+# NFT_TEST_TESTTMPDIR, so that temporary files are placed along side the
+# test data. In some cases, we may want to know the original TMPDIR.
+export NFT_TEST_TMPDIR_ORIG="$_TMPDIR"
+
 if [ "$NFT_TEST_HAS_REALROOT" = "" ] ; then
        # The caller didn't set NFT_TEST_HAS_REALROOT and didn't specify
        # -R/--without-root option. Autodetect it based on `id -u`.