selftests/bpf: print traceback when test fails
authorJakub Kicinski <jakub.kicinski@netronome.com>
Wed, 6 Feb 2019 04:03:22 +0000 (20:03 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 6 Feb 2019 14:35:42 +0000 (15:35 +0100)
Figuring out which exact check in test_offload.py takes more
time than it should.  Print the traceback (to the screen and
the logs).

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/testing/selftests/bpf/test_offload.py

index a564d1a5a1b8fcbb57dded3b9df01bbe08dd3974..c379b36a5443321878fe9e122c92edcbe3e6c4e8 100755 (executable)
@@ -23,6 +23,7 @@ import string
 import struct
 import subprocess
 import time
+import traceback
 
 logfile = None
 log_level = 1
@@ -78,7 +79,9 @@ def fail(cond, msg):
     if not cond:
         return
     print("FAIL: " + msg)
-    log("FAIL: " + msg, "", level=1)
+    tb = "".join(traceback.extract_stack().format())
+    print(tb)
+    log("FAIL: " + msg, tb, level=1)
     os.sys.exit(1)
 
 def start_test(msg):