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

kunit: tool: remove dead parse_crash_in_log() logic

This logic depends on the kernel logging a message containing
'kunit test case crashed', but there is no corresponding logic to do so.

This is likely a relic of the revision process KUnit initially went
through when being upstreamed.

Delete it given
1) it's been missing for years and likely won't get implemented
2) the parser has been moving to be a more general KTAP parser,
kunit-only magic like this isn't how we'd want to implement 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
33d4a933 9660209d

+4 -104
-21
tools/testing/kunit/kunit_parser.py
··· 475 475 log.append(lines.pop()) 476 476 return log 477 477 478 - DIAGNOSTIC_CRASH_MESSAGE = re.compile(r'^# .*?: kunit test case crashed!$') 479 - 480 - def parse_crash_in_log(test: Test) -> bool: 481 - """ 482 - Iterate through the lines of the log to parse for crash message. 483 - If crash message found, set status to crashed and return True. 484 - Otherwise return False. 485 - 486 - Parameters: 487 - test - Test object for current test being parsed 488 - 489 - Return: 490 - True if crash message found in log 491 - """ 492 - for line in test.log: 493 - if DIAGNOSTIC_CRASH_MESSAGE.match(line): 494 - test.status = TestStatus.TEST_CRASHED 495 - return True 496 - return False 497 - 498 478 499 479 # Printing helper methods: 500 480 ··· 662 682 Parameters: 663 683 test - Test object for current test being parsed 664 684 """ 665 - parse_crash_in_log(test) 666 685 subtests = test.subtests 667 686 counts = test.counts 668 687 status = test.status
+4 -13
tools/testing/kunit/kunit_tool_test.py
··· 230 230 print_mock.stop() 231 231 self.assertEqual(0, len(result.subtests)) 232 232 233 - def test_crashed_test(self): 234 - crashed_log = test_data_path('test_is_test_passed-crash.log') 235 - with open(crashed_log) as file: 236 - result = kunit_parser.parse_run_tests( 237 - file.readlines()) 238 - self.assertEqual( 239 - kunit_parser.TestStatus.TEST_CRASHED, 240 - result.status) 241 - 242 233 def test_skipped_test(self): 243 234 skipped_log = test_data_path('test_skip_tests.log') 244 235 with open(skipped_log) as file: ··· 469 478 result["sub_groups"][1]["test_cases"][0]) 470 479 471 480 def test_crashed_test_json(self): 472 - result = self._json_for('test_is_test_passed-crash.log') 481 + result = self._json_for('test_kernel_panic_interrupt.log') 473 482 self.assertEqual( 474 - {'name': 'example_simple_test', 'status': 'ERROR'}, 475 - result["sub_groups"][1]["test_cases"][0]) 483 + {'name': '', 'status': 'ERROR'}, 484 + result["sub_groups"][2]["test_cases"][1]) 476 485 477 486 def test_skipped_test_json(self): 478 487 result = self._json_for('test_skip_tests.log') ··· 553 562 def test_exec_no_tests(self): 554 563 self.linux_source_mock.run_kernel = mock.Mock(return_value=['TAP version 14', '1..0']) 555 564 with self.assertRaises(SystemExit) as e: 556 - kunit.main(['run'], self.linux_source_mock) 565 + kunit.main(['run'], self.linux_source_mock) 557 566 self.linux_source_mock.run_kernel.assert_called_once_with( 558 567 args=None, build_dir='.kunit', filter_glob='', timeout=300) 559 568 self.print_mock.assert_any_call(StrContains(' 0 tests run!'))
-70
tools/testing/kunit/test_data/test_is_test_passed-crash.log
··· 1 - printk: console [tty0] enabled 2 - printk: console [mc-1] enabled 3 - TAP version 14 4 - 1..2 5 - # Subtest: sysctl_test 6 - 1..8 7 - # sysctl_test_dointvec_null_tbl_data: sysctl_test_dointvec_null_tbl_data passed 8 - ok 1 - sysctl_test_dointvec_null_tbl_data 9 - # sysctl_test_dointvec_table_maxlen_unset: sysctl_test_dointvec_table_maxlen_unset passed 10 - ok 2 - sysctl_test_dointvec_table_maxlen_unset 11 - # sysctl_test_dointvec_table_len_is_zero: sysctl_test_dointvec_table_len_is_zero passed 12 - ok 3 - sysctl_test_dointvec_table_len_is_zero 13 - # sysctl_test_dointvec_table_read_but_position_set: sysctl_test_dointvec_table_read_but_position_set passed 14 - ok 4 - sysctl_test_dointvec_table_read_but_position_set 15 - # sysctl_test_dointvec_happy_single_positive: sysctl_test_dointvec_happy_single_positive passed 16 - ok 5 - sysctl_test_dointvec_happy_single_positive 17 - # sysctl_test_dointvec_happy_single_negative: sysctl_test_dointvec_happy_single_negative passed 18 - ok 6 - sysctl_test_dointvec_happy_single_negative 19 - # sysctl_test_dointvec_single_less_int_min: sysctl_test_dointvec_single_less_int_min passed 20 - ok 7 - sysctl_test_dointvec_single_less_int_min 21 - # sysctl_test_dointvec_single_greater_int_max: sysctl_test_dointvec_single_greater_int_max passed 22 - ok 8 - sysctl_test_dointvec_single_greater_int_max 23 - kunit sysctl_test: all tests passed 24 - ok 1 - sysctl_test 25 - # Subtest: example 26 - 1..2 27 - init_suite 28 - # example_simple_test: initializing 29 - Stack: 30 - 6016f7db 6f81bd30 6f81bdd0 60021450 31 - 6024b0e8 60021440 60018bbe 16f81bdc0 32 - 00000001 6f81bd30 6f81bd20 6f81bdd0 33 - Call Trace: 34 - [<6016f7db>] ? kunit_try_run_case+0xab/0xf0 35 - [<60021450>] ? set_signals+0x0/0x60 36 - [<60021440>] ? get_signals+0x0/0x10 37 - [<60018bbe>] ? kunit_um_run_try_catch+0x5e/0xc0 38 - [<60021450>] ? set_signals+0x0/0x60 39 - [<60021440>] ? get_signals+0x0/0x10 40 - [<60018bb3>] ? kunit_um_run_try_catch+0x53/0xc0 41 - [<6016f321>] ? kunit_run_case_catch_errors+0x121/0x1a0 42 - [<60018b60>] ? kunit_um_run_try_catch+0x0/0xc0 43 - [<600189e0>] ? kunit_um_throw+0x0/0x180 44 - [<6016f730>] ? kunit_try_run_case+0x0/0xf0 45 - [<6016f600>] ? kunit_catch_run_case+0x0/0x130 46 - [<6016edd0>] ? kunit_vprintk+0x0/0x30 47 - [<6016ece0>] ? kunit_fail+0x0/0x40 48 - [<6016eca0>] ? kunit_abort+0x0/0x40 49 - [<6016ed20>] ? kunit_printk_emit+0x0/0xb0 50 - [<6016f200>] ? kunit_run_case_catch_errors+0x0/0x1a0 51 - [<6016f46e>] ? kunit_run_tests+0xce/0x260 52 - [<6005b390>] ? unregister_console+0x0/0x190 53 - [<60175b70>] ? suite_kunit_initexample_test_suite+0x0/0x20 54 - [<60001cbb>] ? do_one_initcall+0x0/0x197 55 - [<60001d47>] ? do_one_initcall+0x8c/0x197 56 - [<6005cd20>] ? irq_to_desc+0x0/0x30 57 - [<60002005>] ? kernel_init_freeable+0x1b3/0x272 58 - [<6005c5ec>] ? printk+0x0/0x9b 59 - [<601c0086>] ? kernel_init+0x26/0x160 60 - [<60014442>] ? new_thread_handler+0x82/0xc0 61 - 62 - # example_simple_test: kunit test case crashed! 63 - # example_simple_test: example_simple_test failed 64 - not ok 1 - example_simple_test 65 - # example_mock_test: initializing 66 - # example_mock_test: example_mock_test passed 67 - ok 2 - example_mock_test 68 - kunit example: one or more tests failed 69 - not ok 2 - example 70 - List of all partitions: