Skip to content

Commit 972816d

Browse files
rbmarliererostedt
authored andcommitted
ktest: Add PRE_KTEST_DIE for PRE_KTEST failures
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 <warthog9@eaglescrag.net> Cc: Andrea Righi <arighi@nvidia.com> Cc: Marcos Paulo de Souza <mpdesouza@suse.com> Cc: Matthieu Baerts <matttbe@kernel.org> Cc: Fernando Fernandez Mancera <fmancera@suse.de> Cc: Pedro Falcato <pfalcato@suse.de> Link: https://patch.msgid.link/20260307-ktest-fixes-v1-7-565d412f4925@suse.com Signed-off-by: Ricardo B. Marlière <rbm@suse.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent eae247f commit 972816d

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

tools/testing/ktest/ktest.pl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
my $build_options;
102102
my $final_post_ktest;
103103
my $pre_ktest;
104+
my $pre_ktest_die;
104105
my $post_ktest;
105106
my $pre_test;
106107
my $pre_test_die;
@@ -283,6 +284,7 @@
283284
"BUILD_DIR" => \$builddir,
284285
"TEST_TYPE" => \$test_type,
285286
"PRE_KTEST" => \$pre_ktest,
287+
"PRE_KTEST_DIE" => \$pre_ktest_die,
286288
"POST_KTEST" => \$post_ktest,
287289
"PRE_TEST" => \$pre_test,
288290
"PRE_TEST_DIE" => \$pre_test_die,
@@ -4506,7 +4508,11 @@ sub die_usage {
45064508
if ($i == 1) {
45074509
if (defined($pre_ktest)) {
45084510
doprint "\n";
4509-
run_command $pre_ktest;
4511+
my $ret = run_command $pre_ktest;
4512+
if (!$ret && defined($pre_ktest_die) &&
4513+
$pre_ktest_die) {
4514+
dodie "failed to pre_ktest\n";
4515+
}
45104516
}
45114517
if ($email_when_started) {
45124518
my $name = get_test_name;

tools/testing/ktest/sample.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,12 @@
494494
#
495495
# default (undefined)
496496
#PRE_KTEST = ${SSH} ~/set_up_test
497+
#
498+
# To specify if the test should fail if PRE_KTEST fails,
499+
# PRE_KTEST_DIE needs to be set to 1. Otherwise the PRE_KTEST
500+
# result is ignored.
501+
# (default 0)
502+
#PRE_KTEST_DIE = 1
497503

498504
# If you want to execute some command after all the tests have
499505
# completed, you can set this option. Note, it can be set as a

0 commit comments

Comments
 (0)