Blob Blame History Raw
Working with the gfs2-utils test suite

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 file is the main source file for the tests, written in m4 and
generating a bourne shell script called testsuite, which we run with 'make check'.

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

Writing tests
A number of GFS2-specific convenience macros have been defined in
to make defining new tests quick and easy. Also, some variables have been
defined in so that full paths to programs do not have to be included
in each test. Configuration should be specified in as atconfig is
generated by the configure script and atlocal is generated from at
build time.

To keep the test suite organised, the file sources the actual
tests from other files, e.g.

A single test, specified as a test group in Autotest terms, follows the form

    AT_SETUP([Test title])
    ...test goes here...

so, when adding tests, this is generally all that is required unless the tests
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

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:

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
use by tools such as gcov or lcov. For example, to generate a HTML report of
testsuite code coverage, using lcov, in a directory named 'coverage':

    ./configure --enable-gcov
    make check
    lcov --directory . -c -o
    genhtml -o coverage