diff options
author | Thomas Haller <thaller@redhat.com> | 2023-09-13 00:44:50 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2023-09-14 14:26:44 +0200 |
commit | 65d3e81ce8b98d0bde24f4d8c392c252981c7d8b (patch) | |
tree | 6b8c1bafbc403b791da10e7c3c9a40bf19c27c15 /tests/shell/run-tests.sh | |
parent | 35d437b7cc19d5126736e4820dcb38cfff051200 (diff) |
tests/shell: ensure vgdb-pipe files are deleted from "nft-valgrind-wrapper.sh"
When the valgrind process gets killed, those files can be left over.
They are located in the original $TMPDIR (usually /tmp). They should be
cleaned up.
I tried to cleanup the files from withing "nft-valgrind-wrapper.sh"
itself via a `trap`, but it doesn't work. Instead, let "run-tests.sh"
delete all files with a matching pattern.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'tests/shell/run-tests.sh')
-rwxr-xr-x | tests/shell/run-tests.sh | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/shell/run-tests.sh b/tests/shell/run-tests.sh index cf17302f..7ac6202c 100755 --- a/tests/shell/run-tests.sh +++ b/tests/shell/run-tests.sh @@ -426,6 +426,8 @@ fi declare -A JOBS_PIDLIST +_NFT_TEST_VALGRIND_VGDB_PREFIX= + cleanup_on_exit() { pids_search='' for pid in "${!JOBS_PIDLIST[@]}" ; do @@ -442,13 +444,17 @@ cleanup_on_exit() { if [ "$NFT_TEST_KEEP_LOGS" != y -a -n "$NFT_TEST_TMPDIR" ] ; then rm -rf "$NFT_TEST_TMPDIR" fi + if [ -n "$_NFT_TEST_VALGRIND_VGDB_PREFIX" ] ; then + rm -rf "$_NFT_TEST_VALGRIND_VGDB_PREFIX"* &>/dev/null + fi } trap 'exit 130' SIGINT trap 'exit 143' SIGTERM trap 'rc=$?; cleanup_on_exit; exit $rc' EXIT -NFT_TEST_TMPDIR="$(mktemp --tmpdir="$_TMPDIR" -d "nft-test.$(date '+%Y%m%d-%H%M%S.%3N').XXXXXX")" || +TIMESTAMP=$(date '+%Y%m%d-%H%M%S.%3N') +NFT_TEST_TMPDIR="$(mktemp --tmpdir="$_TMPDIR" -d "nft-test.$TIMESTAMP.XXXXXX")" || msg_error "Failure to create temp directory in \"$_TMPDIR\"" chmod 755 "$NFT_TEST_TMPDIR" @@ -493,6 +499,8 @@ msg_info "info: NFT_TEST_TMPDIR=$(printf '%q' "$NFT_TEST_TMPDIR")" if [ "$VALGRIND" == "y" ]; then NFT="$NFT_TEST_BASEDIR/helpers/nft-valgrind-wrapper.sh" msg_info "info: NFT=$(printf '%q' "$NFT")" + _NFT_TEST_VALGRIND_VGDB_PREFIX="$NFT_TEST_TMPDIR_ORIG/vgdb-pipe-nft-test-$TIMESTAMP.$$.$RANDOM" + export _NFT_TEST_VALGRIND_VGDB_PREFIX fi kernel_cleanup() { |