From: Dave Chinner <david@fromorbit.com>
To: fstests@vger.kernel.org
Subject: [PATCH 6/8] ext4: convert some tests to new setup preamble
Date: Wed, 27 Jun 2018 18:21:01 +1000 [thread overview]
Message-ID: <20180627082103.9662-7-david@fromorbit.com> (raw)
In-Reply-To: <20180627082103.9662-1-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
Small initial batch to demonstrate conversion.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
tests/ext4/001 | 26 +++++++-------------------
tests/ext4/002 | 41 +++++++++++++----------------------------
tests/ext4/003 | 25 +++++++------------------
tests/ext4/004 | 46 ++++++++++++++++------------------------------
tests/ext4/005 | 29 +++++++----------------------
tests/ext4/006 | 38 +++++++++++++-------------------------
tests/ext4/007 | 34 ++++++++++------------------------
tests/ext4/008 | 28 +++++++---------------------
tests/ext4/009 | 34 ++++++++++------------------------
9 files changed, 90 insertions(+), 211 deletions(-)
diff --git a/tests/ext4/001 b/tests/ext4/001
index bf2d16b42b3c..deba9128d833 100755
--- a/tests/ext4/001
+++ b/tests/ext4/001
@@ -6,28 +6,16 @@
#
# Test fallocate FALLOC_FL_ZERO_RANGE
#
-seqfull=$0
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
+. common/setup_test
-here=`pwd`
-tmp=/tmp/$$
-status=1 # failure is the default!
+# test exit cleanup goes here
+cleanup() { :; }
-_cleanup()
-{
- rm -f $tmp.*
-}
+# remove previous $seqres.full before test
+rm -f $seqres.full
-trap "_cleanup ; exit \$status" 0 1 2 3 15
-
-# get standard environment, filters and checks
-. ./common/rc
-. ./common/filter
+# include test specific environments here
. ./common/punch
-
-# real QA test starts here
_supported_fs ext4
_supported_os Linux
_require_xfs_io_command "fzero"
@@ -50,4 +38,4 @@ _test_generic_punch -k falloc fzero fzero fiemap _filter_fiemap $testfile
# Delayed allocation multi zero range tests
_test_generic_punch -d -k falloc fzero fzero fiemap _filter_fiemap $testfile
-status=0 ; exit
+_success
diff --git a/tests/ext4/002 b/tests/ext4/002
index c4fb3bde8ce1..c1324dc04609 100755
--- a/tests/ext4/002
+++ b/tests/ext4/002
@@ -26,26 +26,24 @@
#
# Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682
#
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
+. common/setup_test
-here=`pwd`
-tmp=/tmp/$$
-status=1 # failure is the default!
-trap "_cleanup; exit \$status" 0 1 2 3 15
+# test exit cleanup goes here
+cleanup() { :; }
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# include test specific environments here
+_supported_fs ext4
+_supported_os Linux
+_require_xfs_io_command "falloc"
+_require_test
# Test specific macros.
BIT_NOT_SET=0 # inode flag - 0x400000 bit is not set.
BIT_SET=1 # inode flag - 0x400000 bit is set.
-# Generic test cleanup function.
-_cleanup()
-{
- cd /
- rm -f $tmp.*
-}
-
# Ext4 uses the EOFBLOCKS_FL bit when fallocating blocks with KEEP_SIZE
# enabled. The only time this bit should be set is when extending the allocated
# blocks further than what the i_size represents. In the situations wherein the
@@ -97,18 +95,6 @@ _check_ext4_eof_flag()
fi
}
-# Get standard environment, filters and checks.
-. ./common/rc
-. ./common/filter
-
-# Prerequisites for the test run.
-_supported_fs ext4
-_supported_os Linux
-_require_xfs_io_command "falloc"
-_require_test
-
-# Real QA test starts here.
-rm -f $seqres.full
# Remove any leftover files from last run.
rm -f ${TEST_DIR}/test_?
@@ -162,5 +148,4 @@ ${XFS_IO_PROG} -f -d \
${TEST_DIR}/test_6 | _filter_xfs_io_unique
_check_ext4_eof_flag test_6 ${BIT_NOT_SET}
-status=0
-exit ${status}
+_success
diff --git a/tests/ext4/003 b/tests/ext4/003
index 19fe4b4c1f7d..7e5dfca9468e 100755
--- a/tests/ext4/003
+++ b/tests/ext4/003
@@ -8,30 +8,20 @@
# b5b6077 ext4: fix wrong assert in ext4_mb_normalize_request()
# This testcase checks whether this bug has been fixed.
#
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
+. common/setup_test
-trap "_cleanup; exit \$status" 0 1 2 3 15
+# test exit cleanup goes here
+cleanup() { :; }
-_cleanup()
-{
- _scratch_unmount
-}
-
-# get standard environment, filters and checks
-. ./common/rc
-. ./common/filter
+# remove previous $seqres.full before test
+rm -f $seqres.full
-# real QA test starts here
+# include test specific environments here
_supported_fs ext4
_supported_os Linux
-
_require_scratch
_require_scratch_ext4_feature "bigalloc"
-rm -f $seqres.full
-
$MKFS_EXT4_PROG -F -O bigalloc -C 65536 -g 256 $SCRATCH_DEV 512m \
>> $seqres.full 2>&1
_scratch_mount
@@ -39,5 +29,4 @@ _scratch_mount
$XFS_IO_PROG -f -c "pwrite 0 256m -b 1M" $SCRATCH_MNT/testfile 2>&1 | \
_filter_xfs_io
-status=0
-exit
+_success
diff --git a/tests/ext4/004 b/tests/ext4/004
index e34aaa517b61..775afed4bc2c 100755
--- a/tests/ext4/004
+++ b/tests/ext4/004
@@ -6,26 +6,26 @@
#
# Test "dump | restore"(as opposed to a tape)
#
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
+. common/setup_test
-here=`pwd`
-tmp=/tmp/$$
-status=1 # failure is the default!
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
-_cleanup()
-{
- cd /
- rm -f $tmp.*
+# test exit cleanup goes here
+cleanup() {
# remove the generated data, which is much and meaningless.
rm -rf $restore_dir
}
-# get standard environment, filters and checks
-. ./common/rc
-. ./common/filter
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# include test specific environments here
+_supported_fs ext4
+_supported_os Linux
+_require_test
+_require_scratch
+_require_command "$DUMP_PROG" dump
+_require_command "$RESTORE_PROG" restore
+
+echo "Silence is golden"
dump_dir=$SCRATCH_MNT/dump_restore_dir
restore_dir=$TEST_DIR/dump_restore_dir
@@ -49,19 +49,6 @@ workout()
rm -rf restoresymtable
}
-# real QA test starts here
-_supported_fs ext4
-_supported_os Linux
-
-_require_test
-_require_scratch
-
-_require_command "$DUMP_PROG" dump
-_require_command "$RESTORE_PROG" restore
-
-rm -f $seqres.full
-echo "Silence is golden"
-
_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
_scratch_mount
rm -rf $restore_dir $TEST_DIR/restoresymtable
@@ -69,5 +56,4 @@ rm -rf $restore_dir $TEST_DIR/restoresymtable
workout
diff -r $dump_dir $restore_dir
-status=0
-exit
+_success
diff --git a/tests/ext4/005 b/tests/ext4/005
index db37c2eaa51e..a1e3f08eb1f4 100755
--- a/tests/ext4/005
+++ b/tests/ext4/005
@@ -11,33 +11,20 @@
# ext4: be more strict when migrating to non-extent based file
# ext4: correctly migrate a file with a hole at the beginning
#
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
+. common/setup_test
-here=`pwd`
-tmp=/tmp/$$
-status=1 # failure is the default!
-trap "_cleanup; exit \$status" 0 1 2 3 15
+# test exit cleanup goes here
+cleanup() { :; }
-_cleanup()
-{
- cd /
- rm -f $tmp.*
-}
-
-# get standard environment, filters and checks
-. ./common/rc
-. ./common/filter
+# remove previous $seqres.full before test
+rm -f $seqres.full
-# real QA test starts here
+# include test specific environments here
_supported_fs ext4
_supported_os Linux
_require_scratch
_require_command "$CHATTR_PROG" chattr
-rm -f $seqres.full
-
echo "Silence is golden"
_scratch_mkfs >>$seqres.full 2>&1
@@ -63,6 +50,4 @@ $CHATTR_PROG -e $testfile >>$seqres.full 2>&1
# results in i_blocks corruption
$XFS_IO_PROG -c "pwrite 0 4k" $testfile >>$seqres.full 2>&1
-# success, all done
-status=0
-exit
+_success
diff --git a/tests/ext4/006 b/tests/ext4/006
index 63e42f58906f..3881090efa51 100755
--- a/tests/ext4/006
+++ b/tests/ext4/006
@@ -8,40 +8,30 @@
# the kernel reacts, how e2fsck fares in fixing the mess, and then
# try more kernel accesses to see if it really fixed things.
#
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
-
-here=`pwd`
-tmp=/tmp/$$
-status=1 # failure is the default!
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
-_cleanup()
-{
- cd /
- #rm -f $tmp.*
-}
+. common/setup_test
+
+# test exit cleanup goes here
+cleanup() { :; }
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
-# get standard environment, filters and checks
+# include test specific environments here
. ./common/rc
. ./common/filter
. ./common/attr
. ./common/populate
. ./common/fuzzy
-
-if [ ! -x "$(which e2fuzz)" ]; then
- _notrun "Couldn't find e2fuzz"
-fi
-
-# real QA test starts here
_supported_fs ext4
_supported_os Linux
-
_require_scratch
_require_attrs
_require_populate_commands
+if [ ! -x "$(which e2fuzz)" ]; then
+ _notrun "Couldn't find e2fuzz"
+fi
+
repair_scratch() {
fsck_pass="$1"
@@ -75,7 +65,6 @@ repair_scratch() {
return 1
}
-rm -f $seqres.full
echo "See interesting results in $seqres.full" | sed -e "s,$RESULT_DIR,RESULT_DIR,g"
SRCDIR=`pwd`
test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-b 32 -v"
@@ -144,5 +133,4 @@ if [ "$(wc -l < "$ROUND2_LOG")" -ne 8 ]; then
fi
echo "finished fuzzing" | tee -a "$seqres.full"
-status=0
-exit
+_success
diff --git a/tests/ext4/007 b/tests/ext4/007
index b7f7c6ce517e..be81135b18fa 100755
--- a/tests/ext4/007
+++ b/tests/ext4/007
@@ -7,35 +7,22 @@
# Create and populate an ext4 filesystem, corrupt the primary superblock, then
# see how the kernel and e2fsck deal with it.
#
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
-
-here=`pwd`
-tmp=/tmp/$$
-status=1 # failure is the default!
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
-_cleanup()
-{
- cd /
- #rm -f $tmp.*
-}
-
-# get standard environment, filters and checks
-. ./common/rc
-. ./common/filter
-. ./common/attr
+. common/setup_test
+
+# test exit cleanup goes here
+cleanup() { :; }
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
-# real QA test starts here
+# include test specific environments here
+. ./common/attr
_supported_fs ext4
_supported_os Linux
-
_require_scratch
test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
_require_attrs
-rm -f $seqres.full
TESTDIR="${SCRATCH_MNT}/scratchdir"
TESTFILE="${TESTDIR}/testfile"
@@ -103,5 +90,4 @@ umount "${SCRATCH_MNT}"
echo "+ check fs (2)"
e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
-status=0
-exit
+_success
diff --git a/tests/ext4/008 b/tests/ext4/008
index c553760dd333..6f35511bd366 100755
--- a/tests/ext4/008
+++ b/tests/ext4/008
@@ -7,35 +7,22 @@
# Create and populate an ext4 filesystem, corrupt a group descriptor, then
# see how the kernel and e2fsck deal with it.
#
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
+. common/setup_test
-here=`pwd`
-tmp=/tmp/$$
-status=1 # failure is the default!
-trap "_cleanup; exit \$status" 0 1 2 3 15
+# test exit cleanup goes here
+cleanup() { :; }
-_cleanup()
-{
- cd /
- #rm -f $tmp.*
-}
+# remove previous $seqres.full before test
+rm -f $seqres.full
-# get standard environment, filters and checks
-. ./common/rc
-. ./common/filter
+# include test specific environments here
. ./common/attr
-
-# real QA test starts here
_supported_fs ext4
_supported_os Linux
-
_require_scratch
test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
_require_attrs
-rm -f $seqres.full
TESTDIR="${SCRATCH_MNT}/scratchdir"
TESTFILE="${TESTDIR}/testfile"
@@ -84,5 +71,4 @@ umount "${SCRATCH_MNT}"
echo "+ check fs (2)"
e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
-status=0
-exit
+_success
diff --git a/tests/ext4/009 b/tests/ext4/009
index 9a2cd0f3c669..94da5e91900a 100755
--- a/tests/ext4/009
+++ b/tests/ext4/009
@@ -7,36 +7,23 @@
# Create and populate an ext4 filesystem, corrupt a block bitmap, then
# see how the kernel and e2fsck deal with it.
#
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
-
-here=`pwd`
-tmp=/tmp/$$
-status=1 # failure is the default!
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
-_cleanup()
-{
- cd /
- #rm -f $tmp.*
-}
-
-# get standard environment, filters and checks
-. ./common/rc
-. ./common/filter
-. ./common/attr
+. common/setup_test
+
+# test exit cleanup goes here
+cleanup() { :; }
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
-# real QA test starts here
+# include test specific environments here
+. ./common/attr
_supported_fs ext4
_supported_os Linux
-
_require_xfs_io_command "falloc"
_require_scratch
test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc
_require_attrs
-rm -f $seqres.full
TESTDIR="${SCRATCH_MNT}/scratchdir"
TESTFILE="${TESTDIR}/testfile"
@@ -94,5 +81,4 @@ umount "${SCRATCH_MNT}"
echo "+ check fs (2)"
e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
-status=0
-exit
+_success
--
2.17.0
next prev parent reply other threads:[~2018-06-27 8:21 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-27 8:20 [PATCH 0/6] fstests: start factoring test setup boilerplate Dave Chinner
2018-06-27 8:20 ` [PATCH 1/8] fstests: generic test setup preamble Dave Chinner
2018-06-27 11:07 ` Amir Goldstein
2018-06-27 8:20 ` [PATCH 2/8] tests: convert various test dirs to " Dave Chinner
2018-06-27 10:34 ` Amir Goldstein
2018-06-27 14:03 ` Dave Chinner
2018-06-27 8:20 ` [PATCH 3/8] shared: use new test " Dave Chinner
2018-06-27 10:56 ` Amir Goldstein
2018-06-27 14:27 ` Dave Chinner
2018-06-27 14:43 ` Amir Goldstein
2018-06-27 22:07 ` Dave Chinner
2018-06-28 4:12 ` Amir Goldstein
2018-06-27 8:20 ` [PATCH 4/8] generic: convert some tests to new " Dave Chinner
2018-06-27 11:08 ` Amir Goldstein
2018-07-07 11:28 ` Eryu Guan
2018-06-27 8:21 ` [PATCH 5/8] btrfs: " Dave Chinner
2018-06-27 11:30 ` Amir Goldstein
2018-06-27 14:34 ` Dave Chinner
2018-06-27 14:48 ` Amir Goldstein
2018-07-07 11:22 ` Eryu Guan
2018-06-27 8:21 ` Dave Chinner [this message]
2018-06-27 11:34 ` [PATCH 6/8] ext4: " Amir Goldstein
2018-07-07 11:25 ` Eryu Guan
2018-06-27 8:21 ` [PATCH 7/8] overlay: " Dave Chinner
2018-06-27 11:37 ` Amir Goldstein
2018-06-27 8:21 ` [PATCH 8/8] xfs: " Dave Chinner
2018-06-27 11:42 ` Amir Goldstein
2018-06-28 5:59 ` [PATCH 0/6] fstests: start factoring test setup boilerplate Eryu Guan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180627082103.9662-7-david@fromorbit.com \
--to=david@fromorbit.com \
--cc=fstests@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox