selftests: net: print full exception on failure
authorJakub Kicinski <kuba@kernel.org>
Fri, 12 Apr 2024 14:14:34 +0000 (07:14 -0700)
committerJakub Kicinski <kuba@kernel.org>
Mon, 15 Apr 2024 18:21:12 +0000 (11:21 -0700)
Instead of a summary line print the full exception.
This makes debugging Python tests much easier.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Link: https://lore.kernel.org/r/20240412141436.828666-5-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/lib/py/ksft.py

index b4b0bfff68b009df9e2a272cbd8e9473555311b0..793e4761645eb43a68b0b2994be78e74feddef2a 100644 (file)
@@ -2,6 +2,7 @@
 
 import builtins
 import inspect
+import traceback
 from .consts import KSFT_MAIN_NAME
 
 KSFT_RESULT = None
@@ -85,7 +86,8 @@ def ksft_run(cases, args=()):
             totals['xfail'] += 1
             continue
         except Exception as e:
-            for line in str(e).split('\n'):
+            tb = traceback.format_exc()
+            for line in tb.strip().split('\n'):
                 ksft_pr("Exception|", line)
             ktap_result(False, cnt, case)
             totals['fail'] += 1