From 8d996450d6b88730dc2e8f95374b2cc683a52e0c Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 6 May 2025 11:50:12 +0200 Subject: 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 --- tests/test-subr.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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" -- cgit v1.2.3