2011-01-13 13:58:26 -08:00
|
|
|
This is the README for the AppArmor parser regression testsuite.
|
2006-04-11 21:52:54 +00:00
|
|
|
|
|
|
|
Running the testsuite
|
|
|
|
---------------------
|
|
|
|
Running the tests is pretty easy, a simple 'make tests' should make it
|
2011-01-13 13:58:26 -08:00
|
|
|
go, assuming the subdomain parser and perl are installed.
|
2006-04-11 21:52:54 +00:00
|
|
|
|
|
|
|
There is a user configuration file 'uservars.conf'. If you wish to test
|
|
|
|
against a different parser, or use a different set of profiles for the
|
|
|
|
simple.pl test, you can change those settings in 'uservars.conf'.
|
|
|
|
|
2012-11-05 17:22:37 -08:00
|
|
|
You can also override which parser is used through make by specifying
|
2020-11-19 12:30:04 -08:00
|
|
|
the PARSER variable. For example, to run the tests on the system parser,
|
2012-11-05 17:22:37 -08:00
|
|
|
run 'make PARSER=/sbin/apparmor_parser'.
|
|
|
|
|
2006-04-11 21:52:54 +00:00
|
|
|
Adding to the testsuite
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
The testsuite currently contains one testscript (simple.pl) and makes use
|
|
|
|
of perl's Test::Simple, Test::Harness, and prove utilities (see 'perldoc
|
|
|
|
Test::Tutorial', 'perldoc Test::Simple', 'perldoc Test::Harness', and
|
|
|
|
'man 1 prove' for more information on these).
|
|
|
|
|
|
|
|
It should be relatively easy to extend the suite with other testscripts,
|
|
|
|
as long as they're written using Test::Simple or can emulate the
|
2011-01-13 13:58:26 -08:00
|
|
|
Test::Harness protocol. To add a script, add it to the TESTS variable
|
2006-04-11 21:52:54 +00:00
|
|
|
in the Makefile, and it will included in the tests to be run.
|
|
|
|
|
|
|
|
However, in many cases, it is not necessary to add an entire new
|
|
|
|
testscript for a testcase. Instead, the simple testcase (see below)
|
|
|
|
will run all the profiles it finds on the parser, thus adding testcases
|
|
|
|
is usually as simple as writing a new profile with a couple of extra
|
|
|
|
comments.
|
|
|
|
|
|
|
|
Simple parsing tests (simple.pl)
|
|
|
|
--------------------------------
|
|
|
|
This test script tests the parser front end's ability to identify legal
|
|
|
|
profiles. It does this by running the parser against several legal and
|
|
|
|
illegal profiles (in debug mode, so as not to load them into the module
|
|
|
|
proper)
|
|
|
|
|
|
|
|
The simple script has the parser attempt to parse all of the profiles
|
|
|
|
named *.sd in the simple_tests/ subdirectory; thus, to add a new profile
|
2006-05-02 16:15:41 +00:00
|
|
|
to test, simply add it to the simple_tests/ directory. The simple
|
|
|
|
script also adds the testdir (simple_tests/ by default) to the parsers
|
|
|
|
include path (assuming that particular bug has been fixed :-)). There
|
|
|
|
is an includes/ subdir to place additional includes if necessary (we
|
|
|
|
purposefully choose to use different directory names versus the shipped
|
|
|
|
profiles to minimize testsuite breakage with changes in the external
|
|
|
|
policy).
|
2006-04-11 21:52:54 +00:00
|
|
|
|
|
|
|
The simple script looks for a few special comments in the profile,
|
|
|
|
#=DESCRIPTION, #=EXRESULT, and #=TODO:
|
|
|
|
|
|
|
|
- #=DESCRIPTION -- all text following the keyword is considered a
|
|
|
|
description for the test. Please try to make these meaningful.
|
|
|
|
|
|
|
|
- #=EXRESULT -- This records the expected result of parsing this
|
|
|
|
profile. Values can either be PASS or FAIL; if no comment is found
|
|
|
|
that matches this pattern, then the profile is assumed to have an
|
|
|
|
expected parse result of PASS.
|
2011-01-13 13:58:26 -08:00
|
|
|
|
2006-04-11 21:52:54 +00:00
|
|
|
- #=TODO -- marks the test as being for a future item to implement and
|
2020-11-19 12:30:04 -08:00
|
|
|
thus are expected testsuite failures and should be ignored.
|
2006-04-11 21:52:54 +00:00
|
|
|
|
|
|
|
- #=DISABLED -- skips the test, and marks it as a failed TODO task.
|
|
|
|
Useful if the particular testcase causes the parser to infinite
|
2013-09-11 11:56:47 -07:00
|
|
|
loop or dump core.
|
2006-04-11 21:52:54 +00:00
|
|
|
|
|
|
|
Otherwise, the profile is passed on as-is to the subdomain parser.
|