From: Shivani Bhardwaj Date: Thu, 25 Apr 2019 15:46:39 +0000 (+0530) Subject: run: Make test result output compact X-Git-Tag: suricata-6.0.4~461 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9f4d69010bd32ae40eb78584aa415a1e894d9cc;p=thirdparty%2Fsuricata-verify.git run: Make test result output compact The new sub test routine causes the test result output cluttered. In order to avoid that, only print the information of any sub-tests being skipped or failed. Before ``` ===> alert-testmyids: | --> Sub test #1: OK | --> Sub test #2: SKIPPED : Suricata v6.0 not found | --> Sub test #3: SKIPPED : Suricata v2.0 not found OK ``` After this patch ``` ===> alert-testmyids: Sub test #2: SKIPPED : Suricata v6.0 not found Sub test #3: SKIPPED : Suricata v2.0 not found OK ``` --- diff --git a/run.py b/run.py index a1bb5121f..f9907bf54 100755 --- a/run.py +++ b/run.py @@ -131,14 +131,13 @@ def handle_exceptions(func): try: func(*args,**kwargs) except TestError as te: - print("FAIL : {}".format(te)) + print("Sub test #{}: FAIL : {}".format(kwargs["test_num"], te)) check_args_fail() kwargs["count"]["failure"] += 1 except UnsatisfiedRequirementError as ue: - print("SKIPPED : {}".format(ue)) + print("Sub test #{}: SKIPPED : {}".format(kwargs["test_num"], ue)) kwargs["count"]["skipped"] += 1 else: - print("OK") kwargs["count"]["success"] += 1 return kwargs["count"] return applicator @@ -577,7 +576,8 @@ class TestRunner: if check_value["check_sh"]: return check_value - print("OK%s" % (" (%dx)" % count if count > 1 else "")) + if not check_value["failure"]: + print("OK%s" % (" (%dx)" % count if count > 1 else "")) return check_value def pre_check(self): @@ -585,17 +585,18 @@ class TestRunner: subprocess.call(self.config["pre-check"], shell=True) @handle_exceptions - def perform_filter_checks(self, check, count): - count = FilterCheck(check, self.output, self.suricata_config.version).run() + def perform_filter_checks(self, check, count, test_num): + count = FilterCheck(check, self.output, + self.suricata_config.version).run() return count @handle_exceptions - def perform_shell_checks(self, check, count): + def perform_shell_checks(self, check, count, test_num): count = ShellCheck(check).run() return count @handle_exceptions - def perform_stats_checks(self, check, count): + def perform_stats_checks(self, check, count, test_num): count = StatsCheck(check, self.output).run() return count @@ -612,12 +613,11 @@ class TestRunner: self.pre_check() if "checks" in self.config: for check_count, check in enumerate(self.config["checks"]): - print("\n|\n --> Sub test #{}: ".format(check_count + 1), - end="") for key in check: if key in ["filter", "shell", "stats"]: func = getattr(self, "perform_{}_checks".format(key)) - count = func(check=check[key], count=count) + count = func(check=check[key], count=count, + test_num=check_count + 1) else: print("FAIL: Unknown check type: {}".format(key)) finally: