From: David Gow <david@davidgow.net>
To: "Brendan Higgins" <brendan.higgins@linux.dev>,
"Rae Moar" <raemoar63@gmail.com>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: David Gow <david@davidgow.net>,
kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, workflows@vger.kernel.org
Subject: [PATCH v3 1/2] kunit: tool: Parse and print the reason tests are skipped
Date: Thu, 4 Jun 2026 20:32:04 +0800 [thread overview]
Message-ID: <20260604123207.2615485-1-david@davidgow.net> (raw)
When a KUnit test (or other KTAP test) is skipped, a "skip reason" can be
provided. kunit.py has never done anything with this, ignoring anything
included in the KTAP output after the 'SKIP' directive.
Since we have it, and it's used, print it in a nice friendly yellow in
parentheses after a skipped test's name.
(And, by parsing it, it can be included in the JUnit results as well.)
Signed-off-by: David Gow <david@davidgow.net>
---
There are a few bits of KTAP that kunit.py has never actually parsed, and
this is one of them. It's also nice to have a good way of quickly seeing
why a test has been skipped, given most tests do provide good reason
strings.
Happy to hear comments about the style: yellow in parentheses looks pretty
good here, but could be a bit confusing if KUnit do
This is the first version of this patch, as it's a new dependency of v3 of
patch 2, the JUnit support, which also includes the skip reason.
--
tools/testing/kunit/kunit_parser.py | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py
index 0e1d2f4985eb..22b8464c6383 100644
--- a/tools/testing/kunit/kunit_parser.py
+++ b/tools/testing/kunit/kunit_parser.py
@@ -44,11 +44,12 @@ class Test:
self.subtests = [] # type: List[Test]
self.log = [] # type: List[str]
self.counts = TestCounts()
+ self.skip_reason = ''
def __str__(self) -> str:
"""Returns string representation of a Test class object."""
return (f'Test({self.status}, {self.name}, {self.expected_count}, '
- f'{self.subtests}, {self.log}, {self.counts})')
+ f'{self.subtests}, {self.log}, {self.counts}, {self.skip_reason})')
def __repr__(self) -> str:
"""Returns string representation of a Test class object."""
@@ -352,9 +353,9 @@ def parse_test_plan(lines: LineStream, test: Test) -> bool:
lines.pop()
return True
-TEST_RESULT = re.compile(r'^\s*(ok|not ok) ([0-9]+) ?(- )?([^#]*)( # .*)?$')
+TEST_RESULT = re.compile(r'^\s*(ok|not ok) ([0-9]+) ?(:?- )?([^#]*)( # .*)?$')
-TEST_RESULT_SKIP = re.compile(r'^\s*(ok|not ok) ([0-9]+) ?(- )?(.*) # SKIP ?(.*)$')
+TEST_RESULT_SKIP = re.compile(r'^\s*(ok|not ok) ([0-9]+) ?(:?- )?(.*) # SKIP ?(.*)$')
def peek_test_name_match(lines: LineStream, test: Test) -> bool:
"""
@@ -418,7 +419,7 @@ def parse_test_result(lines: LineStream, test: Test,
# Set name of test object
if skip_match:
- test.name = skip_match.group(4) or skip_match.group(5)
+ test.name = skip_match.group(4)
else:
test.name = match.group(4)
@@ -431,6 +432,7 @@ def parse_test_result(lines: LineStream, test: Test,
status = match.group(1)
if skip_match:
test.status = TestStatus.SKIPPED
+ test.skip_reason = skip_match.group(5) or ''
elif status == 'ok':
test.status = TestStatus.SUCCESS
else:
@@ -539,7 +541,7 @@ def format_test_result(test: Test, printer: Printer) -> str:
if test.status == TestStatus.SUCCESS:
return printer.green('[PASSED] ') + test.name
if test.status == TestStatus.SKIPPED:
- return printer.yellow('[SKIPPED] ') + test.name
+ return printer.yellow('[SKIPPED] ') + test.name + ' (' + printer.yellow(test.skip_reason) + ')'
if test.status == TestStatus.NO_TESTS:
return printer.yellow('[NO TESTS RUN] ') + test.name
if test.status == TestStatus.TEST_CRASHED:
--
2.54.0
next reply other threads:[~2026-06-04 12:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 12:32 David Gow [this message]
2026-06-04 12:32 ` [PATCH v3 2/2] kunit: tool: Add (primitive) support for outputting JUnit XML David Gow
2026-06-05 7:11 ` Thomas Weißschuh
2026-06-05 6:58 ` [PATCH v3 1/2] kunit: tool: Parse and print the reason tests are skipped Thomas Weißschuh
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=20260604123207.2615485-1-david@davidgow.net \
--to=david@davidgow.net \
--cc=brendan.higgins@linux.dev \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=raemoar63@gmail.com \
--cc=skhan@linuxfoundation.org \
--cc=thomas.weissschuh@linutronix.de \
--cc=workflows@vger.kernel.org \
/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