diff options
Diffstat (limited to 'tools/testing/ktest/ktest.pl')
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 33 |
1 files changed, 26 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; | |||
79 | my $power_cycle; | 79 | my $power_cycle; |
80 | my $reboot; | 80 | my $reboot; |
81 | my $reboot_on_error; | 81 | my $reboot_on_error; |
82 | my $switch_to_good; | ||
83 | my $switch_to_test; | ||
82 | my $poweroff_on_error; | 84 | my $poweroff_on_error; |
83 | my $die_on_failure; | 85 | my $die_on_failure; |
84 | my $powercycle_after_reboot; | 86 | my $powercycle_after_reboot; |
@@ -964,6 +966,17 @@ sub reboot { | |||
964 | } | 966 | } |
965 | } | 967 | } |
966 | 968 | ||
969 | sub 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 | |||
967 | sub do_not_reboot { | 980 | sub 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 | ||
1271 | sub reboot_to { | 1284 | sub 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 | ||
1936 | sub bisect_reboot { | 1953 | sub 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 | ||
2529 | sub patchcheck_reboot { | 2546 | sub 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 | ||
2534 | sub patchcheck { | 2551 | sub 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++) { | |||
3472 | if ($opt{"POWEROFF_ON_SUCCESS"}) { | 3491 | if ($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 | ||
3478 | doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n"; | 3497 | doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n"; |