Skip to contentSkip to conversation

kunit fixes update for Linux 7.0-rc3

GIT PULL Merged Shuah Khan 3 participants 4 messages Mar 6

Subsystems (3)
lore
Share & tools
lore

Shuah Khan

author maintainer
#0 lore raw

Hi Linus,

Please pull the following kunit fixes update for Linux 7.0-rc3.

kunit:
- Fixes rust warnings when CONFIG_PRINTK is disabled.
- Reduces stack usage in kunit_run_tests() to fix warnings when CONFIG_FRAME_WARN is set to a relatively low value.
- Updates email address for David Gow.

kunit tool:
- Copies caller args in run_kernel to prevent mutation.

Passed my repo sanity testing. x64_64 tests crash on mainline and my repo because of a known issue - fix is in next-20260302?

Hope it gets into mainline soon.

- https://lore.kernel.org/all/20260226-ungeziefer-erzfeind-13425179c7b2@brauner/

diff is attached.

thanks,
-- Shuah

----------------------------------------------------------------
The following changes since commit 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f:

Linux 7.0-rc1 (2026-02-22 13:18:59 -0800)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux_kselftest-kunit-fixes-7.0-rc3

for you to fetch changes up to b11b9b6751b2cd74960dccd91667c5117fce743c:

kunit: reduce stack usage in kunit_run_tests() (2026-03-02 10:11:06 -0700)

----------------------------------------------------------------
linux_kselftest-kunit-fixes-7.0-rc3

kunit:
- Fixes rust warnings when CONFIG_PRINTK is disabled.
- Reduces stack usage in kunit_run_tests() to fix warnings when CONFIG_FRAME_WARN is set to a relatively low value.
- Updates email address for David Gow.

kunit tool:
- Copies caller args in run_kernel to prevent mutation.

----------------------------------------------------------------
Alexandre Courbot (1):
rust: kunit: fix warning when !CONFIG_PRINTK

Arnd Bergmann (1):
kunit: reduce stack usage in kunit_run_tests()

David Gow (1):
MAINTAINERS: Update email address for David Gow

Shuvam Pandey (1):
kunit: tool: copy caller args in run_kernel to prevent mutation

 .mailmap                               |   1 +
 MAINTAINERS                            |   4 +-
 lib/kunit/test.c                       | 231 ++++++++++++++++++---------------
 rust/kernel/kunit.rs                   |   8 ++
 tools/testing/kunit/kunit_kernel.py    |   6 +-
 tools/testing/kunit/kunit_tool_test.py |  26 ++++
 6 files changed, 166 insertions(+), 110 deletions(-)

----------------------------------------------------------------

.mailmap +1 -0
index e1cf6bb85d33..7d27cd78cfdb 100644
@@ -214,6 +214,7 @@ Daniel Thompson <[email protected]> <[email protected]>
 Danilo Krummrich <[email protected]> <[email protected]>
 David Brownell <[email protected]>
 David Collins <[email protected]> <[email protected]>
+David Gow <[email protected]> <[email protected]>
 David Heidelberg <[email protected]> <[email protected]>
 David Hildenbrand <[email protected]> <[email protected]>
 David Rheinsberg <[email protected]> <[email protected]>
MAINTAINERS +2 -2
index 55af015174a5..372ee16c24f5 100644
@@ -13943,7 +13943,7 @@ F:	fs/smb/server/
 
 KERNEL UNIT TESTING FRAMEWORK (KUnit)
 M:	Brendan Higgins <[email protected]>
-M:	David Gow <[email protected]>
+M:	David Gow <[email protected]>
 R:	Rae Moar <[email protected]>
 L:	[email protected]
 L:	[email protected]
@@ -14763,7 +14763,7 @@ F:	drivers/misc/lis3lv02d/
 F:	drivers/platform/x86/hp/hp_accel.c
 
 LIST KUNIT TEST
-M:	David Gow <[email protected]>
+M:	David Gow <[email protected]>
 L:	[email protected]
 L:	[email protected]
 S:	Maintained
lib/kunit/test.c +125 -106

289 lines not on this page · raw message

