diff options
author | Jakub Kicinski <kuba@kernel.org> | 2024-07-05 04:52:22 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2024-07-08 23:58:23 +0300 |
commit | e0ee68a8bef9cf27e324a017691ee64b235c310e (patch) | |
tree | 11596be970bcad4fbd4f6f1d0787de9ab0b9bfdf /tools/testing/selftests/net/lib | |
parent | 5483cbfd863f01126c08703898a9e71d991a9bfe (diff) | |
download | linux-e0ee68a8bef9cf27e324a017691ee64b235c310e.tar.xz |
selftests: net: ksft: interrupt cleanly on KeyboardInterrupt
It's very useful to be able to interrupt the tests during development.
Detect KeyboardInterrupt, run the cleanups and exit.
Link: https://patch.msgid.link/20240705015222.675840-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/testing/selftests/net/lib')
-rw-r--r-- | tools/testing/selftests/net/lib/py/ksft.py | 9 |
1 files changed, 8 insertions, 1 deletions
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 @@ def ksft_run(cases=None, globs=None, case_pfx=None, args=()): global KSFT_RESULT cnt = 0 + stop = False for case in cases: KSFT_RESULT = True cnt += 1 @@ -160,10 +161,13 @@ def ksft_run(cases=None, globs=None, case_pfx=None, args=()): 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 @@ def ksft_run(cases=None, globs=None, case_pfx=None, args=()): 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" ) |