]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
fstests: stop using /tmp directly
authorDave Chinner <dchinner@redhat.com>
Tue, 26 Nov 2024 21:00:55 +0000 (08:00 +1100)
committerZorro Lang <zlang@kernel.org>
Sun, 8 Dec 2024 14:12:32 +0000 (22:12 +0800)
Tests should be using $tmp, not /tmp. this causes problems when
multiple tests all use /tmp/foo as a temporary test state file
and then step on each other.

Note that there are some tests that use /tmp to store "test stop"
files for background processes. Those that have proven to be
unreliable at stopping tests when interrupted by ctrl-c are also
updated to track and kill background processes in the cleanup
function.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Zorro lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
17 files changed:
tests/generic/162
tests/generic/163
tests/generic/164
tests/generic/165
tests/generic/166
tests/generic/167
tests/generic/168
tests/generic/170
tests/generic/333
tests/generic/334
tests/generic/373
tests/generic/374
tests/generic/670
tests/generic/671
tests/generic/672
tests/generic/722
tests/xfs/601

index e23014f03d4e0003597c18be6943aead3a0c56f1..25d2da7e0723bf21c2fe695b3ba28807e7596d71 100755 (executable)
@@ -15,7 +15,7 @@ _register_cleanup "_cleanup" BUS
 _cleanup()
 {
     cd /
-    rm -rf $tmp.* $finished_file
+    rm -rf $tmp.*
     wait
 }
 
@@ -30,7 +30,7 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-finished_file=/tmp/finished
+finished_file=$tmp.finished
 rm -rf $finished_file
 mkdir $testdir
 
index 51a00e4b71c810a1c6ccca9a08f21e63432748c3..f80d699acaa5e2010a5b444b2aafbfc468c18228 100755 (executable)
@@ -15,7 +15,7 @@ _register_cleanup "_cleanup" BUS
 _cleanup()
 {
     cd /
-    rm -rf $tmp.* $finished_file
+    rm -rf $tmp.*
     wait
 }
 
@@ -30,7 +30,7 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-finished_file=/tmp/finished
+finished_file=$tmp.finished
 rm -rf $finished_file
 mkdir $testdir
 
index e5c8acd02ea1a94ca65e97ba84c1576594966608..f38e398689e0db68f5add60a0f7b9e7defe1ed78 100755 (executable)
@@ -16,7 +16,7 @@ _register_cleanup "_cleanup" BUS
 _cleanup()
 {
     cd /
-    rm -rf $tmp.* $finished_file
+    rm -rf $tmp.*
     wait
 }
 
@@ -32,7 +32,7 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-finished_file=/tmp/finished
+finished_file=$tmp.finished
 rm -rf $finished_file
 mkdir $testdir
 
index 0e565eb1db1e5d79505af7f7baf9960bdc648f0d..128afbeaa1704b9d1f2c631cc0f69d6a93075ab7 100755 (executable)
@@ -16,7 +16,7 @@ _register_cleanup "_cleanup" BUS
 _cleanup()
 {
     cd /
-    rm -rf $tmp.* $finished_file
+    rm -rf $tmp.*
     wait
 }
 
@@ -33,7 +33,7 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-finished_file=/tmp/finished
+finished_file=$tmp.finished
 rm -rf $finished_file
 mkdir $testdir
 
index 16157571f91e7af661fa7ae3aec4bd7a9a58af23..4e0b19170649c20d2c9fb6561e34d141b70f582c 100755 (executable)
@@ -16,7 +16,7 @@ _register_cleanup "_cleanup" BUS
 _cleanup()
 {
     cd /
-    rm -rf $tmp.* $finished_file
+    rm -rf $tmp.* 
     wait
 }
 
@@ -33,8 +33,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-finished_file=/tmp/finished
-do_snapshot=/tmp/snapshot
+finished_file=$tmp.finished
+do_snapshot=$tmp.snapshot
 rm -rf $finished_file
 mkdir $testdir
 
