Commit | Line | Data |
---|---|---|
2545eb61 | 1 | #!/usr/bin/perl -w |
d6ce2a0b SR |
2 | # |
3 | # Copywrite 2010 - Steven Rostedt <srostedt@redhat.com>, Red Hat Inc. | |
4 | # Licensed under the terms of the GNU GPL License version 2 | |
5 | # | |
2545eb61 SR |
6 | |
7 | use strict; | |
8 | use IPC::Open2; | |
9 | use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK); | |
7faafbd6 SR |
10 | use File::Path qw(mkpath); |
11 | use File::Copy qw(cp); | |
2545eb61 SR |
12 | use FileHandle; |
13 | ||
14 | $#ARGV >= 0 || die "usage: autotest.pl config-file\n"; | |
15 | ||
16 | $| = 1; | |
17 | ||
18 | my %opt; | |
a75fecec | 19 | my %default; |
2545eb61 SR |
20 | |
21 | #default opts | |
a75fecec SR |
22 | $default{"NUM_TESTS"} = 5; |
23 | $default{"REBOOT_TYPE"} = "grub"; | |
24 | $default{"TEST_TYPE"} = "test"; | |
25 | $default{"BUILD_TYPE"} = "randconfig"; | |
26 | $default{"MAKE_CMD"} = "make"; | |
27 | $default{"TIMEOUT"} = 120; | |
28 | $default{"TMP_DIR"} = "/tmp/autotest"; | |
29 | $default{"SLEEP_TIME"} = 60; # sleep time between tests | |
30 | $default{"BUILD_NOCLEAN"} = 0; | |
31 | $default{"REBOOT_ON_ERROR"} = 0; | |
32 | $default{"POWEROFF_ON_ERROR"} = 0; | |
33 | $default{"REBOOT_ON_SUCCESS"} = 1; | |
34 | $default{"POWEROFF_ON_SUCCESS"} = 0; | |
35 | $default{"BUILD_OPTIONS"} = ""; | |
36 | $default{"BISECT_SLEEP_TIME"} = 60; # sleep time between bisects | |
37 | $default{"CLEAR_LOG"} = 0; | |
38 | $default{"SUCCESS_LINE"} = "login:"; | |
39 | $default{"BOOTED_TIMEOUT"} = 1; | |
40 | $default{"DIE_ON_FAILURE"} = 1; | |
2545eb61 SR |
41 | |
42 | my $version; | |
a75fecec SR |
43 | my $machine; |
44 | my $tmpdir; | |
45 | my $builddir; | |
46 | my $outputdir; | |
47 | my $test_type; | |
7faafbd6 | 48 | my $build_type; |
a75fecec SR |
49 | my $build_options; |
50 | my $reboot_type; | |
51 | my $reboot_script; | |
52 | my $power_cycle; | |
53 | my $reboot_on_error; | |
54 | my $poweroff_on_error; | |
55 | my $die_on_failure; | |
56 | my $power_off; | |
57 | my $grub_menu; | |
2545eb61 SR |
58 | my $grub_number; |
59 | my $target; | |
60 | my $make; | |
8b37ca8c | 61 | my $post_install; |
5c42fc5b | 62 | my $noclean; |
5f9b6ced | 63 | my $minconfig; |
2b7d9b21 | 64 | my $addconfig; |
5f9b6ced SR |
65 | my $in_bisect = 0; |
66 | my $bisect_bad = ""; | |
d6ce2a0b | 67 | my $reverse_bisect; |
6c5ee0be | 68 | my $in_patchcheck = 0; |
5a391fbf | 69 | my $run_test; |
6c5ee0be | 70 | my $redirect; |
7faafbd6 SR |
71 | my $buildlog; |
72 | my $dmesg; | |
73 | my $monitor_fp; | |
74 | my $monitor_pid; | |
75 | my $monitor_cnt = 0; | |
a75fecec SR |
76 | my $sleep_time; |
77 | my $bisect_sleep_time; | |
78 | my $store_failures; | |
79 | my $timeout; | |
80 | my $booted_timeout; | |
81 | my $console; | |
82 | my $success_line; | |
83 | my $build_target; | |
84 | my $target_image; | |
85 | my $localversion; | |
2545eb61 SR |
86 | |
87 | sub read_config { | |
88 | my ($config) = @_; | |
89 | ||
90 | open(IN, $config) || die "can't read file $config"; | |
91 | ||
92 | while (<IN>) { | |
93 | ||
94 | # ignore blank lines and comments | |
95 | next if (/^\s*$/ || /\s*\#/); | |
96 | ||
97 | if (/^\s*(\S+)\s*=\s*(.*?)\s*$/) { | |
98 | my $lvalue = $1; | |
99 | my $rvalue = $2; | |
100 | ||
a75fecec SR |
101 | if (defined($opt{$lvalue})) { |
102 | die "Error: Option $lvalue defined more than once!\n"; | |
103 | } | |
2545eb61 SR |
104 | $opt{$lvalue} = $rvalue; |
105 | } | |
106 | } | |
107 | ||
108 | close(IN); | |
a75fecec SR |
109 | |
110 | # set any defaults | |
111 | ||
112 | foreach my $default (keys %default) { | |
113 | if (!defined($opt{$default})) { | |
114 | $opt{$default} = $default{$default}; | |
115 | } | |
116 | } | |
2545eb61 SR |
117 | } |
118 | ||
5f9b6ced | 119 | sub logit { |
2545eb61 SR |
120 | if (defined($opt{"LOG_FILE"})) { |
121 | open(OUT, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}"; | |
122 | print OUT @_; | |
123 | close(OUT); | |
124 | } | |
125 | } | |
126 | ||
5f9b6ced SR |
127 | sub doprint { |
128 | print @_; | |
129 | logit @_; | |
130 | } | |
131 | ||
7faafbd6 SR |
132 | sub run_command; |
133 | ||
134 | sub reboot { | |
135 | # try to reboot normally | |
136 | if (!run_command "ssh $target reboot") { | |
137 | # nope? power cycle it. | |
a75fecec | 138 | run_command "$power_cycle"; |
7faafbd6 SR |
139 | } |
140 | } | |
141 | ||
5c42fc5b | 142 | sub dodie { |
5a391fbf | 143 | doprint "CRITICAL FAILURE... ", @_, "\n"; |
5c42fc5b | 144 | |
a75fecec | 145 | if ($reboot_on_error && $test_type ne "build") { |
75c3fda7 | 146 | doprint "REBOOTING\n"; |
7faafbd6 | 147 | reboot; |
75c3fda7 | 148 | |
a75fecec | 149 | } elsif ($poweroff_on_error && defined($power_off)) { |
5c42fc5b | 150 | doprint "POWERING OFF\n"; |
a75fecec | 151 | `$power_off`; |
5c42fc5b | 152 | } |
75c3fda7 | 153 | |
5c42fc5b SR |
154 | die @_; |
155 | } | |
156 | ||
7faafbd6 SR |
157 | sub open_console { |
158 | my ($fp) = @_; | |
159 | ||
160 | my $flags; | |
161 | ||
a75fecec SR |
162 | my $pid = open($fp, "$console|") or |
163 | dodie "Can't open console $console"; | |
7faafbd6 SR |
164 | |
165 | $flags = fcntl($fp, F_GETFL, 0) or | |
166 | dodie "Can't get flags for the socket: $!\n"; | |
167 | $flags = fcntl($fp, F_SETFL, $flags | O_NONBLOCK) or | |
168 | dodie "Can't set flags for the socket: $!\n"; | |
169 | ||
170 | return $pid; | |
171 | } | |
172 | ||
173 | sub close_console { | |
174 | my ($fp, $pid) = @_; | |
175 | ||
176 | doprint "kill child process $pid\n"; | |
177 | kill 2, $pid; | |
178 | ||
179 | print "closing!\n"; | |
180 | close($fp); | |
181 | } | |
182 | ||
183 | sub start_monitor { | |
184 | if ($monitor_cnt++) { | |
185 | return; | |
186 | } | |
187 | $monitor_fp = \*MONFD; | |
188 | $monitor_pid = open_console $monitor_fp; | |
a75fecec SR |
189 | |
190 | return; | |
191 | ||
192 | open(MONFD, "Stop perl from warning about single use of MONFD"); | |
7faafbd6 SR |
193 | } |
194 | ||
195 | sub end_monitor { | |
196 | if (--$monitor_cnt) { | |
197 | return; | |
198 | } | |
199 | close_console($monitor_fp, $monitor_pid); | |
200 | } | |
201 | ||
202 | sub wait_for_monitor { | |
203 | my ($time) = @_; | |
204 | my $line; | |
205 | ||
a75fecec | 206 | doprint "** Wait for monitor to settle down **\n"; |
7faafbd6 SR |
207 | |
208 | # read the monitor and wait for the system to calm down | |
209 | do { | |
210 | $line = wait_for_input($monitor_fp, $time); | |
a75fecec | 211 | print "$line" if (defined($line)); |
7faafbd6 | 212 | } while (defined($line)); |
a75fecec | 213 | print "** Monitor flushed **\n"; |
7faafbd6 SR |
214 | } |
215 | ||
2b7d9b21 SR |
216 | sub fail { |
217 | ||
a75fecec | 218 | if ($die_on_failure) { |
2b7d9b21 SR |
219 | dodie @_; |
220 | } | |
221 | ||
a75fecec | 222 | doprint "FAILED\n"; |
7faafbd6 | 223 | |
a75fecec SR |
224 | # no need to reboot for just building. |
225 | if ($test_type ne "build") { | |
226 | doprint "REBOOTING\n"; | |
227 | reboot; | |
228 | start_monitor; | |
229 | wait_for_monitor $sleep_time; | |
230 | end_monitor; | |
231 | } | |
7faafbd6 | 232 | |
a75fecec SR |
233 | doprint "**** Failed: ", @_, " ****\n"; |
234 | ||
235 | return 1 if (!defined($store_failures)); | |
7faafbd6 SR |
236 | |
237 | my @t = localtime; | |
238 | my $date = sprintf "%04d%02d%02d%02d%02d%02d", | |
239 | 1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0]; | |
240 | ||
a75fecec SR |
241 | my $dir = "$machine-$test_type-$build_type-fail-$date"; |
242 | my $faildir = "$store_failures/$dir"; | |
7faafbd6 SR |
243 | |
244 | if (!-d $faildir) { | |
245 | mkpath($faildir) or | |
a75fecec | 246 | die "can't create $faildir"; |
7faafbd6 | 247 | } |
a75fecec SR |
248 | if (-f "$outputdir/.config") { |
249 | cp "$outputdir/.config", "$faildir/config" or | |
7faafbd6 SR |
250 | die "failed to copy .config"; |
251 | } | |
252 | if (-f $buildlog) { | |
253 | cp $buildlog, "$faildir/buildlog" or | |
254 | die "failed to move $buildlog"; | |
255 | } | |
256 | if (-f $dmesg) { | |
257 | cp $dmesg, "$faildir/dmesg" or | |
258 | die "failed to move $dmesg"; | |
259 | } | |
260 | ||
261 | doprint "*** Saved info to $faildir ***\n"; | |
262 | ||
2b7d9b21 SR |
263 | return 1; |
264 | } | |
265 | ||
2545eb61 SR |
266 | sub run_command { |
267 | my ($command) = @_; | |
d6ce2a0b SR |
268 | my $dolog = 0; |
269 | my $dord = 0; | |
270 | my $pid; | |
271 | ||
272 | doprint("$command ... "); | |
273 | ||
274 | $pid = open(CMD, "$command 2>&1 |") or | |
2b7d9b21 | 275 | (fail "unable to exec $command" and return 0); |
2545eb61 SR |
276 | |
277 | if (defined($opt{"LOG_FILE"})) { | |
d6ce2a0b SR |
278 | open(LOG, ">>$opt{LOG_FILE}") or |
279 | dodie "failed to write to log"; | |
280 | $dolog = 1; | |
6c5ee0be SR |
281 | } |
282 | ||
283 | if (defined($redirect)) { | |
d6ce2a0b SR |
284 | open (RD, ">$redirect") or |
285 | dodie "failed to write to redirect $redirect"; | |
286 | $dord = 1; | |
2545eb61 SR |
287 | } |
288 | ||
d6ce2a0b SR |
289 | while (<CMD>) { |
290 | print LOG if ($dolog); | |
291 | print RD if ($dord); | |
292 | } | |
2545eb61 | 293 | |
d6ce2a0b | 294 | waitpid($pid, 0); |
2545eb61 SR |
295 | my $failed = $?; |
296 | ||
d6ce2a0b SR |
297 | close(CMD); |
298 | close(LOG) if ($dolog); | |
299 | close(RD) if ($dord); | |
300 | ||
2545eb61 SR |
301 | if ($failed) { |
302 | doprint "FAILED!\n"; | |
303 | } else { | |
304 | doprint "SUCCESS\n"; | |
305 | } | |
306 | ||
5f9b6ced SR |
307 | return !$failed; |
308 | } | |
309 | ||
310 | sub get_grub_index { | |
311 | ||
a75fecec SR |
312 | if ($reboot_type ne "grub") { |
313 | return; | |
314 | } | |
5a391fbf | 315 | return if (defined($grub_number)); |
5f9b6ced SR |
316 | |
317 | doprint "Find grub menu ... "; | |
318 | $grub_number = -1; | |
319 | open(IN, "ssh $target cat /boot/grub/menu.lst |") | |
320 | or die "unable to get menu.lst"; | |
321 | while (<IN>) { | |
a75fecec | 322 | if (/^\s*title\s+$grub_menu\s*$/) { |
5f9b6ced SR |
323 | $grub_number++; |
324 | last; | |
325 | } elsif (/^\s*title\s/) { | |
326 | $grub_number++; | |
327 | } | |
328 | } | |
329 | close(IN); | |
330 | ||
a75fecec | 331 | die "Could not find '$grub_menu' in /boot/grub/menu on $machine" |
5f9b6ced SR |
332 | if ($grub_number < 0); |
333 | doprint "$grub_number\n"; | |
2545eb61 SR |
334 | } |
335 | ||
2545eb61 SR |
336 | sub wait_for_input |
337 | { | |
338 | my ($fp, $time) = @_; | |
339 | my $rin; | |
340 | my $ready; | |
341 | my $line; | |
342 | my $ch; | |
343 | ||
344 | if (!defined($time)) { | |
345 | $time = $timeout; | |
346 | } | |
347 | ||
348 | $rin = ''; | |
349 | vec($rin, fileno($fp), 1) = 1; | |
350 | $ready = select($rin, undef, undef, $time); | |
351 | ||
352 | $line = ""; | |
353 | ||
354 | # try to read one char at a time | |
355 | while (sysread $fp, $ch, 1) { | |
356 | $line .= $ch; | |
357 | last if ($ch eq "\n"); | |
358 | } | |
359 | ||
360 | if (!length($line)) { | |
361 | return undef; | |
362 | } | |
363 | ||
364 | return $line; | |
365 | } | |
366 | ||
75c3fda7 | 367 | sub reboot_to { |
a75fecec SR |
368 | if ($reboot_type eq "grub") { |
369 | run_command "ssh $target '(echo \"savedefault --default=$grub_number --once\" | grub --batch; reboot)'"; | |
370 | return; | |
371 | } | |
372 | ||
373 | run_command "$reboot_script"; | |
2545eb61 SR |
374 | } |
375 | ||
5a391fbf | 376 | sub monitor { |
2545eb61 SR |
377 | my $booted = 0; |
378 | my $bug = 0; | |
5c42fc5b | 379 | my $skip_call_trace = 0; |
2b7d9b21 | 380 | my $loops; |
2545eb61 | 381 | |
7faafbd6 | 382 | wait_for_monitor 5; |
2545eb61 SR |
383 | |
384 | my $line; | |
385 | my $full_line = ""; | |
386 | ||
7faafbd6 SR |
387 | open(DMESG, "> $dmesg") or |
388 | die "unable to write to $dmesg"; | |
2545eb61 | 389 | |
75c3fda7 | 390 | reboot_to; |
2545eb61 SR |
391 | |
392 | for (;;) { | |
393 | ||
2b7d9b21 | 394 | if ($booted) { |
a75fecec | 395 | $line = wait_for_input($monitor_fp, $booted_timeout); |
2b7d9b21 | 396 | } else { |
7faafbd6 | 397 | $line = wait_for_input($monitor_fp); |
2b7d9b21 | 398 | } |
2545eb61 SR |
399 | |
400 | last if (!defined($line)); | |
401 | ||
402 | doprint $line; | |
7faafbd6 | 403 | print DMESG $line; |
2545eb61 SR |
404 | |
405 | # we are not guaranteed to get a full line | |
406 | $full_line .= $line; | |
407 | ||
a75fecec | 408 | if ($full_line =~ /$success_line/) { |
2545eb61 SR |
409 | $booted = 1; |
410 | } | |
411 | ||
5c42fc5b SR |
412 | if ($full_line =~ /\[ backtrace testing \]/) { |
413 | $skip_call_trace = 1; | |
414 | } | |
415 | ||
2545eb61 | 416 | if ($full_line =~ /call trace:/i) { |
5c42fc5b SR |
417 | $bug = 1 if (!$skip_call_trace); |
418 | } | |
419 | ||
420 | if ($full_line =~ /\[ end of backtrace testing \]/) { | |
421 | $skip_call_trace = 0; | |
422 | } | |
423 | ||
424 | if ($full_line =~ /Kernel panic -/) { | |
2545eb61 SR |
425 | $bug = 1; |
426 | } | |
427 | ||
428 | if ($line =~ /\n/) { | |
429 | $full_line = ""; | |
430 | } | |
431 | } | |
432 | ||
7faafbd6 | 433 | close(DMESG); |
2545eb61 | 434 | |
a75fecec | 435 | if ($bug) { |
2b7d9b21 | 436 | return 0 if ($in_bisect); |
a75fecec | 437 | fail "failed - got a bug report\n" and return 0; |
2545eb61 SR |
438 | } |
439 | ||
a75fecec | 440 | if (!$booted) { |
2b7d9b21 | 441 | return 0 if ($in_bisect); |
a75fecec | 442 | fail "failed - never got a boot prompt.\n" and return 0; |
2545eb61 | 443 | } |
5f9b6ced | 444 | |
2b7d9b21 | 445 | return 1; |
2545eb61 SR |
446 | } |
447 | ||
448 | sub install { | |
449 | ||
a75fecec | 450 | run_command "scp $outputdir/$build_target $target:$target_image" or |
5c42fc5b | 451 | dodie "failed to copy image"; |
2545eb61 | 452 | |
5f9b6ced | 453 | my $install_mods = 0; |
2545eb61 | 454 | |
5f9b6ced SR |
455 | # should we process modules? |
456 | $install_mods = 0; | |
a75fecec | 457 | open(IN, "$outputdir/.config") or dodie("Can't read config file"); |
5f9b6ced SR |
458 | while (<IN>) { |
459 | if (/CONFIG_MODULES(=y)?/) { | |
460 | $install_mods = 1 if (defined($1)); | |
461 | last; | |
5c42fc5b | 462 | } |
5f9b6ced SR |
463 | } |
464 | close(IN); | |
5c42fc5b | 465 | |
5f9b6ced SR |
466 | if (!$install_mods) { |
467 | doprint "No modules needed\n"; | |
468 | return; | |
469 | } | |
2545eb61 | 470 | |
a75fecec | 471 | run_command "$make INSTALL_MOD_PATH=$tmpdir modules_install" or |
5f9b6ced | 472 | dodie "Failed to install modules"; |
5c42fc5b | 473 | |
5f9b6ced SR |
474 | my $modlib = "/lib/modules/$version"; |
475 | my $modtar = "autotest-mods.tar.bz2"; | |
5c42fc5b | 476 | |
5f9b6ced SR |
477 | run_command "ssh $target rm -rf $modlib" or |
478 | dodie "failed to remove old mods: $modlib"; | |
5c42fc5b | 479 | |
5f9b6ced | 480 | # would be nice if scp -r did not follow symbolic links |
a75fecec | 481 | run_command "cd $tmpdir && tar -cjf $modtar lib/modules/$version" or |
5f9b6ced SR |
482 | dodie "making tarball"; |
483 | ||
a75fecec | 484 | run_command "scp $tmpdir/$modtar $target:/tmp" or |
5f9b6ced SR |
485 | dodie "failed to copy modules"; |
486 | ||
a75fecec | 487 | unlink "$tmpdir/$modtar"; |
5f9b6ced SR |
488 | |
489 | run_command "ssh $target '(cd / && tar xf /tmp/$modtar)'" or | |
490 | dodie "failed to tar modules"; | |
2545eb61 | 491 | |
5f9b6ced | 492 | run_command "ssh $target rm -f /tmp/$modtar"; |
8b37ca8c SR |
493 | |
494 | return if (!defined($post_install)); | |
495 | ||
496 | my $save_env = $ENV{KERNEL_VERSION}; | |
497 | ||
498 | $ENV{KERNEL_VERSION} = $version; | |
499 | run_command "$post_install"; | |
500 | ||
501 | $ENV{KERNEL_VERSION} = $save_env; | |
2545eb61 SR |
502 | } |
503 | ||
6c5ee0be SR |
504 | sub check_buildlog { |
505 | my ($patch) = @_; | |
506 | ||
6c5ee0be SR |
507 | my @files = `git show $patch | diffstat -l`; |
508 | ||
509 | open(IN, "git show $patch |") or | |
510 | dodie "failed to show $patch"; | |
511 | while (<IN>) { | |
512 | if (m,^--- a/(.*),) { | |
513 | chomp $1; | |
514 | $files[$#files] = $1; | |
515 | } | |
516 | } | |
517 | close(IN); | |
518 | ||
519 | open(IN, $buildlog) or dodie "Can't open $buildlog"; | |
520 | while (<IN>) { | |
521 | if (/^\s*(.*?):.*(warning|error)/) { | |
522 | my $err = $1; | |
523 | foreach my $file (@files) { | |
a75fecec | 524 | my $fullpath = "$builddir/$file"; |
6c5ee0be | 525 | if ($file eq $err || $fullpath eq $err) { |
2b7d9b21 | 526 | fail "$file built with warnings" and return 0; |
6c5ee0be SR |
527 | } |
528 | } | |
529 | } | |
530 | } | |
531 | close(IN); | |
2b7d9b21 SR |
532 | |
533 | return 1; | |
6c5ee0be SR |
534 | } |
535 | ||
2545eb61 SR |
536 | sub build { |
537 | my ($type) = @_; | |
5c42fc5b SR |
538 | my $defconfig = ""; |
539 | my $append = ""; | |
540 | ||
7faafbd6 SR |
541 | unlink $buildlog; |
542 | ||
75c3fda7 | 543 | if ($type =~ /^useconfig:(.*)/) { |
a75fecec | 544 | run_command "cp $1 $outputdir/.config" or |
75c3fda7 | 545 | dodie "could not copy $1 to .config"; |
5f9b6ced | 546 | |
75c3fda7 SR |
547 | $type = "oldconfig"; |
548 | } | |
549 | ||
5c42fc5b SR |
550 | # old config can ask questions |
551 | if ($type eq "oldconfig") { | |
552 | $append = "yes ''|"; | |
75c3fda7 SR |
553 | |
554 | # allow for empty configs | |
a75fecec | 555 | run_command "touch $outputdir/.config"; |
75c3fda7 | 556 | |
a75fecec | 557 | run_command "mv $outputdir/.config $outputdir/config_temp" or |
5c42fc5b | 558 | dodie "moving .config"; |
2545eb61 | 559 | |
5f9b6ced | 560 | if (!$noclean && !run_command "$make mrproper") { |
5c42fc5b SR |
561 | dodie "make mrproper"; |
562 | } | |
2545eb61 | 563 | |
a75fecec | 564 | run_command "mv $outputdir/config_temp $outputdir/.config" or |
5c42fc5b | 565 | dodie "moving config_temp"; |
5c42fc5b SR |
566 | |
567 | } elsif (!$noclean) { | |
a75fecec | 568 | unlink "$outputdir/.config"; |
5f9b6ced | 569 | run_command "$make mrproper" or |
5c42fc5b | 570 | dodie "make mrproper"; |
5c42fc5b | 571 | } |
2545eb61 SR |
572 | |
573 | # add something to distinguish this build | |
a75fecec SR |
574 | open(OUT, "> $outputdir/localversion") or dodie("Can't make localversion file"); |
575 | print OUT "$localversion\n"; | |
2545eb61 SR |
576 | close(OUT); |
577 | ||
5f9b6ced SR |
578 | if (defined($minconfig)) { |
579 | $defconfig = "KCONFIG_ALLCONFIG=$minconfig"; | |
2545eb61 SR |
580 | } |
581 | ||
a75fecec | 582 | run_command "$append $defconfig $make $type" or |
5c42fc5b | 583 | dodie "failed make config"; |
2545eb61 | 584 | |
a75fecec SR |
585 | $redirect = "$buildlog"; |
586 | if (!run_command "$make $build_options") { | |
6c5ee0be | 587 | undef $redirect; |
5f9b6ced | 588 | # bisect may need this to pass |
2b7d9b21 SR |
589 | return 0 if ($in_bisect); |
590 | fail "failed build" and return 0; | |
2545eb61 | 591 | } |
6c5ee0be | 592 | undef $redirect; |
5f9b6ced | 593 | |
2b7d9b21 | 594 | return 1; |
2545eb61 SR |
595 | } |
596 | ||
75c3fda7 | 597 | sub halt { |
a75fecec | 598 | if (!run_command "ssh $target halt" or defined($power_off)) { |
75c3fda7 | 599 | # nope? the zap it! |
a75fecec | 600 | run_command "$power_off"; |
75c3fda7 SR |
601 | } |
602 | } | |
603 | ||
5f9b6ced SR |
604 | sub success { |
605 | my ($i) = @_; | |
606 | ||
607 | doprint "\n\n*******************************************\n"; | |
608 | doprint "*******************************************\n"; | |
a75fecec | 609 | doprint "** TEST $i SUCCESS!!!! **\n"; |
5f9b6ced SR |
610 | doprint "*******************************************\n"; |
611 | doprint "*******************************************\n"; | |
612 | ||
a75fecec SR |
613 | if ($i != $opt{"NUM_TESTS"} && $test_type ne "build" && |
614 | !($test_type eq "patchcheck" && $opt{"PATCHCHECK_TYPE[$i]"} eq "build") && | |
615 | !($test_type eq "bisect" && $opt{"BISECT_TYPE[$i]"} eq "build")) { | |
616 | doprint "Reboot and wait $sleep_time seconds\n"; | |
5f9b6ced | 617 | reboot; |
7faafbd6 | 618 | start_monitor; |
a75fecec | 619 | wait_for_monitor $sleep_time; |
7faafbd6 | 620 | end_monitor; |
5f9b6ced SR |
621 | } |
622 | } | |
623 | ||
624 | sub get_version { | |
625 | # get the release name | |
626 | doprint "$make kernelrelease ... "; | |
627 | $version = `$make kernelrelease | tail -1`; | |
628 | chomp($version); | |
629 | doprint "$version\n"; | |
630 | } | |
631 | ||
5a391fbf | 632 | sub child_run_test { |
7faafbd6 | 633 | my $failed = 0; |
5a391fbf | 634 | |
7faafbd6 | 635 | # child should have no power |
a75fecec SR |
636 | $reboot_on_error = 0; |
637 | $poweroff_on_error = 0; | |
638 | $die_on_failure = 1; | |
7faafbd6 SR |
639 | |
640 | run_command $run_test or $failed = 1; | |
5a391fbf SR |
641 | exit $failed; |
642 | } | |
643 | ||
644 | my $child_done; | |
645 | ||
646 | sub child_finished { | |
647 | $child_done = 1; | |
648 | } | |
649 | ||
650 | sub do_run_test { | |
651 | my $child_pid; | |
652 | my $child_exit; | |
5a391fbf SR |
653 | my $line; |
654 | my $full_line; | |
655 | my $bug = 0; | |
5a391fbf | 656 | |
7faafbd6 | 657 | wait_for_monitor 1; |
5a391fbf | 658 | |
7faafbd6 | 659 | doprint "run test $run_test\n"; |
5a391fbf SR |
660 | |
661 | $child_done = 0; | |
662 | ||
663 | $SIG{CHLD} = qw(child_finished); | |
664 | ||
665 | $child_pid = fork; | |
666 | ||
667 | child_run_test if (!$child_pid); | |
668 | ||
669 | $full_line = ""; | |
670 | ||
671 | do { | |
7faafbd6 | 672 | $line = wait_for_input($monitor_fp, 1); |
5a391fbf SR |
673 | if (defined($line)) { |
674 | ||
675 | # we are not guaranteed to get a full line | |
676 | $full_line .= $line; | |
677 | ||
678 | if ($full_line =~ /call trace:/i) { | |
679 | $bug = 1; | |
680 | } | |
681 | ||
682 | if ($full_line =~ /Kernel panic -/) { | |
683 | $bug = 1; | |
684 | } | |
685 | ||
686 | if ($line =~ /\n/) { | |
687 | $full_line = ""; | |
688 | } | |
689 | } | |
690 | } while (!$child_done && !$bug); | |
691 | ||
692 | if ($bug) { | |
693 | doprint "Detected kernel crash!\n"; | |
694 | # kill the child with extreme prejudice | |
695 | kill 9, $child_pid; | |
696 | } | |
697 | ||
698 | waitpid $child_pid, 0; | |
699 | $child_exit = $?; | |
700 | ||
5a391fbf | 701 | if ($bug || $child_exit) { |
2b7d9b21 SR |
702 | return 0 if $in_bisect; |
703 | fail "test failed" and return 0; | |
5a391fbf | 704 | } |
2b7d9b21 | 705 | return 1; |
5a391fbf SR |
706 | } |
707 | ||
a75fecec SR |
708 | sub run_git_bisect { |
709 | my ($command) = @_; | |
710 | ||
711 | doprint "$command ... "; | |
712 | ||
713 | my $output = `$command 2>&1`; | |
714 | my $ret = $?; | |
715 | ||
716 | logit $output; | |
717 | ||
718 | if ($ret) { | |
719 | doprint "FAILED\n"; | |
720 | dodie "Failed to git bisect"; | |
721 | } | |
722 | ||
723 | doprint "SUCCESS\n"; | |
724 | if ($output =~ m/^(Bisecting: .*\(roughly \d+ steps?\))\s+\[([[:xdigit:]]+)\]/) { | |
725 | doprint "$1 [$2]\n"; | |
726 | } elsif ($output =~ m/^([[:xdigit:]]+) is the first bad commit/) { | |
727 | $bisect_bad = $1; | |
728 | doprint "Found bad commit... $1\n"; | |
729 | return 0; | |
730 | } else { | |
731 | # we already logged it, just print it now. | |
732 | print $output; | |
733 | } | |
734 | ||
735 | return 1; | |
736 | } | |
737 | ||
5f9b6ced SR |
738 | sub run_bisect { |
739 | my ($type) = @_; | |
740 | ||
2b7d9b21 | 741 | my $failed = 0; |
5f9b6ced SR |
742 | my $result; |
743 | my $output; | |
744 | my $ret; | |
745 | ||
5f9b6ced | 746 | if (defined($minconfig)) { |
2b7d9b21 | 747 | build "useconfig:$minconfig" or $failed = 1; |
5f9b6ced SR |
748 | } else { |
749 | # ?? no config to use? | |
2b7d9b21 | 750 | build "oldconfig" or $failed = 1; |
5f9b6ced SR |
751 | } |
752 | ||
753 | if ($type ne "build") { | |
7faafbd6 | 754 | dodie "Failed on build" if $failed; |
5f9b6ced SR |
755 | |
756 | # Now boot the box | |
757 | get_grub_index; | |
758 | get_version; | |
759 | install; | |
7faafbd6 SR |
760 | |
761 | start_monitor; | |
2b7d9b21 | 762 | monitor or $failed = 1; |
5f9b6ced SR |
763 | |
764 | if ($type ne "boot") { | |
7faafbd6 | 765 | dodie "Failed on boot" if $failed; |
5a391fbf | 766 | |
2b7d9b21 | 767 | do_run_test or $failed = 1; |
5f9b6ced | 768 | } |
7faafbd6 | 769 | end_monitor; |
5f9b6ced SR |
770 | } |
771 | ||
772 | if ($failed) { | |
773 | $result = "bad"; | |
5a391fbf SR |
774 | |
775 | # reboot the box to a good kernel | |
a75fecec SR |
776 | if ($type ne "build") { |
777 | doprint "Reboot and sleep $bisect_sleep_time seconds\n"; | |
5a391fbf | 778 | reboot; |
7faafbd6 | 779 | start_monitor; |
a75fecec | 780 | wait_for_monitor $bisect_sleep_time; |
7faafbd6 | 781 | end_monitor; |
5a391fbf | 782 | } |
5f9b6ced SR |
783 | } else { |
784 | $result = "good"; | |
785 | } | |
786 | ||
d6ce2a0b SR |
787 | # Are we looking for where it worked, not failed? |
788 | if ($reverse_bisect) { | |
789 | if ($failed) { | |
790 | $result = "good"; | |
791 | } else { | |
792 | $result = "bad"; | |
793 | } | |
794 | } | |
795 | ||
a75fecec | 796 | return $result; |
5f9b6ced SR |
797 | } |
798 | ||
799 | sub bisect { | |
800 | my ($i) = @_; | |
801 | ||
802 | my $result; | |
803 | ||
804 | die "BISECT_GOOD[$i] not defined\n" if (!defined($opt{"BISECT_GOOD[$i]"})); | |
805 | die "BISECT_BAD[$i] not defined\n" if (!defined($opt{"BISECT_BAD[$i]"})); | |
806 | die "BISECT_TYPE[$i] not defined\n" if (!defined($opt{"BISECT_TYPE[$i]"})); | |
807 | ||
808 | my $good = $opt{"BISECT_GOOD[$i]"}; | |
809 | my $bad = $opt{"BISECT_BAD[$i]"}; | |
810 | my $type = $opt{"BISECT_TYPE[$i]"}; | |
a75fecec SR |
811 | my $start = $opt{"BISECT_START[$i]"}; |
812 | my $replay = $opt{"BISECT_REPLAY[$i]"}; | |
5f9b6ced | 813 | |
d6ce2a0b SR |
814 | if (defined($opt{"BISECT_REVERSE[$i]"}) && |
815 | $opt{"BISECT_REVERSE[$i]"} == 1) { | |
816 | doprint "Performing a reverse bisect (bad is good, good is bad!)\n"; | |
817 | $reverse_bisect = 1; | |
818 | } else { | |
819 | $reverse_bisect = 0; | |
820 | } | |
821 | ||
5f9b6ced SR |
822 | $in_bisect = 1; |
823 | ||
a75fecec SR |
824 | # Can't have a test without having a test to run |
825 | if ($type eq "test" && !defined($run_test)) { | |
826 | $type = "boot"; | |
827 | } | |
828 | ||
829 | my $check = $opt{"BISECT_CHECK[$i]"}; | |
830 | if (defined($check) && $check ne "0") { | |
831 | ||
832 | # get current HEAD | |
833 | doprint "git rev-list HEAD --max-count=1 ... "; | |
834 | my $head = `git rev-list HEAD --max-count=1`; | |
835 | my $ret = $?; | |
836 | ||
837 | logit $head; | |
838 | ||
839 | if ($ret) { | |
840 | doprint "FAILED\n"; | |
841 | dodie "Failed to get git HEAD"; | |
842 | } | |
843 | ||
844 | print "SUCCESS\n"; | |
845 | ||
846 | chomp $head; | |
847 | ||
848 | if ($check ne "good") { | |
849 | doprint "TESTING BISECT BAD [$bad]\n"; | |
850 | run_command "git checkout $bad" or | |
851 | die "Failed to checkout $bad"; | |
852 | ||
853 | $result = run_bisect $type; | |
854 | ||
855 | if ($result ne "bad") { | |
856 | fail "Tested BISECT_BAD [$bad] and it succeeded" and return 0; | |
857 | } | |
858 | } | |
859 | ||
860 | if ($check ne "bad") { | |
861 | doprint "TESTING BISECT GOOD [$good]\n"; | |
862 | run_command "git checkout $good" or | |
863 | die "Failed to checkout $good"; | |
864 | ||
865 | $result = run_bisect $type; | |
866 | ||
867 | if ($result ne "good") { | |
868 | fail "Tested BISECT_GOOD [$good] and it failed" and return 0; | |
869 | } | |
870 | } | |
871 | ||
872 | # checkout where we started | |
873 | run_command "git checkout $head" or | |
874 | die "Failed to checkout $head"; | |
875 | } | |
876 | ||
5f9b6ced | 877 | run_command "git bisect start" or |
a75fecec | 878 | dodie "could not start bisect"; |
5f9b6ced SR |
879 | |
880 | run_command "git bisect good $good" or | |
a75fecec | 881 | dodie "could not set bisect good to $good"; |
5f9b6ced | 882 | |
a75fecec SR |
883 | run_git_bisect "git bisect bad $bad" or |
884 | dodie "could not set bisect bad to $bad"; | |
5f9b6ced | 885 | |
a75fecec SR |
886 | if (defined($replay)) { |
887 | run_command "git bisect replay $replay" or | |
888 | dodie "failed to run replay"; | |
5a391fbf SR |
889 | } |
890 | ||
a75fecec SR |
891 | if (defined($start)) { |
892 | run_command "git checkout $start" or | |
893 | dodie "failed to checkout $start"; | |
894 | } | |
895 | ||
896 | my $test; | |
5f9b6ced SR |
897 | do { |
898 | $result = run_bisect $type; | |
a75fecec SR |
899 | $test = run_git_bisect "git bisect $result"; |
900 | } while ($test); | |
5f9b6ced SR |
901 | |
902 | run_command "git bisect log" or | |
903 | dodie "could not capture git bisect log"; | |
904 | ||
905 | run_command "git bisect reset" or | |
906 | dodie "could not reset git bisect"; | |
907 | ||
908 | doprint "Bad commit was [$bisect_bad]\n"; | |
909 | ||
910 | $in_bisect = 0; | |
911 | ||
912 | success $i; | |
913 | } | |
914 | ||
6c5ee0be SR |
915 | sub patchcheck { |
916 | my ($i) = @_; | |
917 | ||
918 | die "PATCHCHECK_START[$i] not defined\n" | |
919 | if (!defined($opt{"PATCHCHECK_START[$i]"})); | |
920 | die "PATCHCHECK_TYPE[$i] not defined\n" | |
921 | if (!defined($opt{"PATCHCHECK_TYPE[$i]"})); | |
922 | ||
923 | my $start = $opt{"PATCHCHECK_START[$i]"}; | |
924 | ||
925 | my $end = "HEAD"; | |
926 | if (defined($opt{"PATCHCHECK_END[$i]"})) { | |
927 | $end = $opt{"PATCHCHECK_END[$i]"}; | |
928 | } | |
929 | ||
930 | my $type = $opt{"PATCHCHECK_TYPE[$i]"}; | |
931 | ||
932 | # Can't have a test without having a test to run | |
933 | if ($type eq "test" && !defined($run_test)) { | |
934 | $type = "boot"; | |
935 | } | |
936 | ||
937 | open (IN, "git log --pretty=oneline $end|") or | |
938 | dodie "could not get git list"; | |
939 | ||
940 | my @list; | |
941 | ||
942 | while (<IN>) { | |
943 | chomp; | |
944 | $list[$#list+1] = $_; | |
945 | last if (/^$start/); | |
946 | } | |
947 | close(IN); | |
948 | ||
949 | if ($list[$#list] !~ /^$start/) { | |
2b7d9b21 | 950 | fail "SHA1 $start not found"; |
6c5ee0be SR |
951 | } |
952 | ||
953 | # go backwards in the list | |
954 | @list = reverse @list; | |
955 | ||
956 | my $save_clean = $noclean; | |
957 | ||
958 | $in_patchcheck = 1; | |
959 | foreach my $item (@list) { | |
960 | my $sha1 = $item; | |
961 | $sha1 =~ s/^([[:xdigit:]]+).*/$1/; | |
962 | ||
963 | doprint "\nProcessing commit $item\n\n"; | |
964 | ||
965 | run_command "git checkout $sha1" or | |
966 | die "Failed to checkout $sha1"; | |
967 | ||
968 | # only clean on the first and last patch | |
969 | if ($item eq $list[0] || | |
970 | $item eq $list[$#list]) { | |
971 | $noclean = $save_clean; | |
972 | } else { | |
973 | $noclean = 1; | |
974 | } | |
975 | ||
976 | if (defined($minconfig)) { | |
2b7d9b21 | 977 | build "useconfig:$minconfig" or return 0; |
6c5ee0be SR |
978 | } else { |
979 | # ?? no config to use? | |
2b7d9b21 | 980 | build "oldconfig" or return 0; |
6c5ee0be SR |
981 | } |
982 | ||
2b7d9b21 | 983 | check_buildlog $sha1 or return 0; |
6c5ee0be SR |
984 | |
985 | next if ($type eq "build"); | |
986 | ||
987 | get_grub_index; | |
988 | get_version; | |
989 | install; | |
6c5ee0be | 990 | |
7faafbd6 SR |
991 | my $failed = 0; |
992 | ||
993 | start_monitor; | |
994 | monitor or $failed = 1; | |
995 | ||
996 | if (!$failed && $type ne "boot"){ | |
997 | do_run_test or $failed = 1; | |
998 | } | |
999 | end_monitor; | |
1000 | return 0 if ($failed); | |
1001 | ||
6c5ee0be SR |
1002 | } |
1003 | $in_patchcheck = 0; | |
1004 | success $i; | |
2b7d9b21 SR |
1005 | |
1006 | return 1; | |
6c5ee0be SR |
1007 | } |
1008 | ||
2545eb61 SR |
1009 | read_config $ARGV[0]; |
1010 | ||
1011 | # mandatory configs | |
1012 | die "MACHINE not defined\n" if (!defined($opt{"MACHINE"})); | |
1013 | die "SSH_USER not defined\n" if (!defined($opt{"SSH_USER"})); | |
1014 | die "BUILD_DIR not defined\n" if (!defined($opt{"BUILD_DIR"})); | |
1015 | die "OUTPUT_DIR not defined\n" if (!defined($opt{"OUTPUT_DIR"})); | |
1016 | die "BUILD_TARGET not defined\n" if (!defined($opt{"BUILD_TARGET"})); | |
75c3fda7 | 1017 | die "TARGET_IMAGE not defined\n" if (!defined($opt{"TARGET_IMAGE"})); |
2545eb61 SR |
1018 | die "POWER_CYCLE not defined\n" if (!defined($opt{"POWER_CYCLE"})); |
1019 | die "CONSOLE not defined\n" if (!defined($opt{"CONSOLE"})); | |
1020 | die "LOCALVERSION not defined\n" if (!defined($opt{"LOCALVERSION"})); | |
2545eb61 | 1021 | |
2b7d9b21 SR |
1022 | if ($opt{"CLEAR_LOG"} && defined($opt{"LOG_FILE"})) { |
1023 | unlink $opt{"LOG_FILE"}; | |
1024 | } | |
2545eb61 | 1025 | |
2b7d9b21 SR |
1026 | doprint "\n\nSTARTING AUTOMATED TESTS\n\n"; |
1027 | ||
1028 | foreach my $option (sort keys %opt) { | |
1029 | doprint "$option = $opt{$option}\n"; | |
1030 | } | |
2545eb61 | 1031 | |
a75fecec | 1032 | sub set_test_option { |
5a391fbf | 1033 | my ($name, $i) = @_; |
2545eb61 | 1034 | |
5a391fbf | 1035 | my $option = "$name\[$i\]"; |
5c42fc5b | 1036 | |
5a391fbf SR |
1037 | if (defined($opt{$option})) { |
1038 | return $opt{$option}; | |
5f9b6ced SR |
1039 | } |
1040 | ||
5a391fbf SR |
1041 | if (defined($opt{$name})) { |
1042 | return $opt{$name}; | |
2545eb61 SR |
1043 | } |
1044 | ||
5a391fbf SR |
1045 | return undef; |
1046 | } | |
1047 | ||
1048 | # First we need to do is the builds | |
a75fecec SR |
1049 | for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { |
1050 | ||
1051 | my $ssh_user = set_test_option("SSH_USER", $i); | |
1052 | my $makecmd = set_test_option("MAKE_CMD", $i); | |
1053 | ||
1054 | $machine = set_test_option("MACHINE", $i); | |
1055 | $tmpdir = set_test_option("TMP_DIR", $i); | |
1056 | $outputdir = set_test_option("OUTPUT_DIR", $i); | |
1057 | $builddir = set_test_option("BUILD_DIR", $i); | |
1058 | $test_type = set_test_option("TEST_TYPE", $i); | |
1059 | $build_type = set_test_option("BUILD_TYPE", $i); | |
1060 | $build_options = set_test_option("BUILD_OPTIONS", $i); | |
1061 | $power_cycle = set_test_option("POWER_CYCLE", $i); | |
1062 | $noclean = set_test_option("BUILD_NOCLEAN", $i); | |
1063 | $minconfig = set_test_option("MIN_CONFIG", $i); | |
1064 | $run_test = set_test_option("TEST", $i); | |
1065 | $addconfig = set_test_option("ADD_CONFIG", $i); | |
1066 | $reboot_type = set_test_option("REBOOT_TYPE", $i); | |
1067 | $grub_menu = set_test_option("GRUB_MENU", $i); | |
8b37ca8c | 1068 | $post_install = set_test_option("POST_INSTALL", $i); |
a75fecec SR |
1069 | $reboot_script = set_test_option("REBOOT_SCRIPT", $i); |
1070 | $reboot_on_error = set_test_option("REBOOT_ON_ERROR", $i); | |
1071 | $poweroff_on_error = set_test_option("POWEROFF_ON_ERROR", $i); | |
1072 | $die_on_failure = set_test_option("DIE_ON_FAILURE", $i); | |
1073 | $power_off = set_test_option("POWER_OFF", $i); | |
1074 | $sleep_time = set_test_option("SLEEP_TIME", $i); | |
1075 | $bisect_sleep_time = set_test_option("BISECT_SLEEP_TIME", $i); | |
1076 | $store_failures = set_test_option("STORE_FAILURES", $i); | |
1077 | $timeout = set_test_option("TIMEOUT", $i); | |
1078 | $booted_timeout = set_test_option("BOOTED_TIMEOUT", $i); | |
1079 | $console = set_test_option("CONSOLE", $i); | |
1080 | $success_line = set_test_option("SUCCESS_LINE", $i); | |
1081 | $build_target = set_test_option("BUILD_TARGET", $i); | |
1082 | $target_image = set_test_option("TARGET_IMAGE", $i); | |
1083 | $localversion = set_test_option("LOCALVERSION", $i); | |
1084 | ||
1085 | chdir $builddir || die "can't change directory to $builddir"; | |
1086 | ||
1087 | if (!-d $tmpdir) { | |
1088 | mkpath($tmpdir) or | |
1089 | die "can't create $tmpdir"; | |
1090 | } | |
1a5cfce3 | 1091 | |
a75fecec SR |
1092 | $target = "$ssh_user\@$machine"; |
1093 | ||
1094 | $buildlog = "$tmpdir/buildlog-$machine"; | |
1095 | $dmesg = "$tmpdir/dmesg-$machine"; | |
1096 | $make = "$makecmd O=$outputdir"; | |
1097 | ||
1098 | if ($reboot_type eq "grub") { | |
1099 | dodie "GRUB_MENU not defined\n" if (!defined($grub_menu)); | |
1100 | } elsif (!defined($reboot_script)) { | |
1101 | dodie "REBOOT_SCRIPT not defined\n" | |
1102 | } | |
1103 | ||
1104 | my $run_type = $build_type; | |
1105 | if ($test_type eq "patchcheck") { | |
1106 | $run_type = $opt{"PATCHCHECK_TYPE[$i]"}; | |
1107 | } elsif ($test_type eq "bisect") { | |
1108 | $run_type = $opt{"BISECT_TYPE[$i]"}; | |
1109 | } | |
1110 | ||
1111 | # mistake in config file? | |
1112 | if (!defined($run_type)) { | |
1113 | $run_type = "ERROR"; | |
1114 | } | |
5a391fbf | 1115 | |
2545eb61 | 1116 | doprint "\n\n"; |
a75fecec | 1117 | doprint "RUNNING TEST $i of $opt{NUM_TESTS} with option $test_type $run_type\n\n"; |
7faafbd6 SR |
1118 | |
1119 | unlink $dmesg; | |
1120 | unlink $buildlog; | |
2545eb61 | 1121 | |
2b7d9b21 SR |
1122 | if (!defined($minconfig)) { |
1123 | $minconfig = $addconfig; | |
1124 | ||
1125 | } elsif (defined($addconfig)) { | |
a75fecec | 1126 | run_command "cat $addconfig $minconfig > $tmpdir/use_config" or |
2b7d9b21 | 1127 | dodie "Failed to create temp config"; |
a75fecec | 1128 | $minconfig = "$tmpdir/use_config"; |
2b7d9b21 SR |
1129 | } |
1130 | ||
6c5ee0be SR |
1131 | my $checkout = $opt{"CHECKOUT[$i]"}; |
1132 | if (defined($checkout)) { | |
1133 | run_command "git checkout $checkout" or | |
1134 | die "failed to checkout $checkout"; | |
1135 | } | |
1136 | ||
a75fecec | 1137 | if ($test_type eq "bisect") { |
5f9b6ced SR |
1138 | bisect $i; |
1139 | next; | |
a75fecec | 1140 | } elsif ($test_type eq "patchcheck") { |
6c5ee0be SR |
1141 | patchcheck $i; |
1142 | next; | |
2545eb61 | 1143 | } |
2545eb61 | 1144 | |
7faafbd6 SR |
1145 | if ($build_type ne "nobuild") { |
1146 | build $build_type or next; | |
2545eb61 SR |
1147 | } |
1148 | ||
a75fecec SR |
1149 | if ($test_type ne "build") { |
1150 | get_grub_index; | |
1151 | get_version; | |
1152 | install; | |
5a391fbf | 1153 | |
a75fecec SR |
1154 | my $failed = 0; |
1155 | start_monitor; | |
1156 | monitor or $failed = 1;; | |
1157 | ||
1158 | if (!$failed && $test_type ne "boot" && defined($run_test)) { | |
1159 | do_run_test or $failed = 1; | |
1160 | } | |
1161 | end_monitor; | |
1162 | next if ($failed); | |
5a391fbf SR |
1163 | } |
1164 | ||
5f9b6ced | 1165 | success $i; |
2545eb61 SR |
1166 | } |
1167 | ||
5c42fc5b | 1168 | if ($opt{"POWEROFF_ON_SUCCESS"}) { |
75c3fda7 | 1169 | halt; |
a75fecec | 1170 | } elsif ($opt{"REBOOT_ON_SUCCESS"} && $test_type ne "build") { |
75c3fda7 | 1171 | reboot; |
5c42fc5b | 1172 | } |
75c3fda7 | 1173 | |
2545eb61 | 1174 | exit 0; |