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.

kunit: tool: test: Don't rely on implicit working directory change

If no kunitconfig_paths are passed to LinuxSourceTree() it falls back to
DEFAULT_KUNITCONFIG_PATH. This resolution only works when the current
working directory is the root of the source tree. This works by chance
when running the full testsuite through the default unittest runner, as
some tests will change the current working directory as a side-effect of
'kunit.main()'. When running a single testcase or using pytest, which
resets the working directory for each test, this assumption breaks.

Explicitly specify an empty kunitconfig for the affected tests.

Link: https://lore.kernel.org/r/20260107015936.2316047-2-davidgow@google.com
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Thomas Weißschuh and committed by
Shuah Khan
f126d688 1cabad3a

+3 -2
+3 -2
tools/testing/kunit/kunit_tool_test.py
··· 477 477 want_kconfig = kunit_config.Kconfig() 478 478 want_kconfig.add_entry('NOT_REAL', 'y') 479 479 480 - tree = kunit_kernel.LinuxSourceTree('', kconfig_add=['CONFIG_NOT_REAL=y']) 480 + tree = kunit_kernel.LinuxSourceTree('', kunitconfig_paths=[os.devnull], 481 + kconfig_add=['CONFIG_NOT_REAL=y']) 481 482 self.assertTrue(want_kconfig.is_subset_of(tree._kconfig), msg=tree._kconfig) 482 483 483 484 def test_invalid_arch(self): ··· 490 489 return subprocess.Popen(['echo "hi\nbye"'], shell=True, text=True, stdout=subprocess.PIPE) 491 490 492 491 with tempfile.TemporaryDirectory('') as build_dir: 493 - tree = kunit_kernel.LinuxSourceTree(build_dir) 492 + tree = kunit_kernel.LinuxSourceTree(build_dir, kunitconfig_paths=[os.devnull]) 494 493 mock.patch.object(tree._ops, 'start', side_effect=fake_start).start() 495 494 496 495 with self.assertRaises(ValueError):