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

Configure Feed

Select the types of activity you want to include in your feed.

kunit: show error if kunit results are not present

Currently, if the kernel is configured incorrectly or if it crashes before any
kunit tests are run, kunit finishes without error, reporting
that 0 test cases were run.

To fix this, an error is shown when the tap header is not found, which
indicates that kunit was not able to run at all.

Signed-off-by: Uriel Guajardo <urielguajardo@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Uriel Guajardo and committed by
Shuah Khan
e173b8b8 3f37d14b

+15 -4
+4 -4
tools/testing/kunit/kunit_parser.py
··· 265 265 return bubble_up_errors(lambda x: x.status, test_suite_list) 266 266 267 267 def parse_test_result(lines: List[str]) -> TestResult: 268 - if not lines: 269 - return TestResult(TestStatus.NO_TESTS, [], lines) 270 268 consume_non_diagnositic(lines) 271 - if not parse_tap_header(lines): 272 - return None 269 + if not lines or not parse_tap_header(lines): 270 + return TestResult(TestStatus.NO_TESTS, [], lines) 273 271 test_suites = [] 274 272 test_suite = parse_test_suite(lines) 275 273 while test_suite: ··· 280 282 failed_tests = 0 281 283 crashed_tests = 0 282 284 test_result = parse_test_result(list(isolate_kunit_output(kernel_output))) 285 + if test_result.status == TestStatus.NO_TESTS: 286 + print_with_timestamp(red('[ERROR] ') + 'no kunit output detected') 283 287 for test_suite in test_result.suites: 284 288 if test_suite.status == TestStatus.SUCCESS: 285 289 print_suite_divider(green('[PASSED] ') + test_suite.name)
+11
tools/testing/kunit/kunit_tool_test.py
··· 170 170 result.status) 171 171 file.close() 172 172 173 + def test_no_kunit_output(self): 174 + crash_log = get_absolute_path( 175 + 'test_data/test_insufficient_memory.log') 176 + file = open(crash_log) 177 + print_mock = mock.patch('builtins.print').start() 178 + result = kunit_parser.parse_run_tests( 179 + kunit_parser.isolate_kunit_output(file.readlines())) 180 + print_mock.assert_any_call(StrContains("no kunit output detected")) 181 + print_mock.stop() 182 + file.close() 183 + 173 184 def test_crashed_test(self): 174 185 crashed_log = get_absolute_path( 175 186 'test_data/test_is_test_passed-crash.log')
tools/testing/kunit/test_data/test_insufficient_memory.log