]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
runner: debug-failed fixups
authorJason Ish <jason.ish@oisf.net>
Tue, 4 Aug 2020 21:07:27 +0000 (15:07 -0600)
committerJason Ish <jason.ish@oisf.net>
Tue, 4 Aug 2020 21:07:27 +0000 (15:07 -0600)
Don't dump a file that looks like binary. This is determined
by trying to utf-8 decode a file.

run.py

diff --git a/run.py b/run.py
index b06a9c6d5b3af952cc0196aa7886473ab7f4f132..f35e634be2eb6757a0e500b4541458d973c4cd22 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -939,9 +939,17 @@ def main():
             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())
+                    path = os.path.join(r, fname)
+                    print("  - %s" % path)
+                    try:
+                        with open(path, "r") as fcontents:
+                            try:
+                                buf = fcontents.read().decode()
+                                print(buf)
+                            except:
+                                print("    - [Not dumping file that won't utf-8 decode]")
+                    except Exception as err:
+                        print("Failed to open %s: %s" % (path, str(err)))
 
     if failed > 0:
         return 1