From: David Gow <davidgow@google.com>
To: shuah@kernel.org,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
"Brendan Higgins" <brendan.higgins@linux.dev>,
"Rae Moar" <raemoar63@gmail.com>
Cc: linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com,
linux-kernel@vger.kernel.org, David Gow <davidgow@google.com>
Subject: [PATCH v2 2/2] kunit: tool: test: Don't rely on implicit working directory change
Date: Wed, 7 Jan 2026 09:59:34 +0800 [thread overview]
Message-ID: <20260107015936.2316047-2-davidgow@google.com> (raw)
In-Reply-To: <20260107015936.2316047-1-davidgow@google.com>
From: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
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.
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>
---
Changes since v1:
https://lore.kernel.org/linux-kselftest/20251230-kunit-pytest-v1-2-e2dae0dae200@linutronix.de/
- No-op rebase on top of kselftest/kunit
---
tools/testing/kunit/kunit_tool_test.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py
index 30ac1cb6c8ed..238a31a5cc29 100755
--- a/tools/testing/kunit/kunit_tool_test.py
+++ b/tools/testing/kunit/kunit_tool_test.py
@@ -477,7 +477,8 @@ class LinuxSourceTreeTest(unittest.TestCase):
want_kconfig = kunit_config.Kconfig()
want_kconfig.add_entry('NOT_REAL', 'y')
- tree = kunit_kernel.LinuxSourceTree('', kconfig_add=['CONFIG_NOT_REAL=y'])
+ tree = kunit_kernel.LinuxSourceTree('', kunitconfig_paths=[os.devnull],
+ kconfig_add=['CONFIG_NOT_REAL=y'])
self.assertTrue(want_kconfig.is_subset_of(tree._kconfig), msg=tree._kconfig)
def test_invalid_arch(self):
@@ -489,7 +490,7 @@ class LinuxSourceTreeTest(unittest.TestCase):
return subprocess.Popen(['echo "hi\nbye"'], shell=True, text=True, stdout=subprocess.PIPE)
with tempfile.TemporaryDirectory('') as build_dir:
- tree = kunit_kernel.LinuxSourceTree(build_dir)
+ tree = kunit_kernel.LinuxSourceTree(build_dir, kunitconfig_paths=[os.devnull])
mock.patch.object(tree._ops, 'start', side_effect=fake_start).start()
with self.assertRaises(ValueError):
--
2.52.0.351.gbe84eed79e-goog
next prev parent reply other threads:[~2026-01-07 1:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-07 1:59 [PATCH v2 1/2] kunit: tool: test: Rename test_data_path() to _test_data_path() David Gow
2026-01-07 1:59 ` David Gow [this message]
2026-01-07 17:28 ` [PATCH v2 2/2] kunit: tool: test: Don't rely on implicit working directory change Shuah Khan
2026-01-07 17:28 ` [PATCH v2 1/2] kunit: tool: test: Rename test_data_path() to _test_data_path() Shuah Khan
-- strict thread matches above, loose matches on Subject: below --
2026-01-07 12:51 [PATCH v2 0/2] kunit: tool: test: Allow running with pytest Thomas Weißschuh
2026-01-07 12:51 ` [PATCH v2 2/2] kunit: tool: test: Don't rely on implicit working directory change Thomas Weißschuh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260107015936.2316047-2-davidgow@google.com \
--to=davidgow@google.com \
--cc=brendan.higgins@linux.dev \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=raemoar63@gmail.com \
--cc=shuah@kernel.org \
--cc=thomas.weissschuh@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox