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