From nobody Tue Apr 7 04:14:07 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