Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ def __init__(self, version):
self.version = version
self.features = set()
self.config = {}
self.extra_set = []
self.load_build_info()

def load_build_info(self):
Expand Down Expand Up @@ -374,6 +375,14 @@ def check_requires(requires, suricata_config: SuricataConfig, test_dir=None):
if not env in os.environ:
raise UnsatisfiedRequirementError(
"requires env var %s" % (env))
elif key == "skip-env":
# Inverse of "env": skip the test when the variable is set. Lets a
# test opt out of a specific run configuration without every other
# run having to set a variable to opt in.
for env in requires["skip-env"]:
if env in os.environ:
raise UnsatisfiedRequirementError(
"skipped because env var %s is set" % (env))
elif key == "files":
for filename in requires["files"]:
if test_dir and not os.path.isabs(filename):
Expand Down Expand Up @@ -1050,6 +1059,12 @@ def default_args(self):

args += ["-c", self.get_suricata_yaml_path()]

# Extra command line arguments provided on the run.py command
# line. Added late so they take precedence over the values set
# above.
for keyvalue in self.suricata_config.extra_set:
args += ["--set", keyvalue]

# Find pcaps.
if "pcap" in self.config:
pcap_path = os.path.join(self.directory, self.config["pcap"])
Expand Down Expand Up @@ -1266,6 +1281,9 @@ def main():
help="Outputs to custom directory")
parser.add_argument("--valgrind", dest="valgrind", action="store_true",
help="Run tests in with valgrind")
parser.add_argument("--set", dest="extra_set", action="append", default=[],
metavar="KEY=VALUE",
help="Pass --set KEY=VALUE to Suricata (may be used multiple times)")
parser.add_argument("--self-test", action="store_true",
help="Run self tests")
parser.add_argument("--debug-failed", dest="debugfailed", action="store_true",
Expand Down Expand Up @@ -1333,6 +1351,7 @@ def main():
print("error: suricatasc binary is missing")

suricata_config.valgrind = args.valgrind
suricata_config.extra_set = args.extra_set
tdir = os.path.join(TOPDIR, "tests")
if args.testdir:
tdir = os.path.abspath(args.testdir)
Expand Down
5 changes: 5 additions & 0 deletions tests/datasets/datasets-absolute-allowed/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ pcap: ../../datasets/datasets-parent-path/one-packet.pcap
requires:
min-version: 8
lambda: sys.platform != "win32"
# The dataset state/save files are absolute paths under /tmp, which is
# outside anything the Landlock sandbox grants, so the rules are rejected
# when it is enabled.
skip-env:
- SV_LANDLOCK

args:
- -vvv
Expand Down
6 changes: 6 additions & 0 deletions tests/lua-output-streaming/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ requires:
features:
- HAVE_LUA
min-version: 8
# The Lua script builds its output filename at runtime, so Suricata cannot
# declare it and the Landlock sandbox denies the write. Running under
# Landlock needs the output directory in security.landlock.directories.write,
# which the test does not control.
skip-env:
- SV_LANDLOCK

pcap: ../filestore-v2.1-forced/suricata-update-pdf.pcap

Expand Down
Loading