Skip to contentSkip to conversation

fstests: cleanup tmp files in tests

PATCH In review Eryu Guan 3 participants 6 messages Jan 6, 2017 – Jan 12, 2017

lore
Share & tools
lore

Eryu Guan

author
#0 lore raw

PATCH 1/1 fstests: cleanup tmp files in tests

$tmp.* files should be removed in _cleanup() even if the test is not using any $tmp.* file explicitly, because common helper functions may take use of them too.

So cleanup tmp files properly in tests, and add a _cleanup() function and trap it on exit if the test doesn't do so, to make all tests consistent on the way they do cleanup.

Also remove other tmp files used by the tests and the harness so that we leave no new tmp files in /tmp dir after a full test run.

---
 common/rc         |  1 +
 tests/btrfs/011   |  2 +-
 tests/btrfs/014   |  8 ++++++++
 tests/btrfs/025   |  3 ++-
 tests/btrfs/030   |  3 ++-
 tests/btrfs/034   |  3 ++-
 tests/btrfs/037   |  4 ++--
 tests/btrfs/038   |  3 ++-
 tests/btrfs/039   |  3 ++-
 tests/btrfs/040   |  3 ++-
 tests/btrfs/041   |  2 +-
 tests/btrfs/043   |  3 ++-
 tests/btrfs/044   |  3 ++-
 tests/btrfs/045   |  3 ++-
 tests/btrfs/046   |  4 ++--
 tests/btrfs/048   |  4 ++--
 tests/btrfs/049   |  2 +-
 tests/btrfs/050   |  4 ++--
 tests/btrfs/051   |  4 ++--
 tests/btrfs/052   |  2 +-
 tests/btrfs/053   |  4 ++--
 tests/btrfs/054   |  4 ++--
 tests/btrfs/055   |  2 +-
 tests/btrfs/056   |  2 +-
 tests/btrfs/058   |  2 +-
 tests/btrfs/059   |  2 +-
 tests/btrfs/076   |  2 +-
 tests/btrfs/077   |  6 +++---
 tests/btrfs/078   |  4 ++--
 tests/ext4/003    |  4 +++-
 tests/ext4/305    |  6 ++++--
 tests/ext4/306    |  4 +++-
 tests/generic/004 |  5 +++--
 tests/generic/005 |  7 ++++---
 tests/generic/008 |  9 ++++++++-
 tests/generic/013 | 19 ++++++++++---------
 tests/generic/015 |  1 +
 tests/generic/034 |  2 ++
 tests/generic/038 |  2 +-
 tests/generic/039 |  1 +
 tests/generic/040 |  1 +
 tests/generic/041 |  1 +
 tests/generic/043 |  8 +++++++-
 tests/generic/044 |  7 ++++++-
 tests/generic/045 |  7 ++++++-
 tests/generic/046 |  7 ++++++-
 tests/generic/047 |  7 ++++++-
 tests/generic/048 |  7 ++++++-
 tests/generic/049 |  7 ++++++-
 tests/generic/050 |  1 +
 tests/generic/068 |  8 +++-----
 tests/generic/079 |  9 +++++----
 tests/generic/087 |  3 ++-
 tests/generic/093 |  3 ++-
 tests/generic/100 |  2 +-
 tests/generic/102 |  7 ++++++-
 tests/generic/105 |  3 ++-
 tests/generic/113 |  5 +++--
 tests/generic/114 |  5 +++--
 tests/generic/123 |  7 ++++---
 tests/generic/124 |  3 ++-
 tests/generic/125 |  7 ++++++-
 tests/generic/126 |  3 ++-
 tests/generic/127 |  3 ++-
 tests/generic/128 |  7 ++++++-
 tests/generic/129 |  7 ++++++-
 tests/generic/130 |  7 ++++++-
 tests/generic/131 |  5 +++--
 tests/generic/132 |  7 ++++++-
 tests/generic/133 |  7 ++++++-
 tests/generic/135 |  7 ++++++-
 tests/generic/141 |  7 ++++++-
 tests/generic/192 |  1 +
 tests/generic/193 |  8 +++++++-
 tests/generic/215 |  1 +
 tests/generic/221 |  6 ++++++
 tests/generic/236 |  2 ++
 tests/generic/239 |  5 +++--
 tests/generic/245 |  1 +
 tests/generic/246 |  1 +
 tests/generic/251 |  1 +
 tests/generic/257 |  1 +
 tests/generic/260 |  9 +++++++--
 tests/generic/275 |  1 +
 tests/generic/277 |  4 +++-
 tests/generic/285 |  2 ++
 tests/generic/286 |  2 ++
 tests/generic/288 |  8 +++++++-
 tests/generic/307 |  2 ++
 tests/generic/308 |  2 ++
 tests/generic/309 |  8 +++++---
 tests/generic/310 |  2 ++
 tests/generic/311 |  2 ++
 tests/generic/313 |  6 ++++--
 tests/generic/317 |  5 +++--
 tests/generic/318 |  5 +++--
 tests/generic/321 |  2 ++
 tests/generic/322 |  2 ++
 tests/generic/325 |  2 ++
 tests/shared/298  |  1 +
 tests/xfs/009     |  5 +++--
 tests/xfs/142     |  7 ++++++-
 tests/xfs/143     |  7 ++++++-
 tests/xfs/144     |  7 ++++++-
 tests/xfs/145     |  7 ++++++-
 tests/xfs/146     |  7 ++++++-
 tests/xfs/147     |  7 ++++++-
 tests/xfs/150     |  7 ++++++-
 tests/xfs/151     |  7 ++++++-
 tests/xfs/152     |  7 ++++++-
 tests/xfs/153     |  7 ++++++-
 tests/xfs/154     |  7 ++++++-
 tests/xfs/155     |  7 ++++++-
 tests/xfs/156     |  7 ++++++-
 tests/xfs/157     |  7 ++++++-
 tests/xfs/158     |  7 ++++++-
 tests/xfs/159     |  7 ++++++-
 tests/xfs/160     |  7 ++++++-
 tests/xfs/161     |  7 ++++++-
 tests/xfs/162     |  7 ++++++-
 tests/xfs/163     |  7 ++++++-
 tests/xfs/166     |  7 ++++++-
 tests/xfs/167     |  1 +
 tests/xfs/168     |  7 ++++++-
 tests/xfs/175     |  2 +-
 tests/xfs/176     |  2 +-
 tests/xfs/185     |  7 ++++++-
 tests/xfs/190     |  7 +++++++
 tests/xfs/195     |  1 +
 tests/xfs/197     |  1 +
 tests/xfs/199     |  1 +
 tests/xfs/201     |  1 +
 tests/xfs/202     |  6 ++++++
 tests/xfs/203     |  1 +
 tests/xfs/205     |  6 ++++++
 tests/xfs/206     |  9 +++++----
 tests/xfs/220     |  1 +
 tests/xfs/229     |  3 ++-
 tests/xfs/250     |  1 +
 tests/xfs/259     |  4 +++-
 tests/xfs/261     |  4 ++--
 tests/xfs/290     |  7 ++++++-
 142 files changed, 493 insertions(+), 150 deletions(-)
