]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
runner: add setup
authorJason Ish <ish@unx.ca>
Tue, 16 Jan 2018 01:19:24 +0000 (19:19 -0600)
committerJason Ish <ish@unx.ca>
Tue, 16 Jan 2018 01:19:24 +0000 (19:19 -0600)
A test.yaml can now have a setup section that is run
before Suricata is executed.

run.py

diff --git a/run.py b/run.py
index cc345c785f10e5447d57346a7da964d58d8a2edb..b46a415bca275e3452fd6bb544e1b995d8023152 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -266,6 +266,16 @@ class TestRunner:
         # List of thread readers.
         self.readers = []
 
+    def setup(self, config):
+        if "setup" in config:
+            for setup in config["setup"]:
+                for command in setup:
+                    if command == "script":
+                        subprocess.check_call(
+                            "%s" % setup[command],
+                            shell=True,
+                            cwd=self.directory)
+
     def run(self):
 
         sys.stdout.write("===> %s: " % os.path.basename(self.directory))
@@ -278,7 +288,13 @@ class TestRunner:
         else:
             test_config = TestConfig({}, self.suricata_config)
 
+        # Cleanup the output directory.
+        if os.path.exists(self.output):
+            shutil.rmtree(self.output)
+        os.makedirs(self.output)
+
         test_config.check_requires()
+        self.setup(test_config.config)
 
         shell = False
 
@@ -296,11 +312,6 @@ class TestRunner:
             "ASAN_OPTIONS": "detect_leaks=0",
         }
 
-        # Cleanup the output directory.
-        if os.path.exists(self.output):
-            shutil.rmtree(self.output)
-        os.makedirs(self.output)
-
         stdout = open(os.path.join(self.output, "stdout"), "w")
         stderr = open(os.path.join(self.output, "stderr"), "w")