Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kunit: tool: make parser stop overwriting status of suites w/ no_tests

Consider this invocation
$ ./tools/testing/kunit/kunit.py parse <<EOF
TAP version 14
1..2
ok 1 - suite
# Subtest: no_tests_suite
# catastrophic error!
not ok 1 - no_tests_suite
EOF

It will have a 0 exit code even though there's a "not ok".

Consider this one:
$ ./tools/testing/kunit/kunit.py parse <<EOF
TAP version 14
1..2
ok 1 - suite
not ok 1 - no_tests_suite
EOF

It will a non-zero exit code.

Why?
We have this line in the kunit_parser.py
> parent_test = parse_test_header(lines, test)
where we have special handling when we see "# Subtest" and we ignore the
explicit reported "not ok 1" status!

Also, NO_TESTS at a suite-level only results in a non-zero status code
where then there's only one suite atm.

This change is the minimal one to make sure we don't overwrite it.

Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Daniel Latypov and committed by
Shuah Khan
dbf0b0d5 33d4a933

+6 -3
+5 -2
tools/testing/kunit/kunit_parser.py
··· 775 775 776 776 # Check for there being no tests 777 777 if parent_test and len(subtests) == 0: 778 - test.status = TestStatus.NO_TESTS 779 - test.add_error('0 tests run!') 778 + # Don't override a bad status if this test had one reported. 779 + # Assumption: no subtests means CRASHED is from Test.__init__() 780 + if test.status in (TestStatus.TEST_CRASHED, TestStatus.SUCCESS): 781 + test.status = TestStatus.NO_TESTS 782 + test.add_error('0 tests run!') 780 783 781 784 # Add statuses to TestCounts attribute in Test object 782 785 bubble_up_test_results(test)
+1 -1
tools/testing/kunit/test_data/test_is_test_passed-no_tests_no_plan.log
··· 3 3 # Subtest: suite 4 4 1..1 5 5 # Subtest: case 6 - ok 1 - case # SKIP 6 + ok 1 - case 7 7 ok 1 - suite