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

kunit: tool: print clearer error message when there's no TAP output

Before:
$ ./tools/testing/kunit/kunit.py parse /dev/null
...
[ERROR] Test : invalid KTAP input!

After:
$ ./tools/testing/kunit/kunit.py parse /dev/null
...
[ERROR] Test <missing>: could not find any KTAP output!

This error message gets printed out when extract_tap_output() yielded no
lines. So while it could be because of malformed KTAP output from KUnit,
it could also be due to not having any KTAP output at all.

Try and make the error message here more clear.

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
9660209d 3f0a50f3

+4 -3
+2 -1
tools/testing/kunit/kunit_parser.py
··· 824 824 lines = extract_tap_lines(kernel_output) 825 825 test = Test() 826 826 if not lines: 827 - test.add_error('invalid KTAP input!') 827 + test.name = '<missing>' 828 + test.add_error('could not find any KTAP output!') 828 829 test.status = TestStatus.FAILURE_TO_PARSE_TESTS 829 830 else: 830 831 test = parse_test(lines, 0, [])
+2 -2
tools/testing/kunit/kunit_tool_test.py
··· 226 226 with open(crash_log) as file: 227 227 result = kunit_parser.parse_run_tests( 228 228 kunit_parser.extract_tap_lines(file.readlines())) 229 - print_mock.assert_any_call(StrContains('invalid KTAP input!')) 229 + print_mock.assert_any_call(StrContains('could not find any KTAP output!')) 230 230 print_mock.stop() 231 231 self.assertEqual(0, len(result.subtests)) 232 232 ··· 557 557 self.assertEqual(e.exception.code, 1) 558 558 self.assertEqual(self.linux_source_mock.build_reconfig.call_count, 1) 559 559 self.assertEqual(self.linux_source_mock.run_kernel.call_count, 1) 560 - self.print_mock.assert_any_call(StrContains('invalid KTAP input!')) 560 + self.print_mock.assert_any_call(StrContains('could not find any KTAP output!')) 561 561 562 562 def test_exec_no_tests(self): 563 563 self.linux_source_mock.run_kernel = mock.Mock(return_value=['TAP version 14', '1..0'])