-
Notifications
You must be signed in to change notification settings - Fork 46
Test Suite
The MUNGE test suite uses Sharness for higher-level tests of the executables, and libtap for lower-level tests of the C internals. Sharness tests reside in the tests/
directory, whereas libtap tests are located in the directories under src/
.
Both Sharness and libtap are TAP Producers, outputting test results according to the Test Anything Protocol. This TAP output can be fed into a TAP Consumer for further processing.
-
Run the tests by using the
check
target of the Makefile. Specify options by appending shell variables to themake
command.
make check root=/tmp/munge-test-$$ verbose=t
-
Run the tests by using the
prove
command. See theprove(1)
manpage or Perl docs for details.
prove tests/*.t
-
Run an individual test directly. Specify options by prepending shell variables to the command, or appending command-line options.
tests/0010-basic.t --root=/tmp/munge-test-$$ --verbose
Package maintainers adding the test suite to their build will probably want to use a command similar to the following:
make check root=/tmp/munge-test-$$ verbose=t VERBOSE=t
-
Specifying the
-j
/--jobs=
option tomake
will run the test suite faster but interleave its output. -
Specifying
root
is commonly needed to overcome permission problems with the build environment. -
Appending "$$" for shell pid expansion may need to be escaped (e.g., using "$$$$" in makefiles).
-
verbose
is needed to capture stdout and stderr from the test commands. It must be set to "t". -
VERBOSE
is needed to display the output from failed tests. -
verbose
andVERBOSE
are different variables that should both be specified. They are essential for troubleshooting failures. -
TEST_LONG
is not recommended here.
-
chain_lint
is a sharness variable for checking whether each test properly "&&-chains" all commands in order to ensure a failure of any command in the chain will cause the test to fail. Ifchain_lint=t
, sharness will perform this check in addition to running the tests. This is primarily intended for development. -
debug
is a sharness variable primarily intended for development. Ifdebug=t
, execution oftest_debug()
commands will be performed, and removal of "trash" directories (for storing all temporary data during a test) will be prevented in order to allow their contents to be inspected afterwards.
-
root
is a sharness variable for specifying a directory to be prepended to the "trash" directories. A trash directory is created for each test script to store temporary data, and that directory becomes theHOME
directory for the given test. If this variable is not specified, these directories are created in the current working directory. Each directory is removed after its corresponding test script finishes unless a test fails ordebug=t
is specified. -
TEST_LONG
is a sharness variable for running tests marked as being "expensive". If this variable is not set, sharness tests requiringsudo
(expensive in privilege) orvalgrind
(expensive in memory and time) will be skipped. This is primarily intended for development. -
verbose
is a sharness variable for making test output more verbose. By default, standard output and standard error streams are discarded, and only a result of "ok" or "not ok" is reported. But ifverbose=t
, the test commands being run and their resulting output will be logged to the corresponding.log
files as well astest-suite.log
. -
VERBOSE
is an automake test harness variable. If set, the output from failed tests collected intest-suite.log
will be displayed after all tests have completed.
- Sharness tests checking the behavior of executables running as root use sudo to elevate privileges. They require sudo-1.7.0 or later. These tests will be skipped unless the
TEST_LONG
variable is set andsudo
is configured to run commands without prompting for a password (see theNOPASSWD:
tag insudoers(5)
).
- Sharness tests using valgrind to check for memory errors require valgrind-3.9.0 (2013-10-31) or later. These tests will be skipped unless the
TEST_LONG
variable is set and valgrind is installed.
-
If tests fail, try running the test suite with
verbose=t
and examiningtests/test-suite.log
afterwards for more information. Search for lines beginning withFAIL:
. -
If your current working directory (or one of its parent directories) has overly-permissive permissions, you may see a multitude of errors noting various files and directories are insecure. Try moving the trash directories to another filesystem such as
/tmp
(which should have its sticky-bit set) by running the test suite withroot=/tmp/munge-test-$$
. -
If your current working directory is inside an NFS mount, you may encounter race conditions with NFS locks; for example,
rm: cannot remove '/path/to/some/.nfs000000000123456789abcdef': Device or resource busy
.* Try moving the trash directories to a non-NFS local filesystem by running the test suite withroot=/tmp/munge-test-$$
.