Skip to content

Commit 4661917

Browse files
committed
selftests: net: ksft: print more of the stack for checks
Print more stack frames and the failing line when check fails. This helps when tests use helpers to do the checks. Before: # At ./ksft/drivers/net/hw/rss_ctx.py line 92: # Check failed 1037698 >= 396893.0 traffic on other queues:[344612, 462380, 233020, 449174, 342298] not ok 8 rss_ctx.test_rss_context_queue_reconfigure After: # Check| At ./ksft/drivers/net/hw/rss_ctx.py, line 387, in test_rss_context_queue_reconfigure: # Check| test_rss_queue_reconfigure(cfg, main_ctx=False) # Check| At ./ksft/drivers/net/hw/rss_ctx.py, line 230, in test_rss_queue_reconfigure: # Check| _send_traffic_check(cfg, port, ctx_ref, { 'target': (0, 3), # Check| At ./ksft/drivers/net/hw/rss_ctx.py, line 92, in _send_traffic_check: # Check| ksft_lt(sum(cnts[i] for i in params['noise']), directed / 2, # Check failed 1045235 >= 405823.5 traffic on other queues (context 1)':[460068, 351995, 565970, 351579, 127270] not ok 8 rss_ctx.test_rss_context_queue_reconfigure Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a48395f commit 4661917

File tree

1 file changed

+12
-2
lines changed
  • tools/testing/selftests/net/lib/py

1 file changed

+12
-2
lines changed

tools/testing/selftests/net/lib/py/ksft.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,18 @@ def _fail(*args):
3434
global KSFT_RESULT
3535
KSFT_RESULT = False
3636

37-
frame = inspect.stack()[2]
38-
ksft_pr("At " + frame.filename + " line " + str(frame.lineno) + ":")
37+
stack = inspect.stack()
38+
started = False
39+
for frame in reversed(stack[2:]):
40+
# Start printing from the test case function
41+
if not started:
42+
if frame.function == 'ksft_run':
43+
started = True
44+
continue
45+
46+
ksft_pr("Check| At " + frame.filename + ", line " + str(frame.lineno) +
47+
", in " + frame.function + ":")
48+
ksft_pr("Check| " + frame.code_context[0].strip())
3949
ksft_pr(*args)
4050

4151

0 commit comments

Comments
 (0)