]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
option: adds debugfailed option
authorPhilippe Antoine <contact@catenacyber.fr>
Wed, 30 Oct 2019 16:12:53 +0000 (17:12 +0100)
committerJason Ish <jason.ish@oisf.net>
Tue, 4 Aug 2020 20:48:10 +0000 (14:48 -0600)
Prints contents of files in output directory of failed tests
Intent is to debug flasky behaviors

run.py

diff --git a/run.py b/run.py
index 8ea99e0f588d3bb917db9f70c94e86b5bf32444d..b06a9c6d5b3af952cc0196aa7886473ab7f4f132 100755 (executable)
--- 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