Libreswan's testsuite is run nightly. The results are published here, with the most recent result here. The tests are categorized as:
good: these tests are expected to pass
Unfortunately, some still have timing problems and occasionally fail; something to work on?wip: these tests require further work
For instance the result may not be deterministic, or the bug they demonstrate hasn't yet been fixedskiptest: these tests require manual intervention to run
For instance, a test requiring a custom NSS build.
To run tests locally, read on.
The libreswan tests, in testing/pluto, can be run using several different mechanisms:
| Framework | KVM | Namespaces |
|---|---|---|
| Full Test Run | Yes Under 5 fails |
No 100+ fails |
| Individual Tests | Yes | Most |
| Interop Testing | Yes Linux: strongSwan, Libreswan FreeBSD: strongswan, Libreswan NetBSD: racoon, racoon2, Libreswan OpenBSD: iked, Libreswan |
Limited Linux: strongSwan, Libreswan |
| Init System Testing | yes | no |
| FIPS testing | yes | no |
| Post-mortem (core, memory leak, shutdown) |
yes | support missing |
| all.*.sh tests | yes | support missing |
| Speed | slower | fast |
| Host OS | Fedora, Debian | Linux (but a Fedora VM is strongly recommended) |
| Notes | gold standard ideal for building on obscure platforms idea for testing custom kernels used by the testing machine requires 9p (virtio anyone?) |
Creating a per-build Fedora VM is strongly recommended; and on iOS and Windows it is a requirement |
Consider the test:
$ ls -1F testing/pluto/ikev2-05-basic-psk
description.txt OUTPUT/
east.conf west.conf
east.console.txt west.console.txt
eastinit.sh westinit.sh
east.secrets westrun.sh
final.sh west.secrets
which can be run using:
./kvm install # only once
./kvm check testing/pluto/ikev2-05-basic-psk
The following happens:
-
the domains needed by the test are booted
For a diagram of the test network, see topology.
-
config files are installed
-
each command from the
.shscripts is fed to the domainoutput from the commands are captured and saved in
OUTPUT/${HOSTNAME}.console.verbose.txtandOUTPUT/all.console.verbose.txt -
post-mortem is performed
See
testing/guest/bin/post-mortem.sh. -
the captured output is sanitised, removing non-deterministic details
The result is saved in
OUTPUT/${HOSTNAME}.console.txt -
the reference (
${HOSTNAME}.console.txt) and sanitised output is comparedThe result is saved in
OUTPUT/${HOSTNAME}.console.diff -
the lack of differences, along with other checks, determine when a test passes
Each test case consists of a few files:
description.txtto explain what this test case actually testsipsec.conffiles - for host west is called west.conf. This can also include configuration files for strongswan or racoon2 for interop testigipsec.secretfiles - if non-default configurations are used. also uses the host syntax, eg west.secrets, east.secrets..shfiles containing the commands to run- Known good (gold) output for each VM (eg
west.console.txt,east.console.txt) testparams.shif there are any non-default test parameters
The domains to use, and the scripts to run, are determined by the file names in the test directory. There's several options.
This is the original script structure and is used by most tests. It turns out it isn't sufficient for robustly testing IKEv1's three message Quick mode exchange.
Most often a test involves a simple interop
from a domain such as west to east.
For the above, the scripts are run in the order:
nicinit.sh,eastinit.sh,westinit.shwestrun.shfinal.sh- on all domains exceptnic
Technical nit: the scripts nicinit.sh then eastinit.sh are always run first, the others are ordered alphabetically.
Numbered scripts: 00-nic-init.sh, 01-east-init.sh, 02-west-init.sh, 03-west-run.sh, 04-east-up.sh, final.sh
This is the second attempt at script structure. It should be used by IKEv1 tests.
Sometimes more complex sequences are required. For instance:
-
a test needing to initiate both ends (almost) simultaneously
-
a test needing to confirm that the peer completed an operation
for instance, that the responder processed the final IKEv1 Quick Mode packet
Scripts, matching NN-*.sh are run in lexicographic order of the files.
As a bonus, final.sh is also run on all test machines except nic.
This is the fourth script framework (the third attempt was removed). It should be used when testing OS interops.
Sometimes tests need to run on different platforms (OS, ...).
For instance:, an interop between NetBSD and Linux.
These tests use a file matching all.*.sh.
The files name defines which hosts and platforms to use.
Each line of the file specifies where the command should be run.
For instance, the file all.netbsdwest-linuxeast.sh may contain:
east# ipsec start
west# ipsec up
so linuxeast runs ipsec start, then netbsdwest runs ipsec up.
Draft: Multi-platform single test: all.east-west.sh, all.linuxeast-netbsdwest.txt, all.netbsdwest-linuxeast.txt
This is is a proposal for a fifth script framework. The testsuite has a growing list of tests which, other than the platforms they run between, are identical. Currently this is achieved by generating the tests using scripts. The proposal is to instead have a single test containing a reference output for each platform that the test should be run on.
There are several steps to adding a test:
-
create, and populate, a new directory under
testing/pluto/While copying a similar looks like a shortcut, it must be updated; here's a check list:
- update
description.txt - update
*.shfiles to useipsec ...and notipsec auto --... - update
{east,west,ipsec}.confremoving any unnecessary fields
- update
-
add an entry to
testing/pluto/TESTLIST-
while the test is being developed it should be marked as
wipA
wiptest can be run manually using./kvm check testing/pluto/new-test -
once the test has become stable, change that to
goodAll good tests are run by default with
./kvm check; and we like to keep all good tests passing.
-
-
the expected test output can be update using
./kvm patch testing/pluto/new-testSee also
./kvm modified.
The raw output from each domain is sanitized (removing non-deterministic output such as NONCES and timers) before being compared to the expected output.
For instance, the raw output from east is written to new-test/OUTPUT/east.console.verbose.txt. It is then sanitized creating new-test/OUTPUT/east.console.txt and finally it is compared against the reference output new-test/east.console.txt.
Occasionally new sanitizers need