Skip to content

Commit bd80c4d

Browse files
t-8chshuahkh
authored andcommitted
kunit: tool: Parse skipped tests from kselftest.h
Skipped tests reported by kselftest.h use a different format than KTAP, there is no explicit test name. Normally the test name is part of the free-form string after the SKIP keyword: ok 3 # SKIP test: some reason Extend the parser to handle those correctly. Use the free-form string as test name instead. Link: https://lore.kernel.org/r/20250813-kunit-kselftesth-skip-v1-1-57ae3de4f109@linutronix.de Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Reviewed-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 29128da commit bd80c4d

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

tools/testing/kunit/kunit_parser.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,9 @@ def parse_test_plan(lines: LineStream, test: Test) -> bool:
352352
lines.pop()
353353
return True
354354

355-
TEST_RESULT = re.compile(r'^\s*(ok|not ok) ([0-9]+) (- )?([^#]*)( # .*)?$')
355+
TEST_RESULT = re.compile(r'^\s*(ok|not ok) ([0-9]+) ?(- )?([^#]*)( # .*)?$')
356356

357-
TEST_RESULT_SKIP = re.compile(r'^\s*(ok|not ok) ([0-9]+) (- )?(.*) # SKIP(.*)$')
357+
TEST_RESULT_SKIP = re.compile(r'^\s*(ok|not ok) ([0-9]+) ?(- )?(.*) # SKIP ?(.*)$')
358358

359359
def peek_test_name_match(lines: LineStream, test: Test) -> bool:
360360
"""
@@ -379,6 +379,8 @@ def peek_test_name_match(lines: LineStream, test: Test) -> bool:
379379
if not match:
380380
return False
381381
name = match.group(4)
382+
if not name:
383+
return False
382384
return name == test.name
383385

384386
def parse_test_result(lines: LineStream, test: Test,
@@ -416,7 +418,7 @@ def parse_test_result(lines: LineStream, test: Test,
416418

417419
# Set name of test object
418420
if skip_match:
419-
test.name = skip_match.group(4)
421+
test.name = skip_match.group(4) or skip_match.group(5)
420422
else:
421423
test.name = match.group(4)
422424

tools/testing/kunit/test_data/test_is_test_passed-kselftest.log

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
TAP version 13
2-
1..2
2+
1..3
33
# selftests: membarrier: membarrier_test_single_thread
44
# TAP version 13
55
# 1..2
@@ -12,3 +12,4 @@ ok 1 selftests: membarrier: membarrier_test_single_thread
1212
# ok 1 sys_membarrier available
1313
# ok 2 sys membarrier invalid command test: command = -1, flags = 0, errno = 22. Failed as expected
1414
ok 2 selftests: membarrier: membarrier_test_multi_thread
15+
ok 3 # SKIP selftests: membarrier: membarrier_test_multi_thread

0 commit comments

Comments
 (0)