aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-12-22 16:29:10 -0500
committerSteven Rostedt <rostedt@goodmis.org>2011-12-22 21:59:41 -0500
commitbc7c580377195f9f4da31b63fbbf52293cb4c861 (patch)
tree561f1038c2546cba3861713fdbf7b0996d989f8d /tools
parentc5dacb88f0a6410b3270f77e3d1e1b159afc4adc (diff)
ktest: Add options SWITCH_TO_GOOD and SWITCH_TO_TEST
For machines that do no use grub, it may be needed to update an external image (tftp) before doing a reboot into either the test image or the known good image. The option SWITCH_TO_GOOD is added, where if it is defined, the command that is specified as its value will be executed before doing a reboot into a known good image. The option SWITCH_TO_TEST is added, where if it is defined, the command that is specified as its value will be executed before doing a reboot into the test image. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/testing/ktest/ktest.pl33
-rw-r--r--tools/testing/ktest/sample.conf21
2 files changed, 47 insertions, 7 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 47c28146dfc2..ff21e921be25 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -79,6 +79,8 @@ my $reboot_script;
79my $power_cycle; 79my $power_cycle;
80my $reboot; 80my $reboot;
81my $reboot_on_error; 81my $reboot_on_error;
82my $switch_to_good;
83my $switch_to_test;
82my $poweroff_on_error; 84my $poweroff_on_error;
83my $die_on_failure; 85my $die_on_failure;
84my $powercycle_after_reboot; 86my $powercycle_after_reboot;
@@ -964,6 +966,17 @@ sub reboot {
964 } 966 }
965} 967}
966 968
969sub reboot_to_good {
970 my ($time) = @_;
971
972 if (defined($switch_to_good)) {
973 run_command $switch_to_good;
974 return;
975 }
976
977 reboot $time;
978}
979
967sub do_not_reboot { 980sub do_not_reboot {
968 my $i = $iteration; 981 my $i = $iteration;
969 982
@@ -980,7 +993,7 @@ sub dodie {
980 if ($reboot_on_error && !do_not_reboot) { 993 if ($reboot_on_error && !do_not_reboot) {
981 994
982 doprint "REBOOTING\n"; 995 doprint "REBOOTING\n";
983 reboot; 996 reboot_to_good;
984 997
985 } elsif ($poweroff_on_error && defined($power_off)) { 998 } elsif ($poweroff_on_error && defined($power_off)) {
986 doprint "POWERING OFF\n"; 999 doprint "POWERING OFF\n";
@@ -1116,7 +1129,7 @@ sub fail {
1116 # no need to reboot for just building. 1129 # no need to reboot for just building.
1117 if (!do_not_reboot) { 1130 if (!do_not_reboot) {
1118 doprint "REBOOTING\n"; 1131 doprint "REBOOTING\n";
1119 reboot $sleep_time; 1132 reboot_to_good $sleep_time;
1120 } 1133 }
1121 1134
1122 my $name = ""; 1135 my $name = "";
@@ -1269,6 +1282,10 @@ sub wait_for_input
1269} 1282}
1270 1283
1271sub reboot_to { 1284sub reboot_to {
1285 if (defined($switch_to_test)) {
1286 run_command $switch_to_test;
1287 }
1288
1272 if ($reboot_type eq "grub") { 1289 if ($reboot_type eq "grub") {
1273 run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch)'"; 1290 run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch)'";
1274 reboot; 1291 reboot;
@@ -1754,7 +1771,7 @@ sub success {
1754 1771
1755 if ($i != $opt{"NUM_TESTS"} && !do_not_reboot) { 1772 if ($i != $opt{"NUM_TESTS"} && !do_not_reboot) {
1756 doprint "Reboot and wait $sleep_time seconds\n"; 1773 doprint "Reboot and wait $sleep_time seconds\n";
1757 reboot $sleep_time; 1774 reboot_to_good $sleep_time;
1758 } 1775 }
1759} 1776}
1760 1777
@@ -1935,7 +1952,7 @@ sub run_git_bisect {
1935 1952
1936sub bisect_reboot { 1953sub bisect_reboot {
1937 doprint "Reboot and sleep $bisect_sleep_time seconds\n"; 1954 doprint "Reboot and sleep $bisect_sleep_time seconds\n";
1938 reboot $bisect_sleep_time; 1955 reboot_to_good $bisect_sleep_time;
1939} 1956}
1940 1957
1941# returns 1 on success, 0 on failure, -1 on skip 1958# returns 1 on success, 0 on failure, -1 on skip
@@ -2528,7 +2545,7 @@ sub config_bisect {
2528 2545
2529sub patchcheck_reboot { 2546sub patchcheck_reboot {
2530 doprint "Reboot and sleep $patchcheck_sleep_time seconds\n"; 2547 doprint "Reboot and sleep $patchcheck_sleep_time seconds\n";
2531 reboot $patchcheck_sleep_time; 2548 reboot_to_good $patchcheck_sleep_time;
2532} 2549}
2533 2550
2534sub patchcheck { 2551sub patchcheck {
@@ -3145,7 +3162,7 @@ sub make_min_config {
3145 } 3162 }
3146 3163
3147 doprint "Reboot and wait $sleep_time seconds\n"; 3164 doprint "Reboot and wait $sleep_time seconds\n";
3148 reboot $sleep_time; 3165 reboot_to_good $sleep_time;
3149 } 3166 }
3150 3167
3151 success $i; 3168 success $i;
@@ -3314,6 +3331,8 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3314 $no_install = set_test_option("NO_INSTALL", $i); 3331 $no_install = set_test_option("NO_INSTALL", $i);
3315 $reboot_script = set_test_option("REBOOT_SCRIPT", $i); 3332 $reboot_script = set_test_option("REBOOT_SCRIPT", $i);
3316 $reboot_on_error = set_test_option("REBOOT_ON_ERROR", $i); 3333 $reboot_on_error = set_test_option("REBOOT_ON_ERROR", $i);
3334 $switch_to_good = set_test_option("SWITCH_TO_GOOD", $i);
3335 $switch_to_test = set_test_option("SWITCH_TO_TEST", $i);
3317 $poweroff_on_error = set_test_option("POWEROFF_ON_ERROR", $i); 3336 $poweroff_on_error = set_test_option("POWEROFF_ON_ERROR", $i);
3318 $die_on_failure = set_test_option("DIE_ON_FAILURE", $i); 3337 $die_on_failure = set_test_option("DIE_ON_FAILURE", $i);
3319 $power_off = set_test_option("POWER_OFF", $i); 3338 $power_off = set_test_option("POWER_OFF", $i);
@@ -3472,7 +3491,7 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3472if ($opt{"POWEROFF_ON_SUCCESS"}) { 3491if ($opt{"POWEROFF_ON_SUCCESS"}) {
3473 halt; 3492 halt;
3474} elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot) { 3493} elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot) {
3475 reboot; 3494 reboot_to_good;
3476} 3495}
3477 3496
3478doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n"; 3497doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n";
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index 2ff0f8c483e9..c8dc7575c2f5 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -468,6 +468,27 @@
468# The test will not modify that file. 468# The test will not modify that file.
469#REBOOT_TYPE = grub 469#REBOOT_TYPE = grub
470 470
471# If you are using a machine that doesn't boot with grub, and
472# perhaps gets its kernel from a remote server (tftp), then
473# you can use this option to update the target image with the
474# test image.
475#
476# You could also do the same with POST_INSTALL, but the difference
477# between that option and this option is that POST_INSTALL runs
478# after the install, where this one runs just before a reboot.
479# (default undefined)
480#SWITCH_TO_TEST = cp ${OUTPUT_DIR}/${BUILD_TARGET} ${TARGET_IMAGE}
481
482# If you are using a machine that doesn't boot with grub, and
483# perhaps gets its kernel from a remote server (tftp), then
484# you can use this option to update the target image with the
485# the known good image to reboot safely back into.
486#
487# This option holds a command that will execute before needing
488# to reboot to a good known image.
489# (default undefined)
490#SWITCH_TO_GOOD = ssh ${SSH_USER}/${MACHINE} cp good_image ${TARGET_IMAGE}
491
471# The min config that is needed to build for the machine 492# The min config that is needed to build for the machine
472# A nice way to create this is with the following: 493# A nice way to create this is with the following:
473# 494#