kunit update for Linux 7.2-rc1
Subsystems (9)
Shuah Khan
maintainerHi Linus,
Please pull this kunit update for Linux 7.2-rc1.
Fixes to tool and kunit core and new features to both to support JUnit XML (primitive) and backtrace suppression API:
- bug/kunit: Core support for suppressing warning backtraces
- kunit: tool: Parse and print the reason tests are skipped
- kunit: tool: Add (primitive) support for outputting JUnit XML
- kunit:tool: Don't write to stdout when it should be disabled
- kunit: Add backtrace suppression self-tests
- drm: Suppress intentional warning backtraces in scaling unit tests
- kunit: Add documentation for warning backtrace suppression API
- kunit: Fix spelling mistakes in comments and messages
- gen_compile_commands: Ignore libgcc.a
- kunit: qemu_configs: Add or1k / openrisc configuration
Please not that this update touches kernel/panic.c and lib/bug.c in backtrace suppression patches.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit 254f49634ee16a731174d2ae34bc50bd5f45e731:
Linux 7.1-rc1 (2026-04-26 14:19:00 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux_kselftest-kunit-7.2-rc1
for you to fetch changes up to 29afed142d64e181749214072315c976f8510bd7:
kunit:tool: Don't write to stdout when it should be disabled (2026-06-07 20:10:30 -0600)
----------------------------------------------------------------
linux_kselftest-kunit-7.2-rc1
Fixes to tool and kunit core and new features to both to support JUnit XML (primitive) and backtrace suppression API:
- bug/kunit: Core support for suppressing warning backtraces
- kunit: tool: Parse and print the reason tests are skipped
- kunit: tool: Add (primitive) support for outputting JUnit XML
- kunit:tool: Don't write to stdout when it should be disabled
- kunit: Add backtrace suppression self-tests
- drm: Suppress intentional warning backtraces in scaling unit tests
- kunit: Add documentation for warning backtrace suppression API
- kunit: Fix spelling mistakes in comments and messages
- gen_compile_commands: Ignore libgcc.a
- kunit: qemu_configs: Add or1k / openrisc configuration
----------------------------------------------------------------
Alessandro Carminati (1):
bug/kunit: Core support for suppressing warning backtraces
David Gow (3):
kunit: tool: Parse and print the reason tests are skipped
kunit: tool: Add (primitive) support for outputting JUnit XML kunit:tool: Don't write to stdout when it should be disabled
Guenter Roeck (3):
kunit: Add backtrace suppression self-tests
drm: Suppress intentional warning backtraces in scaling unit tests
kunit: Add documentation for warning backtrace suppression API
Jinseok Kim (1):
kunit: Fix spelling mistakes in comments and messages
Thomas Weißschuh (2):
gen_compile_commands: Ignore libgcc.a
kunit: qemu_configs: Add or1k / openrisc configuration
Documentation/dev-tools/kunit/run_wrapper.rst | 3 + Documentation/dev-tools/kunit/usage.rst | 46 +++++- drivers/gpu/drm/tests/drm_rect_test.c | 46 +++++- include/kunit/test-bug.h | 26 ++++ include/kunit/test.h | 98 +++++++++++++ kernel/panic.c | 11 ++ lib/bug.c | 14 +- lib/kunit/Makefile | 4 +- lib/kunit/backtrace-suppression-test.c | 198 ++++++++++++++++++++++++++ lib/kunit/bug.c | 120 ++++++++++++++++ lib/kunit/hooks-impl.h | 2 + scripts/clang-tools/gen_compile_commands.py | 2 + tools/testing/kunit/kunit.py | 21 ++- tools/testing/kunit/kunit_junit.py | 61 ++++++++ tools/testing/kunit/kunit_kernel.py | 2 +- tools/testing/kunit/kunit_parser.py | 29 ++-- tools/testing/kunit/kunit_tool_test.py | 56 +++++++- tools/testing/kunit/qemu_configs/or1k.py | 18 +++ 18 files changed, 730 insertions(+), 27 deletions(-) create mode 100644 lib/kunit/backtrace-suppression-test.c create mode 100644 lib/kunit/bug.c create mode 100644 tools/testing/kunit/kunit_junit.py create mode 100644 tools/testing/kunit/qemu_configs/or1k.py
----------------------------------------------------------------
Documentation/dev-tools/kunit/run_wrapper.rst +3 -0
@@ -324,6 +324,9 @@ command line arguments: - ``--json``: If set, stores the test results in a JSON format and prints to `stdout` or saves to a file if a filename is specified. +- ``--junit``: If set, stores the test results in JUnit XML format and prints to `stdout` or + saves to a file if a filename is specified. + - ``--filter``: Specifies filters on test attributes, for example, ``speed!=slow``. Multiple filters can be used by wrapping input in quotes and separating filters by commas. Example: ``--filter "speed>slow, module=example"``.
Documentation/dev-tools/kunit/usage.rst +45 -1
56 lines not on this page · raw message
drivers/gpu/drm/tests/drm_rect_test.c +40 -6
66 lines not on this page · raw message
include/kunit/test-bug.h +26 -0
@@ -10,6 +10,7 @@#define _KUNIT_TEST_BUG_H#include <linux/stddef.h> /* for NULL */ +#include <linux/types.h> /* for bool */ #if IS_ENABLED (CONFIG_KUNIT )
@@ -23,6 +24,7 @@ DECLARE_STATIC_KEY_FALSE(kunit_running);extern struct kunit_hooks_table { __printf(3, 4) void (*fail_current_test)(const char*, int, const char*, ...); void *(*get_static_stub_address)(struct kunit *test, void *real_fn_addr); +bool (*is_suppressed_warning)(bool count); } kunit_hooks;/**
@@ -60,9 +62,33 @@ static inline struct kunit *kunit_get_current_test(void) } \ }while (0 ) +/** +* kunit_is_suppressed_warning() - Check if warnings are being suppressed +* by the current KUnit test. +* @count: if true, increment the suppression counter on match. +* +* Returns true if the current task has active warning suppression. +* Uses the kunit_running static branch for zero overhead when no tests run. +* +* A single WARN*() may traverse multiple call sites in the warning path +* (e.g., __warn_printk() and __report_bug()). Pass @count = true at the +* primary suppression point to count each warning exactly once, and +* @count = false at secondary points to suppress output without +* inflating the count. +*/ +static inline bool kunit_is_suppressed_warning(bool count) +{ +if (!static_branch_unlikely (&kunit_running)) +return false; + +return kunit_hooks.is_suppressed_warning && + kunit_hooks.is_suppressed_warning (count); +} +#else static inline struct kunit *kunit_get_current_test (void ) {return NULL ; } +static inline bool kunit_is_suppressed_warning (bool count) {return false; }#define kunit_fail_current_test (fmt, ...) do {} while (0)
include/kunit/test.h +98 -0
102 lines not on this page · raw message
kernel/panic.c +11 -0
@@ -39,6 +39,7 @@#include <linux/sys_info.h> #include <trace/events/error_report.h> #include <asm/sections.h> +#include <kunit/test-bug.h> #define PANIC_TIMER_STEP 100#define PANIC_BLINK_SPD 18
@@ -1124,6 +1125,11 @@ void warn_slowpath_fmt(const char *file, int line, unsigned taint,bool rcu =warn_rcu_enter ();struct warn_args args; +if (kunit_is_suppressed_warning (true)) { +warn_rcu_exit (rcu); +return ; + } +pr_warn (CUT_HERE );if (!fmt) {
@@ -1146,6 +1152,11 @@ void __warn_printk(const char *fmt, ...)bool rcu =warn_rcu_enter ();va_list args; +if (kunit_is_suppressed_warning (false)) { +warn_rcu_exit (rcu); +return ; + } +pr_warn (CUT_HERE );va_start (args, fmt);
lib/bug.c +12 -2
@@ -48,6 +48,7 @@#include <linux/rculist.h> #include <linux/ftrace.h> #include <linux/context_tracking.h> +#include <kunit/test-bug.h> extern struct bug_entry __start___bug_table[], __stop___bug_table[];
@@ -209,8 +210,6 @@ static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long bugareturn BUG_TRAP_TYPE_NONE ; } -disable_trace_on_warning (); -bug_get_file_line (bug, &file, &line); fmt =bug_get_format (bug);
@@ -220,6 +219,17 @@ static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long buga no_cut = bug->flags &BUGFLAG_NO_CUT_HERE ; has_args = bug->flags &BUGFLAG_ARGS ; +#ifdef CONFIG_KUNIT +/* +* Before the once logic so suppressed warnings do not consume +* the single-fire budget of WARN_ON_ONCE(). +*/ +if (warning &&kunit_is_suppressed_warning (true)) +return BUG_TRAP_TYPE_WARN ; +#endif + +disable_trace_on_warning (); +if (warning && once) {if (done)return BUG_TRAP_TYPE_WARN ;
lib/kunit/Makefile +3 -1
@@ -10,7 +10,8 @@ kunit-objs += test.o \ executor.o \ attributes.o \ device.o \ - platform.o + platform.o \ + bug.o ifeq ($(CONFIG_KUNIT_DEBUGFS),y) kunit-objs += debugfs.o
@@ -21,6 +22,7 @@ obj-$(if $(CONFIG_KUNIT),y) += hooks.o obj-$(CONFIG_KUNIT_TEST) += kunit-test.o obj-$(CONFIG_KUNIT_TEST) += platform-test.o +obj-$(CONFIG_KUNIT_TEST) += backtrace-suppression-test.o # string-stream-test compiles built-in only. ifeq ($(CONFIG_KUNIT_TEST),y)
lib/kunit/backtrace-suppression-test.c new file +198 -0
198 lines not on this page · raw message
lib/kunit/bug.c new file +120 -0
120 lines not on this page · raw message
lib/kunit/hooks-impl.h +2 -0
@@ -19,6 +19,7 @@ void __printf(3, 4) __kunit_fail_current_test_impl(const char *file,int line, const char *fmt, ...);void *__kunit_get_static_stub_address_impl (struct kunit *test,void *real_fn_addr); +bool __kunit_is_suppressed_warning_impl (bool count);/* Code to set all of the function pointers. */ static inline void kunit_install_hooks (void )
@@ -26,6 +27,7 @@ static inline void kunit_install_hooks(void)/* Install the KUnit hook functions. */ kunit_hooks.fail_current_test = __kunit_fail_current_test_impl; kunit_hooks.get_static_stub_address = __kunit_get_static_stub_address_impl; + kunit_hooks.is_suppressed_warning = __kunit_is_suppressed_warning_impl; }#endif /* _KUNIT_HOOKS_IMPL_H */
scripts/clang-tools/gen_compile_commands.py +2 -0
@@ -201,6 +201,8 @@ def main(): # Modules are listed in modules.order. if os.path.isdir(path): cmdfiles = cmdfiles_in_dir(path) + elif os.path.basename(path) == 'libgcc.a': + cmdfiles = [] elif path.endswith('.a'): cmdfiles = cmdfiles_for_a(path, ar) elif path.endswith('modules.order'):
tools/testing/kunit/kunit.py +20 -1
@@ -21,6 +21,7 @@ from enum import Enum, auto from typing import Iterable, List, Optional, Sequence, Tuple import kunit_json +import kunit_junit import kunit_kernel import kunit_parser from kunit_printer import stdout, null_printer
@@ -49,6 +50,7 @@ class KunitBuildRequest(KunitConfigRequest): class KunitParseRequest: raw_output: Optional[str] json: Optional[str] + junit: Optional[str] summary: bool failed: bool
@@ -268,6 +270,13 @@ def parse_tests(request: KunitParseRequest, metadata: kunit_json.Metadata, input stdout.print_with_timestamp("Test results stored in %s" % os.path.abspath(request.json)) + if request.junit: + if request.junit == 'stdout': + kunit_junit.print_junit_result(test=test) + else: + kunit_junit.write_junit_result(test=test,filename=request.junit) + stdout.print_with_timestamp(f"Test results stored in {os.path.abspath(request.junit)}") + if test.status != kunit_parser.TestStatus.SUCCESS: return KunitResult(KunitStatus.TEST_FAILURE, parse_time), test
@@ -309,6 +318,7 @@ def run_tests(linux: kunit_kernel.LinuxSourceTree, # So we hackily automatically rewrite --json => --json=stdout pseudo_bool_flag_defaults = { '--json': 'stdout', + '--junit': 'stdout', '--raw_output': 'kunit', } def massage_argv(argv: Sequence[str]) -> Sequence[str]:
@@ -459,6 +469,11 @@ def add_parse_opts(parser: argparse.ArgumentParser) -> None: help='Prints parsed test results as JSON to stdout or a file if ' 'a filename is specified. Does nothing if --raw_output is set.', type=str, const='stdout', default=None, metavar='FILE') + parser.add_argument('--junit', + nargs='?', + help='Prints parsed test results as JUnit XML to stdout or a file if ' + 'a filename is specified. Does nothing if --raw_output is set.', + type=str, const='stdout', default=None, metavar='FILE') parser.add_argument('--summary', help='Prints only the summary line for parsed test results.' 'Does nothing if --raw_output is set.',
@@ -502,6 +517,7 @@ def run_handler(cli_args: argparse.Namespace) -> None: jobs=cli_args.jobs, raw_output=cli_args.raw_output, json=cli_args.json, + junit=cli_args.junit, summary=cli_args.summary, failed=cli_args.failed, timeout=cli_args.timeout,
@@ -552,6 +568,7 @@ def exec_handler(cli_args: argparse.Namespace) -> None: exec_request = KunitExecRequest(raw_output=cli_args.raw_output, build_dir=cli_args.build_dir, json=cli_args.json, + junit=cli_args.junit, summary=cli_args.summary, failed=cli_args.failed, timeout=cli_args.timeout,
@@ -580,7 +597,9 @@ def parse_handler(cli_args: argparse.Namespace) -> None: # We know nothing about how the result was created! metadata = kunit_json.Metadata() request = KunitParseRequest(raw_output=cli_args.raw_output, - json=cli_args.json, summary=cli_args.summary, + json=cli_args.json, + junit=cli_args.junit, + summary=cli_args.summary, failed=cli_args.failed) result, _ = parse_tests(request, metadata, kunit_output) if result.status != KunitStatus.SUCCESS:
tools/testing/kunit/kunit_junit.py new file +61 -0
61 lines not on this page · raw message
tools/testing/kunit/kunit_kernel.py +1 -1
@@ -218,7 +218,7 @@ def _get_qemu_ops(config_path: str, # exists (I learned this through experimentation and could not find it # anywhere in the Python documentation). # - # Bascially, we completely ignore the actual file location of the config + # Basically, we completely ignore the actual file location of the config # we are loading and just tell Python that the module lives in the # QEMU_CONFIGS_DIR for import purposes regardless of where it actually # exists as a file.
tools/testing/kunit/kunit_parser.py +17 -12
@@ -17,7 +17,7 @@ import textwrap from enum import Enum, auto from typing import Iterable, Iterator, List, Optional, Tuple -from kunit_printer import Printer, stdout +from kunit_printer import Printer class Test: """
@@ -44,11 +44,12 @@ class Test: self.subtests = [] # type: List[Test] self.log = [] # type: List[str] self.counts = TestCounts() + self.skip_reason = '' def __str__(self) -> str: """Returns string representation of a Test class object.""" return (f'Test({self.status}, {self.name}, {self.expected_count}, ' - f'{self.subtests}, {self.log}, {self.counts})') + f'{self.subtests}, {self.log}, {self.counts}, {self.skip_reason})') def __repr__(self) -> str: """Returns string representation of a Test class object."""
@@ -57,7 +58,7 @@ class Test: def add_error(self, printer: Printer, error_message: str) -> None: """Records an error that occurred while parsing this test.""" self.counts.errors += 1 - printer.print_with_timestamp(stdout.red('[ERROR]') + f' Test: {self.name}: {error_message}') + printer.print_with_timestamp(printer.red('[ERROR]') + f' Test: {self.name}: {error_message}') def ok_status(self) -> bool: """Returns true if the status was ok, i.e. passed or skipped."""
@@ -268,7 +269,7 @@ def check_version(version_num: int, accepted_versions: List[int], if version_num < min(accepted_versions): test.add_error(printer, f'{version_type} version lower than expected!') elif version_num > max(accepted_versions): - test.add_error(printer, f'{version_type} version higer than expected!') + test.add_error(printer, f'{version_type} version higher than expected!') def parse_ktap_header(lines: LineStream, test: Test, printer: Printer) -> bool: """
@@ -352,9 +353,9 @@ def parse_test_plan(lines: LineStream, test: Test) -> bool: lines.pop() return True -TEST_RESULT = re.compile(r'^\s*(ok|not ok) ([0-9]+) ?(- )?([^#]*)( # .*)?$') +TEST_RESULT = re.compile(r'^\s*(ok|not ok) ([0-9]+) ?(:?- )?([^#]*)( # .*)?$') -TEST_RESULT_SKIP = re.compile(r'^\s*(ok|not ok) ([0-9]+) ?(- )?(.*) # SKIP ?(.*)$') +TEST_RESULT_SKIP = re.compile(r'^\s*(ok|not ok) ([0-9]+) ?(:?- )?(.*) # SKIP ?(.*)$') def peek_test_name_match(lines: LineStream, test: Test) -> bool: """
@@ -418,7 +419,7 @@ def parse_test_result(lines: LineStream, test: Test, # Set name of test object if skip_match: - test.name = skip_match.group(4) or skip_match.group(5) + test.name = skip_match.group(4) else: test.name = match.group(4)
@@ -431,6 +432,7 @@ def parse_test_result(lines: LineStream, test: Test, status = match.group(1) if skip_match: test.status = TestStatus.SKIPPED + test.skip_reason = skip_match.group(5) or '' elif status == 'ok': test.status = TestStatus.SUCCESS else:
@@ -539,12 +541,15 @@ def format_test_result(test: Test, printer: Printer) -> str: if test.status == TestStatus.SUCCESS: return printer.green('[PASSED] ') + test.name if test.status == TestStatus.SKIPPED: - return printer.yellow('[SKIPPED] ') + test.name + skip_message = printer.yellow('[SKIPPED] ') + test.name + if test.skip_reason != '': + skip_message += printer.yellow(' (' + test.skip_reason + ')') + return skip_message if test.status == TestStatus.NO_TESTS: return printer.yellow('[NO TESTS RUN] ') + test.name if test.status == TestStatus.TEST_CRASHED: print_log(test.log, printer) - return stdout.red('[CRASHED] ') + test.name + return printer.red('[CRASHED] ') + test.name print_log(test.log, printer) return printer.red('[FAILED] ') + test.name
@@ -651,11 +656,11 @@ def print_summary_line(test: Test, printer: Printer) -> None: printer - Printer object to output results """ if test.status == TestStatus.SUCCESS: - color = stdout.green + color = printer.green elif test.status in (TestStatus.SKIPPED, TestStatus.NO_TESTS): - color = stdout.yellow + color = printer.yellow else: - color = stdout.red + color = printer.red printer.print_with_timestamp(color(f'Testing complete. {test.counts}')) # Summarize failures that might have gone off-screen since we had a lot
tools/testing/kunit/kunit_tool_test.py +53 -3
96 lines not on this page · raw message
tools/testing/kunit/qemu_configs/or1k.py new file +18 -0
@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-only +from ..qemu_config import QemuArchParams + +QEMU_ARCH = QemuArchParams(linux_arch='openrisc', + kconfig=''' +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_POWER_RESET=y +CONFIG_POWER_RESET_SYSCON=y +''', + qemu_arch='or1k', + kernel_path='vmlinux', + kernel_command_line='console=ttyS0', + extra_qemu_params=[ + '-machine', 'virt', + '-m', '512', + ])
The pull request you sent on Mon, 15 Jun 2026 10:36:10 -0600:
The pull request you sent on Mon, 15 Jun 2026 10:36:10 -0600:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftesttags/linux_kselftest-kunit-7.2-rc1
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/42eb3a5ef6bc56192bf450c79a3f274e081f8131
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html