index 0c3e20fe2ed694e83703212d034db83e2ebc8be4..ceb53963fba8b8f263a1a5e2f23889c712d4e02a 100755 (executable)
@@ -16,7 +16,7 @@ _register_cleanup "_cleanup" BUS
 _cleanup()
 {
     cd /
-    rm -rf $tmp.* $finished_file
+    rm -rf $tmp.*
     wait
 }
 
@@ -32,7 +32,7 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-finished_file=/tmp/finished
+finished_file=$tmp.finished
 rm -rf $finished_file
 mkdir $testdir
 
index bd9859f7348bbdac18dabc64c5aa327b58f06340..d4b63cec87bebb1292b23f8f3bfb95cb22e29516 100755 (executable)
@@ -16,7 +16,8 @@ _register_cleanup "_cleanup" BUS
 _cleanup()
 {
     cd /
-    rm -rf $tmp.* $finished_file
+    rm -rf $tmp.*
+    [ -n "$write_pid" ] && kill -9 $write_pid > /dev/null 2>&1
     wait
 }
 
@@ -31,7 +32,7 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-finished_file=/tmp/finished
+finished_file=$tmp.finished
 rm -rf $finished_file
 mkdir $testdir
 
@@ -57,6 +58,7 @@ overwrite() {
 
 echo "Reflink and write the target"
 overwrite &
+write_pid=$!
 seq 1 10 | while read j; do
        seq 0 $nr_loops | while read i; do
                _reflink_range  $testdir/file1 $((i * blksz)) \
@@ -66,6 +68,7 @@ seq 1 10 | while read j; do
 done
 touch $finished_file
 wait
+unset write_pid
 
 # success, all done
 status=0
index 35b278b9f7ac62b646bb48fcdb91e012983508e0..be9cf7a18c3823a84fd42ecde6e40dc65fd13a1b 100755 (executable)
@@ -16,7 +16,8 @@ _register_cleanup "_cleanup" BUS
 _cleanup()
 {
     cd /
-    rm -rf $tmp.* $finished_file
+    rm -rf $tmp.*
+    [ -n "$write_pid" ] && kill -9 $write_pid > /dev/null 2>&1
     wait
 }
 
@@ -32,7 +33,7 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-finished_file=/tmp/finished
+finished_file=$tmp.finished
 rm -rf $finished_file
 mkdir $testdir
 
@@ -58,6 +59,7 @@ overwrite() {
 
 echo "Reflink and dio write the target"
 overwrite &
+write_pid=$!
 seq 1 10 | while read j; do
        seq 0 $nr_loops | while read i; do
                _reflink_range  $testdir/file1 $((i * blksz)) \
@@ -67,6 +69,7 @@ seq 1 10 | while read j; do
 done
 touch $finished_file
 wait
+unset write_pid
 
 # success, all done
 status=0
index 03a7bcd0e405c1881fdfe1bdf3d947fd551fec1f..2206141478c882321854476f5c40d177206f8cd3 100755 (executable)
@@ -16,7 +16,7 @@ _register_cleanup "_cleanup" BUS
 _cleanup()
 {
     cd /
-    rm -rf $tmp.* $finished_file $abort_file
+    rm -rf $tmp.*
     wait
 }
 
@@ -33,9 +33,9 @@ _scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-finished_file=/tmp/finished
+finished_file=$tmp.finished
 rm -rf $finished_file
-abort_file=/tmp/abort
+abort_file=$tmp.abort
 rm -rf $abort_file
 mkdir $testdir
 
index 3f9718476a4c4ec73f75c4965305d67ecdca57b2..0faa5d696636255601b5f969a6178cbd22a25a5a 100755 (executable)
@@ -16,7 +16,7 @@ _register_cleanup "_cleanup" BUS
 _cleanup()
 {
     cd /
-    rm -rf $tmp.* $finished_file $abort_file
+    rm -rf $tmp.*
     wait
 }
 
@@ -32,9 +32,9 @@ _scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-finished_file=/tmp/finished
+finished_file=$tmp.finished
 rm -rf $finished_file
-abort_file=/tmp/abort
+abort_file=$tmp.abort
 rm -rf $abort_file
 mkdir $testdir
 
index e6334398f6a6fe0c15b32586ad9128c5a6782659..04ec642518ce705e5e3f0f2344e2f535da876703 100755 (executable)
@@ -32,7 +32,7 @@ _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
-otherdir=/tmp/m.$seq
+otherdir=$tmp.m.$seq
 othertestdir=$otherdir/test-$seq
 rm -rf $otherdir
 mkdir $otherdir
index e56521aa01c1397b8419d7b9c19900f246989694..9a85091e29886ecded98d7f2a2e323b497909bbb 100755 (executable)
@@ -31,7 +31,7 @@ _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
-otherdir=/tmp/m.$seq
+otherdir=$tmp.m.$seq
 othertestdir=$otherdir/test-$seq
 rm -rf $otherdir
 mkdir $otherdir
index 67a8f6fe2eb36bf2056fa0ca0b5ea9746ed9d865..f32199e70f4bd548eb9744b62a1225b0360d2f1b 100755 (executable)
@@ -23,7 +23,7 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-finished_file=/tmp/finished
+finished_file=$tmp.finished
 rm -rf $finished_file
 mkdir $testdir
 
index f20069113143970ec495f55622ad1c9462c1dbf0..3abe12274f564f32cecafcb38efdd2d0ab011c0f 100755 (executable)
@@ -23,7 +23,7 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-finished_file=/tmp/finished
+finished_file=$tmp.finished
 rm -rf $finished_file
 mkdir $testdir
 
index 832907de3277c0a8e7a409770ce80ce66ce2ecd5..a5e65042e4960bb23a00e28086d2f2ea7e8e8e13 100755 (executable)
@@ -22,7 +22,7 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
-finished_file=/tmp/finished
+finished_file=$tmp.finished
 rm -rf $finished_file
 mkdir $testdir
 
index 5542c045fdde43245094c1199399c8341d09a4aa..b9c608713c370c1bfc9dbfbc9b33ddbcc63a9cd9 100755 (executable)
 . ./common/preamble
 _begin_fstest auto quick fiexchange
 
-# Override the default cleanup function.
-_cleanup()
-{
-       cd /
-       rm -r -f $tmp.* $dir
-}
-
 # Import common functions.
 . ./common/filter
 . ./common/reflink
@@ -38,8 +31,8 @@ old_a=$(md5sum $SCRATCH_MNT/a | awk '{print $1}')
 old_b=$(md5sum $SCRATCH_MNT/b | awk '{print $1}')
 echo "md5 a: $old_a md5 b: $old_b" >> $seqres.full
 
-od -tx1 -Ad -c $SCRATCH_MNT/a > /tmp/a0
-od -tx1 -Ad -c $SCRATCH_MNT/b > /tmp/b0
+od -tx1 -Ad -c $SCRATCH_MNT/a > $tmp.a0
+od -tx1 -Ad -c $SCRATCH_MNT/b > $tmp.b0
 
 echo swap >> $seqres.full
 $XFS_IO_PROG -c "exchangerange -f $SCRATCH_MNT/a" $SCRATCH_MNT/b
@@ -53,8 +46,8 @@ echo "md5 a: $new_a md5 b: $new_b" >> $seqres.full
 test $old_a = $new_b || echo "scratch file B doesn't match old file A"
 test $old_b = $new_a || echo "scratch file A doesn't match old file B"
 
-od -tx1 -Ad -c $SCRATCH_MNT/a > /tmp/a1
-od -tx1 -Ad -c $SCRATCH_MNT/b > /tmp/b1
+od -tx1 -Ad -c $SCRATCH_MNT/a > $tmp.a1
+od -tx1 -Ad -c $SCRATCH_MNT/b > $tmp.b1
 
 # success, all done
 echo Silence is golden
index bc8fa719baa7e3f6406390fb81dbf83394e797c2..df382402b958f2285cd8fb8f64017a6cf3128530 100755 (executable)
@@ -15,7 +15,7 @@ _register_cleanup "_cleanup" BUS
 _cleanup()
 {
        cd /
-       rm -rf $tmp.* $testdir
+       rm -rf $tmp.*
 }
 
 # Import common functions.