summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2025-05-06 11:50:12 +0200
committerMark Wielaard <[email protected]>2025-05-13 21:21:34 +0200
commit8d996450d6b88730dc2e8f95374b2cc683a52e0c (patch)
treed2a4599918f1fba480f2bfc12d67ff39c4eecfb3
parent13148250ce0e27cc8145f6ddaa8339f08a5ef993 (diff)
tests: Create random test_dir name
The testsuite relies on there being no files in the test directory after the test finishes. A test will fail if the test dir cannot be removed. But the test dir isn't really random, it uses the pid of the shell script that executes the test. On some of the buildbots that execute a lot of tests it can happen that the pid number wraps around and a pid of a previous pid is reused. To prevent that happening generate a real random number (8 bytes) using od /dev/urandom and xargs (to trim away spaces left by od). * tests/test-subr.sh: Define test_name and random_number and use those to define test_dir. Signed-off-by: Mark Wielaard <[email protected]>
-rw-r--r--tests/test-subr.sh4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/test-subr.sh b/tests/test-subr.sh
index ea80cbec..2a956b47 100644
--- a/tests/test-subr.sh
+++ b/tests/test-subr.sh
@@ -23,7 +23,9 @@
set -e
# Each test runs in its own directory to make sure they can run in parallel.
-test_dir="${TMPDIR-/var/tmp}/elfutils-test-$$"
+test_name=$(basename $0)
+random_number=$(od -An -N8 -tx8 /dev/urandom | xargs)
+test_dir="${TMPDIR-/var/tmp}/elfutils-test-$test_name.${random_number}"
mkdir -p "$test_dir"
orig_dir="${PWD}"
cd "$test_dir"