* [PATCH net-next] selftests: net: ksft: interrupt cleanly on KeyboardInterrupt
@ 2024-07-05 1:52 Jakub Kicinski
2024-07-08 21:00 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Kicinski @ 2024-07-05 1:52 UTC (permalink / raw)
To: davem; +Cc: netdev, edumazet, pabeni, petrm, przemyslaw.kitszel,
Jakub Kicinski
It's very useful to be able to interrupt the tests during development.
Detect KeyboardInterrupt, run the cleanups and exit.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
tools/testing/selftests/net/lib/py/ksft.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/lib/py/ksft.py b/tools/testing/selftests/net/lib/py/ksft.py
index 3aaa2748a58e..f26c20df9db4 100644
--- a/tools/testing/selftests/net/lib/py/ksft.py
+++ b/tools/testing/selftests/net/lib/py/ksft.py
@@ -146,6 +146,7 @@ KSFT_RESULT_ALL = True
global KSFT_RESULT
cnt = 0
+ stop = False
for case in cases:
KSFT_RESULT = True
cnt += 1
@@ -160,10 +161,13 @@ KSFT_RESULT_ALL = True
except KsftXfailEx as e:
comment = "XFAIL " + str(e)
cnt_key = 'xfail'
- except Exception as e:
+ except BaseException as e:
+ stop |= isinstance(e, KeyboardInterrupt)
tb = traceback.format_exc()
for line in tb.strip().split('\n'):
ksft_pr("Exception|", line)
+ if stop:
+ ksft_pr("Stopping tests due to KeyboardInterrupt.")
KSFT_RESULT = False
cnt_key = 'fail'
@@ -175,6 +179,9 @@ KSFT_RESULT_ALL = True
ktap_result(KSFT_RESULT, cnt, case, comment=comment)
totals[cnt_key] += 1
+ if stop:
+ break
+
print(
f"# Totals: pass:{totals['pass']} fail:{totals['fail']} xfail:{totals['xfail']} xpass:0 skip:{totals['skip']} error:0"
)
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] selftests: net: ksft: interrupt cleanly on KeyboardInterrupt
2024-07-05 1:52 [PATCH net-next] selftests: net: ksft: interrupt cleanly on KeyboardInterrupt Jakub Kicinski
@ 2024-07-08 21:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-07-08 21:00 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, petrm, przemyslaw.kitszel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 4 Jul 2024 18:52:22 -0700 you wrote:
> It's very useful to be able to interrupt the tests during development.
> Detect KeyboardInterrupt, run the cleanups and exit.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> tools/testing/selftests/net/lib/py/ksft.py | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
Here is the summary with links:
- [net-next] selftests: net: ksft: interrupt cleanly on KeyboardInterrupt
https://git.kernel.org/netdev/net-next/c/e0ee68a8bef9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-08 21:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-05 1:52 [PATCH net-next] selftests: net: ksft: interrupt cleanly on KeyboardInterrupt Jakub Kicinski
2024-07-08 21:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).