From: Philippe Antoine Date: Wed, 30 Oct 2019 16:12:53 +0000 (+0100) Subject: option: adds debugfailed option X-Git-Tag: suricata-6.0.4~263 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22c6537aec31be8715245b743e730b9dc0bb4b77;p=thirdparty%2Fsuricata-verify.git option: adds debugfailed option Prints contents of files in output directory of failed tests Intent is to debug flasky behaviors --- diff --git a/run.py b/run.py index 8ea99e0f5..b06a9c6d5 100755 --- a/run.py +++ b/run.py @@ -837,6 +837,8 @@ def main(): help="Run tests in with valgrind") parser.add_argument("--self-test", action="store_true", help="Run self tests") + parser.add_argument("--debug-failed", dest="debugfailed", action="store_true", + help="Prints debug output for failed tests") parser.add_argument("patterns", nargs="*", default=[]) args = parser.parse_args() @@ -898,6 +900,7 @@ def main(): # Sort alphabetically. tests.sort() + failedLogs = [] for dirpath in tests: name = os.path.basename(dirpath) @@ -913,6 +916,8 @@ def main(): passed += results["success"] failed += results["failure"] skipped += results["skipped"] + if results["failure"] > 0: + failedLogs.append(dirpath) except UnsatisfiedRequirementError as ue: print("SKIPPED: {}".format(ue)) skipped += 1 @@ -926,6 +931,18 @@ def main(): print("FAILED: %d" % (failed)) print("SKIPPED: %d" % (skipped)) + if args.debugfailed: + if len(failedLogs) > 0: + print("") + print("Failed tests debug output:") + for dirpath in failedLogs: + print("- Test %s:" % os.path.basename(dirpath)) + for r, d, f in os.walk(dirpath+"/output"): + for fname in f: + print(" - %s" % fname) + with open(dirpath + "/output/" + fname, "r") as fcontents: + print(fcontents.read()) + if failed > 0: return 1 return 0