From 262d30566029d1891aa2f2978318fba7c296c5c8 Mon Sep 17 00:00:00 2001 From: Alex Murray Date: Tue, 13 Sep 2022 11:44:26 +0930 Subject: [PATCH] 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 --- utils/test/test-profiles.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/utils/test/test-profiles.py b/utils/test/test-profiles.py index b8300a0c5..59f200a44 100644 --- a/utils/test/test-profiles.py +++ b/utils/test/test-profiles.py @@ -9,6 +9,7 @@ # # ------------------------------------------------------------------ +import os import unittest import apparmor.aa as aa @@ -32,12 +33,22 @@ class TestFoo(AATest): def test_active_profiles(self): aa.read_profiles(skip_profiles=skip_active_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): aa.read_inactive_profiles(skip_profiles=skip_extra_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)