common/rc +1 -0
index 159e73a..e761735 100644
@@ -566,6 +566,7 @@ _scratch_mkfs_ext4()
 	# output mkfs stdout and stderr
 	cat $tmp.mkfsstd
 	cat $tmp.mkfserr >&2
+	rm -f $tmp*
 
 	return $mkfs_status
 }
tests/btrfs/011 +1 -1
index 6bc5ba2..ee3d1e9 100755
@@ -50,7 +50,7 @@ _cleanup()
 		kill -TERM $noise_pid
 	fi
 	wait
-	rm -f $tmp.tmp
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/btrfs/014 +8 -0
index 142423f..b099f0d 100755
@@ -29,6 +29,14 @@ here="`pwd`"
 tmp=/tmp/$$
 status=1	# failure is the default!
 
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+trap "_cleanup ; exit \$status" 0 1 2 3 15
+
 _create_snapshot()
 {
 	for i in $(seq 20)
tests/btrfs/025 +2 -1
index 81ae943..4d1fe39 100755
@@ -36,7 +36,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $tmp
+	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/030 +2 -1
index a8e08f6..76ca4c4 100755
@@ -42,7 +42,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $tmp
+	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/034 +2 -1
index 179c827..9b8f621 100755
@@ -33,7 +33,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $tmp
+	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/037 +2 -2
index 5c0ea66..24b4060 100755
@@ -33,14 +33,14 @@ seq=`basename $0`
 seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
 
-tmp=`mktemp -d`
+tmp=/tmp/$$
 
 status=1	# failure is the default!
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/038 +2 -1
index d75ed48..70373d0 100755
@@ -38,7 +38,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $tmp
+	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/039 +2 -1
index ac7144f..58a066d 100755
@@ -41,7 +41,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $tmp
+	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/040 +2 -1
index c97ed50..2396dee 100755
@@ -41,7 +41,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $tmp
+	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/041 +1 -1
index 8bb74cd..4bd60cd 100755
@@ -40,7 +40,7 @@ restore_dir=$TEST_DIR/btrfs-test-$seq
 
 _cleanup()
 {
-	rm -fr $tmp
+	rm -f $tmp.*
 	rm -fr $restore_dir
 }
 
tests/btrfs/043 +2 -1
index 1ba5acd..9b79b71 100755
@@ -37,7 +37,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $tmp
+	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/044 +2 -1
index 9d6d212..dbe6693 100755
@@ -42,7 +42,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $tmp
+	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/045 +2 -1
index bdafbab..f3184f2 100755
@@ -58,7 +58,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $tmp
+	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/046 +2 -2
index 6bf5000..5964b36 100755
@@ -32,7 +32,7 @@ seq=`basename $0`
 seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
 
-tmp=`mktemp -d`
+tmp=/tmp/$$
 status=1	# failure is the default!
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
@@ -41,7 +41,7 @@ send_files_dir=$TEST_DIR/btrfs-test-$seq
 _cleanup()
 {
 	rm -fr $send_files_dir
-	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/048 +2 -2
index e03b3c5..9a23969 100755
@@ -34,8 +34,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $send_files_dir
-    rm -fr $tmp
+	rm -fr $send_files_dir
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/049 +1 -1
index 4ec5dd8..f92f0cb 100755
@@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _cleanup()
 {
 	_cleanup_flakey
-	rm -rf $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/050 +2 -2
index 9a1f5e4..a2a5432 100755
@@ -40,8 +40,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $send_files_dir
-    rm -fr $tmp
+	rm -fr $send_files_dir
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/051 +2 -2
index 9ffbde3..b029449 100755
@@ -37,8 +37,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $send_files_dir
-    rm -fr $tmp
+	rm -fr $send_files_dir
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/052 +1 -1
index 599d261..ef070d0 100755
@@ -33,7 +33,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/053 +2 -2
index 06dcaff..69a7e54 100755
@@ -38,8 +38,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $send_files_dir
-    rm -fr $tmp
+	rm -fr $send_files_dir
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/054 +2 -2
index 606fb40..adce001 100755
@@ -46,8 +46,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $send_files_dir
-    rm -fr $tmp
+	rm -fr $send_files_dir
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/055 +1 -1
index 29afdba..dee80c3 100755
@@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/056 +1 -1
index ef515a1..0607213 100755
@@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _cleanup()
 {
 	_cleanup_flakey
-	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/058 +1 -1
index ecfe857..c2072aa 100755
@@ -42,7 +42,7 @@ _cleanup()
 	if [ ! -z $XFS_IO_PID ]; then
 		kill $XFS_IO_PID > /dev/null 2>&1
 	fi
-	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/059 +1 -1
index 2d1ec23..16aa50b 100755
@@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/076 +1 -1
index 1c86d81..735ab87 100755
@@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _cleanup()
 {
 	cd /
-	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/077 +3 -3
index e56fe5b..4fa7114 100755
@@ -39,14 +39,14 @@ seq=`basename $0`
 seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
 
-tmp=`mktemp -d`
+tmp=/tmp/$$
 status=1	# failure is the default!
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -fr $send_files_dir
-    rm -fr $tmp
+	rm -fr $send_files_dir
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/btrfs/078 +2 -2
index 2c1dfa3..95261fe 100755
@@ -34,13 +34,13 @@ seq=`basename $0`
 seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
 
-tmp=`mktemp -d`
+tmp=/tmp/$$
 status=1	# failure is the default!
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/ext4/003 +3 -1
index 53875a9..11767ae 100755
@@ -20,13 +20,15 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    _scratch_unmount
+	_scratch_unmount
+	rm $tmp.*
 }
 
 # get standard environment, filters and checks
tests/ext4/305 +4 -2
index 09db2e1..58444d8 100755
@@ -24,6 +24,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 PIDS=""
@@ -32,8 +33,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
-    kill $PIDS >/dev/null 2>&1
+	cd /
+	kill $PIDS >/dev/null 2>&1
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/ext4/306 +3 -1
index fa3b782..fe6bc51 100755
@@ -24,6 +24,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 PIDS=""
@@ -32,7 +33,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    _scratch_unmount
+	_scratch_unmount
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/004 +3 -2
index d0926f1..bc9e18d 100755
@@ -32,8 +32,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
-    rm -f ${testfile}
+	cd /
+	rm -f ${testfile}
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/005 +4 -3
index 70f6073..026ff90 100755
@@ -43,9 +43,10 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd $TEST_DIR
-    rm -f symlink_{0,1,2,3,4}{0,1,2,3,4,5,6,7,8,9} symlink_self empty_file
-    cd /
+	cd $TEST_DIR
+	rm -f symlink_{0,1,2,3,4}{0,1,2,3,4,5,6,7,8,9} symlink_self empty_file
+	cd /
+	rm -f $tmp.*
 }
 
 _touch()
tests/generic/008 +8 -1
index 9b70b28..528527d 100755
@@ -31,7 +31,14 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1	# failure is the default!
-trap "exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/013 +10 -9
index e31fe35..939fb2a 100755
@@ -33,15 +33,16 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
-    # we might get here with a RO FS
-    _test_cycle_mount
-    # now remove fsstress directory.
-    # N.B. rm(1) on IRIX can find problems when building up a long pathname
-    # such that what it has is greater the 1024 chars and will
-    # stop and complain - so get rid of complaint
-    # Ref. pv#935754
-    rm -rf $TEST_DIR/fsstress.$$.* 2>&1 | grep -v 'Path too long'
+	cd /
+	# we might get here with a RO FS
+	_test_cycle_mount
+	# now remove fsstress directory.
+	# N.B. rm(1) on IRIX can find problems when building up a long pathname
+	# such that what it has is greater the 1024 chars and will
+	# stop and complain - so get rid of complaint
+	# Ref. pv#935754
+	rm -rf $TEST_DIR/fsstress.$$.* 2>&1 | grep -v 'Path too long'
+	rm -f $tmp.*
 }
 
 _filesize()
tests/generic/015 +1 -0
index 66c33c2..d53aa30 100755
@@ -37,6 +37,7 @@ status=1	# success is the default!
 _cleanup()
 {
 	_scratch_unmount
+	rm -f $tmp.*
 }
 
 trap "_cleanup; exit \$status" 0 1 2 3 15
tests/generic/034 +2 -0
index 6727b98..cd3a829 100755
@@ -31,6 +31,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 here=`pwd`
@@ -39,6 +40,7 @@ status=1	# failure is the default!
 _cleanup()
 {
 	_cleanup_flakey
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/generic/038 +1 -1
index 025e1b0..b8f5643 100755
@@ -57,7 +57,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-	rm -fr $tmp
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/039 +1 -0
index 7d62393..292aa20 100755
@@ -43,6 +43,7 @@ status=1	# failure is the default!
 _cleanup()
 {
 	_cleanup_flakey
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/generic/040 +1 -0
index 2aeccdd..c603caa 100755
@@ -48,6 +48,7 @@ status=1	# failure is the default!
 _cleanup()
 {
 	_cleanup_flakey
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/generic/041 +1 -0
index 283c305..70549e8 100755
@@ -52,6 +52,7 @@ status=1	# failure is the default!
 _cleanup()
 {
 	_cleanup_flakey
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/generic/043 +7 -1
index b76a5aa..10aba87 100755
@@ -29,7 +29,13 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/044 +6 -1
index 0331baa..ab2d3b9 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/045 +6 -1
index 874c955..9799db1 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/046 +6 -1
index 5a894b8..16c824b 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/047 +6 -1
index 631dc1e..1db981c 100755
@@ -30,7 +30,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/048 +6 -1
index 51d7efd..aee2e85 100755
@@ -30,7 +30,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/049 +6 -1
index 1299242..31dc413 100755
@@ -30,7 +30,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/050 +1 -0
index 5fa28a7..a230c80 100755
@@ -33,6 +33,7 @@ _cleanup()
 {
 	cd /
 	blockdev --setrw $SCRATCH_DEV
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/generic/068 +3 -5
index f9f5f5a..5d1c6c8 100755
@@ -35,13 +35,11 @@ ITERATIONS=10
 
 _cleanup()
 {
-    cd /
-
-    trap 0 1 2 3 15
-    exit $status
+	cd /
+	rm -f $tmp.*
 }
 
-trap "_cleanup" 0 1 2 3 15
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/079 +5 -4
index 5cceeba..3bb895d 100755
@@ -34,10 +34,11 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
-    echo "*** cleaning up"
-    $timmutable -r $SCRATCH_MNT/$seq
-    _scratch_unmount
+	cd /
+	echo "*** cleaning up"
+	$timmutable -r $SCRATCH_MNT/$seq
+	_scratch_unmount
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/087 +2 -1
index 9653230..f6af6e4 100755
@@ -44,7 +44,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
+	cd /
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/093 +2 -1
index 824e9b2..800efe4 100755
@@ -40,7 +40,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    [ -n "$TEST_DIR" ] && rm -f $file
+	[ -n "$TEST_DIR" ] && rm -f $file
+	rm -f $tmp.*
 }
 
 _testfilter()
tests/generic/100 +1 -1
index e5e819d..161982f 100755
@@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-     rm -f $tmp.* $testfile
+     rm -f $tmp.* $TEMP_DIR/$TAR_FILE
 }
  
 # real QA test starts here
tests/generic/102 +6 -1
index 3cdc2ba..b896e26 100755
@@ -34,7 +34,12 @@ echo "QA output created by $seq"
 
 tmp=/tmp/$$
 status=1
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/105 +2 -1
index 9b7beb4..9da204b 100755
@@ -36,7 +36,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
+	cd /
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/113 +3 -2
index 54d6191..fe2b7f9 100755
@@ -33,8 +33,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
-    rm -f $TEST_DIR/aio-stress.$$.*
+	cd /
+	rm -f $TEST_DIR/aio-stress.$$.*
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/114 +3 -2
index 8082a0d..9c7cf61 100755
@@ -32,8 +32,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
-    rm -f $TEST_DIR/tst-aio-dio-eof-race
+	cd /
+	rm -f $TEST_DIR/tst-aio-dio-eof-race
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/123 +4 -3
index 453ede4..2a27b9d 100755
@@ -35,9 +35,10 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd $TEST_DIR
-    rm -rf $my_test_subdir
-    cd /
+	cd $TEST_DIR
+	rm -rf $my_test_subdir
+	cd /
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/124 +2 -1
index b78c189..6e8be66 100755
@@ -37,7 +37,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
+	cd /
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/125 +6 -1
index 67eb63f..a628f08 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1	# failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/126 +2 -1
index bb3a566..6d839b9 100755
@@ -33,7 +33,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
+	cd /
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/127 +2 -1
index 94d15b2..c7acf8d 100755
@@ -37,7 +37,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    rm -f $tmp.output
+	rm -f $tmp.output
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/128 +6 -1
index 39fc807..9470cc4 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1	# failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/129 +6 -1
index 9a10d76..0ed3619 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1	# failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/130 +6 -1
index 1e96630..709d950 100755
@@ -38,7 +38,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/131 +3 -2
index d64ba55..d1d6d44 100755
@@ -33,8 +33,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    kill $locktest_pid2 > /dev/null 2>&1
-    kill $locktest_pid1 > /dev/null 2>&1
+	kill $locktest_pid2 > /dev/null 2>&1
+	kill $locktest_pid1 > /dev/null 2>&1
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/132 +6 -1
index aa52c7d..be2cbe1 100755
@@ -30,7 +30,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/133 +6 -1
index f1a221e..cd7bf09 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/135 +6 -1
index 14b8132..fab9269 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/141 +6 -1
index fa08484..5d715b3 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/192 +1 -0
index d3ed0ec..c62cfaf 100755
@@ -36,6 +36,7 @@ trap "exit \$status" 0 1 2 3 15
 _access_time()
 {
 	stat -c %X $1
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/193 +7 -1
index 6d0754f..3566c1d 100755
@@ -28,7 +28,13 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1	# failure is the default!
-trap "_cleanup_files; exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	_cleanup_files
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 tag="added by qa $seq"
 
 #
tests/generic/215 +1 -0
index 80df55d..dc98069 100755
@@ -31,6 +31,7 @@ _cleanup()
 {
 	cd /
 	rm -f $testfile
+	rm -f $tmp.*
 }
 
 here=`pwd`
tests/generic/221 +6 -0
index aa42f65..a0f575a 100755
@@ -32,6 +32,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1	# failure is the default!
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/236 +2 -0
index 12ea0bc..ed61660 100755
@@ -25,11 +25,13 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 _cleanup()
 {
 	rm -f $TEST_DIR/ouch*
+	rm -f $tmp.*
 }
 
 here=`pwd`
tests/generic/239 +3 -2
index 4f764c2..3e7b889 100755
@@ -33,8 +33,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
-    rm -f $TEST_DIR/tst-aio-dio-sparse-unwritten
+	cd /
+	rm -f $TEST_DIR/tst-aio-dio-sparse-unwritten
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/245 +1 -0
index 4034d04..1592ec5 100755
@@ -46,6 +46,7 @@ dir=$TEST_DIR/test-mv
 _cleanup()
 {
 	rm -rf $dir
+	rm -f $tmp.*
 }
 
 # According to the rename(2) manpage you can get either EEXIST or ENOTEMPTY as an
tests/generic/246 +1 -0
index 4184cfc..25ae556 100755
@@ -48,6 +48,7 @@ _cleanup()
 {
 	rm -rf $file
 	rm -rf $file.NEW
+	rm -f $tmp.*
 }
 
 trap "_cleanup ; exit \$status" 0 1 2 3 15
tests/generic/251 +1 -0
index 848ee74..aaeffe4 100755
@@ -50,6 +50,7 @@ _require_batched_discard $SCRATCH_MNT
 _cleanup()
 {
 	rm -rf $tmp
+	rm -f $tmp.*
 }
 
 _destroy()
tests/generic/257 +1 -0
index 64f2100..85cd525 100755
@@ -32,6 +32,7 @@ status=1	# failure is the default!
 _cleanup()
 {
 	rm -rf $TEST_DIR/ttt
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/generic/260 +7 -2
index 312e6d2..3448b3b 100755
@@ -26,9 +26,14 @@ seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
 
 here=`pwd`
-tmp=`mktemp -d`
+tmp=/tmp/$$
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
 status=0
-trap "exit \$status" 0 1 2 3 15
+trap "_cleanup; exit \$status" 0 1 2 3 15
 chpid=0
 mypid=$$
 
tests/generic/275 +1 -0
index 955c4ac..7bdb0f1 100755
@@ -37,6 +37,7 @@ _cleanup()
 {
 	cd /
 	_scratch_unmount
+	rm -f $tmp.*
 }
 
 . ./common/rc
tests/generic/277 +3 -1
index 4dfc431..14b6527 100755
@@ -24,13 +24,15 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 status=1	# failure is the default!
 
 _cleanup()
 {
-    rm -f $SCRATCH_MNT/tmp*
+	rm -f $SCRATCH_MNT/tmp*
+	rm -f $tmp.*
 }
 
 trap "_cleanup ; exit \$status" 0 1 2 3 15
tests/generic/285 +2 -0
index 16e70b1..050443e 100755
@@ -27,6 +27,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 here=`pwd`
@@ -56,6 +57,7 @@ fi
 _cleanup()
 {
 	eval "rm -f $BASE_TEST_FILE.*"
+	rm -f $tmp.*
 }
 
 $here/src/seek_sanity_test $BASE_TEST_FILE > $seqres.full 2>&1 ||
tests/generic/286 +2 -0
index f88f079..e2dab19 100755
@@ -24,6 +24,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 here=`pwd`
@@ -49,6 +50,7 @@ _require_test_program "seek_copy_test"
 _cleanup()
 {
 	rm -f $src $dest
+	rm -f $tmp.*
 }
 
 # seek_copy_test_01: tests file with holes and written data extents.
tests/generic/288 +7 -1
index aed6238..85a9b8b 100755
@@ -23,10 +23,16 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
 echo "QA output created by $seq"
 
 status=0
-trap "exit \$status" 0 1 2 3 15
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/generic/307 +2 -0
index f5d0680..595cc74 100755
@@ -30,6 +30,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 status=1	# failure is the default!
@@ -39,6 +40,7 @@ _cleanup()
 {
 	cd /
 	rm -f $testfile
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/308 +2 -0
index e639da1..a3ed5a5 100755
@@ -24,6 +24,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 status=1	# failure is the default!
@@ -33,6 +34,7 @@ _cleanup()
 {
 	cd /
 	rm -f $testfile
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/309 +5 -3
index c6b89db..35d5d84 100755
@@ -27,6 +27,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 status=0	# success is the default!
@@ -34,9 +35,10 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
-    rm -rf $TEST_DIR/testdir_$seq
-    rm -f $TEST_DIR/testfile.$seq
+	cd /
+	rm -rf $TEST_DIR/testdir_$seq
+	rm -f $TEST_DIR/testfile.$seq
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/310 +2 -0
index 895481c..ca38a0a 100755
@@ -40,6 +40,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 status=1	# failure is the default!
@@ -47,6 +48,7 @@ status=1	# failure is the default!
 _cleanup()
 {
 	rm -rf $TEST_DIR/tmp
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/generic/311 +2 -0
index d510204..d757bf0 100755
@@ -34,6 +34,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 here=`pwd`
@@ -42,6 +43,7 @@ status=1	# failure is the default!
 _cleanup()
 {
 	_cleanup_flakey
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/generic/313 +4 -2
index a906926..1f133e1 100755
@@ -26,6 +26,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 here=`pwd`
@@ -34,8 +35,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
-    rm -f $testfile
+	cd /
+	rm -f $testfile
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/generic/317 +3 -2
index 7e40b1f..f3f5c41 100755
@@ -36,8 +36,9 @@ status=1	# failure is the default!
 
 _cleanup()
 {
-    cd /
-    _scratch_unmount >/dev/null 2>&1
+	cd /
+	_scratch_unmount >/dev/null 2>&1
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/generic/318 +3 -2
index e284317..adb1cbb 100755
@@ -37,8 +37,9 @@ status=1	# failure is the default!
 
 _cleanup()
 {
-    cd /
-    _scratch_unmount >/dev/null 2>&1
+	cd /
+	_scratch_unmount >/dev/null 2>&1
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/generic/321 +2 -0
index 8798503..3d81640 100755
@@ -23,6 +23,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 here=`pwd`
@@ -31,6 +32,7 @@ status=1	# failure is the default!
 _cleanup()
 {
 	_cleanup_flakey
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/generic/322 +2 -0
index 475a31c..f8d9743 100755
@@ -23,6 +23,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 here=`pwd`
@@ -31,6 +32,7 @@ status=1	# failure is the default!
 _cleanup()
 {
 	_cleanup_flakey
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/generic/325 +2 -0
index a0b641a..75b8908 100755
@@ -33,6 +33,7 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 here=`pwd`
@@ -41,6 +42,7 @@ status=1	# failure is the default!
 _cleanup()
 {
 	_cleanup_flakey
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/shared/298 +1 -0
index 2ed7eab..6c73a71 100755
@@ -47,6 +47,7 @@ _cleanup()
 		rm -rf $tmp
 		rm $img_file
 	fi
+	rm -f $tmp.*
 }
 
 get_holes()
tests/xfs/009 +3 -2
index abef2e0..e1afc47 100755
@@ -36,8 +36,9 @@ bsize=4096
 
 _cleanup()
 {
-    echo "*** unmount"
-    _scratch_unmount
+	echo "*** unmount"
+	_scratch_unmount
+	rm -f $tmp.*
 }
 
 _block_filter()
tests/xfs/142 +6 -1
index a1efcc2..a3db707 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/143 +6 -1
index c389a2b..0d4d6e8 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/144 +6 -1
index 41041c4..aa0a81e 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/145 +6 -1
index 44b3e4e..e4cefd3 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/146 +6 -1
index f6cd3f3..276353a 100755
@@ -30,7 +30,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _report_filter () {
     $PERL_PROG -ne "s/Report: \"0x[0-f]+\" was written and \"0x[0-f]+\" was read at/Report: \"HEX\" was written and \"HEX\" was read at/g ;
tests/xfs/147 +6 -1
index 73ff7f9..2307dfd 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/150 +6 -1
index f9e690a..1e13fa9 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _filter_fs_handle()
 {
tests/xfs/151 +6 -1
index bba7094..1a7a238 100755
@@ -31,7 +31,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _dm_create_session()
 {
tests/xfs/152 +6 -1
index 72bdabf..9e0ba79 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _filter_handles()
 {
tests/xfs/153 +6 -1
index cac7722..95c5b58 100755
@@ -30,7 +30,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/154 +6 -1
index 810a6ac..ad825d1 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/155 +6 -1
index 1a1631e..ac7c2b3 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/156 +6 -1
index d6e22b6..495cffc 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/157 +6 -1
index bf65590..05cca9c 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/158 +6 -1
index 596f4c2..0a2ccd7 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/159 +6 -1
index fc5193f..133f382 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/160 +6 -1
index 9a2e2d0..bc8e1ad 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/161 +6 -1
index 11e53de..475470a 100755
@@ -30,7 +30,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _filter_get_allocinfo()
 {
tests/xfs/162 +6 -1
index 4edb68f..ec2c677 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/163 +6 -1
index e283545..8d6849b 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _filter_paths()
 {
tests/xfs/166 +6 -1
index 2a96f8a..b6e0dc7 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 rm -f $seqres.full
 
 # get standard environment, filters and checks
tests/xfs/167 +1 -0
index a9f0e61..041943d 100755
@@ -36,6 +36,7 @@ _cleanup()
 {
 	$KILLALL_PROG -r -q -TERM fsstress 2> /dev/null
 	wait	# ensures all fsstress processes died
+	rm -f $tmp.*
 }
 
 workout()
tests/xfs/168 +6 -1
index 6fc4540..7f07c4b 100755
@@ -29,9 +29,14 @@ echo "QA output created by $seq"
 
 here=`pwd`
 tmp=/tmp/$$
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
 rm -f $seqres.full
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _filter_dmapi_print_event() {
     $PERL_PROG -ne '
tests/xfs/175 +1 -1
index ad18e42..6bc4b9a 100755
@@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-	rm -f $tmp/*
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/xfs/176 +1 -1
index 035d3b4..995c6fe 100755
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-	rm -f $tmp/*
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/xfs/185 +6 -1
index 17334de..96bc425 100755
@@ -29,7 +29,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/190 +7 -0
index d688216..d68b6ab 100755
@@ -41,6 +41,13 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=0    # success is the default!
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
 rm -f $seqres.full
 
 # get standard environment, filters and checks
tests/xfs/195 +1 -0
index 3948ca4..2716bff 100755
@@ -35,6 +35,7 @@ _cleanup()
 {
 	rm -rf $TEST_DIR/d
 	rm -f $TEST_DIR/dumpfile
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/xfs/197 +1 -0
index 7706e03..aebf167 100755
@@ -38,6 +38,7 @@ status=1	# failure is the default!
 _cleanup()
 {
 	rm -rf $TEST_DIR/ttt
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/xfs/199 +1 -0
index ee26439..c9c0de3 100755
@@ -36,6 +36,7 @@ _cleanup()
 {
 	cd /
 	_scratch_unmount >/dev/null 2>&1
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/xfs/201 +1 -0
index 45dc42f..b947e50 100755
@@ -35,6 +35,7 @@ status=1	# failure is the default!
 _cleanup()
 {
 	_scratch_unmount
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/xfs/202 +6 -0
index b9827a7..4533dfa 100755
@@ -28,6 +28,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1	# failure is the default!
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/203 +1 -0
index 2ac5290..62a5bac 100755
@@ -59,6 +59,7 @@ _filter_bmap()
 _cleanup()
 {
 	rm -f $SCRATCH_MNT/r??
+	rm -f $tmp.*
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
tests/xfs/205 +6 -0
index debdc2a..ec59130 100755
@@ -28,6 +28,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1	# failure is the default!
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/206 +5 -4
index d549a4c..9e0a4d9 100755
@@ -38,10 +38,11 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    umount $tmpdir
-    rmdir $tmpdir
-    rm -f $tmp
-    rm -f $tmpfile
+	umount $tmpdir
+	rmdir $tmpdir
+	rm -f $tmp
+	rm -f $tmpfile
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/xfs/220 +1 -0
index 69b539c..bf7a433 100755
@@ -36,6 +36,7 @@ status=1	# failure is the default!
 _cleanup()
 {
 	cd /
+	rm -f $tmp.*
 	_scratch_unmount >/dev/null 2>&1
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
tests/xfs/229 +2 -1
index 0a42bcf..ee2931b 100755
@@ -38,7 +38,8 @@ status=1	# failure is the default!
 
 _cleanup()
 {
-    rm -rf ${TDIR}
+	rm -rf ${TDIR}
+	rm -f $tmp.*
 }
 
 trap "_cleanup ; exit \$status" 0 1 2 3 15
tests/xfs/250 +1 -0
index f807c5a..f2fbef7 100755
@@ -36,6 +36,7 @@ _cleanup()
 	umount $LOOP_MNT 2>/dev/null
 	rm -f $LOOP_DEV
 	rmdir $LOOP_MNT
+	rm -f $tmp.*
 }
 
 # get standard environment, filters and checks
tests/xfs/259 +3 -1
index 17f3c6d..a931a10 100755
@@ -24,13 +24,15 @@
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
+tmp=/tmp/$$
 echo "QA output created by $seq"
 
 status=1	# failure is the default!
 
 _cleanup()
 {
-    rm -f "$testfile"
+	rm -f "$testfile"
+	rm -f $tmp.*
 }
 
 trap "_cleanup ; exit \$status" 0 1 2 3 15
tests/xfs/261 +2 -2
index e3c2591..1054f7d 100755
@@ -41,8 +41,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _cleanup()
 {
-    cd /
-    rm -f ${tmp}.*
+	cd /
+	rm -f ${tmp}.*
 }
 
 # get standard environment, filters and checks
tests/xfs/290 +6 -1
index adc398f..3bc54e4 100755
@@ -33,7 +33,12 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1	# failure is the default!
-trap "exit \$status" 0 1 2 3 15
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
Signature · 1 line
2.9.3
#1 lore raw

Hi Eryu,

Quoted 11 lines · Eryu Guan

$tmp.* files should be removed in _cleanup() even if the test is not using any $tmp.* file explicitly, because common helper functions may take use of them too.

So cleanup tmp files properly in tests, and add a _cleanup() function and trap it on exit if the test doesn't do so, to make all tests consistent on the way they do cleanup.

Also remove other tmp files used by the tests and the harness so that we leave no new tmp files in /tmp dir after a full test run.

Why exactly can't the boilerplate go in a preamble file which is sourced by all the tests? For example common/preamble containing something like:

	seq=`basename $0`
	seqres=$RESULT_DIR/$seq
	echo "QA output created by $seq"

	_cleanup()
	{
		cd /
		rm -f $tmp.*
	}

	here=`pwd`
	tmp=/tmp/$$
	status=1        # failure is the default!
	trap "_cleanup; exit \$status" 0 1 2 3 15

	. ./common/rc

Tests that need to do more cleanup could override the default trap.

Eric

#5 lore raw
In reply to Eryu Guan
Quoted 8 lines · Eryu Guan

$tmp.* files should be removed in _cleanup() even if the test is not using any $tmp.* file explicitly, because common helper functions may take use of them too.

So cleanup tmp files properly in tests, and add a _cleanup() function and trap it on exit if the test doesn't do so, to make all tests consistent on the way they do cleanup.

Quoted 5 lines

Also remove other tmp files used by the tests and the harness so that we leave no new tmp files in /tmp dir after a full test run.

---

So much duplicated code!!

Did you consider consolidating all those lines that MUST start every test with:

# Always start a test with this line
. ./common/prologue
# This is the standatd cleanup trigger - remove to implement a private cleanup trigger
. ./common/cleanup

And while at it, why not put exit \$status inside the generic _cleanup()?

non generic cleanup implementations could looks like this:

trap "my_cleanup" 0 1 2 3 15

my_cleanup()
{

        # my cleanup stuff...
        # generic cleanup and exit $status
        _cleanup
}
author
#2 lore raw
In reply to Eric Biggers

Hi Eric and Amir,

Quoted 11 lines · Eric Biggers

Hi Eryu,

Quoted 8 lines · Eryu Guan

$tmp.* files should be removed in _cleanup() even if the test is not using any $tmp.* file explicitly, because common helper functions may take use of them too.

So cleanup tmp files properly in tests, and add a _cleanup() function and trap it on exit if the test doesn't do so, to make all tests consistent on the way they do cleanup.

Quoted 6 lines
Quoted 3 lines

Also remove other tmp files used by the tests and the harness so that we leave no new tmp files in /tmp dir after a full test run.

Why exactly can't the boilerplate go in a preamble file which is sourced by all the tests? For example common/preamble containing something like:

Thanks for your review! As you two are basically suggesting the same solution, so I reply to you together.

I agree that we can do a common/preamble for all tests to source, but I don't think we need to do that and it's not worth the effort.

IMO, we define and setup the tests in the tests themselves, not in a common/preamble file, which makes the tests clear and easy to read. We don't want to "hide" any setups in a common file and to be a "surprise" to the reader, we don't have to look around for a certain setup.

Also, all the common setup code are all in "new" script, the template is created automatically, and I fixed all other problematic tests once in this patch, we don't have any extra maintain burden, as long as all new tests are created by "new" script.

And fstests has been this way for a very long time if not from the beginning. All the "old" users are familiar with this code style. Converting to preamble file doesn't seem gain us more, it doesn't seem worth the effort converting all existing 900+ tests to new style. And if we only source common/preamble in new tests, we result in inconsistency across tests.

But I'd like to see what other fstests users think on this.

Thanks,
Eryu

Quoted 25 lines
	seq=`basename $0`
	seqres=$RESULT_DIR/$seq
	echo "QA output created by $seq"

	_cleanup()
	{
		cd /
		rm -f $tmp.*
	}

	here=`pwd`
	tmp=/tmp/$$
	status=1        # failure is the default!
	trap "_cleanup; exit \$status" 0 1 2 3 15

	. ./common/rc

Tests that need to do more cleanup could override the default trap.

Eric
--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 24 lines · Eryu Guan

Hi Eric and Amir,

Quoted 11 lines · Eric Biggers

Hi Eryu,

Quoted 8 lines · Eryu Guan

$tmp.* files should be removed in _cleanup() even if the test is not using any $tmp.* file explicitly, because common helper functions may take use of them too.

So cleanup tmp files properly in tests, and add a _cleanup() function and trap it on exit if the test doesn't do so, to make all tests consistent on the way they do cleanup.

Quoted 6 lines
Quoted 3 lines

Also remove other tmp files used by the tests and the harness so that we leave no new tmp files in /tmp dir after a full test run.

Why exactly can't the boilerplate go in a preamble file which is sourced by all the tests? For example common/preamble containing something like:

Thanks for your review! As you two are basically suggesting the same solution, so I reply to you together.

Quoted 8 lines

I agree that we can do a common/preamble for all tests to source, but I don't think we need to do that and it's not worth the effort.

IMO, we define and setup the tests in the tests themselves, not in a common/preamble file, which makes the tests clear and easy to read. We don't want to "hide" any setups in a common file and to be a "surprise" to the reader, we don't have to look around for a certain setup.

The motivation for your work is the fact that tmp files are being created in a way that is "hidden" from the test author and therefore, IMO, the cleanup of those temp files should also be in a common function that is "hidden" from the test author.

Quoted 7 lines

Also, all the common setup code are all in "new" script, the template is created automatically, and I fixed all other problematic tests once in this patch, we don't have any extra maintain burden, as long as all new tests are created by "new" script.

And fstests has been this way for a very long time if not from the beginning. All the "old" users are familiar with this code style.

I relate to this argument very much and if something works and doesn't both anyone, I believe we should let it be.

OTOH, this is the second tests wide change to _cleanup() that I remember from recent times, the first having to do with cd /. So IMO, _cleanup() should be made a generic function in common/cleanup and those test that wish to override it should use the syntax:

       seq=`basename $0`
       seqres=$RESULT_DIR/$seq
       echo "QA output created by $seq"

       . ./common/cleanup

       my_cleanup()
       {
               # do my cleanup... and call generic cleanup
               generic_cleanup
       }

       here=`pwd`
       tmp=/tmp/$$
       status=1        # failure is the default!
       trap "my_cleanup; exit \$status" 0 1 2 3 15

       . ./common/rc

You don't even have to go over all the old tests and change them, but at least for the test for which you need to add rm -f $tmp.* just add a common _cleanup function and call it instead. The end result would be much nicer, IMO.

Quoted 35 lines

Converting to preamble file doesn't seem gain us more, it doesn't seem worth the effort converting all existing 900+ tests to new style. And if we only source common/preamble in new tests, we result in inconsistency across tests.

But I'd like to see what other fstests users think on this.

Thanks,
Eryu

Quoted 25 lines
      seq=`basename $0`
      seqres=$RESULT_DIR/$seq
      echo "QA output created by $seq"

      _cleanup()
      {
              cd /
              rm -f $tmp.*
      }

      here=`pwd`
      tmp=/tmp/$$
      status=1        # failure is the default!
      trap "_cleanup; exit \$status" 0 1 2 3 15

      . ./common/rc

Tests that need to do more cleanup could override the default trap.

Eric
--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#4 lore raw
Quoted 34 lines · Amir Goldstein
Quoted 24 lines · Eryu Guan

Hi Eric and Amir,

Quoted 11 lines · Eric Biggers

Hi Eryu,

Quoted 8 lines · Eryu Guan

$tmp.* files should be removed in _cleanup() even if the test is not using any $tmp.* file explicitly, because common helper functions may take use of them too.

So cleanup tmp files properly in tests, and add a _cleanup() function and trap it on exit if the test doesn't do so, to make all tests consistent on the way they do cleanup.

Quoted 6 lines
Quoted 3 lines

Also remove other tmp files used by the tests and the harness so that we leave no new tmp files in /tmp dir after a full test run.

Why exactly can't the boilerplate go in a preamble file which is sourced by all the tests? For example common/preamble containing something like:

Thanks for your review! As you two are basically suggesting the same solution, so I reply to you together.

Quoted 8 lines

I agree that we can do a common/preamble for all tests to source, but I don't think we need to do that and it's not worth the effort.

IMO, we define and setup the tests in the tests themselves, not in a common/preamble file, which makes the tests clear and easy to read. We don't want to "hide" any setups in a common file and to be a "surprise" to the reader, we don't have to look around for a certain setup.

Quoted 4 lines

The motivation for your work is the fact that tmp files are being created in a way that is "hidden" from the test author and therefore, IMO, the cleanup of those temp files should also be in a common function that is "hidden" from the test author.

[Sorry, I got back to this late.]

That's a good point, so I think what should be done is let common functions clean up their tmp files, so there's no hidden usage of $tmp and tests only need to remove $tmp.* used explicitly in the tests.

I checked all the common functions, there're only two that are not cleaning up their tmp files properly, _do() and run_fsx().

I'll send v2 patch for review, which will be a much simpler patch.

Thanks,
Eryu