[PATCH 24/40] fstests: stop using /tmp directly

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



From: Dave Chinner <dchinner@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 tests/generic/162 |  4 ++--
 tests/generic/163 |  4 ++--
 tests/generic/164 |  4 ++--
 tests/generic/165 |  4 ++--
 tests/generic/166 |  6 +++---
 tests/generic/167 |  4 ++--
 tests/generic/168 |  7 +++++--
 tests/generic/170 |  7 +++++--
 tests/generic/333 |  6 +++---
 tests/generic/334 |  6 +++---
 tests/generic/373 |  2 +-
 tests/generic/374 |  2 +-
 tests/generic/670 |  2 +-
 tests/generic/671 |  2 +-
 tests/generic/672 |  2 +-
 tests/generic/722 | 15 ++++-----------
 tests/xfs/601     |  2 +-
 17 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/tests/generic/162 b/tests/generic/162
index e23014f03..25d2da7e0 100755
--- a/tests/generic/162
+++ b/tests/generic/162
@@ -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
 
diff --git a/tests/generic/163 b/tests/generic/163
index 51a00e4b7..f80d699ac 100755
--- a/tests/generic/163
+++ b/tests/generic/163
@@ -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
 
diff --git a/tests/generic/164 b/tests/generic/164
index e5c8acd02..f38e39868 100755
--- a/tests/generic/164
+++ b/tests/generic/164
@@ -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
 
diff --git a/tests/generic/165 b/tests/generic/165
index 0e565eb1d..128afbeaa 100755
--- a/tests/generic/165
+++ b/tests/generic/165
@@ -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
 
diff --git a/tests/generic/166 b/tests/generic/166
index 16157571f..4e0b19170 100755
--- a/tests/generic/166
+++ b/tests/generic/166
@@ -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
 
diff --git a/tests/generic/167 b/tests/generic/167
index 0c3e20fe2..ceb53963f 100755
--- a/tests/generic/167
+++ b/tests/generic/167
@@ -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
 
diff --git a/tests/generic/168 b/tests/generic/168
index bd9859f73..d4b63cec8 100755
--- a/tests/generic/168
+++ b/tests/generic/168
@@ -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
diff --git a/tests/generic/170 b/tests/generic/170
index 35b278b9f..be9cf7a18 100755
--- a/tests/generic/170
+++ b/tests/generic/170
@@ -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
diff --git a/tests/generic/333 b/tests/generic/333
index 03a7bcd0e..220614147 100755
--- a/tests/generic/333
+++ b/tests/generic/333
@@ -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
 
diff --git a/tests/generic/334 b/tests/generic/334
index 3f9718476..0faa5d696 100755
--- a/tests/generic/334
+++ b/tests/generic/334
@@ -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
 
diff --git a/tests/generic/373 b/tests/generic/373
index e6334398f..04ec64251 100755
--- a/tests/generic/373
+++ b/tests/generic/373
@@ -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
diff --git a/tests/generic/374 b/tests/generic/374
index e56521aa0..9a85091e2 100755
--- a/tests/generic/374
+++ b/tests/generic/374
@@ -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
diff --git a/tests/generic/670 b/tests/generic/670
index 67a8f6fe2..f32199e70 100755
--- a/tests/generic/670
+++ b/tests/generic/670
@@ -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
 
diff --git a/tests/generic/671 b/tests/generic/671
index f20069113..3abe12274 100755
--- a/tests/generic/671
+++ b/tests/generic/671
@@ -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
 
diff --git a/tests/generic/672 b/tests/generic/672
index 832907de3..a5e65042e 100755
--- a/tests/generic/672
+++ b/tests/generic/672
@@ -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
 
diff --git a/tests/generic/722 b/tests/generic/722
index 5542c045f..b9c608713 100755
--- a/tests/generic/722
+++ b/tests/generic/722
@@ -10,13 +10,6 @@
 . ./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
diff --git a/tests/xfs/601 b/tests/xfs/601
index bc8fa719b..df382402b 100755
--- a/tests/xfs/601
+++ b/tests/xfs/601
@@ -15,7 +15,7 @@ _register_cleanup "_cleanup" BUS
 _cleanup()
 {
 	cd /
-	rm -rf $tmp.* $testdir
+	rm -rf $tmp.*
 }
 
 # Import common functions.
-- 
2.45.2





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux