Skip to content

Commit ccbb22b

Browse files
committed
Merge tag 'linux-kselftest-kunit-fixes-5.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kunit fixes from Shuah Khan: "Fixes to kunit tool and documentation: - fix asserts on older python versions - fixes to misleading error messages when TAP header format is incorrect or when file is missing - documentation fix: drop obsolete information about uml_abort coverage - remove unnecessary annotations" * tag 'linux-kselftest-kunit-fixes-5.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: kunit: tool: Assert the version requirement kunit: tool: remove unnecessary "annotations" import Documentation: kunit: drop obsolete note about uml_abort for coverage kunit: tool: Fix error messages for cases of no tests and wrong TAP header
2 parents 00397e7 + df4b080 commit ccbb22b

File tree

7 files changed

+24
-22
lines changed

7 files changed

+24
-22
lines changed

Documentation/dev-tools/kunit/running_tips.rst

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,7 @@ Generating code coverage reports under UML
8686
.. note::
8787
TODO([email protected]): There are various issues with UML and
8888
versions of gcc 7 and up. You're likely to run into missing ``.gcda``
89-
files or compile errors. We know one `faulty GCC commit
90-
<https://github.com/gcc-mirror/gcc/commit/8c9434c2f9358b8b8bad2c1990edf10a21645f9d>`_
91-
but not how we'd go about getting this fixed. The compile errors still
92-
need some investigation.
93-
94-
.. note::
95-
TODO([email protected]): for recent versions of Linux
96-
(5.10-5.12, maybe earlier), there's a bug with gcov counters not being
97-
flushed in UML. This translates to very low (<1%) reported coverage. This is
98-
related to the above issue and can be worked around by replacing the
99-
one call to ``uml_abort()`` (it's in ``os_dump_core()``) with a plain
100-
``exit()``.
101-
89+
files or compile errors.
10290

10391
This is different from the "normal" way of getting coverage information that is
10492
documented in Documentation/dev-tools/gcov.rst.

tools/testing/kunit/kunit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import os
1313
import time
1414

15+
assert sys.version_info >= (3, 7), "Python version is too old"
16+
1517
from collections import namedtuple
1618
from enum import Enum, auto
1719

tools/testing/kunit/kunit_kernel.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
# Author: Felix Guo <[email protected]>
77
# Author: Brendan Higgins <[email protected]>
88

9-
from __future__ import annotations
109
import importlib.util
1110
import logging
1211
import subprocess
1312
import os
1413
import shutil
1514
import signal
16-
from typing import Iterator
17-
from typing import Optional
15+
from typing import Iterator, Optional, Tuple
1816

1917
from contextlib import ExitStack
2018

@@ -208,7 +206,7 @@ def get_source_tree_ops(arch: str, cross_compile: Optional[str]) -> LinuxSourceT
208206
raise ConfigError(arch + ' is not a valid arch')
209207

210208
def get_source_tree_ops_from_qemu_config(config_path: str,
211-
cross_compile: Optional[str]) -> tuple[
209+
cross_compile: Optional[str]) -> Tuple[
212210
str, LinuxSourceTreeOperations]:
213211
# The module name/path has very little to do with where the actual file
214212
# exists (I learned this through experimentation and could not find it

tools/testing/kunit/kunit_parser.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,11 @@ def bubble_up_suite_errors(test_suites: Iterable[TestSuite]) -> TestStatus:
338338
def parse_test_result(lines: LineStream) -> TestResult:
339339
consume_non_diagnostic(lines)
340340
if not lines or not parse_tap_header(lines):
341-
return TestResult(TestStatus.NO_TESTS, [], lines)
341+
return TestResult(TestStatus.FAILURE_TO_PARSE_TESTS, [], lines)
342342
expected_test_suite_num = parse_test_plan(lines)
343-
if not expected_test_suite_num:
343+
if expected_test_suite_num == 0:
344+
return TestResult(TestStatus.NO_TESTS, [], lines)
345+
elif expected_test_suite_num is None:
344346
return TestResult(TestStatus.FAILURE_TO_PARSE_TESTS, [], lines)
345347
test_suites = []
346348
for i in range(1, expected_test_suite_num + 1):

tools/testing/kunit/kunit_tool_test.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,18 @@ def test_parse_failed_test_log(self):
157157
kunit_parser.TestStatus.FAILURE,
158158
result.status)
159159

160+
def test_no_header(self):
161+
empty_log = test_data_path('test_is_test_passed-no_tests_run_no_header.log')
162+
with open(empty_log) as file:
163+
result = kunit_parser.parse_run_tests(
164+
kunit_parser.extract_tap_lines(file.readlines()))
165+
self.assertEqual(0, len(result.suites))
166+
self.assertEqual(
167+
kunit_parser.TestStatus.FAILURE_TO_PARSE_TESTS,
168+
result.status)
169+
160170
def test_no_tests(self):
161-
empty_log = test_data_path('test_is_test_passed-no_tests_run.log')
171+
empty_log = test_data_path('test_is_test_passed-no_tests_run_with_header.log')
162172
with open(empty_log) as file:
163173
result = kunit_parser.parse_run_tests(
164174
kunit_parser.extract_tap_lines(file.readlines()))
@@ -173,7 +183,7 @@ def test_no_kunit_output(self):
173183
with open(crash_log) as file:
174184
result = kunit_parser.parse_run_tests(
175185
kunit_parser.extract_tap_lines(file.readlines()))
176-
print_mock.assert_any_call(StrContains('no tests run!'))
186+
print_mock.assert_any_call(StrContains('could not parse test results!'))
177187
print_mock.stop()
178188
file.close()
179189

@@ -309,7 +319,7 @@ def test_crashed_test_json(self):
309319
result["sub_groups"][1]["test_cases"][0])
310320

311321
def test_no_tests_json(self):
312-
result = self._json_for('test_is_test_passed-no_tests_run.log')
322+
result = self._json_for('test_is_test_passed-no_tests_run_with_header.log')
313323
self.assertEqual(0, len(result['sub_groups']))
314324

315325
class StrContains(str):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
TAP version 14
2+
1..0

0 commit comments

Comments
 (0)