]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
run.py: allow python lambda expression for requires
authorJason Ish <jason.ish@oisf.net>
Wed, 14 Jun 2023 17:49:47 +0000 (10:49 -0700)
committerJason Ish <jason.ish@oisf.net>
Wed, 14 Jun 2023 17:52:14 +0000 (10:52 -0700)
Add a new require type, "lambda" which will require the Python lambda
expression to return a truthy value.

README.md
run.py

index 674e4803b192e9b7dd72b3b1c4b32da5697fc584..be5b2afa6466e93c62637dd0deecaac49e3d1d39 100644 (file)
--- a/README.md
+++ b/README.md
@@ -72,6 +72,10 @@ requires:
     - command2
     - ...
 
+  # Require the output of a Python expression to be true. For example,
+  # this will run on all platforms other than win32.
+  lambda: "sys.platform != win32"
+
 skip:
   # Skip a test if a feature is present, with a message that is logged.
   - feature: RUST
diff --git a/run.py b/run.py
index af79c1360f7de3af7bf2ccc7fa44b5c9786c1821..8e2f1acee041a5b2c45198d81456d6ae0c541cf4 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -365,6 +365,9 @@ def check_requires(requires, suricata_config: SuricataConfig):
         elif key == "pcap":
             # A valid requires argument, but not verified here.
             pass
+        elif key == "lambda":
+            if not eval(requires["lambda"]):
+                raise UnsatisfiedRequirementError(requires["lambda"])
         else:
             raise Exception("unknown requires types: %s" % (key))