xref: /freebsd/tests/README (revision ec994981447e8a974426660b5071bc405280af73)
1src/tests: The FreeBSD test suite
2=================================
3
4Usage of the FreeBSD test suite:
5(1)  Run the tests:
6       kyua test -k /usr/tests/Kyuafile
7(2)  See the test results:
8       kyua report
9
10For further information on using the test suite, read tests(7):
11       man tests
12
13Description of FreeBSD test suite
14=================================
15The build of the test suite is organized in the following manner:
16
17* The build of all test artifacts is protected by the MK_TESTS knob.
18  The user can disable these with the WITHOUT_TESTS setting in
19  src.conf(5).
20
21* The goal for /usr/tests/ (the installed test programs) is to follow
22  the same hierarchy as /usr/src/ wherever possible, which in turn drives
23  several of the design decisions described below.  This simplifies the
24  discoverability of tests.  We want a mapping such as:
25
26    /usr/src/bin/cp/      -> /usr/tests/bin/cp/
27    /usr/src/lib/libc/    -> /usr/tests/lib/libc/
28    /usr/src/usr.bin/cut/ -> /usr/tests/usr.bin/cut/
29    ... and many more ...
30
31* Test programs for specific utilities and libraries are located next
32  to the source code of such programs.  For example, the tests for the
33  src/lib/libcrypt/ library live in src/lib/libcrypt/tests/.  The tests/
34  subdirectory is optional and should, in general, be avoided.
35
36* The src/tests/ hierarchy (this directory) provides generic test
37  infrastructure and glue code to join all test programs together into
38  a single test suite definition.
39
40* The src/tests/ hierarchy also includes cross-functional test programs:
41  i.e. test programs that cover more than a single utility or library
42  and thus don't fit anywhere else in the tree.  Consider this to follow
43  the same rationale as src/share/man/: this directory contains generic
44  manual pages while the manual pages that are specific to individual
45  tools or libraries live next to the source code.
46
47In order to keep the src/tests/ hierarchy decoupled from the actual test
48programs being installed --which is a worthy goal because it simplifies
49the addition of new test programs and simplifies the maintenance of the
50tree-- the top-level Kyuafile does not know which subdirectories may
51exist upfront.  Instead, such Kyuafile automatically detects, at
52run-time, which */Kyuafile files exist and uses those directly.
53
54Similarly, every directory in src/ that wants to install a Kyuafile to
55just recurse into other subdirectories reuses this Kyuafile with
56auto-discovery features.  As an example, take a look at src/lib/tests/
57whose sole purpose is to install a Kyuafile into /usr/tests/lib/.
58The goal in this specific case is for /usr/tests/lib/ to be generated
59entirely from src/lib/.
60
61--
62