From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
przemyslaw.kitszel@intel.com, petrm@nvidia.com,
willemdebruijn.kernel@gmail.com, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next v2 1/3] selftests: net: ksft: avoid continue when handling results
Date: Thu, 27 Jun 2024 11:55:00 -0700 [thread overview]
Message-ID: <20240627185502.3069139-2-kuba@kernel.org> (raw)
In-Reply-To: <20240627185502.3069139-1-kuba@kernel.org>
Exception handlers print the result and use continue
to skip the non-exception result printing. This makes
inserting common post-test code hard. Refactor to
avoid the continues and have only one ktap_result() call.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
tools/testing/selftests/net/lib/py/ksft.py | 28 +++++++++++-----------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/tools/testing/selftests/net/lib/py/ksft.py b/tools/testing/selftests/net/lib/py/ksft.py
index b6ce3f33d41e..789433262dc7 100644
--- a/tools/testing/selftests/net/lib/py/ksft.py
+++ b/tools/testing/selftests/net/lib/py/ksft.py
@@ -130,29 +130,29 @@ KSFT_RESULT_ALL = True
for case in cases:
KSFT_RESULT = True
cnt += 1
+ comment = ""
+ cnt_key = ""
+
try:
case(*args)
except KsftSkipEx as e:
- ktap_result(True, cnt, case, comment="SKIP " + str(e))
- totals['skip'] += 1
- continue
+ comment = "SKIP " + str(e)
+ cnt_key = 'skip'
except KsftXfailEx as e:
- ktap_result(True, cnt, case, comment="XFAIL " + str(e))
- totals['xfail'] += 1
- continue
+ comment = "XFAIL " + str(e)
+ cnt_key = 'xfail'
except Exception as e:
tb = traceback.format_exc()
for line in tb.strip().split('\n'):
ksft_pr("Exception|", line)
- ktap_result(False, cnt, case)
- totals['fail'] += 1
- continue
+ KSFT_RESULT = False
+ cnt_key = 'fail'
- ktap_result(KSFT_RESULT, cnt, case)
- if KSFT_RESULT:
- totals['pass'] += 1
- else:
- totals['fail'] += 1
+ if not cnt_key:
+ cnt_key = 'pass' if KSFT_RESULT else 'fail'
+
+ ktap_result(KSFT_RESULT, cnt, case, comment=comment)
+ totals[cnt_key] += 1
print(
f"# Totals: pass:{totals['pass']} fail:{totals['fail']} xfail:{totals['xfail']} xpass:0 skip:{totals['skip']} error:0"
--
2.45.2
next prev parent reply other threads:[~2024-06-27 18:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-27 18:54 [PATCH net-next v2 0/3] selftests: drv-net: add ability to schedule cleanup with defer() Jakub Kicinski
2024-06-27 18:55 ` Jakub Kicinski [this message]
2024-06-28 14:30 ` [PATCH net-next v2 1/3] selftests: net: ksft: avoid continue when handling results Petr Machata
2024-06-27 18:55 ` [PATCH net-next v2 2/3] selftests: drv-net: add ability to schedule cleanup with defer() Jakub Kicinski
2024-06-28 12:35 ` Przemek Kitszel
2024-06-28 14:31 ` Petr Machata
2024-06-27 18:55 ` [PATCH net-next v2 3/3] selftests: drv-net: rss_ctx: convert to defer() Jakub Kicinski
2024-06-28 14:31 ` Petr Machata
2024-06-29 1:50 ` [PATCH net-next v2 0/3] selftests: drv-net: add ability to schedule cleanup with defer() 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=20240627185502.3069139-2-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 \
--cc=willemdebruijn.kernel@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.