aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/ktest/ktest.pl
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2012-07-19 15:18:27 -0400
committerSteven Rostedt <rostedt@goodmis.org>2012-07-19 15:18:27 -0400
commit921ed4c7208e5c466a87db0a11c6fdd26bcc2fe7 (patch)
tree58245d96a213b292ad100f03cdec6dc3642681b9 /tools/testing/ktest/ktest.pl
parent958d8435c257f93123dec83647130457816a23e6 (diff)
ktest: Add PRE/POST_KTEST and TEST options
In order to let the user add commands before and after ktest runs, the PRE_KTEST and POST_KTEST options are defined. They hold shell commands that will execute befor ktest runs its first test, as well as when it completed its last test. The PRE_TEST and POST_TEST will be run befor and after (respectively) for a given test. They can either be global (done for all tests) or defined by a single test. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing/ktest/ktest.pl')
-rwxr-xr-xtools/testing/ktest/ktest.pl37
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index a40af07e7772..31b941613f98 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -77,6 +77,11 @@ my $output_config;
77my $test_type; 77my $test_type;
78my $build_type; 78my $build_type;
79my $build_options; 79my $build_options;
80my $final_post_ktest;
81my $pre_ktest;
82my $post_ktest;
83my $pre_test;
84my $post_test;
80my $pre_build; 85my $pre_build;
81my $post_build; 86my $post_build;
82my $pre_build_die; 87my $pre_build_die;
@@ -197,6 +202,10 @@ my %option_map = (
197 "OUTPUT_DIR" => \$outputdir, 202 "OUTPUT_DIR" => \$outputdir,
198 "BUILD_DIR" => \$builddir, 203 "BUILD_DIR" => \$builddir,
199 "TEST_TYPE" => \$test_type, 204 "TEST_TYPE" => \$test_type,
205 "PRE_KTEST" => \$pre_ktest,
206 "POST_KTEST" => \$post_ktest,
207 "PRE_TEST" => \$pre_test,
208 "POST_TEST" => \$post_test,
200 "BUILD_TYPE" => \$build_type, 209 "BUILD_TYPE" => \$build_type,
201 "BUILD_OPTIONS" => \$build_options, 210 "BUILD_OPTIONS" => \$build_options,
202 "PRE_BUILD" => \$pre_build, 211 "PRE_BUILD" => \$pre_build,
@@ -1273,6 +1282,10 @@ sub save_logs {
1273 1282
1274sub fail { 1283sub fail {
1275 1284
1285 if (defined($post_test)) {
1286 run_command $post_test;
1287 }
1288
1276 if ($die_on_failure) { 1289 if ($die_on_failure) {
1277 dodie @_; 1290 dodie @_;
1278 } 1291 }
@@ -1937,6 +1950,10 @@ sub halt {
1937sub success { 1950sub success {
1938 my ($i) = @_; 1951 my ($i) = @_;
1939 1952
1953 if (defined($post_test)) {
1954 run_command $post_test;
1955 }
1956
1940 $successes++; 1957 $successes++;
1941 1958
1942 my $name = ""; 1959 my $name = "";
@@ -3518,6 +3535,18 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3518 3535
3519 $start_minconfig_defined = 1; 3536 $start_minconfig_defined = 1;
3520 3537
3538 # The first test may override the PRE_KTEST option
3539 if (defined($pre_ktest) && $i == 1) {
3540 doprint "\n";
3541 run_command $pre_ktest;
3542 }
3543
3544 # Any test can override the POST_KTEST option
3545 # The last test takes precedence.
3546 if (defined($post_ktest)) {
3547 $final_post_ktest = $post_ktest;
3548 }
3549
3521 if (!defined($start_minconfig)) { 3550 if (!defined($start_minconfig)) {
3522 $start_minconfig_defined = 0; 3551 $start_minconfig_defined = 0;
3523 $start_minconfig = $minconfig; 3552 $start_minconfig = $minconfig;
@@ -3572,6 +3601,10 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3572 doprint "\n\n"; 3601 doprint "\n\n";
3573 doprint "RUNNING TEST $i of $opt{NUM_TESTS} with option $test_type $run_type$installme\n\n"; 3602 doprint "RUNNING TEST $i of $opt{NUM_TESTS} with option $test_type $run_type$installme\n\n";
3574 3603
3604 if (defined($pre_test)) {
3605 run_command $pre_test;
3606 }
3607
3575 unlink $dmesg; 3608 unlink $dmesg;
3576 unlink $buildlog; 3609 unlink $buildlog;
3577 unlink $testlog; 3610 unlink $testlog;
@@ -3637,6 +3670,10 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3637 success $i; 3670 success $i;
3638} 3671}
3639 3672
3673if (defined($final_post_ktest)) {
3674 run_command $final_post_ktest;
3675}
3676
3640if ($opt{"POWEROFF_ON_SUCCESS"}) { 3677if ($opt{"POWEROFF_ON_SUCCESS"}) {
3641 halt; 3678 halt;
3642} elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot && $reboot_success) { 3679} elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot && $reboot_success) {