From: Jason Ish Date: Fri, 1 Dec 2017 23:06:10 +0000 (-0600) Subject: add feature requires; remove skip.sh scripts X-Git-Tag: suricata-6.0.4~565 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62e2d5e35657723b172f8a1bf537d6dc583fb418;p=thirdparty%2Fsuricata-verify.git add feature requires; remove skip.sh scripts requires.features for required features requires.not-features for when a test should be skipped if a feature is present. --- diff --git a/run.py b/run.py index a61ebf176..a44187a4e 100755 --- a/run.py +++ b/run.py @@ -88,6 +88,18 @@ class TestConfig: raise UnsatisfiedRequirementError( "requires at least version %s" % (min_version.raw)) + if "features" in requires: + for feature in requires["features"]: + if not self.suricata_config.has_feature(feature): + raise UnsatisfiedRequirementError( + "requires feature %s" % (feature)) + + if "not-features" in requires: + for feature in requires["not-features"]: + if self.suricata_config.has_feature(feature): + raise UnsatisfiedRequirementError( + "not for feature %s" % (feature)) + def _version_gte(self, v1, v2): """Return True if v1 is great than or equal to v2.""" if v1.major < v2.major: @@ -109,6 +121,18 @@ class SuricataConfig: def __init__(self, version): self.version = version + self.features = set() + + self.load_build_info() + + def load_build_info(self): + output = subprocess.check_output(["./src/suricata", "--build-info"]) + for line in output.splitlines(): + if line.startswith("Features:"): + self.features = set(line.split()[1:]) + + def has_feature(self, feature): + return feature in self.features class TestRunner: @@ -136,6 +160,12 @@ class TestRunner: test_config = TestConfig(test_config, self.suricata_config) test_config.check_requires() + # Additional requirement checks. + # - If lua is in the test name, make sure we HAVE_LUA. + if self.directory.find("lua"): + if not self.suricata_config.has_feature("HAVE_LUA"): + raise UnsatisfiedRequirementError("requires feature HAVE_LUA") + args = [] if os.path.exists(os.path.join(self.directory, "run.sh")): args.append(os.path.join(self.directory, "run.sh")) @@ -234,27 +264,8 @@ class TestRunner: t.start() self.readers.append(t) -def check_for_lua(): - output = subprocess.check_output(["./src/suricata", "--build-info"]) - if output.find("HAVE_LUA") > -1: - return True - return False - def check_skip(directory): - if os.path.exists(os.path.join(directory, "skip")): - return (True, None) - - if os.path.exists(os.path.join(directory, "skip.sh")): - rc = subprocess.call([ - "/bin/sh", os.path.join(directory, "skip.sh")]) - if rc == 0: - return True, None - - if directory.find("lua") > -1: - if not check_for_lua(): - return (True, "lua not available") - - return (False, None) + return os.path.exists(os.path.join(directory, "skip")) def main(): @@ -301,13 +312,8 @@ def main(): if args.force: do_test = True else: - skip, reason = check_skip(dirpath) - if skip: - skipped += 1 - if reason: - print("===> %s: SKIPPED: %s" % (name, reason)) - else: - print("===> %s: SKIPPED" % (name)) + if check_skip(dirpath): + print("===> %s: SKIPPED" % (name)) else: do_test = True else: diff --git a/tests/dns-udp-dns-log-unanswered/skip.sh b/tests/dns-udp-dns-log-unanswered/skip.sh deleted file mode 100644 index 079d0c3d3..000000000 --- a/tests/dns-udp-dns-log-unanswered/skip.sh +++ /dev/null @@ -1,9 +0,0 @@ -#! /bin/sh - -# Skip this test if Rust is enabled. Rust does not handle the non-eve -# DNS log. -if ./src/suricata --build-info | grep Rust | grep -q yes; then - exit 0 -fi - -exit 1 diff --git a/tests/dns-udp-dns-log-unanswered/test.yaml b/tests/dns-udp-dns-log-unanswered/test.yaml new file mode 100644 index 000000000..dfbdcfb53 --- /dev/null +++ b/tests/dns-udp-dns-log-unanswered/test.yaml @@ -0,0 +1,4 @@ +requires: + # Test will be skipped if any of these features are present. + not-features: + - RUST diff --git a/tests/dns-udp-unsolicited-response/skip.sh b/tests/dns-udp-unsolicited-response/skip.sh deleted file mode 100644 index d809eeda8..000000000 --- a/tests/dns-udp-unsolicited-response/skip.sh +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/sh - -# Skip this test if Rust is enabled. -if ./src/suricata --build-info | grep Rust | grep -q yes; then - exit 0 -fi - -exit 1 diff --git a/tests/dns-udp-unsolicited-response/test.yaml b/tests/dns-udp-unsolicited-response/test.yaml new file mode 100644 index 000000000..dfbdcfb53 --- /dev/null +++ b/tests/dns-udp-unsolicited-response/test.yaml @@ -0,0 +1,4 @@ +requires: + # Test will be skipped if any of these features are present. + not-features: + - RUST diff --git a/tests/lua-output-dns/test.yaml b/tests/lua-output-dns/test.yaml new file mode 100644 index 000000000..4bb475d43 --- /dev/null +++ b/tests/lua-output-dns/test.yaml @@ -0,0 +1,3 @@ +requires: + features: + - HAVE_LUA