diff mbox

[2/8] tests: convert various test dirs to setup preamble

Message ID 20180627082103.9662-3-david@fromorbit.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dave Chinner June 27, 2018, 8:20 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

Convert all the test dirs with a very small number of tests in one
go.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 tests/cifs/001  | 25 +++++++------------------
 tests/f2fs/001  | 25 +++++++------------------
 tests/nfs/001   | 28 +++++++---------------------
 tests/ocfs2/001 | 29 +++++++----------------------
 tests/perf/001  | 30 +++++++++++++-----------------
 tests/udf/102   | 29 ++++++++---------------------
 6 files changed, 49 insertions(+), 117 deletions(-)

Comments

Amir Goldstein June 27, 2018, 10:34 a.m. UTC | #1
On Wed, Jun 27, 2018 at 11:20 AM, Dave Chinner <david@fromorbit.com> wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> Convert all the test dirs with a very small number of tests in one
> go.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
[...]

> -rm -f $seqres.full
> +echo "Silence is golden"
> +
> +fio_config=$tmp.fio
> +fio_results=$tmp.json
>
>  _size=$((16 * $LOAD_FACTOR))
>  cat >$fio_config <<EOF
> @@ -60,5 +56,5 @@ $FIO_PROG --output-format=json --output=$fio_results $fio_config
>  _scratch_unmount
>  cat $fio_results >> $seqres.full
>  _fio_results_compare $seq $fio_results
> -echo "Silence is golden"
> -status=0; exit
> +
> +_success

I realize that without status=0 test will not pass, but it always
annoys me that echo "Silence is golden" before the end of the test.

How about _success_silent to further reduce the boilerplate echo
"Silence is golden"?

Thanks,
Amir.
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dave Chinner June 27, 2018, 2:03 p.m. UTC | #2
On Wed, Jun 27, 2018 at 01:34:07PM +0300, Amir Goldstein wrote:
> On Wed, Jun 27, 2018 at 11:20 AM, Dave Chinner <david@fromorbit.com> wrote:
> > From: Dave Chinner <dchinner@redhat.com>
> >
> > Convert all the test dirs with a very small number of tests in one
> > go.
> >
> > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > ---
> [...]
> 
> > -rm -f $seqres.full
> > +echo "Silence is golden"
> > +
> > +fio_config=$tmp.fio
> > +fio_results=$tmp.json
> >
> >  _size=$((16 * $LOAD_FACTOR))
> >  cat >$fio_config <<EOF
> > @@ -60,5 +56,5 @@ $FIO_PROG --output-format=json --output=$fio_results $fio_config
> >  _scratch_unmount
> >  cat $fio_results >> $seqres.full
> >  _fio_results_compare $seq $fio_results
> > -echo "Silence is golden"
> > -status=0; exit
> > +
> > +_success
> 
> I realize that without status=0 test will not pass, but it always
> annoys me that echo "Silence is golden" before the end of the test.

That's because it's supposed to be at the start of the test,
documenting the fact that any output from the test is expected to
cause it to fail. That's generally important to know before you get
ot the last line of the test code....

> How about _success_silent to further reduce the boilerplate echo
> "Silence is golden"?

No.  Removing "silence is golden" (and all the variations that have
crept in over the years) and replacing them with
_success_silent can be mostly scripted once everything
has first been converted to call _success. IMO that's a relatively easy followup
patchset, and it's precisely what this initial conversion is supposed to
enable us to do. i.e. make codebase wide setup/completion
maintenance much easier to perform.

So let's not make the hard part of converting 1260 tests to common
setup infrastructure any harder than it already is going to be by
adding lots of other random cleanups into it as well.....

Cheers,

Dave.
diff mbox

Patch

diff --git a/tests/cifs/001 b/tests/cifs/001
index 193103bf8877..5bfc6ae46c92 100755
--- a/tests/cifs/001
+++ b/tests/cifs/001
@@ -6,27 +6,17 @@ 
 #
 # Sanity test for server-side copies initiated via CIFS_IOC_COPYCHUNK_FILE
 #
