Tests¶
Programs in the tests
directory test functions of the same name.
Integration Tests¶
Integration tests are run by main.
Add integration tests by adding a test configuration to integration
sub-directory. Test configuration files are shell scripts, but should only
set variables specifying the test, namely:
- output¶
Vertical bar (
|
)-separated list of partial lines expected on standard output. Set to-
to indicate thatcommand
is expected to print no output.
- error¶
Vertical bar (
|
)-separated list of partial lines expected on standard error. Set to-
to indicate thatcommand
is expected to print no errors.
- check¶
Command to run as test. Takes precedence over
command
.The command must exit with the result of OR-ing:
0
Every test succeeded.
1
Some tests failed.
2
Some tests were skipped.
4
An unexpected error occurred.
The command may also exit with status 4 right away.
- skip¶
Set to a non-empty value to skip the test.
- slow¶
Set to a non-empty value to mark the test as slow. It will then be skipped by make quickcheck.
For example:
command="para FOO=quux 'sh -c \"echo \$FOO\"'"
environ='FOO=qux'
output=quux
Scripts run by integration tests can be found in
the scripts
sub-directory.
Note
Commands run by integration tests are also
run by scripts/runvalgrind
and
scripts/runleaks
.
See also
tests/main -h
Unit tests¶
Any program other than main
performs a unit test.
Add unit tests by adding their sources to the unittestsrcs
macro
and their dependencies to the Tests section of Makefile.in
.
For example:
unittestsrcs = \
# [...]
tests/foo.c \
# [...]
#
# Tests
#
# [...]
tests/foo: tests/foo.o
tests/foo.o: tests/foo.c
file.x
files hold auto-generated test cases.