]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
requires: allow require to be a script that returns true
authorJason Ish <ish@unx.ca>
Wed, 24 Jan 2018 22:49:33 +0000 (16:49 -0600)
committerJason Ish <ish@unx.ca>
Wed, 24 Jan 2018 22:49:33 +0000 (16:49 -0600)
run.py

diff --git a/run.py b/run.py
index 52728c23ae9dd00e4f615fb554c6cc47b365510b..662b9ea1b69779628030d33530da53fc2584b9a7 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -134,7 +134,10 @@ def find_value(name, obj):
         obj = obj[name]
 
         if index is not None:
-            obj = obj[int(index)]
+            try:
+                obj = obj[int(index)]
+            except:
+                return None
 
     return obj
 
@@ -293,6 +296,14 @@ class TestRunner:
                     raise UnsatisfiedRequirementError(
                         "requires file %s" % (filename))
 
+        if "script" in requires:
+            for script in requires["script"]:
+                try:
+                    subprocess.check_call("%s" % script, shell=True)
+                except:
+                    raise UnsatisfiedRequirementError(
+                        "requires script returned false")
+
         # Check if a pcap is required or not. By default a pcap is
         # required unless a "command" has been provided.
         if not "command" in self.config: