2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 10:07:12 +00:00

Merge utils/test/test-profiles.py: Don't count profiles when USE_SYSTEM=1

If USE_SYSTEM=1 then we can't assume all the various profiles have been
installed and therefore that the counts of the profiles will be as expected. In
that case, simply testing that parsing the profiles occurs without errors is
sufficient.

Signed-off-by: Alex Murray <alex.murray@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/924
Merged-by: Alex Murray <alex.murray@canonical.com>
This commit is contained in:
Alex Murray 2025-08-21 15:15:58 +00:00
commit 0c26459cfa

View File

@ -9,6 +9,7 @@
# #
# ------------------------------------------------------------------ # ------------------------------------------------------------------
import os
import unittest import unittest
import apparmor.aa as aa import apparmor.aa as aa
@ -25,12 +26,22 @@ class TestFoo(AATest):
def test_active_profiles(self): def test_active_profiles(self):
aa.read_profiles() aa.read_profiles()
self.assertGreaterEqual(len(aa.active_profiles.profile_names), 42) # when using system apparmor then we haven't necessarily installed all
# the profiles so checking against a specific number may fail - instead
# it is sufficient that profiles were read without an exception being
# thrown above
if os.getenv("USE_SYSTEM", "0") != "1":
self.assertGreaterEqual(len(aa.active_profiles.profile_names), 42)
def test_extra_profiles(self): def test_extra_profiles(self):
aa.read_inactive_profiles() aa.read_inactive_profiles()
self.assertGreaterEqual(len(aa.extra_profiles.profile_names), 100) # when using system apparmor then we haven't necessarily installed all
# the profiles so checking against a specific number may fail - instead
# it is sufficient that profiles were read without an exception being
# thrown above
if os.getenv("USE_SYSTEM", "0") != "1":
self.assertGreaterEqual(len(aa.extra_profiles.profile_names), 100)
setup_aa(aa) setup_aa(aa)