"make check" is a target in the top level makefile. It takes care of running a number of unit and system tests to confirm that FreeSWAN has been compiled correctly, and that no new bugs have been introduced.
As FreeSWAN contains both kernel and userspace components, doing testing of FreeSWAN requires that the kernel be simulated. This is typically difficult to do as a kernel requires that it be run on bare hardware. A technology has emerged that makes this simpler. This is User Mode Linux.
User-Mode Linux is a way to build a Linux kernel such that it can run as a process under another Linux (or in the future other) kernel. Presently, this can only be done for 2.4 guest kernels. The host kernel can be 2.2 or 2.4.
"make check" expects to be able to build User-Mode Linux kernels with FreeSWAN included. To do this it needs to have some files downloaded and extracted prior to running "make check". This is described in the UML testing document.
After having run the example in the UML testing document and successfully brought up the four machine combination, you are ready to use "make check"
"make check" works by walking the FreeSWAN source tree invoking the
"check" target at each node. At present there are tests defined only
for the klips
directory. These tests will use the UML
infrastructure to test out pieces of the klips
code.
The results of the tests can be recorded. If the environment
variable $REGRESSRESULTS
is non-null, then the results of
each test will be recorded. This can be used as part of a nightly
regression testing system, see Nightly testing
for more details.
"make check" otherwise prints a minimal amount of output for each test, and indicates pass/fail status of each test as they are run. Failed tests do not cause failure of the target in the form of exit codes.
Each test consists of a directory in klips/test
. The
list of tests to run is stored in the file klips/test/TESTLIST
. The test types are:
klipstest
has been defined.
Each test directory has a file in it called testparams.sh
. This file sets a number of environment variables to define the
parameters of the test.
klips/test/fixups
) to apply
to sanitize the console output of the machine under test. These are
typically perl, awk or sed scripts that remove things in the kernel
output that change each time the test is run and/or compiled.a file of commands that is fed into the virtual machine's console in single user mode prior to starting the tests. This file will usually set up any eroute's and SADB entries that are required for the test.
Lines beginning with # are skipped. Blank lines are skipped.
Otherwise, a shell prompted is waited for each time (consisting of
\n#
) and then the command is sent. Note that the prompt is waited
for before the command and not after, so completion of the last command
in the script is not required. This is often used to invoke a program
to monitor the system, e.g. ipsec pf_key
.
The klipstest function starts a program (
testing/utils/uml_netjig/uml_netjig
) to setup a bunch of I/O
sockets (that simulate network interfaces). It then exports the
references to these sockets to the environment and invokes (using
system()) a given script. It waits for the script to finish.
The script invoked (testing/utils/host-test.tcl
) is a
TCL expect script that arranges
to start the UML and configure it appropriately for the test. The
configuration is done with the script given above for SCRIPT
. The TCL script then forks, leaves the UML in the background and exits.
uml_netjig continues. It then starts listening to the simulated network
answering ARPs and inserting packets as appropriate.
The klipstest function invokes uml_netjig
with
arguments to capture output from network interface(s) and insert
packets as appropriate:
uml_netjig
. The klipstest function then uses
tcpdump on the file to produce text output, which is compared to the
file given.uml_netjig
. It should contain
"--exitonempty" of uml_netjig should exit when all of the input (
PUBINPUT,PRIVINPUT) packets have been injected.uml_netjig
. It should contain "--arpreply"
if uml_netjig
should reply to ARP requests. One will
typically set this to avoid having to fudge the ARP cache manually.If you need to interactively control the UML under test, then you can invoke netjig directly with the right arguments, but give it "sh" as the startup script. An easy way is to do this is to edit "NETJIGDEBUG" in setup.sh to "true" and run the test:
e.g:
cassidy-[nightly/klips/test/east-pass-01] mcr 1009 %NETJIGDEBUG=true ../runme.sh /c2/freeswan/sandboxes/nightly/testing/utils/uml_netjig/uml_netjig --tcpdump --exitonempty --playprivate ../inputs/01-sunrise-sunset-ping.pcap --recordpublic OUTPUT/spi1-output.pcap --startup expect -f /c2/freeswan/sandboxes/nightly/testing/utils/host-test.tcl /c2/freeswan/sandboxes/nightly/UMLPOOL/east/start.sh spi1.shso, substitute "sh" for the startup script.
/c2/freeswan/sandboxes/nightly/testing/utils/uml_netjig/uml_netjig --tcpdump --exitonempty --playprivate ../inputs/01-sunrise-sunset-ping.pcap --recordpublic OUTPUT/spi1-output.pcap --startup sh sh-2.05a$ env | grep UML_ UML_private_CTL=/tmp/umlz8Xrpn/private/ctl UML_public_DATA=/tmp/umlz8Xrpn/public/data UML_public_CTL=/tmp/umlz8Xrpn/public/ctl UML_private_DATA=/tmp/umlz8Xrpn/private/data
then, in a *new window*, paste those variables in place, and start the UML you need. The start.sh scripts looks for UML_{private,public}_{CTL,DATA} and will connect them to eth0/eth1. Setup the UML as appropriate, etc. When you are ready, exit the above shell, and the uml_netjig will start to inject packets and record them.