aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2017-10-15 16:19:04 -0400
committerTheodore Ts'o <tytso@mit.edu>2017-10-15 16:19:04 -0400
commitfe6e2a7ed801823123663eed001aeeee971fefe3 (patch)
tree0e165c37701bc24f6733fa93491a7e38d3e7af3d /tests
parent845eac42ed0da466eb4f8e23e0855d8968ac1b7f (diff)
downloade2fsprogs-fe6e2a7ed801823123663eed001aeeee971fefe3.tar.gz
tests: fix d_inline_dump and f_mke2fs_baddisk from leaving behind temp files
These two tests could leave an temp file behind if the test is skipped. In general test script files should avoid using 'exit', since this bypasses the test cleanup scripting. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'tests')
-rw-r--r--tests/d_inline_dump/script59
-rw-r--r--tests/f_mke2fs_baddisk/script26
2 files changed, 41 insertions, 44 deletions
diff --git a/tests/d_inline_dump/script b/tests/d_inline_dump/script
index 7199453e9..6df34b62b 100644
--- a/tests/d_inline_dump/script
+++ b/tests/d_inline_dump/script
@@ -1,43 +1,42 @@
if ! test -x $DEBUGFS_EXE; then
- echo "$test_name: $test_description: skipped"
- exit 0
-fi
-
-OUT=$test_name.log
-EXP=$test_dir/expect
-VERIFY_FSCK_OPT=-yf
+ echo "$test_name: $test_description: skipped"
+else
+ OUT=$test_name.log
+ EXP=$test_dir/expect
+ VERIFY_FSCK_OPT=-yf
-ZIMAGE=$test_dir/image.gz
-gzip -d < $ZIMAGE > $TMPFILE
+ ZIMAGE=$test_dir/image.gz
+ gzip -d < $ZIMAGE > $TMPFILE
-echo "*** long file" > $OUT
-$DEBUGFS -R 'stat /file' $TMPFILE 2>&1 | $CLEAN_OUTPUT >> $OUT 2>&1
-echo "*** short file" >> $OUT
-$DEBUGFS -R 'stat /shortfile' $TMPFILE 2>&1 | $CLEAN_OUTPUT >> $OUT 2>&1
-echo >> $OUT
+ echo "*** long file" > $OUT
+ $DEBUGFS -R 'stat /file' $TMPFILE 2>&1 | $CLEAN_OUTPUT >> $OUT 2>&1
+ echo "*** short file" >> $OUT
+ $DEBUGFS -R 'stat /shortfile' $TMPFILE 2>&1 | $CLEAN_OUTPUT >> $OUT 2>&1
+ echo >> $OUT
-echo "*** long dir" >> $OUT
-$DEBUGFS -R 'stat /dir' $TMPFILE 2>&1 | $CLEAN_OUTPUT >> $OUT 2>&1
-echo "*** short dir" >> $OUT
-$DEBUGFS -R 'stat /shortdir' $TMPFILE 2>&1 | $CLEAN_OUTPUT >> $OUT 2>&1
-echo >> $OUT
+ echo "*** long dir" >> $OUT
+ $DEBUGFS -R 'stat /dir' $TMPFILE 2>&1 | $CLEAN_OUTPUT >> $OUT 2>&1
+ echo "*** short dir" >> $OUT
+ $DEBUGFS -R 'stat /shortdir' $TMPFILE 2>&1 | $CLEAN_OUTPUT >> $OUT 2>&1
+ echo >> $OUT
-echo "*** long link" >> $OUT
-$DEBUGFS -R 'stat /link' $TMPFILE 2>&1 | $CLEAN_OUTPUT >> $OUT 2>&1
-echo "*** short link" >> $OUT
-$DEBUGFS -R 'stat /shortlink' $TMPFILE 2>&1 | $CLEAN_OUTPUT >> $OUT 2>&1
+ echo "*** long link" >> $OUT
+ $DEBUGFS -R 'stat /link' $TMPFILE 2>&1 | $CLEAN_OUTPUT >> $OUT 2>&1
+ echo "*** short link" >> $OUT
+ $DEBUGFS -R 'stat /shortlink' $TMPFILE 2>&1 | $CLEAN_OUTPUT >> $OUT 2>&1
-echo "*** end test" >> $OUT
+ echo "*** end test" >> $OUT
-cmp -s $OUT $EXP
-status=$?
+ cmp -s $OUT $EXP
+ status=$?
-if [ "$status" = 0 ] ; then
+ if [ "$status" = 0 ] ; then
echo "$test_name: $test_description: ok"
touch $test_name.ok
-else
+ else
echo "$test_name: $test_description: failed"
diff $DIFF_OPTS $EXP $OUT > $test_name.failed
-fi
+ fi
-unset VERIFY_FSCK_OPT NATIVE_FSCK_OPT OUT EXP TEST_DATA VERIFY_DATA ZIMAGE
+ unset VERIFY_FSCK_OPT NATIVE_FSCK_OPT OUT EXP TEST_DATA VERIFY_DATA ZIMAGE
+fi
diff --git a/tests/f_mke2fs_baddisk/script b/tests/f_mke2fs_baddisk/script
index 0e6d3cd07..7ce8c5c43 100644
--- a/tests/f_mke2fs_baddisk/script
+++ b/tests/f_mke2fs_baddisk/script
@@ -7,20 +7,18 @@ status=$?
if [ "$status" != 0 ]; then
echo "$test_name: $test_description: skip"
touch $test_name.ok
- exit 0
-fi
-
-echo mke2fs /dev/mapper/bad_disk >> $OUT
-$MKE2FS /dev/mapper/bad_disk >> $OUT 2>&1
-status=$?
-sleep 1
-dmsetup remove --retry bad_disk >> $OUT 2>&1
-
-if [ "$status" = 0 ] ; then
- ln -f $test_name.log $test_name.failed
- echo "$test_name: $test_description: failed"
else
- echo "$test_name: $test_description: ok"
- touch $test_name.ok
+ echo mke2fs /dev/mapper/bad_disk >> $OUT
+ $MKE2FS /dev/mapper/bad_disk >> $OUT 2>&1
+ status=$?
+ sleep 1
+ dmsetup remove --retry bad_disk >> $OUT 2>&1
+ if [ "$status" = 0 ] ; then
+ ln -f $test_name.log $test_name.failed
+ echo "$test_name: $test_description: failed"
+ else
+ echo "$test_name: $test_description: ok"
+ touch $test_name.ok
+ fi
fi