]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
runner: allow a test to require the existent of files
authorJason Ish <ish@unx.ca>
Fri, 12 Jan 2018 18:59:28 +0000 (12:59 -0600)
committerJason Ish <ish@unx.ca>
Fri, 12 Jan 2018 18:59:28 +0000 (12:59 -0600)
For example, a test could depend on src/output-filestore.c.

run.py

diff --git a/run.py b/run.py
index 8a1dec31861920777665b96004987c5f97982879..cc345c785f10e5447d57346a7da964d58d8a2edb 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -115,6 +115,12 @@ class TestConfig:
                         raise UnsatisfiedRequirementError(
                             "requires env var %s" % (env))
 
+            if "files" in requires:
+                for filename in requires["files"]:
+                    if not os.path.exists(filename):
+                        raise UnsatisfiedRequirementError(
+                            "requires file %s" % (filename))
+
     def has_command(self):
         return "command" in self.config
 
@@ -189,10 +195,13 @@ class ShellCheck:
         self.config = config
 
     def run(self):
-        output = subprocess.check_output(self.config["args"], shell=True)
-        if "expect" in self.config:
-            return str(self.config["expect"]) == output.decode().strip()
-        return True
+        try:
+            output = subprocess.check_output(self.config["args"], shell=True)
+            if "expect" in self.config:
+                return str(self.config["expect"]) == output.decode().strip()
+            return True
+        except subprocess.CalledProcessError as err:
+            raise TestError(err)
 
 class StatsCheck: