summaryrefslogtreecommitdiffstats
path: root/tests/shell/helpers/nft-valgrind-wrapper.sh
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-09-06 13:52:16 +0200
committerFlorian Westphal <fw@strlen.de>2023-09-07 19:35:20 +0200
commit63739f4b7f923def1db8e2d988ad18d021a9cf2e (patch)
treedcd080a5f58f9bd47460401295a66d77cf677194 /tests/shell/helpers/nft-valgrind-wrapper.sh
parent86ccd72e589105b5277cf81f9e8dc1e208d25f45 (diff)
tests/shell: move valgrind wrapper script to separate script
Previously, in valgrind mode we would generate one script, which had "$NFT" variable and the temp directory hard coded. Soon, we will run jobs in parallel, so they would need at least different temp directories. Also, we want to put the valgrind results are inside "$NFT_TEST_TESTTMPDIR", along the test data. Extract the wrapper script to a separate script. It does not need to be generated ad-hoc, instead it uses the environment variables "$NFT_REAL" and "$NFT_TEST_TESTTMPDIR", as "run-tests.sh" prepares them. Also, add a "$NFT_REAL" variable for the actual NFT binary. We wrap the "$NFT" variable with VALGRIND=y or the user may pass "NFT='valgrind nft'". We should have access to the real binary. That might be useful for example to call `ldd "$NFT_REAL" | grep libjansson` to check for JSON support. Also, we use libtool. So quite possible the nft binary is actually a shell script. Calling valgrind on that script results in a lot of leak reports from shell (and slows down the command). Instead, use `libtool --mode=execute`. Signed-off-by: Thomas Haller <thaller@redhat.com> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'tests/shell/helpers/nft-valgrind-wrapper.sh')
-rwxr-xr-xtests/shell/helpers/nft-valgrind-wrapper.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/shell/helpers/nft-valgrind-wrapper.sh b/tests/shell/helpers/nft-valgrind-wrapper.sh
new file mode 100755
index 00000000..9da50d4d
--- /dev/null
+++ b/tests/shell/helpers/nft-valgrind-wrapper.sh
@@ -0,0 +1,17 @@
+#!/bin/bash -e
+
+SUFFIX="$(date '+%Y%m%d-%H%M%S.%6N')"
+
+rc=0
+libtool \
+ --mode=execute \
+ valgrind \
+ --log-file="$NFT_TEST_TESTTMPDIR/valgrind.$SUFFIX.%p.log" \
+ --trace-children=yes \
+ --leak-check=full \
+ --show-leak-kinds=all \
+ "$NFT_REAL" \
+ "$@" \
+ || rc=$?
+
+exit $rc