diff options
Diffstat (limited to 'tools/testing/ktest/ktest.pl')
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 682 |
1 files changed, 492 insertions, 190 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 8b4c2535b266..62a134dc421a 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
@@ -18,40 +18,50 @@ $| = 1; | |||
18 | my %opt; | 18 | my %opt; |
19 | my %repeat_tests; | 19 | my %repeat_tests; |
20 | my %repeats; | 20 | my %repeats; |
21 | my %default; | ||
22 | 21 | ||
23 | #default opts | 22 | #default opts |
24 | $default{"NUM_TESTS"} = 1; | 23 | my %default = ( |
25 | $default{"REBOOT_TYPE"} = "grub"; | 24 | "NUM_TESTS" => 1, |
26 | $default{"TEST_TYPE"} = "test"; | 25 | "TEST_TYPE" => "build", |
27 | $default{"BUILD_TYPE"} = "randconfig"; | 26 | "BUILD_TYPE" => "randconfig", |
28 | $default{"MAKE_CMD"} = "make"; | 27 | "MAKE_CMD" => "make", |
29 | $default{"TIMEOUT"} = 120; | 28 | "TIMEOUT" => 120, |
30 | $default{"TMP_DIR"} = "/tmp/ktest/\${MACHINE}"; | 29 | "TMP_DIR" => "/tmp/ktest/\${MACHINE}", |
31 | $default{"SLEEP_TIME"} = 60; # sleep time between tests | 30 | "SLEEP_TIME" => 60, # sleep time between tests |
32 | $default{"BUILD_NOCLEAN"} = 0; | 31 | "BUILD_NOCLEAN" => 0, |
33 | $default{"REBOOT_ON_ERROR"} = 0; | 32 | "REBOOT_ON_ERROR" => 0, |
34 | $default{"POWEROFF_ON_ERROR"} = 0; | 33 | "POWEROFF_ON_ERROR" => 0, |
35 | $default{"REBOOT_ON_SUCCESS"} = 1; | 34 | "REBOOT_ON_SUCCESS" => 1, |
36 | $default{"POWEROFF_ON_SUCCESS"} = 0; | 35 | "POWEROFF_ON_SUCCESS" => 0, |
37 | $default{"BUILD_OPTIONS"} = ""; | 36 | "BUILD_OPTIONS" => "", |
38 | $default{"BISECT_SLEEP_TIME"} = 60; # sleep time between bisects | 37 | "BISECT_SLEEP_TIME" => 60, # sleep time between bisects |
39 | $default{"PATCHCHECK_SLEEP_TIME"} = 60; # sleep time between patch checks | 38 | "PATCHCHECK_SLEEP_TIME" => 60, # sleep time between patch checks |
40 | $default{"CLEAR_LOG"} = 0; | 39 | "CLEAR_LOG" => 0, |
41 | $default{"BISECT_MANUAL"} = 0; | 40 | "BISECT_MANUAL" => 0, |
42 | $default{"BISECT_SKIP"} = 1; | 41 | "BISECT_SKIP" => 1, |
43 | $default{"SUCCESS_LINE"} = "login:"; | 42 | "SUCCESS_LINE" => "login:", |
44 | $default{"DETECT_TRIPLE_FAULT"} = 1; | 43 | "DETECT_TRIPLE_FAULT" => 1, |
45 | $default{"NO_INSTALL"} = 0; | 44 | "NO_INSTALL" => 0, |
46 | $default{"BOOTED_TIMEOUT"} = 1; | 45 | "BOOTED_TIMEOUT" => 1, |
47 | $default{"DIE_ON_FAILURE"} = 1; | 46 | "DIE_ON_FAILURE" => 1, |
48 | $default{"SSH_EXEC"} = "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND"; | 47 | "SSH_EXEC" => "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND", |
49 | $default{"SCP_TO_TARGET"} = "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE"; | 48 | "SCP_TO_TARGET" => "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE", |
50 | $default{"REBOOT"} = "ssh \$SSH_USER\@\$MACHINE reboot"; | 49 | "REBOOT" => "ssh \$SSH_USER\@\$MACHINE reboot", |
51 | $default{"STOP_AFTER_SUCCESS"} = 10; | 50 | "STOP_AFTER_SUCCESS" => 10, |
52 | $default{"STOP_AFTER_FAILURE"} = 60; | 51 | "STOP_AFTER_FAILURE" => 60, |
53 | $default{"STOP_TEST_AFTER"} = 600; | 52 | "STOP_TEST_AFTER" => 600, |
54 | $default{"LOCALVERSION"} = "-test"; | 53 | |
54 | # required, and we will ask users if they don't have them but we keep the default | ||
55 | # value something that is common. | ||
56 | "REBOOT_TYPE" => "grub", | ||
57 | "LOCALVERSION" => "-test", | ||
58 | "SSH_USER" => "root", | ||
59 | "BUILD_TARGET" => "arch/x86/boot/bzImage", | ||
60 | "TARGET_IMAGE" => "/boot/vmlinuz-test", | ||
61 | |||
62 | "LOG_FILE" => undef, | ||
63 | "IGNORE_UNUSED" => 0, | ||
64 | ); | ||
55 | 65 | ||
56 | my $ktest_config; | 66 | my $ktest_config; |
57 | my $version; | 67 | my $version; |
@@ -73,6 +83,8 @@ my $reboot_script; | |||
73 | my $power_cycle; | 83 | my $power_cycle; |
74 | my $reboot; | 84 | my $reboot; |
75 | my $reboot_on_error; | 85 | my $reboot_on_error; |
86 | my $switch_to_good; | ||
87 | my $switch_to_test; | ||
76 | my $poweroff_on_error; | 88 | my $poweroff_on_error; |
77 | my $die_on_failure; | 89 | my $die_on_failure; |
78 | my $powercycle_after_reboot; | 90 | my $powercycle_after_reboot; |
@@ -92,17 +104,24 @@ my $start_minconfig; | |||
92 | my $start_minconfig_defined; | 104 | my $start_minconfig_defined; |
93 | my $output_minconfig; | 105 | my $output_minconfig; |
94 | my $ignore_config; | 106 | my $ignore_config; |
107 | my $ignore_errors; | ||
95 | my $addconfig; | 108 | my $addconfig; |
96 | my $in_bisect = 0; | 109 | my $in_bisect = 0; |
97 | my $bisect_bad = ""; | 110 | my $bisect_bad_commit = ""; |
98 | my $reverse_bisect; | 111 | my $reverse_bisect; |
99 | my $bisect_manual; | 112 | my $bisect_manual; |
100 | my $bisect_skip; | 113 | my $bisect_skip; |
101 | my $config_bisect_good; | 114 | my $config_bisect_good; |
115 | my $bisect_ret_good; | ||
116 | my $bisect_ret_bad; | ||
117 | my $bisect_ret_skip; | ||
118 | my $bisect_ret_abort; | ||
119 | my $bisect_ret_default; | ||
102 | my $in_patchcheck = 0; | 120 | my $in_patchcheck = 0; |
103 | my $run_test; | 121 | my $run_test; |
104 | my $redirect; | 122 | my $redirect; |
105 | my $buildlog; | 123 | my $buildlog; |
124 | my $testlog; | ||
106 | my $dmesg; | 125 | my $dmesg; |
107 | my $monitor_fp; | 126 | my $monitor_fp; |
108 | my $monitor_pid; | 127 | my $monitor_pid; |
@@ -112,6 +131,7 @@ my $bisect_sleep_time; | |||
112 | my $patchcheck_sleep_time; | 131 | my $patchcheck_sleep_time; |
113 | my $ignore_warnings; | 132 | my $ignore_warnings; |
114 | my $store_failures; | 133 | my $store_failures; |
134 | my $store_successes; | ||
115 | my $test_name; | 135 | my $test_name; |
116 | my $timeout; | 136 | my $timeout; |
117 | my $booted_timeout; | 137 | my $booted_timeout; |
@@ -124,10 +144,34 @@ my $stop_after_failure; | |||
124 | my $stop_test_after; | 144 | my $stop_test_after; |
125 | my $build_target; | 145 | my $build_target; |
126 | my $target_image; | 146 | my $target_image; |
147 | my $checkout; | ||
127 | my $localversion; | 148 | my $localversion; |
128 | my $iteration = 0; | 149 | my $iteration = 0; |
129 | my $successes = 0; | 150 | my $successes = 0; |
130 | 151 | ||
152 | my $bisect_good; | ||
153 | my $bisect_bad; | ||
154 | my $bisect_type; | ||
155 | my $bisect_start; | ||
156 | my $bisect_replay; | ||
157 | my $bisect_files; | ||
158 | my $bisect_reverse; | ||
159 | my $bisect_check; | ||
160 | |||
161 | my $config_bisect; | ||
162 | my $config_bisect_type; | ||
163 | |||
164 | my $patchcheck_type; | ||
165 | my $patchcheck_start; | ||
166 | my $patchcheck_end; | ||
167 | |||
168 | # set when a test is something other that just building or install | ||
169 | # which would require more options. | ||
170 | my $buildonly = 1; | ||
171 | |||
172 | # set when creating a new config | ||
173 | my $newconfig = 0; | ||
174 | |||
131 | my %entered_configs; | 175 | my %entered_configs; |
132 | my %config_help; | 176 | my %config_help; |
133 | my %variable; | 177 | my %variable; |
@@ -136,11 +180,99 @@ my %force_config; | |||
136 | # do not force reboots on config problems | 180 | # do not force reboots on config problems |
137 | my $no_reboot = 1; | 181 | my $no_reboot = 1; |
138 | 182 | ||
183 | my %option_map = ( | ||
184 | "MACHINE" => \$machine, | ||
185 | "SSH_USER" => \$ssh_user, | ||
186 | "TMP_DIR" => \$tmpdir, | ||
187 | "OUTPUT_DIR" => \$outputdir, | ||
188 | "BUILD_DIR" => \$builddir, | ||
189 | "TEST_TYPE" => \$test_type, | ||
190 | "BUILD_TYPE" => \$build_type, | ||
191 | "BUILD_OPTIONS" => \$build_options, | ||
192 | "PRE_BUILD" => \$pre_build, | ||
193 | "POST_BUILD" => \$post_build, | ||
194 | "PRE_BUILD_DIE" => \$pre_build_die, | ||
195 | "POST_BUILD_DIE" => \$post_build_die, | ||
196 | "POWER_CYCLE" => \$power_cycle, | ||
197 | "REBOOT" => \$reboot, | ||
198 | "BUILD_NOCLEAN" => \$noclean, | ||
199 | "MIN_CONFIG" => \$minconfig, | ||
200 | "OUTPUT_MIN_CONFIG" => \$output_minconfig, | ||
201 | "START_MIN_CONFIG" => \$start_minconfig, | ||
202 | "IGNORE_CONFIG" => \$ignore_config, | ||
203 | "TEST" => \$run_test, | ||
204 | "ADD_CONFIG" => \$addconfig, | ||
205 | "REBOOT_TYPE" => \$reboot_type, | ||
206 | "GRUB_MENU" => \$grub_menu, | ||
207 | "POST_INSTALL" => \$post_install, | ||
208 | "NO_INSTALL" => \$no_install, | ||
209 | "REBOOT_SCRIPT" => \$reboot_script, | ||
210 | "REBOOT_ON_ERROR" => \$reboot_on_error, | ||
211 | "SWITCH_TO_GOOD" => \$switch_to_good, | ||
212 | "SWITCH_TO_TEST" => \$switch_to_test, | ||
213 | "POWEROFF_ON_ERROR" => \$poweroff_on_error, | ||
214 | "DIE_ON_FAILURE" => \$die_on_failure, | ||
215 | "POWER_OFF" => \$power_off, | ||
216 | "POWERCYCLE_AFTER_REBOOT" => \$powercycle_after_reboot, | ||
217 | "POWEROFF_AFTER_HALT" => \$poweroff_after_halt, | ||
218 | "SLEEP_TIME" => \$sleep_time, | ||
219 | "BISECT_SLEEP_TIME" => \$bisect_sleep_time, | ||
220 | "PATCHCHECK_SLEEP_TIME" => \$patchcheck_sleep_time, | ||
221 | "IGNORE_WARNINGS" => \$ignore_warnings, | ||
222 | "IGNORE_ERRORS" => \$ignore_errors, | ||
223 | "BISECT_MANUAL" => \$bisect_manual, | ||
224 | "BISECT_SKIP" => \$bisect_skip, | ||
225 | "CONFIG_BISECT_GOOD" => \$config_bisect_good, | ||
226 | "BISECT_RET_GOOD" => \$bisect_ret_good, | ||
227 | "BISECT_RET_BAD" => \$bisect_ret_bad, | ||
228 | "BISECT_RET_SKIP" => \$bisect_ret_skip, | ||
229 | "BISECT_RET_ABORT" => \$bisect_ret_abort, | ||
230 | "BISECT_RET_DEFAULT" => \$bisect_ret_default, | ||
231 | "STORE_FAILURES" => \$store_failures, | ||
232 | "STORE_SUCCESSES" => \$store_successes, | ||
233 | "TEST_NAME" => \$test_name, | ||
234 | "TIMEOUT" => \$timeout, | ||
235 | "BOOTED_TIMEOUT" => \$booted_timeout, | ||
236 | "CONSOLE" => \$console, | ||
237 | "DETECT_TRIPLE_FAULT" => \$detect_triplefault, | ||
238 | "SUCCESS_LINE" => \$success_line, | ||
239 | "REBOOT_SUCCESS_LINE" => \$reboot_success_line, | ||
240 | "STOP_AFTER_SUCCESS" => \$stop_after_success, | ||
241 | "STOP_AFTER_FAILURE" => \$stop_after_failure, | ||
242 | "STOP_TEST_AFTER" => \$stop_test_after, | ||
243 | "BUILD_TARGET" => \$build_target, | ||
244 | "SSH_EXEC" => \$ssh_exec, | ||
245 | "SCP_TO_TARGET" => \$scp_to_target, | ||
246 | "CHECKOUT" => \$checkout, | ||
247 | "TARGET_IMAGE" => \$target_image, | ||
248 | "LOCALVERSION" => \$localversion, | ||
249 | |||
250 | "BISECT_GOOD" => \$bisect_good, | ||
251 | "BISECT_BAD" => \$bisect_bad, | ||
252 | "BISECT_TYPE" => \$bisect_type, | ||
253 | "BISECT_START" => \$bisect_start, | ||
254 | "BISECT_REPLAY" => \$bisect_replay, | ||
255 | "BISECT_FILES" => \$bisect_files, | ||
256 | "BISECT_REVERSE" => \$bisect_reverse, | ||
257 | "BISECT_CHECK" => \$bisect_check, | ||
258 | |||
259 | "CONFIG_BISECT" => \$config_bisect, | ||
260 | "CONFIG_BISECT_TYPE" => \$config_bisect_type, | ||
261 | |||
262 | "PATCHCHECK_TYPE" => \$patchcheck_type, | ||
263 | "PATCHCHECK_START" => \$patchcheck_start, | ||
264 | "PATCHCHECK_END" => \$patchcheck_end, | ||
265 | ); | ||
266 | |||
267 | # Options may be used by other options, record them. | ||
268 | my %used_options; | ||
269 | |||
139 | # default variables that can be used | 270 | # default variables that can be used |
140 | chomp ($variable{"PWD"} = `pwd`); | 271 | chomp ($variable{"PWD"} = `pwd`); |
141 | 272 | ||
142 | $config_help{"MACHINE"} = << "EOF" | 273 | $config_help{"MACHINE"} = << "EOF" |
143 | The machine hostname that you will test. | 274 | The machine hostname that you will test. |
275 | For build only tests, it is still needed to differentiate log files. | ||
144 | EOF | 276 | EOF |
145 | ; | 277 | ; |
146 | $config_help{"SSH_USER"} = << "EOF" | 278 | $config_help{"SSH_USER"} = << "EOF" |
@@ -150,11 +282,15 @@ EOF | |||
150 | ; | 282 | ; |
151 | $config_help{"BUILD_DIR"} = << "EOF" | 283 | $config_help{"BUILD_DIR"} = << "EOF" |
152 | The directory that contains the Linux source code (full path). | 284 | The directory that contains the Linux source code (full path). |
285 | You can use \${PWD} that will be the path where ktest.pl is run, or use | ||
286 | \${THIS_DIR} which is assigned \${PWD} but may be changed later. | ||
153 | EOF | 287 | EOF |
154 | ; | 288 | ; |
155 | $config_help{"OUTPUT_DIR"} = << "EOF" | 289 | $config_help{"OUTPUT_DIR"} = << "EOF" |
156 | The directory that the objects will be built (full path). | 290 | The directory that the objects will be built (full path). |
157 | (can not be same as BUILD_DIR) | 291 | (can not be same as BUILD_DIR) |
292 | You can use \${PWD} that will be the path where ktest.pl is run, or use | ||
293 | \${THIS_DIR} which is assigned \${PWD} but may be changed later. | ||
158 | EOF | 294 | EOF |
159 | ; | 295 | ; |
160 | $config_help{"BUILD_TARGET"} = << "EOF" | 296 | $config_help{"BUILD_TARGET"} = << "EOF" |
@@ -162,6 +298,11 @@ $config_help{"BUILD_TARGET"} = << "EOF" | |||
162 | (relative to OUTPUT_DIR) | 298 | (relative to OUTPUT_DIR) |
163 | EOF | 299 | EOF |
164 | ; | 300 | ; |
301 | $config_help{"BUILD_OPTIONS"} = << "EOF" | ||
302 | Options to add to \"make\" when building. | ||
303 | i.e. -j20 | ||
304 | EOF | ||
305 | ; | ||
165 | $config_help{"TARGET_IMAGE"} = << "EOF" | 306 | $config_help{"TARGET_IMAGE"} = << "EOF" |
166 | The place to put your image on the test machine. | 307 | The place to put your image on the test machine. |
167 | EOF | 308 | EOF |
@@ -227,20 +368,36 @@ $config_help{"REBOOT_SCRIPT"} = << "EOF" | |||
227 | EOF | 368 | EOF |
228 | ; | 369 | ; |
229 | 370 | ||
230 | sub read_yn { | 371 | sub read_prompt { |
231 | my ($prompt) = @_; | 372 | my ($cancel, $prompt) = @_; |
232 | 373 | ||
233 | my $ans; | 374 | my $ans; |
234 | 375 | ||
235 | for (;;) { | 376 | for (;;) { |
236 | print "$prompt [Y/n] "; | 377 | if ($cancel) { |
378 | print "$prompt [y/n/C] "; | ||
379 | } else { | ||
380 | print "$prompt [Y/n] "; | ||
381 | } | ||
237 | $ans = <STDIN>; | 382 | $ans = <STDIN>; |
238 | chomp $ans; | 383 | chomp $ans; |
239 | if ($ans =~ /^\s*$/) { | 384 | if ($ans =~ /^\s*$/) { |
240 | $ans = "y"; | 385 | if ($cancel) { |
386 | $ans = "c"; | ||
387 | } else { | ||
388 | $ans = "y"; | ||
389 | } | ||
241 | } | 390 | } |
242 | last if ($ans =~ /^y$/i || $ans =~ /^n$/i); | 391 | last if ($ans =~ /^y$/i || $ans =~ /^n$/i); |
243 | print "Please answer either 'y' or 'n'.\n"; | 392 | if ($cancel) { |
393 | last if ($ans =~ /^c$/i); | ||
394 | print "Please answer either 'y', 'n' or 'c'.\n"; | ||
395 | } else { | ||
396 | print "Please answer either 'y' or 'n'.\n"; | ||
397 | } | ||
398 | } | ||
399 | if ($ans =~ /^c/i) { | ||
400 | exit; | ||
244 | } | 401 | } |
245 | if ($ans !~ /^y$/i) { | 402 | if ($ans !~ /^y$/i) { |
246 | return 0; | 403 | return 0; |
@@ -248,6 +405,18 @@ sub read_yn { | |||
248 | return 1; | 405 | return 1; |
249 | } | 406 | } |
250 | 407 | ||
408 | sub read_yn { | ||
409 | my ($prompt) = @_; | ||
410 | |||
411 | return read_prompt 0, $prompt; | ||
412 | } | ||
413 | |||
414 | sub read_ync { | ||
415 | my ($prompt) = @_; | ||
416 | |||
417 | return read_prompt 1, $prompt; | ||
418 | } | ||
419 | |||
251 | sub get_ktest_config { | 420 | sub get_ktest_config { |
252 | my ($config) = @_; | 421 | my ($config) = @_; |
253 | my $ans; | 422 | my $ans; |
@@ -261,7 +430,7 @@ sub get_ktest_config { | |||
261 | 430 | ||
262 | for (;;) { | 431 | for (;;) { |
263 | print "$config = "; | 432 | print "$config = "; |
264 | if (defined($default{$config})) { | 433 | if (defined($default{$config}) && length($default{$config})) { |
265 | print "\[$default{$config}\] "; | 434 | print "\[$default{$config}\] "; |
266 | } | 435 | } |
267 | $ans = <STDIN>; | 436 | $ans = <STDIN>; |
@@ -274,22 +443,37 @@ sub get_ktest_config { | |||
274 | next; | 443 | next; |
275 | } | 444 | } |
276 | } | 445 | } |
277 | $entered_configs{$config} = process_variables($ans); | 446 | $entered_configs{$config} = ${ans}; |
278 | last; | 447 | last; |
279 | } | 448 | } |
280 | } | 449 | } |
281 | 450 | ||
282 | sub get_ktest_configs { | 451 | sub get_ktest_configs { |
283 | get_ktest_config("MACHINE"); | 452 | get_ktest_config("MACHINE"); |
284 | get_ktest_config("SSH_USER"); | ||
285 | get_ktest_config("BUILD_DIR"); | 453 | get_ktest_config("BUILD_DIR"); |
286 | get_ktest_config("OUTPUT_DIR"); | 454 | get_ktest_config("OUTPUT_DIR"); |
287 | get_ktest_config("BUILD_TARGET"); | 455 | |
288 | get_ktest_config("TARGET_IMAGE"); | 456 | if ($newconfig) { |
289 | get_ktest_config("POWER_CYCLE"); | 457 | get_ktest_config("BUILD_OPTIONS"); |
290 | get_ktest_config("CONSOLE"); | 458 | } |
459 | |||
460 | # options required for other than just building a kernel | ||
461 | if (!$buildonly) { | ||
462 | get_ktest_config("POWER_CYCLE"); | ||
463 | get_ktest_config("CONSOLE"); | ||
464 | } | ||
465 | |||
466 | # options required for install and more | ||
467 | if ($buildonly != 1) { | ||
468 | get_ktest_config("SSH_USER"); | ||
469 | get_ktest_config("BUILD_TARGET"); | ||
470 | get_ktest_config("TARGET_IMAGE"); | ||
471 | } | ||
472 | |||
291 | get_ktest_config("LOCALVERSION"); | 473 | get_ktest_config("LOCALVERSION"); |
292 | 474 | ||
475 | return if ($buildonly); | ||
476 | |||
293 | my $rtype = $opt{"REBOOT_TYPE"}; | 477 | my $rtype = $opt{"REBOOT_TYPE"}; |
294 | 478 | ||
295 | if (!defined($rtype)) { | 479 | if (!defined($rtype)) { |
@@ -303,8 +487,6 @@ sub get_ktest_configs { | |||
303 | 487 | ||
304 | if ($rtype eq "grub") { | 488 | if ($rtype eq "grub") { |
305 | get_ktest_config("GRUB_MENU"); | 489 | get_ktest_config("GRUB_MENU"); |
306 | } else { | ||
307 | get_ktest_config("REBOOT_SCRIPT"); | ||
308 | } | 490 | } |
309 | } | 491 | } |
310 | 492 | ||
@@ -334,6 +516,10 @@ sub process_variables { | |||
334 | } else { | 516 | } else { |
335 | # put back the origin piece. | 517 | # put back the origin piece. |
336 | $retval = "$retval\$\{$var\}"; | 518 | $retval = "$retval\$\{$var\}"; |
519 | # This could be an option that is used later, save | ||
520 | # it so we don't warn if this option is not one of | ||
521 | # ktests options. | ||
522 | $used_options{$var} = 1; | ||
337 | } | 523 | } |
338 | $value = $end; | 524 | $value = $end; |
339 | } | 525 | } |
@@ -348,6 +534,19 @@ sub process_variables { | |||
348 | sub set_value { | 534 | sub set_value { |
349 | my ($lvalue, $rvalue, $override, $overrides, $name) = @_; | 535 | my ($lvalue, $rvalue, $override, $overrides, $name) = @_; |
350 | 536 | ||
537 | my $prvalue = process_variables($rvalue); | ||
538 | |||
539 | if ($buildonly && $lvalue =~ /^TEST_TYPE(\[.*\])?$/ && $prvalue ne "build") { | ||
540 | # Note if a test is something other than build, then we | ||
541 | # will need other manditory options. | ||
542 | if ($prvalue ne "install") { | ||
543 | $buildonly = 0; | ||
544 | } else { | ||
545 | # install still limits some manditory options. | ||
546 | $buildonly = 2; | ||
547 | } | ||
548 | } | ||
549 | |||
351 | if (defined($opt{$lvalue})) { | 550 | if (defined($opt{$lvalue})) { |
352 | if (!$override || defined(${$overrides}{$lvalue})) { | 551 | if (!$override || defined(${$overrides}{$lvalue})) { |
353 | my $extra = ""; | 552 | my $extra = ""; |
@@ -356,13 +555,12 @@ sub set_value { | |||
356 | } | 555 | } |
357 | die "$name: $.: Option $lvalue defined more than once!\n$extra"; | 556 | die "$name: $.: Option $lvalue defined more than once!\n$extra"; |
358 | } | 557 | } |
359 | ${$overrides}{$lvalue} = $rvalue; | 558 | ${$overrides}{$lvalue} = $prvalue; |
360 | } | 559 | } |
361 | if ($rvalue =~ /^\s*$/) { | 560 | if ($rvalue =~ /^\s*$/) { |
362 | delete $opt{$lvalue}; | 561 | delete $opt{$lvalue}; |
363 | } else { | 562 | } else { |
364 | $rvalue = process_variables($rvalue); | 563 | $opt{$lvalue} = $prvalue; |
365 | $opt{$lvalue} = $rvalue; | ||
366 | } | 564 | } |
367 | } | 565 | } |
368 | 566 | ||
@@ -712,6 +910,15 @@ sub __read_config { | |||
712 | return $test_case; | 910 | return $test_case; |
713 | } | 911 | } |
714 | 912 | ||
913 | sub get_test_case { | ||
914 | print "What test case would you like to run?\n"; | ||
915 | print " (build, install or boot)\n"; | ||
916 | print " Other tests are available but require editing the config file\n"; | ||
917 | my $ans = <STDIN>; | ||
918 | chomp $ans; | ||
919 | $default{"TEST_TYPE"} = $ans; | ||
920 | } | ||
921 | |||
715 | sub read_config { | 922 | sub read_config { |
716 | my ($config) = @_; | 923 | my ($config) = @_; |
717 | 924 | ||
@@ -726,10 +933,7 @@ sub read_config { | |||
726 | # was a test specified? | 933 | # was a test specified? |
727 | if (!$test_case) { | 934 | if (!$test_case) { |
728 | print "No test case specified.\n"; | 935 | print "No test case specified.\n"; |
729 | print "What test case would you like to run?\n"; | 936 | get_test_case; |
730 | my $ans = <STDIN>; | ||
731 | chomp $ans; | ||
732 | $default{"TEST_TYPE"} = $ans; | ||
733 | } | 937 | } |
734 | 938 | ||
735 | # set any defaults | 939 | # set any defaults |
@@ -739,6 +943,37 @@ sub read_config { | |||
739 | $opt{$default} = $default{$default}; | 943 | $opt{$default} = $default{$default}; |
740 | } | 944 | } |
741 | } | 945 | } |
946 | |||
947 | if ($opt{"IGNORE_UNUSED"} == 1) { | ||
948 | return; | ||
949 | } | ||
950 | |||
951 | my %not_used; | ||
952 | |||
953 | # check if there are any stragglers (typos?) | ||
954 | foreach my $option (keys %opt) { | ||
955 | my $op = $option; | ||
956 | # remove per test labels. | ||
957 | $op =~ s/\[.*\]//; | ||
958 | if (!exists($option_map{$op}) && | ||
959 | !exists($default{$op}) && | ||
960 | !exists($used_options{$op})) { | ||
961 | $not_used{$op} = 1; | ||
962 | } | ||
963 | } | ||
964 | |||
965 | if (%not_used) { | ||
966 | my $s = "s are"; | ||
967 | $s = " is" if (keys %not_used == 1); | ||
968 | print "The following option$s not used; could be a typo:\n"; | ||
969 | foreach my $option (keys %not_used) { | ||
970 | print "$option\n"; | ||
971 | } | ||
972 | print "Set IGRNORE_UNUSED = 1 to have ktest ignore unused variables\n"; | ||
973 | if (!read_yn "Do you want to continue?") { | ||
974 | exit -1; | ||
975 | } | ||
976 | } | ||
742 | } | 977 | } |
743 | 978 | ||
744 | sub __eval_option { | 979 | sub __eval_option { |
@@ -873,6 +1108,17 @@ sub reboot { | |||
873 | } | 1108 | } |
874 | } | 1109 | } |
875 | 1110 | ||
1111 | sub reboot_to_good { | ||
1112 | my ($time) = @_; | ||
1113 | |||
1114 | if (defined($switch_to_good)) { | ||
1115 | run_command $switch_to_good; | ||
1116 | return; | ||
1117 | } | ||
1118 | |||
1119 | reboot $time; | ||
1120 | } | ||
1121 | |||
876 | sub do_not_reboot { | 1122 | sub do_not_reboot { |
877 | my $i = $iteration; | 1123 | my $i = $iteration; |
878 | 1124 | ||
@@ -889,7 +1135,7 @@ sub dodie { | |||
889 | if ($reboot_on_error && !do_not_reboot) { | 1135 | if ($reboot_on_error && !do_not_reboot) { |
890 | 1136 | ||
891 | doprint "REBOOTING\n"; | 1137 | doprint "REBOOTING\n"; |
892 | reboot; | 1138 | reboot_to_good; |
893 | 1139 | ||
894 | } elsif ($poweroff_on_error && defined($power_off)) { | 1140 | } elsif ($poweroff_on_error && defined($power_off)) { |
895 | doprint "POWERING OFF\n"; | 1141 | doprint "POWERING OFF\n"; |
@@ -975,6 +1221,43 @@ sub wait_for_monitor { | |||
975 | print "** Monitor flushed **\n"; | 1221 | print "** Monitor flushed **\n"; |
976 | } | 1222 | } |
977 | 1223 | ||
1224 | sub save_logs { | ||
1225 | my ($result, $basedir) = @_; | ||
1226 | my @t = localtime; | ||
1227 | my $date = sprintf "%04d%02d%02d%02d%02d%02d", | ||
1228 | 1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0]; | ||
1229 | |||
1230 | my $type = $build_type; | ||
1231 | if ($type =~ /useconfig/) { | ||
1232 | $type = "useconfig"; | ||
1233 | } | ||
1234 | |||
1235 | my $dir = "$machine-$test_type-$type-$result-$date"; | ||
1236 | |||
1237 | $dir = "$basedir/$dir"; | ||
1238 | |||
1239 | if (!-d $dir) { | ||
1240 | mkpath($dir) or | ||
1241 | die "can't create $dir"; | ||
1242 | } | ||
1243 | |||
1244 | my %files = ( | ||
1245 | "config" => $output_config, | ||
1246 | "buildlog" => $buildlog, | ||
1247 | "dmesg" => $dmesg, | ||
1248 | "testlog" => $testlog, | ||
1249 | ); | ||
1250 | |||
1251 | while (my ($name, $source) = each(%files)) { | ||
1252 | if (-f "$source") { | ||
1253 | cp "$source", "$dir/$name" or | ||
1254 | die "failed to copy $source"; | ||
1255 | } | ||
1256 | } | ||
1257 | |||
1258 | doprint "*** Saved info to $dir ***\n"; | ||
1259 | } | ||
1260 | |||
978 | sub fail { | 1261 | sub fail { |
979 | 1262 | ||
980 | if ($die_on_failure) { | 1263 | if ($die_on_failure) { |
@@ -988,7 +1271,7 @@ sub fail { | |||
988 | # no need to reboot for just building. | 1271 | # no need to reboot for just building. |
989 | if (!do_not_reboot) { | 1272 | if (!do_not_reboot) { |
990 | doprint "REBOOTING\n"; | 1273 | doprint "REBOOTING\n"; |
991 | reboot $sleep_time; | 1274 | reboot_to_good $sleep_time; |
992 | } | 1275 | } |
993 | 1276 | ||
994 | my $name = ""; | 1277 | my $name = ""; |
@@ -1003,38 +1286,9 @@ sub fail { | |||
1003 | doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; | 1286 | doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; |
1004 | doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; | 1287 | doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; |
1005 | 1288 | ||
1006 | return 1 if (!defined($store_failures)); | 1289 | if (defined($store_failures)) { |
1007 | 1290 | save_logs "fail", $store_failures; | |
1008 | my @t = localtime; | 1291 | } |
1009 | my $date = sprintf "%04d%02d%02d%02d%02d%02d", | ||
1010 | 1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0]; | ||
1011 | |||
1012 | my $type = $build_type; | ||
1013 | if ($type =~ /useconfig/) { | ||
1014 | $type = "useconfig"; | ||
1015 | } | ||
1016 | |||
1017 | my $dir = "$machine-$test_type-$type-fail-$date"; | ||
1018 | my $faildir = "$store_failures/$dir"; | ||
1019 | |||
1020 | if (!-d $faildir) { | ||
1021 | mkpath($faildir) or | ||
1022 | die "can't create $faildir"; | ||
1023 | } | ||
1024 | if (-f "$output_config") { | ||
1025 | cp "$output_config", "$faildir/config" or | ||
1026 | die "failed to copy .config"; | ||
1027 | } | ||
1028 | if (-f $buildlog) { | ||
1029 | cp $buildlog, "$faildir/buildlog" or | ||
1030 | die "failed to move $buildlog"; | ||
1031 | } | ||
1032 | if (-f $dmesg) { | ||
1033 | cp $dmesg, "$faildir/dmesg" or | ||
1034 | die "failed to move $dmesg"; | ||
1035 | } | ||
1036 | |||
1037 | doprint "*** Saved info to $faildir ***\n"; | ||
1038 | 1292 | ||
1039 | return 1; | 1293 | return 1; |
1040 | } | 1294 | } |
@@ -1170,13 +1424,16 @@ sub wait_for_input | |||
1170 | } | 1424 | } |
1171 | 1425 | ||
1172 | sub reboot_to { | 1426 | sub reboot_to { |
1427 | if (defined($switch_to_test)) { | ||
1428 | run_command $switch_to_test; | ||
1429 | } | ||
1430 | |||
1173 | if ($reboot_type eq "grub") { | 1431 | if ($reboot_type eq "grub") { |
1174 | run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch)'"; | 1432 | run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch)'"; |
1175 | reboot; | 1433 | } elsif (defined $reboot_script) { |
1176 | return; | 1434 | run_command "$reboot_script"; |
1177 | } | 1435 | } |
1178 | 1436 | reboot; | |
1179 | run_command "$reboot_script"; | ||
1180 | } | 1437 | } |
1181 | 1438 | ||
1182 | sub get_sha1 { | 1439 | sub get_sha1 { |
@@ -1274,7 +1531,7 @@ sub monitor { | |||
1274 | } | 1531 | } |
1275 | 1532 | ||
1276 | if ($full_line =~ /call trace:/i) { | 1533 | if ($full_line =~ /call trace:/i) { |
1277 | if (!$bug && !$skip_call_trace) { | 1534 | if (!$ignore_errors && !$bug && !$skip_call_trace) { |
1278 | $bug = 1; | 1535 | $bug = 1; |
1279 | $failure_start = time; | 1536 | $failure_start = time; |
1280 | } | 1537 | } |
@@ -1341,12 +1598,19 @@ sub monitor { | |||
1341 | return 1; | 1598 | return 1; |
1342 | } | 1599 | } |
1343 | 1600 | ||
1601 | sub eval_kernel_version { | ||
1602 | my ($option) = @_; | ||
1603 | |||
1604 | $option =~ s/\$KERNEL_VERSION/$version/g; | ||
1605 | |||
1606 | return $option; | ||
1607 | } | ||
1608 | |||
1344 | sub do_post_install { | 1609 | sub do_post_install { |
1345 | 1610 | ||
1346 | return if (!defined($post_install)); | 1611 | return if (!defined($post_install)); |
1347 | 1612 | ||
1348 | my $cp_post_install = $post_install; | 1613 | my $cp_post_install = eval_kernel_version $post_install; |
1349 | $cp_post_install =~ s/\$KERNEL_VERSION/$version/g; | ||
1350 | run_command "$cp_post_install" or | 1614 | run_command "$cp_post_install" or |
1351 | dodie "Failed to run post install"; | 1615 | dodie "Failed to run post install"; |
1352 | } | 1616 | } |
@@ -1355,7 +1619,9 @@ sub install { | |||
1355 | 1619 | ||
1356 | return if ($no_install); | 1620 | return if ($no_install); |
1357 | 1621 | ||
1358 | run_scp "$outputdir/$build_target", "$target_image" or | 1622 | my $cp_target = eval_kernel_version $target_image; |
1623 | |||
1624 | run_scp "$outputdir/$build_target", "$cp_target" or | ||
1359 | dodie "failed to copy image"; | 1625 | dodie "failed to copy image"; |
1360 | 1626 | ||
1361 | my $install_mods = 0; | 1627 | my $install_mods = 0; |
@@ -1640,9 +1906,13 @@ sub success { | |||
1640 | doprint "*******************************************\n"; | 1906 | doprint "*******************************************\n"; |
1641 | doprint "*******************************************\n"; | 1907 | doprint "*******************************************\n"; |
1642 | 1908 | ||
1909 | if (defined($store_successes)) { | ||
1910 | save_logs "success", $store_successes; | ||
1911 | } | ||
1912 | |||
1643 | if ($i != $opt{"NUM_TESTS"} && !do_not_reboot) { | 1913 | if ($i != $opt{"NUM_TESTS"} && !do_not_reboot) { |
1644 | doprint "Reboot and wait $sleep_time seconds\n"; | 1914 | doprint "Reboot and wait $sleep_time seconds\n"; |
1645 | reboot $sleep_time; | 1915 | reboot_to_good $sleep_time; |
1646 | } | 1916 | } |
1647 | } | 1917 | } |
1648 | 1918 | ||
@@ -1669,7 +1939,10 @@ sub child_run_test { | |||
1669 | $poweroff_on_error = 0; | 1939 | $poweroff_on_error = 0; |
1670 | $die_on_failure = 1; | 1940 | $die_on_failure = 1; |
1671 | 1941 | ||
1942 | $redirect = "$testlog"; | ||
1672 | run_command $run_test or $failed = 1; | 1943 | run_command $run_test or $failed = 1; |
1944 | undef $redirect; | ||
1945 | |||
1673 | exit $failed; | 1946 | exit $failed; |
1674 | } | 1947 | } |
1675 | 1948 | ||
@@ -1744,6 +2017,43 @@ sub do_run_test { | |||
1744 | waitpid $child_pid, 0; | 2017 | waitpid $child_pid, 0; |
1745 | $child_exit = $?; | 2018 | $child_exit = $?; |
1746 | 2019 | ||
2020 | if (!$bug && $in_bisect) { | ||
2021 | if (defined($bisect_ret_good)) { | ||
2022 | if ($child_exit == $bisect_ret_good) { | ||
2023 | return 1; | ||
2024 | } | ||
2025 | } | ||
2026 | if (defined($bisect_ret_skip)) { | ||
2027 | if ($child_exit == $bisect_ret_skip) { | ||
2028 | return -1; | ||
2029 | } | ||
2030 | } | ||
2031 | if (defined($bisect_ret_abort)) { | ||
2032 | if ($child_exit == $bisect_ret_abort) { | ||
2033 | fail "test abort" and return -2; | ||
2034 | } | ||
2035 | } | ||
2036 | if (defined($bisect_ret_bad)) { | ||
2037 | if ($child_exit == $bisect_ret_skip) { | ||
2038 | return 0; | ||
2039 | } | ||
2040 | } | ||
2041 | if (defined($bisect_ret_default)) { | ||
2042 | if ($bisect_ret_default eq "good") { | ||
2043 | return 1; | ||
2044 | } elsif ($bisect_ret_default eq "bad") { | ||
2045 | return 0; | ||
2046 | } elsif ($bisect_ret_default eq "skip") { | ||
2047 | return -1; | ||
2048 | } elsif ($bisect_ret_default eq "abort") { | ||
2049 | return -2; | ||
2050 | } else { | ||
2051 | fail "unknown default action: $bisect_ret_default" | ||
2052 | and return -2; | ||
2053 | } | ||
2054 | } | ||
2055 | } | ||
2056 | |||
1747 | if ($bug || $child_exit) { | 2057 | if ($bug || $child_exit) { |
1748 | return 0 if $in_bisect; | 2058 | return 0 if $in_bisect; |
1749 | fail "test failed" and return 0; | 2059 | fail "test failed" and return 0; |
@@ -1770,7 +2080,7 @@ sub run_git_bisect { | |||
1770 | if ($output =~ m/^(Bisecting: .*\(roughly \d+ steps?\))\s+\[([[:xdigit:]]+)\]/) { | 2080 | if ($output =~ m/^(Bisecting: .*\(roughly \d+ steps?\))\s+\[([[:xdigit:]]+)\]/) { |
1771 | doprint "$1 [$2]\n"; | 2081 | doprint "$1 [$2]\n"; |
1772 | } elsif ($output =~ m/^([[:xdigit:]]+) is the first bad commit/) { | 2082 | } elsif ($output =~ m/^([[:xdigit:]]+) is the first bad commit/) { |
1773 | $bisect_bad = $1; | 2083 | $bisect_bad_commit = $1; |
1774 | doprint "Found bad commit... $1\n"; | 2084 | doprint "Found bad commit... $1\n"; |
1775 | return 0; | 2085 | return 0; |
1776 | } else { | 2086 | } else { |
@@ -1783,7 +2093,7 @@ sub run_git_bisect { | |||
1783 | 2093 | ||
1784 | sub bisect_reboot { | 2094 | sub bisect_reboot { |
1785 | doprint "Reboot and sleep $bisect_sleep_time seconds\n"; | 2095 | doprint "Reboot and sleep $bisect_sleep_time seconds\n"; |
1786 | reboot $bisect_sleep_time; | 2096 | reboot_to_good $bisect_sleep_time; |
1787 | } | 2097 | } |
1788 | 2098 | ||
1789 | # returns 1 on success, 0 on failure, -1 on skip | 2099 | # returns 1 on success, 0 on failure, -1 on skip |
@@ -1868,21 +2178,28 @@ sub run_bisect { | |||
1868 | } | 2178 | } |
1869 | } | 2179 | } |
1870 | 2180 | ||
2181 | sub update_bisect_replay { | ||
2182 | my $tmp_log = "$tmpdir/ktest_bisect_log"; | ||
2183 | run_command "git bisect log > $tmp_log" or | ||
2184 | die "can't create bisect log"; | ||
2185 | return $tmp_log; | ||
2186 | } | ||
2187 | |||
1871 | sub bisect { | 2188 | sub bisect { |
1872 | my ($i) = @_; | 2189 | my ($i) = @_; |
1873 | 2190 | ||
1874 | my $result; | 2191 | my $result; |
1875 | 2192 | ||
1876 | die "BISECT_GOOD[$i] not defined\n" if (!defined($opt{"BISECT_GOOD[$i]"})); | 2193 | die "BISECT_GOOD[$i] not defined\n" if (!defined($bisect_good)); |
1877 | die "BISECT_BAD[$i] not defined\n" if (!defined($opt{"BISECT_BAD[$i]"})); | 2194 | die "BISECT_BAD[$i] not defined\n" if (!defined($bisect_bad)); |
1878 | die "BISECT_TYPE[$i] not defined\n" if (!defined($opt{"BISECT_TYPE[$i]"})); | 2195 | die "BISECT_TYPE[$i] not defined\n" if (!defined($bisect_type)); |
1879 | 2196 | ||
1880 | my $good = $opt{"BISECT_GOOD[$i]"}; | 2197 | my $good = $bisect_good; |
1881 | my $bad = $opt{"BISECT_BAD[$i]"}; | 2198 | my $bad = $bisect_bad; |
1882 | my $type = $opt{"BISECT_TYPE[$i]"}; | 2199 | my $type = $bisect_type; |
1883 | my $start = $opt{"BISECT_START[$i]"}; | 2200 | my $start = $bisect_start; |
1884 | my $replay = $opt{"BISECT_REPLAY[$i]"}; | 2201 | my $replay = $bisect_replay; |
1885 | my $start_files = $opt{"BISECT_FILES[$i]"}; | 2202 | my $start_files = $bisect_files; |
1886 | 2203 | ||
1887 | if (defined($start_files)) { | 2204 | if (defined($start_files)) { |
1888 | $start_files = " -- " . $start_files; | 2205 | $start_files = " -- " . $start_files; |
@@ -1894,8 +2211,7 @@ sub bisect { | |||
1894 | $good = get_sha1($good); | 2211 | $good = get_sha1($good); |
1895 | $bad = get_sha1($bad); | 2212 | $bad = get_sha1($bad); |
1896 | 2213 | ||
1897 | if (defined($opt{"BISECT_REVERSE[$i]"}) && | 2214 | if (defined($bisect_reverse) && $bisect_reverse == 1) { |
1898 | $opt{"BISECT_REVERSE[$i]"} == 1) { | ||
1899 | doprint "Performing a reverse bisect (bad is good, good is bad!)\n"; | 2215 | doprint "Performing a reverse bisect (bad is good, good is bad!)\n"; |
1900 | $reverse_bisect = 1; | 2216 | $reverse_bisect = 1; |
1901 | } else { | 2217 | } else { |
@@ -1907,8 +2223,31 @@ sub bisect { | |||
1907 | $type = "boot"; | 2223 | $type = "boot"; |
1908 | } | 2224 | } |
1909 | 2225 | ||
1910 | my $check = $opt{"BISECT_CHECK[$i]"}; | 2226 | # Check if a bisect was running |
1911 | if (defined($check) && $check ne "0") { | 2227 | my $bisect_start_file = "$builddir/.git/BISECT_START"; |
2228 | |||
2229 | my $check = $bisect_check; | ||
2230 | my $do_check = defined($check) && $check ne "0"; | ||
2231 | |||
2232 | if ( -f $bisect_start_file ) { | ||
2233 | print "Bisect in progress found\n"; | ||
2234 | if ($do_check) { | ||
2235 | print " If you say yes, then no checks of good or bad will be done\n"; | ||
2236 | } | ||
2237 | if (defined($replay)) { | ||
2238 | print "** BISECT_REPLAY is defined in config file **"; | ||
2239 | print " Ignore config option and perform new git bisect log?\n"; | ||
2240 | if (read_ync " (yes, no, or cancel) ") { | ||
2241 | $replay = update_bisect_replay; | ||
2242 | $do_check = 0; | ||
2243 | } | ||
2244 | } elsif (read_yn "read git log and continue?") { | ||
2245 | $replay = update_bisect_replay; | ||
2246 | $do_check = 0; | ||
2247 | } | ||
2248 | } | ||
2249 | |||
2250 | if ($do_check) { | ||
1912 | 2251 | ||
1913 | # get current HEAD | 2252 | # get current HEAD |
1914 | my $head = get_sha1("HEAD"); | 2253 | my $head = get_sha1("HEAD"); |
@@ -1973,7 +2312,7 @@ sub bisect { | |||
1973 | run_command "git bisect reset" or | 2312 | run_command "git bisect reset" or |
1974 | dodie "could not reset git bisect"; | 2313 | dodie "could not reset git bisect"; |
1975 | 2314 | ||
1976 | doprint "Bad commit was [$bisect_bad]\n"; | 2315 | doprint "Bad commit was [$bisect_bad_commit]\n"; |
1977 | 2316 | ||
1978 | success $i; | 2317 | success $i; |
1979 | } | 2318 | } |
@@ -2129,7 +2468,7 @@ sub run_config_bisect { | |||
2129 | } | 2468 | } |
2130 | 2469 | ||
2131 | doprint "***** RUN TEST ***\n"; | 2470 | doprint "***** RUN TEST ***\n"; |
2132 | my $type = $opt{"CONFIG_BISECT_TYPE[$iteration]"}; | 2471 | my $type = $config_bisect_type; |
2133 | my $ret; | 2472 | my $ret; |
2134 | my %current_config; | 2473 | my %current_config; |
2135 | 2474 | ||
@@ -2233,7 +2572,7 @@ sub run_config_bisect { | |||
2233 | sub config_bisect { | 2572 | sub config_bisect { |
2234 | my ($i) = @_; | 2573 | my ($i) = @_; |
2235 | 2574 | ||
2236 | my $start_config = $opt{"CONFIG_BISECT[$i]"}; | 2575 | my $start_config = $config_bisect; |
2237 | 2576 | ||
2238 | my $tmpconfig = "$tmpdir/use_config"; | 2577 | my $tmpconfig = "$tmpdir/use_config"; |
2239 | 2578 | ||
@@ -2346,29 +2685,29 @@ sub config_bisect { | |||
2346 | 2685 | ||
2347 | sub patchcheck_reboot { | 2686 | sub patchcheck_reboot { |
2348 | doprint "Reboot and sleep $patchcheck_sleep_time seconds\n"; | 2687 | doprint "Reboot and sleep $patchcheck_sleep_time seconds\n"; |
2349 | reboot $patchcheck_sleep_time; | 2688 | reboot_to_good $patchcheck_sleep_time; |
2350 | } | 2689 | } |
2351 | 2690 | ||
2352 | sub patchcheck { | 2691 | sub patchcheck { |
2353 | my ($i) = @_; | 2692 | my ($i) = @_; |
2354 | 2693 | ||
2355 | die "PATCHCHECK_START[$i] not defined\n" | 2694 | die "PATCHCHECK_START[$i] not defined\n" |
2356 | if (!defined($opt{"PATCHCHECK_START[$i]"})); | 2695 | if (!defined($patchcheck_start)); |
2357 | die "PATCHCHECK_TYPE[$i] not defined\n" | 2696 | die "PATCHCHECK_TYPE[$i] not defined\n" |
2358 | if (!defined($opt{"PATCHCHECK_TYPE[$i]"})); | 2697 | if (!defined($patchcheck_type)); |
2359 | 2698 | ||
2360 | my $start = $opt{"PATCHCHECK_START[$i]"}; | 2699 | my $start = $patchcheck_start; |
2361 | 2700 | ||
2362 | my $end = "HEAD"; | 2701 | my $end = "HEAD"; |
2363 | if (defined($opt{"PATCHCHECK_END[$i]"})) { | 2702 | if (defined($patchcheck_end)) { |
2364 | $end = $opt{"PATCHCHECK_END[$i]"}; | 2703 | $end = $patchcheck_end; |
2365 | } | 2704 | } |
2366 | 2705 | ||
2367 | # Get the true sha1's since we can use things like HEAD~3 | 2706 | # Get the true sha1's since we can use things like HEAD~3 |
2368 | $start = get_sha1($start); | 2707 | $start = get_sha1($start); |
2369 | $end = get_sha1($end); | 2708 | $end = get_sha1($end); |
2370 | 2709 | ||
2371 | my $type = $opt{"PATCHCHECK_TYPE[$i]"}; | 2710 | my $type = $patchcheck_type; |
2372 | 2711 | ||
2373 | # Can't have a test without having a test to run | 2712 | # Can't have a test without having a test to run |
2374 | if ($type eq "test" && !defined($run_test)) { | 2713 | if ($type eq "test" && !defined($run_test)) { |
@@ -2963,7 +3302,7 @@ sub make_min_config { | |||
2963 | } | 3302 | } |
2964 | 3303 | ||
2965 | doprint "Reboot and wait $sleep_time seconds\n"; | 3304 | doprint "Reboot and wait $sleep_time seconds\n"; |
2966 | reboot $sleep_time; | 3305 | reboot_to_good $sleep_time; |
2967 | } | 3306 | } |
2968 | 3307 | ||
2969 | success $i; | 3308 | success $i; |
@@ -2985,13 +3324,27 @@ if ($#ARGV == 0) { | |||
2985 | } | 3324 | } |
2986 | 3325 | ||
2987 | if (! -f $ktest_config) { | 3326 | if (! -f $ktest_config) { |
3327 | $newconfig = 1; | ||
3328 | get_test_case; | ||
2988 | open(OUT, ">$ktest_config") or die "Can not create $ktest_config"; | 3329 | open(OUT, ">$ktest_config") or die "Can not create $ktest_config"; |
2989 | print OUT << "EOF" | 3330 | print OUT << "EOF" |
2990 | # Generated by ktest.pl | 3331 | # Generated by ktest.pl |
2991 | # | 3332 | # |
3333 | |||
3334 | # PWD is a ktest.pl variable that will result in the process working | ||
3335 | # directory that ktest.pl is executed in. | ||
3336 | |||
3337 | # THIS_DIR is automatically assigned the PWD of the path that generated | ||
3338 | # the config file. It is best to use this variable when assigning other | ||
3339 | # directory paths within this directory. This allows you to easily | ||
3340 | # move the test cases to other locations or to other machines. | ||
3341 | # | ||
3342 | THIS_DIR := $variable{"PWD"} | ||
3343 | |||
2992 | # Define each test with TEST_START | 3344 | # Define each test with TEST_START |
2993 | # The config options below it will override the defaults | 3345 | # The config options below it will override the defaults |
2994 | TEST_START | 3346 | TEST_START |
3347 | TEST_TYPE = $default{"TEST_TYPE"} | ||
2995 | 3348 | ||
2996 | DEFAULTS | 3349 | DEFAULTS |
2997 | EOF | 3350 | EOF |
@@ -3011,7 +3364,7 @@ if ($#new_configs >= 0) { | |||
3011 | open(OUT, ">>$ktest_config") or die "Can not append to $ktest_config"; | 3364 | open(OUT, ">>$ktest_config") or die "Can not append to $ktest_config"; |
3012 | foreach my $config (@new_configs) { | 3365 | foreach my $config (@new_configs) { |
3013 | print OUT "$config = $entered_configs{$config}\n"; | 3366 | print OUT "$config = $entered_configs{$config}\n"; |
3014 | $opt{$config} = $entered_configs{$config}; | 3367 | $opt{$config} = process_variables($entered_configs{$config}); |
3015 | } | 3368 | } |
3016 | } | 3369 | } |
3017 | 3370 | ||
@@ -3091,61 +3444,10 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
3091 | 3444 | ||
3092 | my $makecmd = set_test_option("MAKE_CMD", $i); | 3445 | my $makecmd = set_test_option("MAKE_CMD", $i); |
3093 | 3446 | ||
3094 | $machine = set_test_option("MACHINE", $i); | 3447 | # Load all the options into their mapped variable names |
3095 | $ssh_user = set_test_option("SSH_USER", $i); | 3448 | foreach my $opt (keys %option_map) { |
3096 | $tmpdir = set_test_option("TMP_DIR", $i); | 3449 | ${$option_map{$opt}} = set_test_option($opt, $i); |
3097 | $outputdir = set_test_option("OUTPUT_DIR", $i); | 3450 | } |
3098 | $builddir = set_test_option("BUILD_DIR", $i); | ||
3099 | $test_type = set_test_option("TEST_TYPE", $i); | ||
3100 | $build_type = set_test_option("BUILD_TYPE", $i); | ||
3101 | $build_options = set_test_option("BUILD_OPTIONS", $i); | ||
3102 | $pre_build = set_test_option("PRE_BUILD", $i); | ||
3103 | $post_build = set_test_option("POST_BUILD", $i); | ||
3104 | $pre_build_die = set_test_option("PRE_BUILD_DIE", $i); | ||
3105 | $post_build_die = set_test_option("POST_BUILD_DIE", $i); | ||
3106 | $power_cycle = set_test_option("POWER_CYCLE", $i); | ||
3107 | $reboot = set_test_option("REBOOT", $i); | ||
3108 | $noclean = set_test_option("BUILD_NOCLEAN", $i); | ||
3109 | $minconfig = set_test_option("MIN_CONFIG", $i); | ||
3110 | $output_minconfig = set_test_option("OUTPUT_MIN_CONFIG", $i); | ||
3111 | $start_minconfig = set_test_option("START_MIN_CONFIG", $i); | ||
3112 | $ignore_config = set_test_option("IGNORE_CONFIG", $i); | ||
3113 | $run_test = set_test_option("TEST", $i); | ||
3114 | $addconfig = set_test_option("ADD_CONFIG", $i); | ||
3115 | $reboot_type = set_test_option("REBOOT_TYPE", $i); | ||
3116 | $grub_menu = set_test_option("GRUB_MENU", $i); | ||
3117 | $post_install = set_test_option("POST_INSTALL", $i); | ||
3118 | $no_install = set_test_option("NO_INSTALL", $i); | ||
3119 | $reboot_script = set_test_option("REBOOT_SCRIPT", $i); | ||
3120 | $reboot_on_error = set_test_option("REBOOT_ON_ERROR", $i); | ||
3121 | $poweroff_on_error = set_test_option("POWEROFF_ON_ERROR", $i); | ||
3122 | $die_on_failure = set_test_option("DIE_ON_FAILURE", $i); | ||
3123 | $power_off = set_test_option("POWER_OFF", $i); | ||
3124 | $powercycle_after_reboot = set_test_option("POWERCYCLE_AFTER_REBOOT", $i); | ||
3125 | $poweroff_after_halt = set_test_option("POWEROFF_AFTER_HALT", $i); | ||
3126 | $sleep_time = set_test_option("SLEEP_TIME", $i); | ||
3127 | $bisect_sleep_time = set_test_option("BISECT_SLEEP_TIME", $i); | ||
3128 | $patchcheck_sleep_time = set_test_option("PATCHCHECK_SLEEP_TIME", $i); | ||
3129 | $ignore_warnings = set_test_option("IGNORE_WARNINGS", $i); | ||
3130 | $bisect_manual = set_test_option("BISECT_MANUAL", $i); | ||
3131 | $bisect_skip = set_test_option("BISECT_SKIP", $i); | ||
3132 | $config_bisect_good = set_test_option("CONFIG_BISECT_GOOD", $i); | ||
3133 | $store_failures = set_test_option("STORE_FAILURES", $i); | ||
3134 | $test_name = set_test_option("TEST_NAME", $i); | ||
3135 | $timeout = set_test_option("TIMEOUT", $i); | ||
3136 | $booted_timeout = set_test_option("BOOTED_TIMEOUT", $i); | ||
3137 | $console = set_test_option("CONSOLE", $i); | ||
3138 | $detect_triplefault = set_test_option("DETECT_TRIPLE_FAULT", $i); | ||
3139 | $success_line = set_test_option("SUCCESS_LINE", $i); | ||
3140 | $reboot_success_line = set_test_option("REBOOT_SUCCESS_LINE", $i); | ||
3141 | $stop_after_success = set_test_option("STOP_AFTER_SUCCESS", $i); | ||
3142 | $stop_after_failure = set_test_option("STOP_AFTER_FAILURE", $i); | ||
3143 | $stop_test_after = set_test_option("STOP_TEST_AFTER", $i); | ||
3144 | $build_target = set_test_option("BUILD_TARGET", $i); | ||
3145 | $ssh_exec = set_test_option("SSH_EXEC", $i); | ||
3146 | $scp_to_target = set_test_option("SCP_TO_TARGET", $i); | ||
3147 | $target_image = set_test_option("TARGET_IMAGE", $i); | ||
3148 | $localversion = set_test_option("LOCALVERSION", $i); | ||
3149 | 3451 | ||
3150 | $start_minconfig_defined = 1; | 3452 | $start_minconfig_defined = 1; |
3151 | 3453 | ||
@@ -3166,26 +3468,26 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
3166 | $ENV{"SSH_USER"} = $ssh_user; | 3468 | $ENV{"SSH_USER"} = $ssh_user; |
3167 | $ENV{"MACHINE"} = $machine; | 3469 | $ENV{"MACHINE"} = $machine; |
3168 | 3470 | ||
3169 | $target = "$ssh_user\@$machine"; | ||
3170 | |||
3171 | $buildlog = "$tmpdir/buildlog-$machine"; | 3471 | $buildlog = "$tmpdir/buildlog-$machine"; |
3472 | $testlog = "$tmpdir/testlog-$machine"; | ||
3172 | $dmesg = "$tmpdir/dmesg-$machine"; | 3473 | $dmesg = "$tmpdir/dmesg-$machine"; |
3173 | $make = "$makecmd O=$outputdir"; | 3474 | $make = "$makecmd O=$outputdir"; |
3174 | $output_config = "$outputdir/.config"; | 3475 | $output_config = "$outputdir/.config"; |
3175 | 3476 | ||
3176 | if ($reboot_type eq "grub") { | 3477 | if (!$buildonly) { |
3177 | dodie "GRUB_MENU not defined" if (!defined($grub_menu)); | 3478 | $target = "$ssh_user\@$machine"; |
3178 | } elsif (!defined($reboot_script)) { | 3479 | if ($reboot_type eq "grub") { |
3179 | dodie "REBOOT_SCRIPT not defined" | 3480 | dodie "GRUB_MENU not defined" if (!defined($grub_menu)); |
3481 | } | ||
3180 | } | 3482 | } |
3181 | 3483 | ||
3182 | my $run_type = $build_type; | 3484 | my $run_type = $build_type; |
3183 | if ($test_type eq "patchcheck") { | 3485 | if ($test_type eq "patchcheck") { |
3184 | $run_type = $opt{"PATCHCHECK_TYPE[$i]"}; | 3486 | $run_type = $patchcheck_type; |
3185 | } elsif ($test_type eq "bisect") { | 3487 | } elsif ($test_type eq "bisect") { |
3186 | $run_type = $opt{"BISECT_TYPE[$i]"}; | 3488 | $run_type = $bisect_type; |
3187 | } elsif ($test_type eq "config_bisect") { | 3489 | } elsif ($test_type eq "config_bisect") { |
3188 | $run_type = $opt{"CONFIG_BISECT_TYPE[$i]"}; | 3490 | $run_type = $config_bisect_type; |
3189 | } | 3491 | } |
3190 | 3492 | ||
3191 | if ($test_type eq "make_min_config") { | 3493 | if ($test_type eq "make_min_config") { |
@@ -3205,6 +3507,7 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
3205 | 3507 | ||
3206 | unlink $dmesg; | 3508 | unlink $dmesg; |
3207 | unlink $buildlog; | 3509 | unlink $buildlog; |
3510 | unlink $testlog; | ||
3208 | 3511 | ||
3209 | if (defined($addconfig)) { | 3512 | if (defined($addconfig)) { |
3210 | my $min = $minconfig; | 3513 | my $min = $minconfig; |
@@ -3216,7 +3519,6 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
3216 | $minconfig = "$tmpdir/add_config"; | 3519 | $minconfig = "$tmpdir/add_config"; |
3217 | } | 3520 | } |
3218 | 3521 | ||
3219 | my $checkout = $opt{"CHECKOUT[$i]"}; | ||
3220 | if (defined($checkout)) { | 3522 | if (defined($checkout)) { |
3221 | run_command "git checkout $checkout" or | 3523 | run_command "git checkout $checkout" or |
3222 | die "failed to checkout $checkout"; | 3524 | die "failed to checkout $checkout"; |
@@ -3267,7 +3569,7 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
3267 | if ($opt{"POWEROFF_ON_SUCCESS"}) { | 3569 | if ($opt{"POWEROFF_ON_SUCCESS"}) { |
3268 | halt; | 3570 | halt; |
3269 | } elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot) { | 3571 | } elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot) { |
3270 | reboot; | 3572 | reboot_to_good; |
3271 | } | 3573 | } |
3272 | 3574 | ||
3273 | doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n"; | 3575 | doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n"; |