From bcdcea3b5c99131c4311032d2323082f57766d5f Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Wed, 17 Jan 2018 14:25:05 -0600 Subject: [PATCH] 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. --- run.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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")) -- 2.47.2