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.

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

+24 -22
+1 -13
Documentation/dev-tools/kunit/running_tips.rst
··· 86 86 .. note:: 87 87 TODO(brendanhiggins@google.com): There are various issues with UML and 88 88 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(brendanhiggins@google.com): 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. 102 90 103 91 This is different from the "normal" way of getting coverage information that is 104 92 documented in Documentation/dev-tools/gcov.rst.
+2
tools/testing/kunit/kunit.py
··· 12 12 import os 13 13 import time 14 14 15 + assert sys.version_info >= (3, 7), "Python version is too old" 16 + 15 17 from collections import namedtuple 16 18 from enum import Enum, auto 17 19
+2 -4
tools/testing/kunit/kunit_kernel.py
··· 6 6 # Author: Felix Guo <felixguoxiuping@gmail.com> 7 7 # Author: Brendan Higgins <brendanhiggins@google.com> 8 8 9 - from __future__ import annotations 10 9 import importlib.util 11 10 import logging 12 11 import subprocess 13 12 import os 14 13 import shutil 15 14 import signal 16 - from typing import Iterator 17 - from typing import Optional 15 + from typing import Iterator, Optional, Tuple 18 16 19 17 from contextlib import ExitStack 20 18 ··· 206 208 raise ConfigError(arch + ' is not a valid arch') 207 209 208 210 def get_source_tree_ops_from_qemu_config(config_path: str, 209 - cross_compile: Optional[str]) -> tuple[ 211 + cross_compile: Optional[str]) -> Tuple[ 210 212 str, LinuxSourceTreeOperations]: 211 213 # The module name/path has very little to do with where the actual file 212 214 # exists (I learned this through experimentation and could not find it
+4 -2
tools/testing/kunit/kunit_parser.py
··· 338 338 def parse_test_result(lines: LineStream) -> TestResult: 339 339 consume_non_diagnostic(lines) 340 340 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) 342 342 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: 344 346 return TestResult(TestStatus.FAILURE_TO_PARSE_TESTS, [], lines) 345 347 test_suites = [] 346 348 for i in range(1, expected_test_suite_num + 1):
+13 -3
tools/testing/kunit/kunit_tool_test.py
··· 157 157 kunit_parser.TestStatus.FAILURE, 158 158 result.status) 159 159 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 + 160 170 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') 162 172 with open(empty_log) as file: 163 173 result = kunit_parser.parse_run_tests( 164 174 kunit_parser.extract_tap_lines(file.readlines())) ··· 183 173 with open(crash_log) as file: 184 174 result = kunit_parser.parse_run_tests( 185 175 kunit_parser.extract_tap_lines(file.readlines())) 186 - print_mock.assert_any_call(StrContains('no tests run!')) 176 + print_mock.assert_any_call(StrContains('could not parse test results!')) 187 177 print_mock.stop() 188 178 file.close() 189 179 ··· 319 309 result["sub_groups"][1]["test_cases"][0]) 320 310 321 311 def test_no_tests_json(self): 322 - result = self._json_for('test_is_test_passed-no_tests_run.log') 312 + result = self._json_for('test_is_test_passed-no_tests_run_with_header.log') 323 313 self.assertEqual(0, len(result['sub_groups'])) 324 314 325 315 class StrContains(str):
tools/testing/kunit/test_data/test_is_test_passed-no_tests_run.log tools/testing/kunit/test_data/test_is_test_passed-no_tests_run_no_header.log
+2
tools/testing/kunit/test_data/test_is_test_passed-no_tests_run_with_header.log
··· 1 + TAP version 14 2 + 1..0