From: Thomas Haller <thaller@redhat.com>
To: NetFilter <netfilter-devel@vger.kernel.org>
Cc: Thomas Haller <thaller@redhat.com>
Subject: [PATCH nft 2/2] tests/shell: ensure vgdb-pipe files are deleted from "nft-valgrind-wrapper.sh"
Date: Wed, 13 Sep 2023 00:44:50 +0200 [thread overview]
Message-ID: <20230912224501.2549359-2-thaller@redhat.com> (raw)
In-Reply-To: <20230912224501.2549359-1-thaller@redhat.com>
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>
---
tests/shell/helpers/nft-valgrind-wrapper.sh | 4 ++--
tests/shell/run-tests.sh | 10 +++++++++-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/tests/shell/helpers/nft-valgrind-wrapper.sh b/tests/shell/helpers/nft-valgrind-wrapper.sh
index 6125dd0f3089..98bbdf43570e 100755
--- a/tests/shell/helpers/nft-valgrind-wrapper.sh
+++ b/tests/shell/helpers/nft-valgrind-wrapper.sh
@@ -1,6 +1,6 @@
#!/bin/bash -e
-SUFFIX="$(date "+%Y%m%d-%H%M%S.%6N.$$")"
+SUFFIX="$(date "+%H%M%S.%6N").$$"
rc=0
libtool \
@@ -12,7 +12,7 @@ libtool \
--show-leak-kinds=all \
--num-callers=100 \
--error-exitcode=122 \
- --vgdb-prefix="$NFT_TEST_TMPDIR_ORIG/vgdb-pipe-nft-test-$SUFFIX" \
+ --vgdb-prefix="$_NFT_TEST_VALGRIND_VGDB_PREFIX-$SUFFIX" \
$NFT_TEST_VALGRIND_OPTS \
"$NFT_REAL" \
"$@" \
diff --git a/tests/shell/run-tests.sh b/tests/shell/run-tests.sh
index cf17302fdc19..7ac6202ca43c 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() {
--
2.41.0
prev parent reply other threads:[~2023-09-12 22:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-12 22:44 [PATCH nft 1/2] tests/shell: kill running child processes when aborting "run-tests.sh" Thomas Haller
2023-09-12 22:44 ` Thomas Haller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230912224501.2549359-2-thaller@redhat.com \
--to=thaller@redhat.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).