Skip to content

Commit d53cdda

Browse files
committed
ktest.pl: Define PRE_TEST_DIE to kill the test if the PRE_TEST fails
Currently, if a PRE_TEST is defined and ran, but fails, there's nothing currently available to make the test fail too. Add a PRE_TEST_DIE option that when set, if a PRE_TEST is defined and fails, the test will die too. Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 2f059db commit d53cdda

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

tools/testing/ktest/ktest.pl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
my $pre_ktest;
9999
my $post_ktest;
100100
my $pre_test;
101+
my $pre_test_die;
101102
my $post_test;
102103
my $pre_build;
103104
my $post_build;
@@ -273,6 +274,7 @@
273274
"PRE_KTEST" => \$pre_ktest,
274275
"POST_KTEST" => \$post_ktest,
275276
"PRE_TEST" => \$pre_test,
277+
"PRE_TEST_DIE" => \$pre_test_die,
276278
"POST_TEST" => \$post_test,
277279
"BUILD_TYPE" => \$build_type,
278280
"BUILD_OPTIONS" => \$build_options,
@@ -4347,7 +4349,11 @@ sub cancel_test {
43474349
doprint "RUNNING TEST $i of $opt{NUM_TESTS}$name with option $test_type $run_type$installme\n\n";
43484350

43494351
if (defined($pre_test)) {
4350-
run_command $pre_test;
4352+
my $ret = run_command $pre_test;
4353+
if (!$ret && defined($pre_test_die) &&
4354+
$pre_test_die) {
4355+
dodie "failed to pre_test\n";
4356+
}
43514357
}
43524358

43534359
unlink $dmesg;

tools/testing/ktest/sample.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,11 @@
557557
# default (undefined)
558558
#PRE_TEST = ${SSH} reboot_to_special_kernel
559559

560+
# To kill the entire test if PRE_TEST is defined but fails set this
561+
# to 1.
562+
# (default 0)
563+
#PRE_TEST_DIE = 1
564+
560565
# If there is a command you want to run after the individual test case
561566
# completes, then you can set this option.
562567
#

0 commit comments

Comments
 (0)