9a924ba875
A new mode for checkfc is introduced (-t) which takes a file_contexts and a test data file. Each line in the test data file contains a path and the expected type. checkfc loads the file_contexts and repeatedly calls selabel_lookup(3) to verify that the computed type is as expected. This mode can be used to confirm that any modification to file_contexts or its build process is benign. A test data file (plat_file_contexts_test) is added. This file was manually created based on private/file_contexts. Each static path was copied as-is. Each regular expression was expanded into a couple of entries. For instance, /dev/adf[0-9]* generated /dev/adf, /dev/adf0 and /dev/adf123. libselinux keeps track of which specification is being hit when using selabel_lookup. When calling selabel_stats(3), the file backend will output a warning if a specification has not been used. This can be leveraged to ensure that each rule is at least hit once. This property will be leveraged in a follow-up change (by running the test as part of the build process), to ensure that the plat_file_contexts_test file remains up-to-date (that is, when an entry is added to private/file_contexts, the build will fail unless a test is also added to plat_file_contexts_test to exercice the specification/regular expression). Test: m checkfc && checkfc -t ./private/file_contexts ./tests/plat_file_contexts_test Bug: 299839280 Change-Id: Ibf56859a16bd17e1f878ce7b0570b2aead79c7e0 |
||
---|---|---|
.. | ||
include | ||
Android.bp | ||
apex_sepolicy_tests.py | ||
apex_sepolicy_tests_test.py | ||
check_prop_prefix.py | ||
combine_maps.py | ||
fc_sort.py | ||
fc_sort_test.py | ||
fix_policies.sh | ||
mini_parser.py | ||
plat_file_contexts_test | ||
policy.py | ||
policy_test.py | ||
searchpolicy.py | ||
sepol_wrap.cpp | ||
sepolicy_freeze_test.py | ||
sepolicy_tests.py | ||
treble_sepolicy_tests.py |