Skip to content

Commit

Permalink
kunit: tool: remove dead parse_crash_in_log() logic
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Latypov authored and Shuah Khan committed May 16, 2022
1 parent 9660209 commit 33d4a93
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 104 deletions.
21 changes: 0 additions & 21 deletions tools/testing/kunit/kunit_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,26 +475,6 @@ def parse_diagnostic(lines: LineStream) -> List[str]:
log.append(lines.pop())
return log

DIAGNOSTIC_CRASH_MESSAGE = re.compile(r'^# .*?: kunit test case crashed!$')

def parse_crash_in_log(test: Test) -> bool:
"""
Iterate through the lines of the log to parse for crash message.
If crash message found, set status to crashed and return True.
Otherwise return False.
Parameters:
test - Test object for current test being parsed
Return:
True if crash message found in log
"""
for line in test.log:
if DIAGNOSTIC_CRASH_MESSAGE.match(line):
test.status = TestStatus.TEST_CRASHED
return True
return False


# Printing helper methods:

Expand Down Expand Up @@ -682,7 +662,6 @@ def bubble_up_test_results(test: Test) -> None:
Parameters:
test - Test object for current test being parsed
"""
parse_crash_in_log(test)
subtests = test.subtests
counts = test.counts
status = test.status
Expand Down
17 changes: 4 additions & 13 deletions tools/testing/kunit/kunit_tool_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,6 @@ def test_no_kunit_output(self):
print_mock.stop()
self.assertEqual(0, len(result.subtests))

def test_crashed_test(self):
crashed_log = test_data_path('test_is_test_passed-crash.log')
with open(crashed_log) as file:
result = kunit_parser.parse_run_tests(
file.readlines())
self.assertEqual(
kunit_parser.TestStatus.TEST_CRASHED,
result.status)

def test_skipped_test(self):
skipped_log = test_data_path('test_skip_tests.log')
with open(skipped_log) as file:
Expand Down Expand Up @@ -478,10 +469,10 @@ def test_failed_test_json(self):
result["sub_groups"][1]["test_cases"][0])

def test_crashed_test_json(self):
result = self._json_for('test_is_test_passed-crash.log')
result = self._json_for('test_kernel_panic_interrupt.log')
self.assertEqual(
{'name': 'example_simple_test', 'status': 'ERROR'},
result["sub_groups"][1]["test_cases"][0])
{'name': '', 'status': 'ERROR'},
result["sub_groups"][2]["test_cases"][1])

def test_skipped_test_json(self):
result = self._json_for('test_skip_tests.log')
Expand Down Expand Up @@ -562,7 +553,7 @@ def test_run_passes_args_fail(self):
def test_exec_no_tests(self):
self.linux_source_mock.run_kernel = mock.Mock(return_value=['TAP version 14', '1..0'])
with self.assertRaises(SystemExit) as e:
kunit.main(['run'], self.linux_source_mock)
kunit.main(['run'], self.linux_source_mock)
self.linux_source_mock.run_kernel.assert_called_once_with(
args=None, build_dir='.kunit', filter_glob='', timeout=300)
self.print_mock.assert_any_call(StrContains(' 0 tests run!'))
Expand Down
70 changes: 0 additions & 70 deletions tools/testing/kunit/test_data/test_is_test_passed-crash.log

This file was deleted.

0 comments on commit 33d4a93

Please sign in to comment.