-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!
-
-_cleanup()
-{
-	rm -f $tmp.*
+# test exit cleanup goes here
+cleanup() {
 	rm -rf $TEST_DIR/$$
 }
 
-trap "_cleanup ; exit \$status" 0 1 2 3 15
-
-# 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 cifs
 _supported_os Linux
 _require_cloner
@@ -49,5 +39,4 @@  for i in `seq 1 10`; do
 	diff $TEST_DIR/$$/src/${i} $TEST_DIR/$$/dest/${i}
 done
 
-status=0
-exit
+_success
diff --git a/tests/f2fs/001 b/tests/f2fs/001
index f9cd2cf089a3..c23c1cc6da36 100755
--- a/tests/f2fs/001
+++ b/tests/f2fs/001
@@ -15,25 +15,15 @@ 
 # In ext4, up to 132 bytes of data can be stored in 256 bytes-sized inode.
 # In f2fs, up to 3.4KB of data can be embedded into 4KB-sized inode block.
 #
-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
 
+# include test specific environments here
 _supported_fs f2fs
 _supported_os Linux
 _require_scratch
@@ -65,5 +55,4 @@  hexdump -C $testfile
 rm $testfile
 rm $dummyfile
 
-status=0
-exit
+_success
diff --git a/tests/nfs/001 b/tests/nfs/001
index d7a79cb07d83..ca5d96093bf9 100755
--- a/tests/nfs/001
+++ b/tests/nfs/001
@@ -9,29 +9,17 @@ 
 # ERANGE. Upstream commit ed92d8c137b7 ("NFSv4: fix getacl ERANGE for some ACL
 # buffer sizes") fixed this bug.
 #
-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.* $acltest.*
-}
+. common/setup_test
 
-# get standard environment, filters and checks
-. ./common/rc
-. ./common/filter
+# test exit cleanup goes here
+cleanup() {
+	rm -f $acltest.*
+}
 
 # remove previous $seqres.full before test
 rm -f $seqres.full
 
-# real QA test starts here
+# include test specific environments here
 _supported_fs nfs
 _supported_os Linux
 _require_test_nfs_version 4
@@ -57,6 +45,4 @@  $NFS4_SETFACL_PROG -S $acltest.list $acltest.file
 $NFS4_GETFACL_PROG $acltest.file >>$seqres.full 2>&1
 $NFS4_GETFACL_PROG $acltest.file | wc -l
 
-# success, all done
-status=0
-exit
+_success
diff --git a/tests/ocfs2/001 b/tests/ocfs2/001
index af304b8281a3..ad4ed58cd875 100755
--- a/tests/ocfs2/001
+++ b/tests/ocfs2/001
@@ -6,34 +6,21 @@ 
 #
 # Ensure that reflink works correctly with inline-data files.
 #
-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 -rf $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/reflink
-
-# real QA test starts here
 _supported_os Linux
 _supported_fs ocfs2
 _require_scratch_reflink
 _require_cp_reflink
 
-rm -f $seqres.full
-
 echo "Format and mount"
 _scratch_mkfs --fs-features=local,unwritten,refcount,inline-data > $seqres.full 2>&1
 tunefs.ocfs2 --query '%H' $SCRATCH_DEV | grep -q 'inline-data' || \
@@ -69,6 +56,4 @@  echo "Verify the whole mess"
 _scratch_cycle_mount
 md5sum $testdir/file* | _filter_scratch
 
-# success, all done
-status=0
-exit
+_success
diff --git a/tests/perf/001 b/tests/perf/001
index 5a6d9b29cb93..b28081eb1872 100755
--- a/tests/perf/001
+++ b/tests/perf/001
@@ -6,30 +6,26 @@ 
 #
 # Buffered random write performance test.
 #
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
+. common/setup_test
 
-here=`pwd`
-tmp=/tmp/$$
-fio_config=$tmp.fio
-fio_results=$tmp.json
-status=1	# failure is the default!
-trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
+# test exit cleanup goes here
+cleanup() { :; }
 
-# get standard environment, filters and checks
-. ./common/rc
-. ./common/filter
-. ./common/perf
+# remove previous $seqres.full before test
+rm -f $seqres.full
 
-# real QA test starts here
+# include test specific environments here
+. ./common/perf
 _supported_fs generic
 _supported_os Linux
 _require_scratch
 _require_block_device $SCRATCH_DEV
 _require_fio_results
 
-rm -f $seqres.full
+echo "Silence is golden"
+
+fio_config=$tmp.fio
+fio_results=$tmp.json
 
 _size=$((16 * $LOAD_FACTOR))
 cat >$fio_config <<EOF
@@ -60,5 +56,5 @@  $FIO_PROG --output-format=json --output=$fio_results $fio_config
 _scratch_unmount
 cat $fio_results >> $seqres.full
 _fio_results_compare $seq $fio_results
-echo "Silence is golden"
-status=0; exit
+
+_success
diff --git a/tests/udf/102 b/tests/udf/102
index acfa85c30387..e3ea7da75f64 100755
--- a/tests/udf/102
+++ b/tests/udf/102
@@ -7,28 +7,17 @@ 
 # This tests mkfs_udf/mkudffs and the device detection code
 # Modified from UDFQA test 031.
 #
-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()
-{
-    rm -f $tmp.*
-    cd /
-}
-# 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
-_supported_fs udf 
+# include test specific environments here
+_supported_fs udf
 _supported_os Linux
-
 _require_scratch
 _setup_udf_scratchdir
 
@@ -37,6 +26,4 @@  _check_udf_filesystem $SCRATCH_DEV
 
 echo "Finished"
 
-# success, all done
-status=0
-exit
+_success