Re: [PATCH net-next 4/6] selftests: net: print full exception on failure

2024-04-12 Thread Petr Machata


Jakub Kicinski  writes:

> Instead of a summary line print the full exception.
> This makes debugging Python tests much easier.
>
> Signed-off-by: Jakub Kicinski 

Reviewed-by: Petr Machata 

> @@ -85,7 +86,8 @@ KSFT_RESULT = None
>  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'):

(The strip is necessary to get rid of trailing newlines.)

>  ksft_pr("Exception|", line)
>  ktap_result(False, cnt, case)
>  totals['fail'] += 1




[PATCH net-next 4/6] selftests: net: print full exception on failure

2024-04-10 Thread Jakub Kicinski
Instead of a summary line print the full exception.
This makes debugging Python tests much easier.

Signed-off-by: Jakub Kicinski 
---
 tools/testing/selftests/net/lib/py/ksft.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/lib/py/ksft.py 
b/tools/testing/selftests/net/lib/py/ksft.py
index 5838aadd95a7..6e1f4685669c 100644
--- a/tools/testing/selftests/net/lib/py/ksft.py
+++ b/tools/testing/selftests/net/lib/py/ksft.py
@@ -2,6 +2,7 @@
 
 import builtins
 import inspect
+import traceback
 from .consts import KSFT_MAIN_NAME
 
 KSFT_RESULT = None
@@ -85,7 +86,8 @@ KSFT_RESULT = None
 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
-- 
2.44.0