From 1d0cde7cc338819d813b22b803e7ed4da7bc3f99 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Thu, 8 May 2025 10:04:47 -0700 Subject: [PATCH] Clean up old test data as needed. If run without `-m` (explicit mkfs) in subsequent testing, old test data files may break several tests. Most failures are -EEXIST, but there are some more subtle ones. This change erases any existing test dir as needed just before we run the tests, and avoids the issue entirely. I considered doing a `mv dir dir.$$ && rm -rf dir.$$ &` alternative solution but that likely will interfere disproportionally with tests that do disconnects and other thing that can be impacted by an unlink storm. This has an obvious performance aspect - tests will be a little slower to start on subsequent runs. In CI, this will effectively be a no-op though. Signed-off-by: Auke Kok --- tests/run-tests.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/run-tests.sh b/tests/run-tests.sh index 3bc494c0..b9917d4f 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -532,12 +532,15 @@ for t in $tests; do cmd rm -rf "$T_TMPDIR" cmd mkdir -p "$T_TMPDIR" - # create a test name dir in the fs + # create a test name dir in the fs, clean up old data as needed T_DS="" for i in $(seq 0 $((T_NR_MOUNTS - 1))); do dir="${T_M[$i]}/test/$test_name" - test $i == 0 && cmd mkdir -p "$dir" + test $i == 0 && ( + test -d "$dir" && cmd rm -rf "$dir" + cmd mkdir -p "$dir" + ) eval T_D$i=$dir T_D[$i]=$dir