rust/kernel/kunit.rs +8 -0
index f93f24a60bdd..a1edf7491579 100644
@@ -14,6 +14,10 @@
 /// Public but hidden since it should only be used from KUnit generated code.
 #[doc(hidden)]
 pub fn err(args: fmt::Arguments<'_>) {
+    // `args` is unused if `CONFIG_PRINTK` is not set - this avoids a build-time warning.
+    #[cfg(not(CONFIG_PRINTK))]
+    let _ = args;
+
     // SAFETY: The format string is null-terminated and the `%pA` specifier matches the argument we
     // are passing.
     #[cfg(CONFIG_PRINTK)]
@@ -30,6 +34,10 @@ pub fn err(args: fmt::Arguments<'_>) {
 /// Public but hidden since it should only be used from KUnit generated code.
 #[doc(hidden)]
 pub fn info(args: fmt::Arguments<'_>) {
+    // `args` is unused if `CONFIG_PRINTK` is not set - this avoids a build-time warning.
+    #[cfg(not(CONFIG_PRINTK))]
+    let _ = args;
+
     // SAFETY: The format string is null-terminated and the `%pA` specifier matches the argument we
     // are passing.
     #[cfg(CONFIG_PRINTK)]
tools/testing/kunit/kunit_kernel.py +4 -2
index 260d8d9aa1db..2998e1bc088b 100644
@@ -346,8 +346,10 @@ class LinuxSourceTree:
 		return self.validate_config(build_dir)
 
 	def run_kernel(self, args: Optional[List[str]]=None, build_dir: str='', filter_glob: str='', filter: str='', filter_action: Optional[str]=None, timeout: Optional[int]=None) -> Iterator[str]:
-		if not args:
-			args = []
+		# Copy to avoid mutating the caller-supplied list. exec_tests() reuses
+		# the same args across repeated run_kernel() calls (e.g. --run_isolated),
+		# so appending to the original would accumulate stale flags on each call.
+		args = list(args) if args else []
 		if filter_glob:
 			args.append('kunit.filter_glob=' + filter_glob)
 		if filter:
tools/testing/kunit/kunit_tool_test.py +26 -0
index b67408147c1f..f6383884c599 100755
@@ -503,6 +503,32 @@ class LinuxSourceTreeTest(unittest.TestCase):
 			with open(kunit_kernel.get_outfile_path(build_dir), 'rt') as outfile:
 				self.assertEqual(outfile.read(), 'hi\nbye\n', msg='Missing some output')
 
+	def test_run_kernel_args_not_mutated(self):
+		"""Verify run_kernel() copies args so callers can reuse them."""
+		start_calls = []
+
+		def fake_start(start_args, unused_build_dir):
+			start_calls.append(list(start_args))
+			return subprocess.Popen(['printf', 'KTAP version 1\n'],
+						text=True, stdout=subprocess.PIPE)
+
+		with tempfile.TemporaryDirectory('') as build_dir:
+			tree = kunit_kernel.LinuxSourceTree(build_dir,
+					kunitconfig_paths=[os.devnull])
+			with mock.patch.object(tree._ops, 'start', side_effect=fake_start), \
+			     mock.patch.object(kunit_kernel.subprocess, 'call'):
+				kernel_args = ['mem=1G']
+				for _ in tree.run_kernel(args=kernel_args, build_dir=build_dir,
+							 filter_glob='suite.test1'):
+					pass
+				for _ in tree.run_kernel(args=kernel_args, build_dir=build_dir,
+							 filter_glob='suite.test2'):
+					pass
+				self.assertEqual(kernel_args, ['mem=1G'],
+					'run_kernel() should not modify caller args')
+				self.assertIn('kunit.filter_glob=suite.test1', start_calls[0])
+				self.assertIn('kunit.filter_glob=suite.test2', start_calls[1])
+
 	def test_build_reconfig_no_config(self):
 		with tempfile.TemporaryDirectory('') as build_dir:
 			with open(kunit_kernel.get_kunitconfig_path(build_dir), 'w') as f:
author maintainer
#2 lore raw
Quoted 5 lines · Linus Torvalds
Quoted 4 lines · Shuah Khan

Passed my repo sanity testing. x64_64 tests crash on mainline and my repo because of a known issue - fix is in next-20260302?

Quoted 7 lines
Quoted 3 lines

Hope it gets into mainline soon.

- https://lore.kernel.org/all/20260226-ungeziefer-erzfeind-13425179c7b2@brauner/

Already merged as commit 28aaa9c39945 ("kthread: consolidate kthread exit paths to prevent use-after-free")

Thank you.

-- Shuah

merge bot Merged
#3 lore raw
In reply to Shuah Khan
The pull request you sent on Fri, 6 Mar 2026 13:30:47 -0700:

The pull request you sent on Fri, 6 Mar 2026 13:30:47 -0700:

Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux_kselftest-kunit-fixes-7.0-rc3

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/3593e678f5e8b21b8f54b4267027bd55b19cb7b8

Thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html