From: Jason Ish Date: Wed, 17 Jan 2018 20:25:05 +0000 (-0600) Subject: test.yaml: allow a pcap to be referenced X-Git-Tag: suricata-6.0.4~525 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcdcea3b5c99131c4311032d2323082f57766d5f;p=thirdparty%2Fsuricata-verify.git test.yaml: allow a pcap to be referenced So a single PCAP can be shared by multiple tests with only one copy of the pcap. --- diff --git a/run.py b/run.py index 958bd3b9a..90ad96ea6 100755 --- a/run.py +++ b/run.py @@ -287,7 +287,7 @@ class TestRunner: pcap_required = requires["pcap"] else: pcap_required = True - if pcap_required: + if pcap_required and not "pcap" in self.config: if not glob.glob(os.path.join(self.directory, "*.pcap")) + \ glob.glob(os.path.join(self.directory, "*.pcapng")): raise UnsatisfiedRequirementError("No pcap file found") @@ -419,12 +419,15 @@ class TestRunner: args += ["-c", os.path.join(self.cwd, "suricata.yaml")] # Find pcaps. - pcaps = glob.glob(os.path.join(self.directory, "*.pcap")) - pcaps += glob.glob(os.path.join(self.directory, "*.pcapng")) - if len(pcaps) > 1: - raise TestError("More than 1 pcap file found") - if pcaps: - args += ["-r", pcaps[0]] + if "pcap" in self.config: + args += ["-r", self.config["pcap"]] + else: + pcaps = glob.glob(os.path.join(self.directory, "*.pcap")) + pcaps += glob.glob(os.path.join(self.directory, "*.pcapng")) + if len(pcaps) > 1: + raise TestError("More than 1 pcap file found") + if pcaps: + args += ["-r", pcaps[0]] # Find rules. rules = glob.glob(os.path.join(self.directory, "*.rules"))