mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavee Zheng via B4 Relay <devnull+pavee.zheng.gmail.com@kernel.org>
To: Brendan Higgins <brendan.higgins@linux.dev>,
	 David Gow <david@davidgow.net>
Cc: Rae Moar <raemoar63@gmail.com>,
	Shuah Khan <skhan@linuxfoundation.org>,
	 Ryota Sakamoto <sakamo.ryota@gmail.com>,
	linux-kselftest@vger.kernel.org,  kunit-dev@googlegroups.com,
	linux-kernel@vger.kernel.org,
	 Pavee Zheng <pavee.zheng@gmail.com>
Subject: [PATCH 2/2] kunit: tool: Create missing build directory before build
Date: Sat, 05 Dec 2026 09:17:15 +0800	[thread overview]
Message-ID: <20261205-patch-kunit-build-dir-v1-2-52d42f301f40@gmail.com> (raw)
In-Reply-To: <20261205-patch-kunit-build-dir-v1-0-52d42f301f40@gmail.com>

From: Pavee Zheng <pavee.zheng@gmail.com>

Commit 1ee2ba89bea8 ("kunit: tool: make `build` subcommand also
reconfigure if needed") made kunit.py build run configuration before
building, so it can be used standalone without first running
kunit.py config. However, unlike run_handler() and config_handler(),
build_handler() does not create build_dir before calling
tree_from_args(). Because LinuxSourceTree.__init__() copies the default
.kunitconfig into build_dir when no --kunitconfig is given, running
kunit.py build on a clean checkout or with a non-existent build
directory fails with FileNotFoundError before configuring or building
the kernel.

Create cli_args.build_dir with os.makedirs(..., exist_ok=True) when
non-empty in build_handler() before calling tree_from_args(), matching
config_handler(). Extend test_commands_create_nested_builddir to cover
the build subcommand.

Fixes: 1ee2ba89bea8 ("kunit: tool: make `build` subcommand also reconfigure if needed")
Signed-off-by: Pavee Zheng <pavee.zheng@gmail.com>
---
 tools/testing/kunit/kunit.py           | 3 +++
 tools/testing/kunit/kunit_tool_test.py | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py
index 5070a831e4e8..312e184f1a52 100755
--- a/tools/testing/kunit/kunit.py
+++ b/tools/testing/kunit/kunit.py
@@ -564,6 +564,9 @@ def config_handler(cli_args: argparse.Namespace) -> None:
 
 
 def build_handler(cli_args: argparse.Namespace) -> None:
+	if cli_args.build_dir:
+		os.makedirs(cli_args.build_dir, exist_ok=True)
+
 	linux = tree_from_args(cli_args)
 	request = KunitBuildRequest(build_dir=cli_args.build_dir,
 					make_options=cli_args.make_options,
diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py
index 95809cdec7d2..921907c5771a 100755
--- a/tools/testing/kunit/kunit_tool_test.py
+++ b/tools/testing/kunit/kunit_tool_test.py
@@ -901,7 +901,7 @@ class KUnitMainTest(unittest.TestCase):
 
 		self.mock_linux_init.side_effect = init_linux
 		with tempfile.TemporaryDirectory() as tmpdir:
-			for command in ('config', 'run'):
+			for command in ('config', 'build', 'run'):
 				with self.subTest(command=command):
 					self.mock_linux_init.reset_mock()
 					build_dir = os.path.join(tmpdir, command, 'arm64')

-- 
Git-157)



      parent reply	other threads:[~2026-12-05  1:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  1:17 [PATCH 0/2] kunit: tool: Create missing build directories and parents Pavee Zheng via B4 Relay
2026-12-05  1:17 ` [PATCH 1/2] kunit: tool: Create missing parent directories for build_dir Pavee Zheng via B4 Relay
2026-12-05  1:17 ` Pavee Zheng via B4 Relay [this message]

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=20261205-patch-kunit-build-dir-v1-2-52d42f301f40@gmail.com \
    --to=devnull+pavee.zheng.gmail.com@kernel.org \
    --cc=brendan.higgins@linux.dev \
    --cc=david@davidgow.net \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pavee.zheng@gmail.com \
    --cc=raemoar63@gmail.com \
    --cc=sakamo.ryota@gmail.com \
    --cc=skhan@linuxfoundation.org \
    /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

all inboxes | Powered by JetHome®