apparmor/utils/test
Georgia Garcia 2ed74be1bb Merge utils: test: account for last cmd format change in test-aa-notify
The "last" command, which was supplied by util-linux in older Ubuntu
versions, is now supplied by wtmpdb in Oracular and Plucky. Unfortunately,
this changed the output format and broke our column based parsing.

While the wtmpdb upstream has added json support at
https://github.com/thkukuk/wtmpdb/issues/20, we cannot use it because
we need to support systems that do not have this new feature added.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1508
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit 3b7ee81f04)

afd6aa05 utils: test: account for last cmd format change in test-aa-notify

Co-authored-by: John Johansen <john@jjmx.net>
2025-01-28 12:35:40 +00:00
..
logprof Merge ping: allow reading /proc/sys/net/ipv6/conf/all/disable_ipv6 2024-09-30 21:43:19 +00:00
wtmp-examples Add truncated and ancient wtmp example to tests 2021-10-24 17:24:43 +02:00
cleanprof_test.in Preserve 'hat' keyword in ProfileStorage 2021-05-23 18:19:28 +02:00
cleanprof_test.out Adding userspace support for mount rules in aa-genprof/aa-logprof 2024-02-29 17:59:50 +00:00
common_test.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
easyprof.conf This patchset is broken into 4 parts: 2012-05-07 22:37:48 -07:00
fake_ldd Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
logprof.conf Fix extra profiles path in utils/test/logprof.conf 2021-07-13 21:09:35 +02:00
Makefile Merge Allow overrides and preservation of some environment variables in utils make check 2025-01-23 19:11:59 +00:00
README.md use new build_platlib path with setuptools >= 61.2 2022-07-16 17:47:18 +02:00
runtests-py3.sh fix utils/test/runtests-py*.sh exitcode 2014-10-03 11:48:21 +02:00
severity.db Add aa-logprof test framework 2023-08-13 21:02:50 +02:00
severity_broken.db Update perl abstraction, logprof.conf, severity.db and tests for Debian/Ubuntu 2014-08-20 19:14:24 -05:00
test-aa-cli-bootstrap.py Add option to log aa-logprof json input and output 2023-07-30 21:28:35 +02:00
test-aa-decode.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-aa-easyprof.py Replace mutable default arguments in tests 2023-02-19 17:12:30 -05:00
test-aa-notify.py Merge utils: test: account for last cmd format change in test-aa-notify 2025-01-28 12:35:40 +00:00
test-aa.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-aare.py AARE: add __eq__() to allow checking aare1 == aare2 2023-10-11 20:38:38 +02:00
test-abi.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-alias.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-all.py Utils: add support for the 'all,' rule 2023-09-10 18:07:41 +02:00
test-baserule.py Resolve string escape sequence DeprecationWarnings 2022-11-21 22:08:42 -05:00
test-boolean.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-capability.py Add test for unknown capability 2023-10-29 22:10:07 +01:00
test-change_profile.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-common.py Change apparmor.common.combine_profname arguments from list to tuple literals. 2022-09-11 21:56:26 -04:00
test-config.py Ensure variables inside functions are lower_case_with_underscores. 2022-08-21 11:15:07 -04:00
test-dbus.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-example.py Order imports and module-level dunder name assignments. 2022-08-21 11:15:07 -04:00
test-file.py Merge utils: fixes when handling owner file rules 2024-10-07 10:18:46 -03:00
test-include.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-io_uring.py utils: add io_uring python tool support 2023-05-03 16:04:32 +02:00
test-libapparmor-test_multi.py Merge Handle mount events/log entries without class 2024-05-10 12:31:41 +00:00
test-logparser.py libapparmor: add support for class in logparsing 2022-10-27 18:16:53 +00:00
test-logprof.py Merge test-logprof: Increase timeout once more 2024-11-10 16:34:59 +00:00
test-minitools.py Merge utils: test: various fixes for utils testing in Ubuntu packaging 2025-01-23 19:07:33 +00:00
test-mount.py MountRule: Add support for empty ("") source 2024-06-11 13:36:24 +02:00
test-mqueue.py MqueueRule: allow / as mqueue name 2024-07-21 19:13:50 +02:00
test-network.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-notify.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-parser-simple-tests.py Cherry-pick: MountRule: Aligning behavior with apparmor_parser 2024-05-22 08:31:27 +02:00
test-pivot_root_parse.py Order imports and module-level dunder name assignments. 2022-08-21 11:15:07 -04:00
test-profile-list.py ProfileList: merge self.attachments_AARE into self.attachments['re'] 2023-10-11 20:39:37 +02:00
test-profile-storage.py Order imports and module-level dunder name assignments. 2022-08-21 11:15:07 -04:00
test-profiles.py Order imports and module-level dunder name assignments. 2022-08-21 11:15:07 -04:00
test-ptrace.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-regex_matches.py Cleanup old handling of mount rules 2024-03-01 19:46:02 +01:00
test-rlimit.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-severity.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-signal.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00
test-translations.py Improve utils hotkey handling 2023-01-29 13:33:44 +01:00
test-unix_parse.py Order imports and module-level dunder name assignments. 2022-08-21 11:15:07 -04:00
test-userns.py utils: add userns python tool support 2022-11-04 12:39:18 +00:00
test-variable.py Change string formatting method in Python tests 2023-02-19 16:54:38 -05:00

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