]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
runner: fail test if pcap cannot be found 1402/head
authorJason Ish <jason.ish@oisf.net>
Thu, 28 Sep 2023 18:11:15 +0000 (12:11 -0600)
committerVictor Julien <victor@inliniac.net>
Fri, 29 Sep 2023 04:53:25 +0000 (06:53 +0200)
Will fail with an error like:
FAILED: PCAP filename does not exist: ../tls/tls-certs-alert/input.pcap

run.py

diff --git a/run.py b/run.py
index 0025d5ef8f14e4c03b8e062cce34b970f9920661..7a67738afdc8ddaca32e628fb9af4c930698061c 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -909,7 +909,14 @@ class TestRunner:
 
         # Find pcaps.
         if "pcap" in self.config:
-            args += ["-r", os.path.realpath(os.path.join(self.directory, self.config["pcap"]))]
+            try:
+                curdir = os.getcwd()
+                os.chdir(self.directory)
+                if not os.path.exists(self.config["pcap"]):
+                    raise TestError("PCAP filename does not exist: {}".format(self.config["pcap"]))
+                args += ["-r", os.path.realpath(os.path.join(self.directory, self.config["pcap"]))]
+            finally:
+                os.chdir(curdir)
         else:
             pcaps = glob.glob(os.path.join(self.directory, "*.pcap"))
             pcaps += glob.glob(os.path.join(self.directory, "*.pcapng"))