]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
runner: add less-than version requirements
authorJason Ish <jason.ish@oisf.net>
Fri, 15 May 2020 16:20:19 +0000 (10:20 -0600)
committerVictor Julien <victor@inliniac.net>
Sat, 23 May 2020 13:35:11 +0000 (15:35 +0200)
lt-version can be used to specify that the Suricata version must
be less than a certain value. This is similar to what a max-version
might look like but be more predictable.

For example, to run a test on all versions less than 6:
    lt-version: 6

README.md
run.py

index 26632dbf78538e5cadfdcd95c0d9f9001f2419cb..5ad0cfaee3da9d76827d526a6fc1bca1736b89e2 100644 (file)
--- a/README.md
+++ b/README.md
@@ -48,6 +48,9 @@ requires:
   # Require a minimum version of Suricata.
   min-version: 4.1.0
 
+  # Require that the Suricata version be less than a version.
+  lt-version: 6
+
   # Test is only for this version. For example, 4.0 would match any 4.0 
   # release, but 4.0.3 would only match 4.0.3.
   version: 4.0
diff --git a/run.py b/run.py
index 32f651e645eede8440843884d9adba4339d78b66..15d9dce5844342313ac265ef347b2ebfee38a8d4 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -181,6 +181,15 @@ class Version:
 
         return True
 
+    def is_lt(self, v1, v2):
+        """Return True if v1 is less than v2."""
+        if v1.major < v2.major:
+            return True
+        elif v1.minor < v2.minor:
+            return True
+        elif v1.patch < v2.patch:
+            return True
+        return False
 
 class SuricataConfig:
 
@@ -453,6 +462,12 @@ class TestRunner:
                         suri_version=suri_version, expr="gte"):
                     raise UnsatisfiedRequirementError(
                             "requires at least version {}".format(min_version))
+            elif key == "lt-version":
+                lt_version = requires["lt-version"]
+                if not is_version_compatible(version=lt_version,
+                        suri_version=suri_version, expr="lt"):
+                    raise UnsatisfiedRequirementError(
+                            "for version less than {}".format(lt_version))
             elif key == "version":
                 req_version = requires["version"]
                 if not is_version_compatible(version=req_version,