From nobody Tue Apr 7 02:33:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F2033E0233 for ; Mon, 16 Mar 2026 18:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686452; cv=none; b=gzlran5Ju0GdngbReDQ9uFugr1QHT+PCV7UMwz7TygFk1EEygzvG3BluZ+qQ7E7SYvVKQ1PtKkqGc0DGFNdE30CDsImWO3+1wf5yAgxT7tfSkQ9X6NiC1XbHlCpNr8z4dGObDDL8hKxSPdXYCGJE4z1eFden6IfteC25k1H7ZRs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686452; c=relaxed/simple; bh=185RqqWcCOnKuq5ZXnAXkFRu6tv+tRMLZcuB2gTRoWE=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=pvEYpwJ+nupYaSQbcWwsGmb0ds0liJsMr6geUEeCvTOWU717g4CAaswBpkygXa1hQAqXC4HvtEZfxdIcur/puSqf3WVJg+rpVQq/i8GT7FzmE98n0qAfeH5KNRDKdr9fJILP8dGJBRDWZHRJJs/i5+2wIPZbhsKY/chb54Ed7H8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Kvp1AYgr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Kvp1AYgr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9C9CC2BCAF; Mon, 16 Mar 2026 18:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773686451; bh=185RqqWcCOnKuq5ZXnAXkFRu6tv+tRMLZcuB2gTRoWE=; h=Date:From:To:Cc:Subject:References:From; b=Kvp1AYgryLe52qCi6a2dueUVgWbWil7kuGet10LTEEWR7Ak7iYeb+7MqtjJfkQsb2 AEaEnYbWJZGbRiO0a64C45rincnazPDXArbLwyNQVpugCEdTNAsJEbKWLCN+cU5NE7 CfZ6KbOo/kzDaY/Y+ThGIerAQDA99Aol0A9ECBh1aKSM9gxCt2lchqOaJhArzOhyP4 oqrOAHizR4+xeTrjhmtAPGU55RQ4QTs/INbDSaqlXeUmRANQ5VMAhbFzCVQbTeJ+th tbyk5B7t7/aLoWX1VOMWNKJP4hxO179sLKYMnMGzLpsfbJxqDDox0xoqeZjRfJg8At mzkz+0FdtXkIA== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1w2CsN-0000000851y-3iAx; Mon, 16 Mar 2026 14:41:15 -0400 Message-ID: <20260316184115.741900299@kernel.org> User-Agent: quilt/0.69 Date: Mon, 16 Mar 2026 14:40:34 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: "John Warthog9 Hawley" , =?UTF-8?q?Ricardo=20B.=20Marli=C3=A8re?= , John Hawley , Andrea Righi , Marcos Paulo de Souza , Matthieu Baerts , Fernando Fernandez Mancera , Pedro Falcato Subject: [for-next][PATCH 1/9] ktest: Avoid undef warning when WARNINGS_FILE is unset References: <20260316184033.927944169@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Ricardo=3D20B=3D2E=3D20Marli=3DC3=3DA8re?=3D check_buildlog() probes $warnings_file with -f even when WARNINGS_FILE is not configured. Perl warns about the uninitialized value and adds noise to the test log, which can hide the output we actually care about. Check that WARNINGS_FILE is defined before testing whether the file exists. Cc: John Hawley Cc: Andrea Righi Cc: Marcos Paulo de Souza Cc: Matthieu Baerts Cc: Fernando Fernandez Mancera Cc: Pedro Falcato Link: https://patch.msgid.link/20260307-ktest-fixes-v1-1-565d412f4925@suse.= com Fixes: 4283b169abfb ("ktest: Add make_warnings_file and process full warnin= gs") Signed-off-by: Ricardo B. Marli=C3=A8re Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 001c4df9f7df..f48ee64c69da 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -2508,7 +2508,7 @@ sub check_buildlog { my $save_no_reboot =3D $no_reboot; $no_reboot =3D 1; =20 - if (-f $warnings_file) { + if (defined($warnings_file) && -f $warnings_file) { open(IN, $warnings_file) or dodie "Error opening $warnings_file"; =20 --=20 2.51.0 From nobody Tue Apr 7 02:33:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DC013E0244 for ; Mon, 16 Mar 2026 18:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686452; cv=none; b=J/18nKXxyQwlvNLwafJqsuai0MJ2y1pdenwcoERpC9QEtfIRQgriC7d+jHp2cUPx22J7rqRc84JKKwoI8Wx7eCUQcPDFFrsWoEHhpXTyKrg8WkuADVm33CnWAGGrPYHhzHEOB0iVdwXrZdBq+j+VQUvDz1RLTKtg9umokodSXa8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686452; c=relaxed/simple; bh=uJbyMDXF8H1WV+Bor074OuWARJwauyMBmt3wPZvh4kM=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=agmVk133s+7wu9eyX0/Jc3MmYB/h1634+pgSErB52LB+Iw06xkS+QRE43cEjdFSLXR6eWab0gY3UkmdUO2u7XyjDFut5efn01Fq87OR6XiyWHKfc4bAHM7f/9G3X7BJKX6IWD+zKpeq7jfRVlf3TJXuMHeiDz3KFaTwxjeux7hk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Si+YQQnD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Si+YQQnD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBF4DC2BCB3; Mon, 16 Mar 2026 18:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773686451; bh=uJbyMDXF8H1WV+Bor074OuWARJwauyMBmt3wPZvh4kM=; h=Date:From:To:Cc:Subject:References:From; b=Si+YQQnDJpidHKocLAwgCz8jaK6dmaqbF2JG6JeNm9VHzjQQ8r/zJPYGZ72Mv7Dkd 6lAUOdqzoeBrguG5myRXjAUxUsvlaXZdFPkzm0WFZHtmyy3kHUX3VYnZc5d1azjj73 TG5u2MSVgUG9gAvnpDzJH9LH08fcHhh6WCxVyhunh0ccKEVQerVgq/pPhYsgwDpy9m snPR3XjsLl9h3vDQbs5gslvXFcCZwp1nBl6nz5+fX6vQmjQ6qgXX1iQFMfbn8PRRZP jZmdCvPsjZVMPDYEKrdZu3pLZKt9skOoX+1MpcF4pvvmojb05ZFif1wsCrK5WKv/N4 a43QoR9o79GCA== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1w2CsO-0000000852T-0Dih; Mon, 16 Mar 2026 14:41:16 -0400 Message-ID: <20260316184115.909768613@kernel.org> User-Agent: quilt/0.69 Date: Mon, 16 Mar 2026 14:40:35 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: "John Warthog9 Hawley" , =?UTF-8?q?Ricardo=20B.=20Marli=C3=A8re?= , John Hawley , Andrea Righi , Marcos Paulo de Souza , Matthieu Baerts , Fernando Fernandez Mancera , Pedro Falcato Subject: [for-next][PATCH 2/9] ktest: Resolve LOG_FILE in test option context References: <20260316184033.927944169@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Ricardo=3D20B=3D2E=3D20Marli=3DC3=3DA8re?=3D LOG_FILE is expanded immediately after the config file is parsed with eval_option(..., -1). That uses the default context, not the same option resolution path used for tests. If LOG_FILE depends on options that are finalized per test, it can be resolved from stale values before the first test starts. Resolve LOG_FILE through set_test_option("LOG_FILE", 1) instead so it uses the same expansion rules as the rest of the test options. Cc: John Hawley Cc: Andrea Righi Cc: Marcos Paulo de Souza Cc: Matthieu Baerts Cc: Fernando Fernandez Mancera Cc: Pedro Falcato Link: https://patch.msgid.link/20260307-ktest-fixes-v1-2-565d412f4925@suse.= com Signed-off-by: Ricardo B. Marli=C3=A8re Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index f48ee64c69da..b7a1c8c617e0 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -4391,7 +4391,7 @@ EOF read_config $ktest_config; =20 if (defined($opt{"LOG_FILE"})) { - $opt{"LOG_FILE"} =3D eval_option("LOG_FILE", $opt{"LOG_FILE"}, -1); + $opt{"LOG_FILE"} =3D set_test_option("LOG_FILE", 1); } =20 # Append any configs entered in manually to the config file. --=20 2.51.0 From nobody Tue Apr 7 02:33:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 683643E0247 for ; Mon, 16 Mar 2026 18:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686452; cv=none; b=cN7PmatPovXghgLTRWeHZjFwf8pKy9/ZPnJ1zfGUIeiwP4QyoOQZbTJhKaR7kESHkoN1CmenKDLrUe7wLCilKqEghXahp+xXEt1nUlWL7hS9LUGexYg25AeKV6Usxdjd8s5axW+cNp4y7f3HWk6kIAyZGcdwYDd0HuaWLdriY1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686452; c=relaxed/simple; bh=vmqrNQECX9cSDdui4MaBOyr6FGJ7iKqAsoFzXdvgxAc=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=iS9TGis/wXc4uCjj/vlkiLwUPeRZw6TbFoHc2MIJkxuzro+LRYPC/wxp2XLpAsJtkqx9lm8wooHhMTT8sBZgu0FrDNJcmKLpYCJNG5flKanqXe8BR93BgQsJCy5xh4Z2Q8m9kDWngzo/gkPz4CDxS73DBJ8NyiI5lzjaIpDS4r0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AUtolVNh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AUtolVNh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4E04C2BCB2; Mon, 16 Mar 2026 18:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773686451; bh=vmqrNQECX9cSDdui4MaBOyr6FGJ7iKqAsoFzXdvgxAc=; h=Date:From:To:Cc:Subject:References:From; b=AUtolVNhuOTnqVWvnCvV2VZhjhRongp7dSvWoNwcIXFhRgr19/rOTTXwsjBxCWuXo jxBDj3UMkhEm3Rb3bM62Tc/odjnTw8fCdJl97WIgGAfA/r1KUVxIbnsYuC0HB/ORmI s0mUQTUtgx3ZTftmipLkUZSZo5/tntb0UmoLpote9VgjOKchPZhGbQCishJbNjvZGO H1Lqp9clY/5HsQ2JmzrqBWCeEE8GcvUDzZmQwLP6KRMkYqyjGZDN6Id1J9PGN5jFft Wk+LAf4WKtG+WLaia0VnQOo2AZndFlBqmHZHm07P5hl1/EyaTcre4jVXOjWApaHlq5 gO7VJfBodqRzA== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1w2CsO-0000000852x-0qF1; Mon, 16 Mar 2026 14:41:16 -0400 Message-ID: <20260316184116.072994651@kernel.org> User-Agent: quilt/0.69 Date: Mon, 16 Mar 2026 14:40:36 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: "John Warthog9 Hawley" , =?UTF-8?q?Ricardo=20B.=20Marli=C3=A8re?= , John Hawley , Andrea Righi , Marcos Paulo de Souza , Matthieu Baerts , Fernando Fernandez Mancera , Pedro Falcato Subject: [for-next][PATCH 3/9] ktest: Treat undefined self-reference as empty References: <20260316184033.927944169@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Ricardo=3D20B=3D2E=3D20Marli=3DC3=3DA8re?=3D Config variables are expanded when they are assigned. A first-time append such as: VAR :=3D ${VAR} foo leaves the literal ${VAR} in the stored value because VAR has not been defined yet. Later expansions then carry the self-reference forward instead of behaving like an empty prefix. Drop an unescaped self-reference when the variable has no current value, and trim the outer whitespace left behind. Keep escaped \${VAR} references unchanged so literal text still works. Cc: John Hawley Cc: Andrea Righi Cc: Marcos Paulo de Souza Cc: Matthieu Baerts Cc: Fernando Fernandez Mancera Cc: Pedro Falcato Link: https://patch.msgid.link/20260307-ktest-fixes-v1-3-565d412f4925@suse.= com Signed-off-by: Ricardo B. Marli=C3=A8re Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index b7a1c8c617e0..b8fcdabffffe 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -910,6 +910,14 @@ sub set_variable { if (defined($command_tmp_vars{$lvalue})) { return; } + + # If a variable is undefined, treat an unescaped self-reference as emp= ty. + if (!defined($variable{$lvalue})) { + $rvalue =3D~ s/(?; Mon, 16 Mar 2026 18:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686452; cv=none; b=VsNZon2V+gPSK9ZINJl8wbs6LsTgJklQIPMj2orUAF2Nc6iarTdLFtT3h8qr4zwCUQscToA03RUBdh3vz5L1yoyBsxa0uqRtH3+kiHPRT1tumHtot+OgAVwrf4DXpWei2czkRgP3occGkd6yk1zKDZSoS3pfjm/AyJ0aXOYmSp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686452; c=relaxed/simple; bh=SZ/IL34NHcZwnXFZZbmcd3SNKWhqZaJwLFTc1LsZ++U=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=aNhZNTWO7AFCe5x8eI/PmYfIugOgqTfnU59dBh1HAnx6V3WDFURvXiBp+SubIkOe6x9WJXMolCQeluTdGUTYohgnFqoLqVgMMBNjaR8tmaqgK5mWtpKp6UYwoM3W5vUHSer3jqF/tI68z0eZAfDXhw7R+++waXoL3RQXbCfJ/tk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bdeYBarW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bdeYBarW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16FD0C2BCB5; Mon, 16 Mar 2026 18:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773686452; bh=SZ/IL34NHcZwnXFZZbmcd3SNKWhqZaJwLFTc1LsZ++U=; h=Date:From:To:Cc:Subject:References:From; b=bdeYBarWzXiifzf5386sT0QMhK++YxKQAFO/b0LUo5/FwPanyYhkuYymdfD+oed8B hV3kbHoG4O1MG3RVYJNkADdHx1oNf6ang6HSW0v4HlzYqLPXRPYGOsCi/ZC8TZ/wjy Wqd5Lj2l1dlb6cZZigFZAnXvi9eOHe1acEiTcEdsgiVl9yV1apGJ6tahT2hVwIH08k Cgixfraon2wXl5RQ0UfyOcA4mZHGQMIdl9ISNLLO5j20c3X/EnWU++e0ck9IuFbLwY 4enM7w5tCIO/xpfPEd6wBqPHRhrT+HFthlyeQPYt2LkLhlNGgKa25CMMSi8Qzjll6W JA5dR+CrC3QjQ== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1w2CsO-0000000853R-1YeV; Mon, 16 Mar 2026 14:41:16 -0400 Message-ID: <20260316184116.219854590@kernel.org> User-Agent: quilt/0.69 Date: Mon, 16 Mar 2026 14:40:37 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: "John Warthog9 Hawley" , =?UTF-8?q?Ricardo=20B.=20Marli=C3=A8re?= , John Hawley , Andrea Righi , Marcos Paulo de Souza , Matthieu Baerts , Fernando Fernandez Mancera , Pedro Falcato Subject: [for-next][PATCH 4/9] ktest: Honor empty per-test option overrides References: <20260316184033.927944169@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Ricardo=3D20B=3D2E=3D20Marli=3DC3=3DA8re?=3D A per-test override can clear an inherited default option by assigning an empty value, but __set_test_option() still used option_defined() to decide whether a per-test key existed. That turned an empty per-test assignment back into "fall back to the default", so tests still could not clear inherited settings. For example: DEFAULTS (...) LOG_FILE =3D /tmp/ktest-empty-override.log CLEAR_LOG =3D 1 ADD_CONFIG =3D /tmp/.config TEST_START TEST_TYPE =3D build BUILD_TYPE =3D nobuild ADD_CONFIG =3D This would run the test with ADD_CONFIG[1] =3D /tmp/.config Fix by checking whether the per-test key exists before falling back. If it does exist but is empty, treat it as unset for that test and stop the fallback chain there. Cc: John Hawley Cc: Andrea Righi Cc: Marcos Paulo de Souza Cc: Matthieu Baerts Cc: Fernando Fernandez Mancera Cc: Pedro Falcato Link: https://patch.msgid.link/20260307-ktest-fixes-v1-4-565d412f4925@suse.= com Fixes: 22c37a9ac49d ("ktest: Allow tests to undefine default options") Signed-off-by: Ricardo B. Marli=C3=A8re Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index b8fcdabffffe..42bc505e14cb 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -4191,7 +4191,8 @@ sub __set_test_option { =20 my $option =3D "$name\[$i\]"; =20 - if (option_defined($option)) { + if (exists($opt{$option})) { + return undef if (!option_defined($option)); return $opt{$option}; } =20 @@ -4199,7 +4200,8 @@ sub __set_test_option { if ($i >=3D $test && $i < $test + $repeat_tests{$test}) { $option =3D "$name\[$test\]"; - if (option_defined($option)) { + if (exists($opt{$option})) { + return undef if (!option_defined($option)); return $opt{$option}; } } --=20 2.51.0 From nobody Tue Apr 7 02:33:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CF4F3E023E for ; Mon, 16 Mar 2026 18:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686452; cv=none; b=Jm8KzfCYOGSxHtQxomdR+addP03LSjjn3VtPNF0jzrkR4CoXlAvZsKlxjQIgY8FwICaml/DOFz2aZCe2EJjQq/86Hr7Nib39qjmqKcKOPvY8eEI70LRPx0XpN97TFXbXvbK3VTZefFSKRPHqVZQDKRz2i8qVpNT6g6VLetlHpn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686452; c=relaxed/simple; bh=bKW4WMs3JH5EpHet7R5WXoshw8T6K7Q2rEq+33ehq0Y=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=FlkLNafr+s+tHJ/TjwcJGwh1g8f3UC/++LvCVBWdpQYBKn6J7B+zZftjilOQdKLMKP3V7+bw3HqCUPmhWxgMiHV+cmyEodZFzKBzSC9fHM8TGgyAXoVAqAB2U1Jk5SHyT2jKORlQHjzB9TT+4WU0anUIdeJ40BpbLjyg5/ngag8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j3+WwTjz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j3+WwTjz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4350AC2BC9E; Mon, 16 Mar 2026 18:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773686452; bh=bKW4WMs3JH5EpHet7R5WXoshw8T6K7Q2rEq+33ehq0Y=; h=Date:From:To:Cc:Subject:References:From; b=j3+WwTjzG3OlPgAT+GfO3+qoZb7KCJDG3Gvemxc5/9TaipVZXVNZWQqOYOJlHE/SN gfyMqB2OmUNUEnx8fegpfftnC8o9BtohjBaK4ikFXSBiwWYO/EbM0rsc/Kn3PaFxY+ 9Nkq5/ql7dMKiyuUPLoxV2L/02wrZsh8cZLifpc9DFbpVJn8zBssZvRt0OcU8DAR+c uDXzMGUyrWvpvFvTBDPQlK9WE76NIt1sloqYS6kaFDHos5lC1ViSyh+OiOWGkolmpQ JI7cr5sSL6r9pTC83dQX8lFO+/gSPpb0FG7eupjulnTDNBeZhrmjpQ7xCkaa6qSU0E YtCVoyfLyHf4g== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1w2CsO-0000000853v-2FLT; Mon, 16 Mar 2026 14:41:16 -0400 Message-ID: <20260316184116.391842142@kernel.org> User-Agent: quilt/0.69 Date: Mon, 16 Mar 2026 14:40:38 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: "John Warthog9 Hawley" , =?UTF-8?q?Ricardo=20B.=20Marli=C3=A8re?= , John Hawley , Andrea Righi , Marcos Paulo de Souza , Matthieu Baerts , Fernando Fernandez Mancera , Pedro Falcato Subject: [for-next][PATCH 5/9] ktest: Run commands through list-form shell open References: <20260316184033.927944169@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Ricardo=3D20B=3D2E=3D20Marli=3DC3=3DA8re?=3D run_command() currently uses string-form open(): open(CMD, "$command 2>&1 |") That delegates parsing to the shell but also mixes the stderr redirection into the command string. Switch to list-form open() with an explicit sh -c wrapper so shell syntax errors are captured in the same output stream as command output. Otherwise, important errors can not be retrieved from the ktest LOG_FILE. Cc: John Hawley Cc: Andrea Righi Cc: Marcos Paulo de Souza Cc: Matthieu Baerts Cc: Fernando Fernandez Mancera Cc: Pedro Falcato Link: https://patch.msgid.link/20260307-ktest-fixes-v1-5-565d412f4925@suse.= com Signed-off-by: Ricardo B. Marli=C3=A8re Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 42bc505e14cb..9d6f50045dbd 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -1921,7 +1921,10 @@ sub run_command { doprint("$command ... "); $start_time =3D time; =20 - $pid =3D open(CMD, "$command 2>&1 |") or + $pid =3D open(CMD, "-|", + "sh", "-c", + 'command=3D$1; shift; exec 2>&1; eval "$command"', + "sh", $command) or (fail "unable to exec $command" and return 0); =20 if (defined($opt{"LOG_FILE"})) { --=20 2.51.0 From nobody Tue Apr 7 02:33:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD9AD3E022D for ; Mon, 16 Mar 2026 18:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686452; cv=none; b=tiNk2VcXYs4v+2gyxIWkkBL9a6vA8cHZ8AQWbTrAYO+ax4fPDJ05req80XsGoUZV1KMsDtsNJQE7JTam/7bPmG31lxWc0XArRWwXvyGGaxnbqCwH6Dg8+LjCXT0bcaAb3xqJySLD2GouZSp5U74/hQ5NxOOiAEyp0WbStzQHi/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686452; c=relaxed/simple; bh=UFuVlewfajqwppv+1GGRpSZagwtIXopeyq/TTvgiuRQ=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=tHjGcQ9kPnciFh6HL8NIuOYvzj+3XXSFOavSXWX2OG2SW9e+Dx4g+Q/srmO8ulfN7dTBvy04hZ53un03hnKEDKf0uX/KF7rpsT9yal/LTB+ijo0m+SkPwNucgPOxzfKCwGbObBZmavz422DYZJshtoV988b43zf3rMlYliOSxe0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k8KhMir9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="k8KhMir9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63EEBC2BCB7; Mon, 16 Mar 2026 18:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773686452; bh=UFuVlewfajqwppv+1GGRpSZagwtIXopeyq/TTvgiuRQ=; h=Date:From:To:Cc:Subject:References:From; b=k8KhMir9sFAheHWy2tLq9PNmQa3nU418MD7pQ+CBJzRAKCRz74x1hW5SF0p7lHwge x7hGl7+A/O8Z5iIBiOE5hhEbowJNITpfgfwgcKPuyW5092GsyyCvV5wpCfbFLIz656 HUhhhT48cRKHOoRadvZnhhD9oHFv5ioj6L2PUybc5MpRAVgpJEJSdbc5oKSxVZfyvB O4y013UIqTbgQlPPyU7cz8FdytQvtQ40vlzqSTh1n87dRJQ9GABcIVkt6RUQpYUcp7 QdL+x9whsSEutHA4mrwWK+s0kkeBYHgCmVXZEHyz8XAjYSlOx9tIEXJtvDqfi8wqtX TBXHDycgJe0gA== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1w2CsO-0000000854P-2qEf; Mon, 16 Mar 2026 14:41:16 -0400 Message-ID: <20260316184116.554314614@kernel.org> User-Agent: quilt/0.69 Date: Mon, 16 Mar 2026 14:40:39 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: "John Warthog9 Hawley" , =?UTF-8?q?Ricardo=20B.=20Marli=C3=A8re?= , John Hawley , Andrea Righi , Marcos Paulo de Souza , Matthieu Baerts , Fernando Fernandez Mancera , Pedro Falcato Subject: [for-next][PATCH 6/9] ktest: Stop dropping console output during power-cycle reboot References: <20260316184033.927944169@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Ricardo=3D20B=3D2E=3D20Marli=3DC3=3DA8re?=3D The POWER_CYCLE fallback added to reboot() flushes monitor output at the wrong time. In the untimed reboot path, flushing immediately after start_monitor() can consume the first output from the new boot before monitor() begins reading it. In the timed path, flushing after POWER_CYCLE can eat the "Linux version" banner or REBOOT_SUCCESS_LINE from the new kernel. That makes ktest miss the boot it is waiting for and can trigger an unnecessary second power cycle. Start the monitor before POWER_CYCLE so the reference counting stays balanced, but only flush when reboot() was asked to wait for a timed reboot. Perform that flush before issuing POWER_CYCLE so it drains stale output from the old kernel instead of consuming the next boot. Cc: John Hawley Cc: Andrea Righi Cc: Marcos Paulo de Souza Cc: Matthieu Baerts Cc: Fernando Fernandez Mancera Cc: Pedro Falcato Link: https://patch.msgid.link/20260307-ktest-fixes-v1-6-565d412f4925@suse.= com Signed-off-by: Ricardo B. Marli=C3=A8re Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 9d6f50045dbd..bd2e2311884c 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -1499,12 +1499,13 @@ sub reboot { } =20 if ($powercycle) { - run_command "$power_cycle"; - start_monitor; - # flush out current monitor - # May contain the reboot success line - wait_for_monitor 1; + if (defined($time)) { + # Flush stale console output from the old kernel before power-cycling. + wait_for_monitor 1; + } + + run_command "$power_cycle"; =20 } else { # Make sure everything has been written to disk --=20 2.51.0 From nobody Tue Apr 7 02:33:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF4A53E0C48 for ; Mon, 16 Mar 2026 18:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686453; cv=none; b=uc4NJ4ME2SJDkY9+MTVY0lFrYCzu9UDMbpVLoHHjZH5zsk/iFApez5PkOOos6PStnnLVw/L/m2F+TVHzpIP+WplLywtfvguNVhLHSOCcHI1pArI816M2PGLPpV7cMw4GyTgkERCjoYOdmFNTMbYIrNJlU437WzSgAufpQs2GT3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686453; c=relaxed/simple; bh=npn5yCqDMSOsKuKAbRBrbWNTJ++bqhBqf3BU2qEe2fU=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=iWz4jq8yt4pmHWwGYuDNNJJ/ZksrjiYJ5PCr1gRmdlMvESYVw1D+IAAx9BtPoLY4GoFS4SE50kX2Dgwqr4NxEqWKBYRuBKxiOCrGCKchTxlknEAuCiMF9A/TOTn24ktx25NUDLuLp4PwX7+cNelqU9pjeOMEjkfrJgcCOhDNLVQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oZy58dt6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oZy58dt6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8423FC2BCB8; Mon, 16 Mar 2026 18:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773686452; bh=npn5yCqDMSOsKuKAbRBrbWNTJ++bqhBqf3BU2qEe2fU=; h=Date:From:To:Cc:Subject:References:From; b=oZy58dt6d/rd3KchJ8EnGuMJbtepsLw3nUxChTyanpHPwOjUB2IPeNYwaYAhhzfZQ UIbHTGETAtxTmI8QPffRnakp/6WawaGGq8/aK1GGbErMh/aTF/2ozoNefcDZiP5q9s pGN/PZJMOnNrsTZc6XFXNjRm5TJoyWDERZPUJgdKIu02nCtH0+Urx8z3xKlrZKCCKx bfWIN0wPRM/vUGxM1keiTVkd1I97z1qwE7ifX9SEESMVoYaMAvPjCshFS2ncTfsh+h ykBGhdmTm0XKuRSCCVsNdLqNPK4lBWOI4mc3lpEGX/atYWmZVad0eeHuAoSRxm0Xeh Be5GL6z550RCQ== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1w2CsO-0000000854t-3TaV; Mon, 16 Mar 2026 14:41:16 -0400 Message-ID: <20260316184116.695990593@kernel.org> User-Agent: quilt/0.69 Date: Mon, 16 Mar 2026 14:40:40 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: "John Warthog9 Hawley" , =?UTF-8?q?Ricardo=20B.=20Marli=C3=A8re?= , John Hawley , Andrea Righi , Marcos Paulo de Souza , Matthieu Baerts , Fernando Fernandez Mancera , Pedro Falcato Subject: [for-next][PATCH 7/9] ktest: Add PRE_KTEST_DIE for PRE_KTEST failures References: <20260316184033.927944169@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Ricardo=3D20B=3D2E=3D20Marli=3DC3=3DA8re?=3D PRE_KTEST runs before the first test, but its return status is currently ignored. A failing setup hook can leave the rest of the run executing in a partially initialized environment. Add PRE_KTEST_DIE so PRE_KTEST can fail the run in the same way PRE_BUILD_DIE and PRE_TEST_DIE already can. Keep the default behavior unchanged when the new option is not set. Cc: John Hawley Cc: Andrea Righi Cc: Marcos Paulo de Souza Cc: Matthieu Baerts Cc: Fernando Fernandez Mancera Cc: Pedro Falcato Link: https://patch.msgid.link/20260307-ktest-fixes-v1-7-565d412f4925@suse.= com Signed-off-by: Ricardo B. Marli=C3=A8re Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 8 +++++++- tools/testing/ktest/sample.conf | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index bd2e2311884c..b018b937e028 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -101,6 +101,7 @@ my $build_type; my $build_options; my $final_post_ktest; my $pre_ktest; +my $pre_ktest_die; my $post_ktest; my $pre_test; my $pre_test_die; @@ -283,6 +284,7 @@ my %option_map =3D ( "BUILD_DIR" =3D> \$builddir, "TEST_TYPE" =3D> \$test_type, "PRE_KTEST" =3D> \$pre_ktest, + "PRE_KTEST_DIE" =3D> \$pre_ktest_die, "POST_KTEST" =3D> \$post_ktest, "PRE_TEST" =3D> \$pre_test, "PRE_TEST_DIE" =3D> \$pre_test_die, @@ -4506,7 +4508,11 @@ for (my $i =3D 1; $i <=3D $opt{"NUM_TESTS"}; $i++) { if ($i =3D=3D 1) { if (defined($pre_ktest)) { doprint "\n"; - run_command $pre_ktest; + my $ret =3D run_command $pre_ktest; + if (!$ret && defined($pre_ktest_die) && + $pre_ktest_die) { + dodie "failed to pre_ktest\n"; + } } if ($email_when_started) { my $name =3D get_test_name; diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.c= onf index 9c4c449a8f3e..b6e439ef511b 100644 --- a/tools/testing/ktest/sample.conf +++ b/tools/testing/ktest/sample.conf @@ -494,6 +494,12 @@ # # default (undefined) #PRE_KTEST =3D ${SSH} ~/set_up_test +# +# To specify if the test should fail if PRE_KTEST fails, +# PRE_KTEST_DIE needs to be set to 1. Otherwise the PRE_KTEST +# result is ignored. +# (default 0) +#PRE_KTEST_DIE =3D 1 =20 # If you want to execute some command after all the tests have # completed, you can set this option. Note, it can be set as a --=20 2.51.0 From nobody Tue Apr 7 02:33:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 089043E0C4E for ; Mon, 16 Mar 2026 18:40:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686453; cv=none; b=PfnX1acVVRulp14JcbLI6owxQb7utFuwapPhI1kzC6DYzsbvjjyJc/HQzIOJZvJdsZfU3EFPs7u3V0+1CtQ15rgj0X0q93JXKMsiBNunZC130mcV1M9lRGbmx/yow5kSMDoBq9sBZZMgitCtZVL5/17+oB4O978qg48w/OzyXd4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686453; c=relaxed/simple; bh=6qZkbVnkcbyDKNTFPeLtDr8tCnz30c0+OKblk/GUdNg=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=PQKVf6GN5vySERgObbonD0L4liyFVoU/ZNDu5MtSvgdusLmjsalqi60jJN4RE545fnLZEKje+exmeHkqRVKJs6CSO8XNajtzcL3JIU30gLU/fRdut6MbvAYVOytrxMNbsN+zLYehgU2iyI3FiajwiggfaHdoKjXM2pENVE2aWxk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q+H4UE0y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q+H4UE0y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA644C19421; Mon, 16 Mar 2026 18:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773686452; bh=6qZkbVnkcbyDKNTFPeLtDr8tCnz30c0+OKblk/GUdNg=; h=Date:From:To:Cc:Subject:References:From; b=Q+H4UE0yXIjr4xxZQl054mHHAqHCJ2/DUAjpr6UF3Z7XH5mKqjukPTnaAGOKsgf05 4rYExEBkD6UbbLE5kCpRN0E4toJPo/ts+ABSnbXyddHSkUEW6mBVjxGR9wQQ1u/N5+ 1nc0e2C3Coglot0CBYWGlypN2crdi8XOFYCYMoBklqvYOgUQDTHUzBULdS3JdVACAv EfP/w8CjpiLVPFrahITXHKyPXNS4FQqJbRzU+0gV08nu9QyT860XTPVFwJLdiTpCwS UOlvPQjxvO7cg5PQZ98JJDR2cYJIkuCL13sldGREeutfAzlAj8IAc7jFvPZQ/zoICZ U0Hb80W3PWALw== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1w2CsO-0000000855N-466X; Mon, 16 Mar 2026 14:41:16 -0400 Message-ID: <20260316184116.847775505@kernel.org> User-Agent: quilt/0.69 Date: Mon, 16 Mar 2026 14:40:41 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: "John Warthog9 Hawley" , =?UTF-8?q?Ricardo=20B.=20Marli=C3=A8re?= , John Hawley , Andrea Righi , Marcos Paulo de Souza , Matthieu Baerts , Fernando Fernandez Mancera , Pedro Falcato Subject: [for-next][PATCH 8/9] ktest: Run POST_KTEST hooks on failure and cancellation References: <20260316184033.927944169@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Ricardo=3D20B=3D2E=3D20Marli=3DC3=3DA8re?=3D PRE_KTEST can be useful for setting up the environment and POST_KTEST to tear it down, however POST_KTEST only runs on the normal end-of-run path. It is skipped when ktest exits through dodie() or cancel_test(). Final cleanup hooks are skipped. Factor the final hook execution into run_post_ktest(), call it from the normal exit path and from the early exit paths, and guard it so the hook runs at most once. Cc: John Hawley Cc: Andrea Righi Cc: Marcos Paulo de Souza Cc: Matthieu Baerts Cc: Fernando Fernandez Mancera Cc: Pedro Falcato Link: https://patch.msgid.link/20260307-ktest-fixes-v1-8-565d412f4925@suse.= com Fixes: 921ed4c7208e ("ktest: Add PRE/POST_KTEST and TEST options") Signed-off-by: Ricardo B. Marli=C3=A8re Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index b018b937e028..8962857ce4a6 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -100,6 +100,7 @@ my $test_type; my $build_type; my $build_options; my $final_post_ktest; +my $post_ktest_done =3D 0; my $pre_ktest; my $pre_ktest_die; my $post_ktest; @@ -1586,6 +1587,24 @@ sub get_test_name() { return $name; } =20 +sub run_post_ktest { + my $cmd; + + return if ($post_ktest_done); + + if (defined($final_post_ktest)) { + $cmd =3D $final_post_ktest; + } elsif (defined($post_ktest)) { + $cmd =3D $post_ktest; + } else { + return; + } + + my $cp_post_ktest =3D eval_kernel_version($cmd); + run_command $cp_post_ktest; + $post_ktest_done =3D 1; +} + sub dodie { # avoid recursion return if ($in_die); @@ -1645,6 +1664,7 @@ sub dodie { if (defined($post_test)) { run_command $post_test; } + run_post_ktest; =20 die @_, "\n"; } @@ -4314,6 +4334,7 @@ sub cancel_test { send_email("KTEST: Your [$name] test was cancelled", "Your test started at $script_start_time was cancelled: sig int"); } + run_post_ktest; die "\nCaught Sig Int, test interrupted: $!\n" } =20 @@ -4679,11 +4700,7 @@ for (my $i =3D 1; $i <=3D $opt{"NUM_TESTS"}; $i++) { success $i; } =20 -if (defined($final_post_ktest)) { - - my $cp_final_post_ktest =3D eval_kernel_version $final_post_ktest; - run_command $cp_final_post_ktest; -} +run_post_ktest; =20 if ($opt{"POWEROFF_ON_SUCCESS"}) { halt; --=20 2.51.0 From nobody Tue Apr 7 02:33:53 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 180723E0C4F for ; Mon, 16 Mar 2026 18:40:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686453; cv=none; b=CVXrdHNwjb2xDx8OtlHt0fRWGZ3/ADmCiOTrFEu9qc706jH+XOy+PXvDIx5R/4dCmnb7v3WaluDSm5kA9iORZcCUhwn4d2ensXMHUS12dF0fWxKM7VkdJu2WawOyYsCfR8FQaQMYKyhi3ElwPwvi23T2xig+xI0N9HqNVguozB8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773686453; c=relaxed/simple; bh=rFpRJGWnR56PQNeRVS/JPOaAgy9LQ64AaLZKmEymeM8=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=DEIjRoH1/FqN3RPMH0cyDcQnBQuoVFNBL58P4rsFW7/4bP6AkomDnb18zbZ/vqtoX/UgmLTkyWFGdejydwB4DT4KmooF2QPqeR2nbEL2he7DQ0bDfuCCsZuUhG+NcsQrfdW6U2ymejJuW3ffFooV9bJZ5Tp0zEwZRVKl6os6LSw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F11QwzHR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F11QwzHR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E35C7C2BCAF; Mon, 16 Mar 2026 18:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773686453; bh=rFpRJGWnR56PQNeRVS/JPOaAgy9LQ64AaLZKmEymeM8=; h=Date:From:To:Cc:Subject:References:From; b=F11QwzHRgG87nAx7ulYVlGNMeugEqp+mm6p+JY0XloFVLnJQNGuLTgevk4elV+frM 3ep21T0Ez99CZJLLPfEoEUq81B070kMjizO/wenOtcDxteahJkt3x7MQch2pmq3eLI h0TcYnLWR/gyjwsy3csBWugv/61xhCyM8+7pCATw/PTPFlcafdR8lkAYqEWpvTxOVt R6obpubZf14adSsrCIE+IHinj8B1PFsDN6xzr0ToN9pn1fFrQymhPxlg22ce0oB2Ul eh4kwLW4lqItqYsCtBcVtD0/ItD4MOvHoOqsfmRLTg5wydcgZEQ+V9R1nIv3uCQ/Bi oOQpHKs9HiieA== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1w2CsP-0000000855t-0Ugn; Mon, 16 Mar 2026 14:41:17 -0400 Message-ID: <20260316184116.993622559@kernel.org> User-Agent: quilt/0.69 Date: Mon, 16 Mar 2026 14:40:42 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: "John Warthog9 Hawley" , =?UTF-8?q?Ricardo=20B.=20Marli=C3=A8re?= , John Hawley , Andrea Righi , Marcos Paulo de Souza , Matthieu Baerts , Fernando Fernandez Mancera , Pedro Falcato Subject: [for-next][PATCH 9/9] ktest: Add a --dry-run mode References: <20260316184033.927944169@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Ricardo=3D20B=3D2E=3D20Marli=3DC3=3DA8re?=3D When working on a ktest configuration, it is often useful to inspect the final option values after includes, defaults, per-test overrides, and variable expansion have been applied, without actually starting a test run. Add a --dry-run option that reads the configuration, prints the test preamble using resolved option values, and exits before opening LOG_FILE or executing any test logic. This is useful for debugging ktest configurations and for scripts that need to validate the final resolved settings without triggering side effects. Cc: John Hawley Cc: Andrea Righi Cc: Marcos Paulo de Souza Cc: Matthieu Baerts Cc: Fernando Fernandez Mancera Cc: Pedro Falcato Link: https://patch.msgid.link/20260307-ktest-fixes-v1-9-565d412f4925@suse.= com Signed-off-by: Ricardo B. Marli=C3=A8re Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 89 +++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 26 deletions(-) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 8962857ce4a6..de99b82d16ad 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -85,6 +85,7 @@ my %default =3D ( ); =20 my $test_log_start =3D 0; +my $dry_run =3D 0; =20 my $ktest_config =3D "ktest.conf"; my $version; @@ -587,7 +588,7 @@ sub end_monitor; sub wait_for_monitor; =20 sub _logit { - if (defined($opt{"LOG_FILE"})) { + if (defined($opt{"LOG_FILE"}) && defined(fileno(LOG))) { print LOG @_; } } @@ -1365,6 +1366,9 @@ sub read_config { print "$option\n"; } print "Set IGNORE_UNUSED =3D 1 to have ktest ignore unused variables\n"; + if ($dry_run) { + return; + } if (!read_yn "Do you want to continue?") { exit -1; } @@ -4249,6 +4253,53 @@ sub set_test_option { return eval_option($name, $option, $i); } =20 +sub print_test_preamble { + my ($resolved) =3D @_; + + doprint "\n\nSTARTING AUTOMATED TESTS\n\n"; + + for (my $i =3D 0, my $repeat =3D 1; $i <=3D $opt{"NUM_TESTS"}; $i +=3D= $repeat) { + + if (!$i) { + doprint "DEFAULT OPTIONS:\n"; + } else { + doprint "\nTEST $i OPTIONS"; + if (defined($repeat_tests{$i})) { + $repeat =3D $repeat_tests{$i}; + doprint " ITERATE $repeat"; + } + doprint "\n"; + } + + foreach my $option (sort keys %opt) { + my $value; + + if ($option =3D~ /\[(\d+)\]$/) { + next if ($i !=3D $1); + + if ($resolved) { + my $name =3D $option; + $name =3D~ s/\[\d+\]$//; + $value =3D set_test_option($name, $i); + } else { + $value =3D $opt{$option}; + } + } else { + next if ($i); + + if ($resolved) { + $value =3D set_test_option($option, 0); + } else { + $value =3D $opt{$option}; + } + } + + $value =3D "" if (!defined($value)); + doprint "$option =3D $value\n"; + } + } +} + sub find_mailer { my ($mailer) =3D @_; =20 @@ -4348,6 +4399,8 @@ ktest.pl version: $VERSION Sets global BUILD_NOCLEAN to 1 -D TEST_TYPE[2]=3Dbuild Sets TEST_TYPE of test 2 to "build" + --dry-run + Print resolved test options and exit without running tests. =20 It can also override all temp variables. -D USE_TEMP_DIR:=3D1 @@ -4379,6 +4432,9 @@ while ( $#ARGV >=3D 0 ) { } else { $command_vars[$#command_vars + 1] =3D $val; } + } elsif ( $ARGV[0] eq "--dry-run" ) { + $dry_run =3D 1; + shift; } elsif ( $ARGV[0] eq "-h" ) { die_usage; } else { @@ -4427,6 +4483,11 @@ EOF } read_config $ktest_config; =20 +if ($dry_run) { + print_test_preamble 1; + exit 0; +} + if (defined($opt{"LOG_FILE"})) { $opt{"LOG_FILE"} =3D set_test_option("LOG_FILE", 1); } @@ -4458,31 +4519,7 @@ if (defined($opt{"LOG_FILE"})) { LOG->autoflush(1); } =20 -doprint "\n\nSTARTING AUTOMATED TESTS\n\n"; - -for (my $i =3D 0, my $repeat =3D 1; $i <=3D $opt{"NUM_TESTS"}; $i +=3D $re= peat) { - - if (!$i) { - doprint "DEFAULT OPTIONS:\n"; - } else { - doprint "\nTEST $i OPTIONS"; - if (defined($repeat_tests{$i})) { - $repeat =3D $repeat_tests{$i}; - doprint " ITERATE $repeat"; - } - doprint "\n"; - } - - foreach my $option (sort keys %opt) { - if ($option =3D~ /\[(\d+)\]$/) { - next if ($i !=3D $1); - } else { - next if ($i); - } - - doprint "$option =3D $opt{$option}\n"; - } -} +print_test_preamble 0; =20 $SIG{INT} =3D qw(cancel_test); =20 --=20 2.51.0