aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt2012-07-19 14:18:27 -0500
committerSteven Rostedt2012-07-19 14:18:27 -0500
commit921ed4c7208e5c466a87db0a11c6fdd26bcc2fe7 (patch)
tree58245d96a213b292ad100f03cdec6dc3642681b9 /tools/testing/ktest
parent958d8435c257f93123dec83647130457816a23e6 (diff)
downloadkernel-omap-921ed4c7208e5c466a87db0a11c6fdd26bcc2fe7.tar.gz
kernel-omap-921ed4c7208e5c466a87db0a11c6fdd26bcc2fe7.tar.xz
kernel-omap-921ed4c7208e5c466a87db0a11c6fdd26bcc2fe7.zip
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')
-rwxr-xr-xtools/testing/ktest/ktest.pl37
-rw-r--r--tools/testing/ktest/sample.conf30
2 files changed, 67 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) {
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index cf362b3d1ec9..4472452f5be1 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -376,6 +376,24 @@
376# DEFAULTS 376# DEFAULTS
377# DEFAULTS SKIP 377# DEFAULTS SKIP
378 378
379# If you want to execute some command before the first test runs
380# you can set this option. Note, it can be set as a default option
381# or an option in the first test case. All other test cases will
382# ignore it. If both the default and first test have this option
383# set, then the first test will take precedence.
384#
385# default (undefined)
386#PRE_KTEST = ${SSH} ~/set_up_test
387
388# If you want to execute some command after all the tests have
389# completed, you can set this option. Note, it can be set as a
390# default or any test case can override it. If multiple test cases
391# set this option, then the last test case that set it will take
392# precedence
393#
394# default (undefined)
395#POST_KTEST = ${SSH} ~/dismantle_test
396
379# The default test type (default test) 397# The default test type (default test)
380# The test types may be: 398# The test types may be:
381# build - only build the kernel, do nothing else 399# build - only build the kernel, do nothing else
@@ -426,6 +444,18 @@
426# (default 0) 444# (default 0)
427#NO_INSTALL = 1 445#NO_INSTALL = 1
428 446
447# If there is a command that you want to run before the individual test
448# case executes, then you can set this option
449#
450# default (undefined)
451#PRE_TEST = ${SSH} reboot_to_special_kernel
452
453# If there is a command you want to run after the individual test case
454# completes, then you can set this option.
455#
456# default (undefined)
457#POST_TEST = cd ${BUILD_DIR}; git reset --hard
458
429# If there is a script that you require to run before the build is done 459# If there is a script that you require to run before the build is done
430# you can specify it with PRE_BUILD. 460# you can specify it with PRE_BUILD.
431# 461#