![]() So far, exec events were accidentally skipped in test-libapparmor-test_multi.py because aa[profile][hat] was not initialized, and ask_exec() exited early because of this. Initialize aa[profile][hat] in the test to fix this. To avoid that someone needs to select "inherit" each time the tests run, add an optional default_ans parameter to ask_exec(), and let the test call it with 'CMD_ix'. (In case you wonder - defaulting to CMD_cx would ask to sanitize the environment. CMD_ix avoids this.) Also, we have to copy over aa[profile][hat] to log_dict in the test because ask_exec() modifies aa[...], but the test only checks its local log_dict. Finally, add the expected exec rules to the *.profile files |
||
---|---|---|
.. | ||
logprof | ||
wtmp-examples | ||
cleanprof_test.in | ||
cleanprof_test.out | ||
common_test.py | ||
easyprof.conf | ||
logprof.conf | ||
Makefile | ||
README.md | ||
runtests-py3.sh | ||
severity.db | ||
severity_broken.db | ||
test-aa-cli-bootstrap.py | ||
test-aa-decode.py | ||
test-aa-easyprof.py | ||
test-aa-notify.py | ||
test-aa.py | ||
test-aare.py | ||
test-abi.py | ||
test-alias.py | ||
test-all.py | ||
test-baserule.py | ||
test-boolean.py | ||
test-capability.py | ||
test-change_profile.py | ||
test-common.py | ||
test-config.py | ||
test-dbus.py | ||
test-example.py | ||
test-file.py | ||
test-include.py | ||
test-io_uring.py | ||
test-libapparmor-test_multi.py | ||
test-logparser.py | ||
test-logprof.py | ||
test-minitools.py | ||
test-mount.py | ||
test-mqueue.py | ||
test-network.py | ||
test-notify.py | ||
test-parser-simple-tests.py | ||
test-pivot_root.py | ||
test-profile-list.py | ||
test-profile-storage.py | ||
test-profiles.py | ||
test-ptrace.py | ||
test-regex_matches.py | ||
test-rlimit.py | ||
test-severity.py | ||
test-signal.py | ||
test-translations.py | ||
test-unix.py | ||
test-userns.py | ||
test-variable.py |
Test data generated elsewhere
The tests in parser
generate additional test profiles in
parser/tst/simple_tests/
: see gen-dbus.py
and gen-xtrans.py
.
utils/test/test-parser-simple-tests.py
uses this test data when it is
available. If this test data has not been generated, this test will not
complain: it will simply exercise fewer test profiles.
Running individual tests
Python's unittest allows individual tests to be executed by specifying the class name and the test on the command line. When running tests individually, the unittest framework executes the "setUp" and "tearDown" methods automatically. For more information, refer to the unittest documentation.
Make sure to set the environment variables pointing to the in-tree apparmor modules, and the in-tree libapparmor and its python wrapper:
$ export PYTHONPATH=..:../../libraries/libapparmor/swig/python/build/$(/usr/bin/python3 ../../libraries/libapparmor/swig/python/test/buildpath.py)
$ export __AA_CONFDIR=.
To execute the test individually, run:
$ python3 ./test-tile.py ClassFoo.test_bar