From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pavee Zheng Date: Sat, 05 Dec 2026 09:17:15 +0800 Subject: [PATCH 2/2] kunit: tool: Create missing build directory before build MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261205-patch-kunit-build-dir-v1-2-52d42f301f40@gmail.com> References: <20261205-patch-kunit-build-dir-v1-0-52d42f301f40@gmail.com> In-Reply-To: <20261205-patch-kunit-build-dir-v1-0-52d42f301f40@gmail.com> To: Brendan Higgins , David Gow Cc: Rae Moar , Shuah Khan , Ryota Sakamoto , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Pavee Zheng X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796433438; l=2338; i=pavee.zheng@gmail.com; s=20261203; h=from:subject:message-id; bh=IFDQc1NrqCKp21vrLIEIvRBlaaN6jaxFvAmjvQ19VHc=; b=xRemJuovD8y1a3ax65AaKLsLPIjGwofpXRck/CHmGyddBoCJ5GfXBnXKv42OQ0BcuplfELRa8 X7WUAB9YnXECk8GB+l3N1ZFPvvy73O77jXof0IQoOLHu28ZVe8+TdKH X-Developer-Key: i=pavee.zheng@gmail.com; a=ed25519; pk=tKWX/JHvHgKJscWsVefc3+t39eSysVDI8/ZkQl1Rlyo= X-Endpoint-Received: by B4 Relay for pavee.zheng@gmail.com/20261203 with auth_id=1729 List-Id: B4 Relay Submissions 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 --- 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) From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796433441; b=wj5bSrRLHEwqFdQUeSrviTnjKtx3MBd4ubpp5NYAtt3aNlC2Y0AnsBerSaCnOAm05T4V OnWvuhnz77kGMzrQYP3Ss/XDC6lHYiu/5p1bSIZF8PDCLV+EO4R8CyjXI0ezfgXfxcQjT EoKTfhlw0vrAWjwwg6yTolvU2hZ43hXNsAAdHa9WVUFM03plbAa37V2pJ4gjUBpVZWkl9 lHPhmC8LiUgUO5OLHLEuVsdhoOFoH6O9+dRRlN2nnDadJ6F3uTn0yzxWbJ9anHGcYZf8m +nig68Qy7ygAvSdPQRoRgQUMy1hbamOJLWKLXffNVqyfDoortNlEzQqfqonlVy+gctA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796433441; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=UQVCPSx/5YBl9I8Ng3p4h+QToxVVut5f11FQxjgsJ60=; b=ymKIEL3Kfi297eLEqkmA8k4LDOYPz+1C2EKsbu3pnE6iXq/lnSYM98vKFBr4DUjisM7L MLeXn3ZQy+VZuT2SfPDe8XAnCvX9pLdTfQXnV1Yvm6AbFF9c5urpbwYSqv09fRMt9JoRN 8uOW+I7uRkJagaXulW3r5Q4fpceHr27KQjM2M2gwk+nWkBdo572Jhgbd/qWLMU260mEJQ MaRvrk+MDzQdyy8lz0Wy2ZXUR20Di9jZ3UzRUGi+2n3JLHDRid76ukur9fPnIFpyyLYej gcCPJ1uGi9JQioQrOXnSFBjEcZFO8SJjaRf+eFR/Czx+N0SY5lv6/ZnoAK5oMxHHg2A== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gHdLlq58; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B9DE606A330; Sat, 5 Dec 2026 01:17:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gHdLlq58 Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796433441; b=cRUS+TEhqqo1uwyusaP6Q4mf7acqDCPU9iw5jEAsWaw8F73WQ8b35CLG7hKpM1xd6rjG mPWGeNwNbtiT7jiBKW3xIRsxhYbI1PO6hNjUtuufMWMrPXYuByTFVmenj3nLtjIb++eQN kUfA5MDu3ChJLQGRJ6wG9pdkAlXdfJaAAWt61VhCo3rm6YInNpd2lIElO/vwVJHypHTbW ERUpNk2tVsLLwMWOpx5p68sQ6bWtHyoeBkI4TQcPl+SoIysUUoXi83E50PCYznml85pA7 m4epJiusjv9/CfbDeqqEslxZZU7KmhorK6aWXZqPRXyRdlFI1rVmjfHwsNdlFuOkV3w== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796433441; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=UQVCPSx/5YBl9I8Ng3p4h+QToxVVut5f11FQxjgsJ60=; b=0NEkO19A+MZHj0L2/YsdiqwG7PFUqXrdT61O7Zkvin17AbCWceGi8a+dlXMTZQyxgQZq GkTyme3HjvDgMUNNvTpSIlsyf7J9WKmF9Njb1Abi+7JVIcHkukD+DcbW69rPyaA0AS+Pv wDKjvs6BEJXITRx9ciO491nk+uo0yqfZ43Cu17ZofmMMEAOG/RQIrznDL44jTjNGP3FG0 ZmMy6yB+a9K8BriJStlm1cnDQGPmuJq7BolkLfv2+EOWXRP/VgNswWuc3YHYPcUzEr3tA ssR8G3dGALXuWjGeoe6q693wsJGvE2LYDd6HbMrk/gKjxkCfoHqQQ2Ow9Nrz7wA6m6w== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 895801F00A06; Sat, 5 Dec 2026 01:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796433441; bh=UQVCPSx/5YBl9I8Ng3p4h+QToxVVut5f11FQxjgsJ60=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=gHdLlq58sZhMKCZPOswWanaPc+0EWmvEZVGa+qAgUhrFhxd35kILqJak/opnjGUJy LotCGa0DUJ/p4n+P/vESwgKoBzOxLJB0cnQXhfk/jJoNjdsxTnfTE6BgsYDphuGpYY F6e+92puUYFpCe1NgpilOcvmkb1EzVmPDNdCn8LcY8zhY2eBsUbIfcGCLXwxVpsovf pxPSIGv94gRY1cNy2Ice8xHj0lMAneAIeIwHLoQTwUTiwg6IVeEgNuCjqlER5grdy0 5my5iuSHaxmBSdIM8eRwlYkvtvnWIW7rmEkfWhYEyaoRnLJfZ4XEnL2SNsdoghCjfL ryZ8R5M5g5j3Q== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 197745010E; Sat, 5 Dec 2026 01:17:20 +0000 (UTC) From: Pavee Zheng via B4 Relay Date: Sat, 05 Dec 2026 09:17:15 +0800 Subject: [PATCH 2/2] kunit: tool: Create missing build directory before build X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261205-patch-kunit-build-dir-v1-2-52d42f301f40@gmail.com> References: <20261205-patch-kunit-build-dir-v1-0-52d42f301f40@gmail.com> In-Reply-To: <20261205-patch-kunit-build-dir-v1-0-52d42f301f40@gmail.com> To: Brendan Higgins , David Gow Cc: Rae Moar , Shuah Khan , Ryota Sakamoto , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Pavee Zheng X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796433438; l=2338; i=pavee.zheng@gmail.com; s=20261203; h=from:subject:message-id; bh=IFDQc1NrqCKp21vrLIEIvRBlaaN6jaxFvAmjvQ19VHc=; b=xRemJuovD8y1a3ax65AaKLsLPIjGwofpXRck/CHmGyddBoCJ5GfXBnXKv42OQ0BcuplfELRa8 X7WUAB9YnXECk8GB+l3N1ZFPvvy73O77jXof0IQoOLHu28ZVe8+TdKH X-Developer-Key: i=pavee.zheng@gmail.com; a=ed25519; pk=tKWX/JHvHgKJscWsVefc3+t39eSysVDI8/ZkQl1Rlyo= X-Endpoint-Received: by B4 Relay for pavee.zheng@gmail.com/20261203 with auth_id=1729 X-Original-From: Pavee Zheng Reply-To: pavee.zheng@gmail.com Content-Transfer-Encoding: 7bit From: Pavee Zheng 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 --- 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)