gfs2-utils tests: Add keywords to tests
PATCH 1/5 gfs2-utils tests: Add keywords to tests
The testsuite script generated by autotest accepts a -k <keyword> option which limits the set of tests to be run to a specified group. Add keywords to tests to take advantage of this feature.
--- tests/edit.at | 5 +++++ tests/fsck.at | 2 ++ tests/libgfs2.at | 2 ++ tests/mkfs.at | 16 ++++++++++++++++ 4 files changed, 25 insertions(+)
tests/edit.at +5 -0
@@ -2,6 +2,7 @@ AT_TESTED([gfs2_edit]) AT_BANNER([gfs2_edit tests]) AT_SETUP([Save/restoremeta, defaults]) +AT_KEYWORDS(gfs2_edit edit) GFS_TGT_REGEN AT_CHECK([$GFS_MKFS -p lock_nolock $GFS_TGT $(($(gfs_max_blocks 4096)/2))], 0, [ignore], [ignore]) AT_CHECK([gfs2_edit savemeta $GFS_TGT test.meta > savemeta.log], 0, [ignore], [ignore])
@@ -14,6 +15,7 @@ AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore]) AT_CLEANUP AT_SETUP([Save/restoremeta, no compression]) +AT_KEYWORDS(gfs2_edit edit) GFS_TGT_REGEN AT_CHECK([$GFS_MKFS -p lock_nolock $GFS_TGT $(($(gfs_max_blocks 4096)/2))], 0, [ignore], [ignore]) AT_CHECK([gfs2_edit savemeta -z0 $GFS_TGT test.meta], 0, [ignore], [ignore])
@@ -23,6 +25,7 @@ AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore]) AT_CLEANUP AT_SETUP([Save/restoremeta, min. block size]) +AT_KEYWORDS(gfs2_edit edit) GFS_TGT_REGEN AT_CHECK([$GFS_MKFS -p lock_nolock -b512 $GFS_TGT], 0, [ignore], [ignore]) AT_CHECK([gfs2_edit savemeta -z0 $GFS_TGT test.meta], 0, [ignore], [ignore])
@@ -32,6 +35,7 @@ AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore]) AT_CLEANUP AT_SETUP([Save/restoremeta, 4 journals]) +AT_KEYWORDS(gfs2_edit edit) GFS_TGT_REGEN AT_CHECK([$GFS_MKFS -p lock_nolock -j4 -J8 $GFS_TGT], 0, [ignore], [ignore]) AT_CHECK([gfs2_edit savemeta -z0 $GFS_TGT test.meta], 0, [ignore], [ignore])
@@ -41,6 +45,7 @@ AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore]) AT_CLEANUP AT_SETUP([Save/restoremeta, min. block size, 4 journals]) +AT_KEYWORDS(gfs2_edit edit) GFS_TGT_REGEN AT_CHECK([$GFS_MKFS -p lock_nolock -b512 -j4 -J8 $GFS_TGT], 0, [ignore], [ignore]) AT_CHECK([gfs2_edit savemeta -z0 $GFS_TGT test.meta], 0, [ignore], [ignore])
tests/fsck.at +2 -0
@@ -2,6 +2,7 @@ AT_TESTED([fsck.gfs2]) AT_BANNER([fsck.gfs2 tests]) AT_SETUP([Fix invalid block sizes]) +AT_KEYWORDS(fsck.gfs2 fsck) GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set sb { sb_bsize: 0 }]) GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set sb { sb_bsize: 1 }]) GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set sb { sb_bsize: 513 }])
@@ -10,6 +11,7 @@ GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set sb { sb_bsize: 4097 AT_CLEANUP AT_SETUP([Fix invalid goal blocks]) +AT_KEYWORDS(fsck.gfs2 fsck) GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set '/' { di_goal_meta: 0 }]) GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set '/' { di_goal_data: 0 }]) AT_CLEANUP
tests/libgfs2.at +2 -0
@@ -1,9 +1,11 @@ AT_BANNER([libgfs2 unit tests]) AT_SETUP([meta.c]) +AT_KEYWORDS(libgfs2) AT_CHECK([check_meta], 0, [ignore], [ignore]) AT_CLEANUP AT_SETUP([rgrp.c]) +AT_KEYWORDS(libgfs2) AT_CHECK([check_rgrp], 0, [ignore], [ignore]) AT_CLEANUP
tests/mkfs.at +16 -0
@@ -2,36 +2,43 @@ AT_TESTED([mkfs.gfs2]) AT_BANNER([mkfs.gfs2 tests]) AT_SETUP([Locking protocol validation]) +AT_KEYWORDS(mkfs.gfs2 mkfs) AT_CHECK([$GFS_MKFS -p badprotocol $GFS_TGT], 255, [ignore], [ignore]) AT_CLEANUP AT_SETUP([Resource group size validation]) +AT_KEYWORDS(mkfs.gfs2 mkfs) AT_CHECK([$GFS_MKFS -p lock_nolock -r 31 $GFS_TGT], 255, [ignore], [ignore]) AT_CHECK([$GFS_MKFS -p lock_nolock -r 2049 $GFS_TGT], 255, [ignore], [ignore]) AT_CLEANUP AT_SETUP([Journal size validation]) +AT_KEYWORDS(mkfs.gfs2 mkfs) AT_CHECK([$GFS_MKFS -p lock_nolock -J 7 $GFS_TGT], 255, [ignore], [ignore]) AT_CHECK([$GFS_MKFS -p lock_nolock -J 1025 $GFS_TGT], 255, [ignore], [ignore]) AT_CLEANUP AT_SETUP([Block count validation]) +AT_KEYWORDS(mkfs.gfs2 mkfs) GFS_TGT_REGEN AT_CHECK([$GFS_MKFS -p lock_nolock -b 512 $GFS_TGT $(($(gfs_max_blocks 512)+1))], 255, [ignore], [ignore]) AT_CHECK([$GFS_MKFS -p lock_nolock -b 4096 $GFS_TGT $(($(gfs_max_blocks 4096)+1))], 255, [ignore], [ignore]) AT_CLEANUP AT_SETUP([Quota change file size validation]) +AT_KEYWORDS(mkfs.gfs2 mkfs) AT_CHECK([$GFS_MKFS -p lock_nolock -c 0 $GFS_TGT], 255, [ignore], [ignore]) AT_CHECK([$GFS_MKFS -p lock_nolock -c 65 $GFS_TGT], 255, [ignore], [ignore]) AT_CLEANUP AT_SETUP([Locking protocols]) +AT_KEYWORDS(mkfs.gfs2 mkfs) GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock $GFS_TGT]) GFS_FSCK_CHECK([$GFS_MKFS -p lock_dlm -t foo:bar $GFS_TGT]) AT_CLEANUP AT_SETUP([Valid block sizes 512-4096]) +AT_KEYWORDS(mkfs.gfs2 mkfs) GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -b 512 $GFS_TGT]) GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -b 1024 $GFS_TGT]) GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -b 2048 $GFS_TGT])
@@ -39,37 +46,46 @@ GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -b 4096 $GFS_TGT]) AT_CLEANUP AT_SETUP([Max. blocks, min. block size]) +AT_KEYWORDS(mkfs.gfs2 mkfs) GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -b 512 $GFS_TGT $(gfs_max_blocks 512)]) AT_CLEANUP AT_SETUP([Max. blocks, max. block size]) +AT_KEYWORDS(mkfs.gfs2 mkfs) GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -b 4096 $GFS_TGT $(util_max_blocks 4096)]) AT_CLEANUP AT_SETUP([Max. resource group size]) +AT_KEYWORDS(mkfs.gfs2 mkfs) GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -r 2048 $GFS_TGT]) AT_CLEANUP AT_SETUP([Min. resource group size]) +AT_KEYWORDS(mkfs.gfs2 mkfs) GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -r 32 $GFS_TGT]) AT_CLEANUP AT_SETUP([Max. resource group size, min. block size]) +AT_KEYWORDS(mkfs.gfs2 mkfs) GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -r 2048 -b 512 $GFS_TGT]) AT_CLEANUP AT_SETUP([Max. journal size]) +AT_KEYWORDS(mkfs.gfs2 mkfs) GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -J 1024 $GFS_TGT]) AT_CLEANUP AT_SETUP([Min. journal size]) +AT_KEYWORDS(mkfs.gfs2 mkfs) GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -J 8 $GFS_TGT]) AT_CLEANUP AT_SETUP([Max. quota change file size]) +AT_KEYWORDS(mkfs.gfs2 mkfs) GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -c 64 $GFS_TGT]) AT_CLEANUP AT_SETUP([Min. quota change file size]) +AT_KEYWORDS(mkfs.gfs2 mkfs) GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -c 1 $GFS_TGT]) AT_CLEANUP
Signature · 1 line
1.9.3
PATCH 2/5 gfs2-utils tests: Shorten TESTSUITEFLAGS to TOPTS
TESTSUITEFLAGS is too long, replace it with TOPTS
--- tests/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/Makefile.am +2 -2
@@ -64,10 +64,10 @@ endif TESTSUITE = $(srcdir)/testsuite check-local: atconfig atlocal $(TESTSUITE) - $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) + $(SHELL) '$(TESTSUITE)' $(TOPTS) installcheck-local: atconfig atlocal $(TESTSUITE) - $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(sbindir):tests' $(TESTSUITEFLAGS) + $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(sbindir):tests' $(TOPTS) clean-local: test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' --clean
Signature · 1 line
1.9.3
PATCH 3/5 gfs2-utils tests: Improve docs
In reply to Andrew PriceAdd a pointer to doc/README.tests in README.build and be more consistent about how the test suite is run in doc/README.tests. Add example usage and mention the TOPTS argument.
--- README.build | 3 ++- doc/README.tests | 32 ++++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-)
README.build +2 -1
@@ -29,4 +29,5 @@ To install gfs2-utils, run: make install -See also doc/README.contributing for details on submitting patches. +See also doc/README.contributing for details on submitting patches and +doc/README.tests for more details regarding the test suite.
doc/README.tests +24 -8
@@ -1,16 +1,30 @@ Working with the gfs2-utils test suite -------------------------------------- +Overview +-------- The test suite in the tests directory of the gfs2-utils source tree is based on the Autotest framework provided by Autoconf. The basic idea is that the testsuite.at file is the main source file for the tests, written in m4 and -generating a bourne shell script called testsuite. +generating a bourne shell script called testsuite, which we run with 'make check'. -When run, either using 'make check' or directly from within the tests -directory, the testsuite script sources atconfig and atlocal for configuration -and then runs the whole testsuite or a specified set of tests (see ./testsuite --h for help). +When run, the test suite sources tests/atconfig and tests/atlocal for +configuration and then runs the whole suite or a specified set of tests, +depending on options passed to the test suite using TOPTS. For example, to see +a list of available options, use 'make check TOPTS=-h' and to see a numbered +list of the available tests, use 'make check TOPTS=-l'. +A subset of the available tests can be run using keywords and/or by specifying +the test ID numbers in TOPTS, e.g. make check TOPTS='-k mkfs 24 25' + +Test output is captured and, if a test fails, a log is kept in +tests/testsuite.dir/$n/testsuite.log where $n is the test's ID number. Failed +tests can be re-run using make check TOPTS='--recheck' although it's better to +re-run the entire suite after fixing tests as a fix for one test could break +another. + +Writing tests +------------- A number of GFS2-specific convenience macros have been defined in testsuite.at to make defining new tests quick and easy. Also, some variables have been defined in atlocal.in so that full paths to programs do not have to be included
@@ -32,15 +46,17 @@ do not fit into an existing category, in which case AT_BANNER can be used to group them, and they can be organised into a new .at file and sourced from testsuite.at. -Since the tests can be run individually (e.g. ./testsuite 15) any new tests -which require the dummy volume $GFS_TGT to be present should call GFS_TGT_REGEN -before attempting to use it. +As the tests can be run individually, any new tests which require the dummy +volume $GFS_TGT to be present should call GFS_TGT_REGEN before attempting to +use it. Documentation for Autotest, including the AT_* macros used to define tests, can be found in the autoconf manual at: http://www.gnu.org/software/autoconf/manual/index.html +Generating coverage reports +--------------------------- Test coverage instrumentation can be enabled using the --enable-gcov option at the configure stage. Once the tools have been built and run with this option enabled, coverage data will be written to files in the source directories for
Signature · 1 line
1.9.3
PATCH 4/5 gfs2-utils tests: Skip unit tests if check is not found
In reply to Andrew PriceThe check package (check-devel in Fedora) is required for building the unit tests. When the configure script doesn't find check, it prevents the unit tests from being built, but the test suite still tries to run the unit tests. Introduce a wrapper m4 macro GFS_UNIT_TEST to set up unit test test groups which will be skipped if check was not found in the configure stage.
--- configure.ac | 2 +- tests/Makefile.am | 13 +++++++------ tests/libgfs2.at | 6 ++---- tests/testsuite.at | 8 ++++++++ 4 files changed, 18 insertions(+), 11 deletions(-)
configure.ac +1 -1
@@ -97,7 +97,7 @@ AC_ARG_ENABLE([gcov], PKG_CHECK_MODULES([check], [check >= 0.9.8], [have_check=yes], [have_check=no]) -AM_CONDITIONAL([BUILD_TESTS], [test "x$have_check" = "xyes"]) +AM_CONDITIONAL([HAVE_CHECK], [test "x$have_check" = "xyes"]) PKG_CHECK_MODULES([zlib],[zlib]) PKG_CHECK_MODULES([blkid],[blkid])
tests/Makefile.am +7 -6
@@ -2,7 +2,7 @@ EXTRA_DIST = $(TESTSUITE_AT) package.m4 $(TESTSUITE) atlocal atconfig DISTCLEANFILES = atlocal atconfig CLEANFILES = testvol -if BUILD_TESTS +if HAVE_CHECK UNIT_TESTS = \ check_meta \ check_rgrp
@@ -55,19 +55,20 @@ TESTSUITE_AT = \ testsuite.at \ mkfs.at \ fsck.at \ - edit.at + edit.at \ + libgfs2.at -if BUILD_TESTS -TESTSUITE_AT += libgfs2.at +if HAVE_CHECK +ENABLE_UNIT=yes endif TESTSUITE = $(srcdir)/testsuite check-local: atconfig atlocal $(TESTSUITE) - $(SHELL) '$(TESTSUITE)' $(TOPTS) + $(SHELL) '$(TESTSUITE)' ENABLE_UNIT_TESTS=$(ENABLE_UNIT) $(TOPTS) installcheck-local: atconfig atlocal $(TESTSUITE) - $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(sbindir):tests' $(TOPTS) + $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(sbindir):tests' ENABLE_UNIT_TESTS=$(ENABLE_UNIT) $(TOPTS) clean-local: test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' --clean
tests/libgfs2.at +2 -4
@@ -1,11 +1,9 @@ AT_BANNER([libgfs2 unit tests]) -AT_SETUP([meta.c]) -AT_KEYWORDS(libgfs2) +GFS_UNIT_TEST([meta.c],[libgfs2]) AT_CHECK([check_meta], 0, [ignore], [ignore]) AT_CLEANUP -AT_SETUP([rgrp.c]) -AT_KEYWORDS(libgfs2) +GFS_UNIT_TEST([rgrp.c],[libgfs2]) AT_CHECK([check_rgrp], 0, [ignore], [ignore]) AT_CLEANUP
tests/testsuite.at +8 -0
@@ -17,6 +17,14 @@ AT_CHECK([echo "$2" | gfs2l ${GFS_TGT}], 0, [ignore], [ignore]) AT_CHECK([fsck.gfs2 -y $GFS_TGT], 1, [ignore], [ignore]) AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore])]) +# Set up a unit test, skipping if unit tests are disabled +# Usage: GFS_UNIT_TEST ([name], [keywords]) +m4_define([GFS_UNIT_TEST], +[AT_SETUP($1) +AT_KEYWORDS($2) +AT_CHECK([test x"$ENABLE_UNIT_TESTS" = "xyes" || exit 77])]) + +# Test suite begins here AT_INIT([]) AT_COLOR_TESTS
Signature · 1 line
1.9.3
PATCH 5/5 gfs2-utils tests: Document usage of convenience macros
In reply to Andrew PriceLower the barrier to writing tests by adding some docs to clarify the m4 convenience macros in testsuite.at.
--- tests/testsuite.at | 3 +++ 1 file changed, 3 insertions(+)
tests/testsuite.at +3 -0
@@ -1,15 +1,18 @@ # Regenerate the sparse file used for testing and skip the test if it fails +# Usage: GFS_TGT_REGEN m4_define([GFS_TGT_REGEN], [AT_CHECK([rm -f $GFS_TGT && truncate -s ${GFS_TGT_SZ}G ${GFS_TGT}], [ignore], [ignore], [ignore]) AT_SKIP_IF([test ! -f ${GFS_TGT}])]) # Regenerate, check, fsck is used a lot so combine it into one macro +# Usage: GFS_FSCK_CHECK ([mkfs.gfs2 ... $GFS_TGT]) m4_define([GFS_FSCK_CHECK], [GFS_TGT_REGEN AT_CHECK($1, 0, [ignore], [ignore]) AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore])]) # Regenerate, mkfs, modify fs with gfs2l, fsck +# Usage: GFS_TGT_REGEN ([<mkfs.gfs2 command>], [<gfs2l script>]) m4_define([GFS_LANG_CHECK], [GFS_TGT_REGEN AT_CHECK($1, 0, [ignore], [ignore])
Signature · 1 line
1.9.3