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

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>
This commit is contained in:
Alex Murray 2022-09-13 11:44:26 +09:30
parent c038682745
commit 262d305660
No known key found for this signature in database
GPG Key ID: F498D2D9DE7DAD9C

View File

@ -9,6 +9,7 @@
#
# ------------------------------------------------------------------
import os
import unittest
import apparmor.aa as aa
@ -32,11 +33,21 @@ class TestFoo(AATest):
def test_active_profiles(self):
aa.read_profiles(skip_profiles=skip_active_profiles)
# 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):
aa.read_inactive_profiles(skip_profiles=skip_extra_profiles)
# 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)