We have created a test suite for pfctl and integrated it under
FreeBSD's source tree using kyua/ATF. The tests reside under
src/sbin/pfctl/tests.
We have copied the most important test cases from OpenBSD's
corresponding src/regress/sbin/pfctl, those that run pfctl on a test
input file and check correctness of its output. We have also added
some new tests using the same format.
The tests consist of a collection of input files (pf*.in) and
corresponding output files (pf*.ok). We run pfctl -nv on the input
files and check that the output matches the output files. If any
discrepancy is discovered during future development in the source
tree, we know that a regression bug has been introduced into the tree.
This form of testing makes it easy to add new tests. The way to do it
is to create a pf*.in and matching pf*.ok file, add them to
src/tests/sbin/pfctl, and update the run file to include the new
files.
The tests are put together using FreeBSD's recommended test suite
which uses kyua. The tests are installed under /usr/tests using a
structure of files named Kyuafile. That means that running 'kyua
test' under /usr/tests will find our tests and run them as part of the
complete test suite.