Skip to content

Commit

Permalink
ktest.pl: Define PRE_TEST_DIE to kill the test if the PRE_TEST fails
Browse files Browse the repository at this point in the history
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) <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt (VMware) committed Jul 1, 2020
1 parent 2f059db commit d53cdda
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tools/testing/ktest/ktest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
my $pre_ktest;
my $post_ktest;
my $pre_test;
my $pre_test_die;
my $post_test;
my $pre_build;
my $post_build;
Expand Down Expand Up @@ -273,6 +274,7 @@
"PRE_KTEST" => \$pre_ktest,
"POST_KTEST" => \$post_ktest,
"PRE_TEST" => \$pre_test,
"PRE_TEST_DIE" => \$pre_test_die,
"POST_TEST" => \$post_test,
"BUILD_TYPE" => \$build_type,
"BUILD_OPTIONS" => \$build_options,
Expand Down Expand Up @@ -4347,7 +4349,11 @@ sub cancel_test {
doprint "RUNNING TEST $i of $opt{NUM_TESTS}$name with option $test_type $run_type$installme\n\n";

if (defined($pre_test)) {
run_command $pre_test;
my $ret = run_command $pre_test;
if (!$ret && defined($pre_test_die) &&
$pre_test_die) {
dodie "failed to pre_test\n";
}
}

unlink $dmesg;
Expand Down
5 changes: 5 additions & 0 deletions tools/testing/ktest/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,11 @@
# default (undefined)
#PRE_TEST = ${SSH} reboot_to_special_kernel

# To kill the entire test if PRE_TEST is defined but fails set this
# to 1.
# (default 0)
#PRE_TEST_DIE = 1

# If there is a command you want to run after the individual test case
# completes, then you can set this option.
#
Expand Down

0 comments on commit d53cdda

Please sign in to comment.