Blame doc/README.tests

Packit 6ef888
Working with the gfs2-utils test suite
Packit 6ef888
--------------------------------------
Packit 6ef888
Packit 6ef888
Overview
Packit 6ef888
--------
Packit 6ef888
The test suite in the tests directory of the gfs2-utils source tree is based on
Packit 6ef888
the Autotest framework provided by Autoconf. The basic idea is that the
Packit 6ef888
testsuite.at file is the main source file for the tests, written in m4 and
Packit 6ef888
generating a bourne shell script called testsuite, which we run with 'make check'.
Packit 6ef888
Packit 6ef888
When run, the test suite sources tests/atconfig and tests/atlocal for
Packit 6ef888
configuration and then runs the whole suite or a specified set of tests,
Packit 6ef888
depending on options passed to the test suite using TOPTS. For example, to see
Packit 6ef888
a list of available options, use 'make check TOPTS=-h' and to see a numbered
Packit 6ef888
list of the available tests, use 'make check TOPTS=-l'.
Packit 6ef888
Packit 6ef888
A subset of the available tests can be run using keywords and/or by specifying
Packit 6ef888
the test ID numbers in TOPTS, e.g. make check TOPTS='-k mkfs 24 25'
Packit 6ef888
Packit 6ef888
Test output is captured and, if a test fails, a log is kept in
Packit 6ef888
tests/testsuite.dir/$n/testsuite.log where $n is the test's ID number. Failed
Packit 6ef888
tests can be re-run using make check TOPTS='--recheck' although it's better to
Packit 6ef888
re-run the entire suite after fixing tests as a fix for one test could break
Packit 6ef888
another.
Packit 6ef888
Packit 6ef888
Writing tests
Packit 6ef888
-------------
Packit 6ef888
A number of GFS2-specific convenience macros have been defined in testsuite.at
Packit 6ef888
to make defining new tests quick and easy. Also, some variables have been
Packit 6ef888
defined in atlocal.in so that full paths to programs do not have to be included
Packit 6ef888
in each test. Configuration should be specified in atlocal.in as atconfig is
Packit 6ef888
generated by the configure script and atlocal is generated from atlocal.in at
Packit 6ef888
build time.
Packit 6ef888
Packit 6ef888
To keep the test suite organised, the testsuite.at file sources the actual
Packit 6ef888
tests from other files, e.g. mkfs.at.
Packit 6ef888
Packit 6ef888
A single test, specified as a test group in Autotest terms, follows the form
Packit 6ef888
Packit 6ef888
    AT_SETUP([Test title])
Packit 6ef888
    ...test goes here...
Packit 6ef888
    AT_CLEANUP
Packit 6ef888
Packit 6ef888
so, when adding tests, this is generally all that is required unless the tests
Packit 6ef888
do not fit into an existing category, in which case AT_BANNER can be used to
Packit 6ef888
group them, and they can be organised into a new .at file and sourced from
Packit 6ef888
testsuite.at.
Packit 6ef888
Packit 6ef888
As the tests can be run individually, any new tests which require the dummy
Packit 6ef888
volume $GFS_TGT to be present should call GFS_TGT_REGEN before attempting to
Packit 6ef888
use it.
Packit 6ef888
Packit 6ef888
Documentation for Autotest, including the AT_* macros used to define tests, can
Packit 6ef888
be found in the autoconf manual at:
Packit 6ef888
Packit 6ef888
    http://www.gnu.org/software/autoconf/manual/index.html
Packit 6ef888
Packit 6ef888
Generating coverage reports
Packit 6ef888
---------------------------
Packit 6ef888
Test coverage instrumentation can be enabled using the --enable-gcov option at
Packit 6ef888
the configure stage. Once the tools have been built and run with this option
Packit 6ef888
enabled, coverage data will be written to files in the source directories for
Packit 6ef888
use by tools such as gcov or lcov. For example, to generate a HTML report of
Packit 6ef888
testsuite code coverage, using lcov, in a directory named 'coverage':
Packit 6ef888
Packit 6ef888
    ./autogen.sh
Packit 6ef888
    ./configure --enable-gcov
Packit 6ef888
    make check
Packit 6ef888
    lcov --directory . -c -o gfs2-utils.info
Packit 6ef888
    genhtml -o coverage gfs2-utils.info