]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
runner: wrap file compare exceptions in TestError
authorJason Ish <jason.ish@oisf.net>
Tue, 21 Dec 2021 16:13:12 +0000 (10:13 -0600)
committerJason Ish <jason.ish@oisf.net>
Tue, 21 Dec 2021 17:10:41 +0000 (11:10 -0600)
If filecmp.cmp failed with an exception due to a missing file,
its exception was being lost due to another issue in the runner.

For this case it makes sense to catch this exception and wrap
it in a TestError exception as its most likely a missing file.

run.py

diff --git a/run.py b/run.py
index 522d953cd27966157627ae29287f2bed8969a040..d5440343d46d2e48d49159b1e7cbe47925fc53e2 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -378,10 +378,13 @@ class FileCompareCheck:
             return True;
         expected = os.path.join(self.directory, self.config["expected"])
         filename = self.config["filename"]
-        if filecmp.cmp(expected, filename):
-            return True
-        else:
-            raise TestError("%s %s \nFAILED: verification failed" % (expected, filename))
+        try:
+            if filecmp.cmp(expected, filename):
+                return True
+            else:
+                raise TestError("%s %s \nFAILED: verification failed" % (expected, filename))
+        except Exception as err:
+            raise TestError("file-compare check failed with exception: %s" % (err))
 
 class ShellCheck: