From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
petrm@nvidia.com, przemyslaw.kitszel@intel.com,
Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next] selftests: net: ksft: interrupt cleanly on KeyboardInterrupt
Date: Thu, 4 Jul 2024 18:52:22 -0700 [thread overview]
Message-ID: <20240705015222.675840-1-kuba@kernel.org> (raw)
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
next reply other threads:[~2024-07-05 1:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-05 1:52 Jakub Kicinski [this message]
2024-07-08 21:00 ` [PATCH net-next] selftests: net: ksft: interrupt cleanly on KeyboardInterrupt patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240705015222.675840-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=przemyslaw.kitszel@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).