From 183856ed5d4252c63eb80d4e92c6230645bdd6ce Mon Sep 17 00:00:00 2001 From: Lucas Moura Date: Thu, 12 Sep 2024 11:43:13 -0400 Subject: [PATCH] tests: handle when syslog file do not exist When collecting apparmor logs, we pull the /var/log/syslog file from the system under test. However, if the file doesn't exist, we shouldn't block the whole test, but instead alert about that --- features/environment.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/features/environment.py b/features/environment.py index 345c7d9245..e01897a36d 100644 --- a/features/environment.py +++ b/features/environment.py @@ -529,6 +529,12 @@ def _get_relevant_apparmor_logs(context): "Unable to pull syslog. Skipping apparmor log check." ) return None + except FileNotFoundError: + logging.warning( + "syslog file doesn't exist. Skipping apparmor log check." + ) + return None + with open(syslog_dest, "r") as syslog_fd: syslog_messages = syslog_fd.readlines() apparmor_denied = [