xref: /freebsd/tools/regression/README (revision 05248206f720394d95c2a7475429311df670a2e9)
1e5f1b1b1SPeter Dufault
29e9d8a46SPoul-Henning KampThis directory is for regression test programs.
39e9d8a46SPoul-Henning Kamp
403bbd5ccSMike PritchardA regression test program is one that will exercise a particular bit of the
59e9d8a46SPoul-Henning Kampsystem to check that we have not reintroduced an old bug.
69e9d8a46SPoul-Henning Kamp
700e13b1dSNik ClaytonTests should be implemented in files with a .t extension.  Each .t file
800e13b1dSNik Claytoncan contain more than one test, and can be implemented in any scripting
900e13b1dSNik Claytonlanguage -- /bin/sh, Perl...
1000e13b1dSNik Clayton
1100e13b1dSNik ClaytonThe test protocol is quite simple.  At its most basic, each .t file should,
1200e13b1dSNik Claytonwhen run, print a line in this format:
1300e13b1dSNik Clayton
1400e13b1dSNik Clayton   1..m
1500e13b1dSNik Clayton
1600e13b1dSNik Claytonwhere m is the number of tests that will be run.
1700e13b1dSNik Clayton
1800e13b1dSNik ClaytonEach test should produce a single line of output.  This line should start
1900e13b1dSNik Claytonwith one of
2000e13b1dSNik Clayton
2100e13b1dSNik Clayton   ok n
2200e13b1dSNik Clayton   not ok n
2300e13b1dSNik Clayton
2400e13b1dSNik Claytonto indicate whether or not the test succeeded.  'n' is the test's number.
2500e13b1dSNik ClaytonAnything after this on the line (up to the first '#' if present) is
2600e13b1dSNik Claytonconsidered to be the name of the test.  Naming tests is optional, but
2700e13b1dSNik Claytonencouraged.
2800e13b1dSNik Clayton
2900e13b1dSNik ClaytonA test may be written which is conditional, and may need to be skipped.
30*45c203fcSGleb SmirnoffFor example, the netinet tests require 'options INET' in the kernel.
3100e13b1dSNik ClaytonA test may be skipped by printing '# skip Reason for skipping' after the
3200e13b1dSNik Claytontest name.  For example,
3300e13b1dSNik Clayton
34*45c203fcSGleb Smirnoff    ok 1 - netinet # skip 'options INET' not compiled in
3500e13b1dSNik Clayton
3600e13b1dSNik ClaytonA test may be flagged as 'todo'.  This indicates that you expect the test
3700e13b1dSNik Claytonto fail (perhaps because the necessary functionality hasn't been written
3800e13b1dSNik Claytonyet).  'todo' tests are expected to fail, so when they start working the
398ce070c1SUlrich Spörleintest framework can alert you to this happy occurrence.  Flag these tests
4000e13b1dSNik Claytonwith a '# TODO' comment after the test name
4100e13b1dSNik Clayton
4200e13b1dSNik Clayton    not ok 1 - infiniteloop # TODO write test for an infinite loop
4300e13b1dSNik Clayton
4400e13b1dSNik ClaytonThis is modelled on the protocol followed by the Test::Harness Perl
4500e13b1dSNik Claytonmodule (and therefore much of the automated testing carried out by the
4600e13b1dSNik ClaytonPerl community).  More documentation can be found at:
4700e13b1dSNik Clayton
4800e13b1dSNik Clayton    http://search.cpan.org/~petdance/Test-Harness-2.42/lib/Test/Harness.pm
4900e13b1dSNik Clayton
5000e13b1dSNik ClaytonTo run the tests and parse their output install the devel/p5-Test-Harness
5100e13b1dSNik Claytonport.  This includes the prove(1) command which is used to run the tests
5200e13b1dSNik Claytonand collate the output.
5300e13b1dSNik Clayton
5400e13b1dSNik Clayton    prove geom_concat		# run all the tests in geom_concat
5500e13b1dSNik Clayton    prove -r lib		# run all tests in lib/, and subdirectories
5600e13b1dSNik Clayton    prove -r -v lib		# as above, with verbose output
5700e13b1dSNik Clayton    prove -r			# run *all* the tests
5800e13b1dSNik Clayton
5988ef0373SJuli MallettTests that are for parts of the base system should go into a directory here
6088ef0373SJuli Mallettwhich is the same as their path relative to src/, for example the uuencode(1)
6188ef0373SJuli Mallettutility resides in src/usr.bin/uuencode so its regression test resides in
6288ef0373SJuli Mallettsrc/tools/regression/usr.bin/uuencode.
6388ef0373SJuli Mallett
64ffc44a27SDiomidis SpinellisTo avoid the pre-commit check program complaining about the lack of
65ffc44a27SDiomidis SpinellisCVS keywords in test data files, use a .in suffix for input files and
66ffc44a27SDiomidis Spinellisa .out suffix for output files.
67ffc44a27SDiomidis Spinellis
68259dde6eSDiomidis SpinellisTo execute individual regression tests for binaries that you are
69259dde6eSDiomidis Spinellisdeveloping, add their directory in the path before running the tests.
70259dde6eSDiomidis SpinellisExample:
71259dde6eSDiomidis Spinelliscd /usr/src/tools/regression/usr.bin
72259dde6eSDiomidis Spinellis(PATH=/home/user/src/experimental/jot:$PATH ; make SUBDIR=jot)
73259dde6eSDiomidis Spinellis
7488ef0373SJuli MallettPlease make a subdir per other regression test, and add a brief description to
7588ef0373SJuli Mallettthis file.
766527fda5SDoug Rabson
77ffc44a27SDiomidis Spinellisacct		Exercise the integer to float conversion used in acct(5)
7880ad7ca9SJuli Mallettgeom		Some tests and an out-of-kernel simulator for the GEOM code
796527fda5SDoug Rabsonnfsmmap		Some tests to exercise some tricky cases in NFS and mmap
80e5f1b1b1SPeter Dufaultp1003_1b	Exercise 1003.1B scheduler
81af1a7621SPierre Beyssacpipe		Pipe code regression test
8261404abcSJordan K. Hubbardfsx		General filesystem exerciser
83ba05755cSAlfred Perlsteinsysvmsg 	SysV IPC Message Queue Regression Utility
84ba05755cSAlfred Perlsteinsysvsem 	SysV IPC Semaphore Regression Utility
85ba05755cSAlfred Perlsteinsysvshm 	SysV IPC Shared Memory Regression Utility
86e858faa9SBrian Feldmangaithrstress	General threaded getaddrinfo(3) exerciser
8784ccb25dSEdwin Groothuisdate		Date(1) + format string regression test
88