mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 05:47:59 +00:00
test-aa-show-usage: correctly handle disabled profiles
test_show_unconfined_profiles did not exclude disabled profiles from the expected results, which led to test failures when some profiles were disabled. Disabled profiles are now correctly excluded from the results, fixing the test. Reported-by: Georgia Garcia <georgia.garcia@canonical.com> Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
This commit is contained in:
parent
0e755d24bb
commit
b80179834d
@ -92,7 +92,16 @@ Filtering options:
|
|||||||
if line.startswith(' Profile '):
|
if line.startswith(' Profile '):
|
||||||
nb_profile += 1
|
nb_profile += 1
|
||||||
|
|
||||||
command = ['grep', '-Er', r'flags=.*unconfined.*\{', '--', aa.profile_dir]
|
command = ['grep', '-Er', r'flags=.*unconfined.*\{']
|
||||||
|
|
||||||
|
# Remove disabled profiles from grep
|
||||||
|
disable_dir = os.path.join(aa.profile_dir, 'disable')
|
||||||
|
if os.path.isdir(disable_dir):
|
||||||
|
for name in os.listdir(disable_dir):
|
||||||
|
command.append('--exclude=' + name)
|
||||||
|
|
||||||
|
command.extend(['--', aa.profile_dir])
|
||||||
|
|
||||||
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True, check=False)
|
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True, check=False)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
len(result.stdout.splitlines()), nb_profile,
|
len(result.stdout.splitlines()), nb_profile,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user