3 # Copywrite 2010 - Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.
4 # Licensed under the terms of the GNU GPL License version 2
9 use Fcntl
qw(F_GETFL F_SETFL O_NONBLOCK);
10 use File
::Path
qw(mkpath);
11 use File
::Copy
qw(cp);
14 $#ARGV >= 0 || die "usage: ktest.pl config-file\n";
24 $default{"NUM_TESTS"} = 1;
25 $default{"REBOOT_TYPE"} = "grub";
26 $default{"TEST_TYPE"} = "test";
27 $default{"BUILD_TYPE"} = "randconfig";
28 $default{"MAKE_CMD"} = "make";
29 $default{"TIMEOUT"} = 120;
30 $default{"TMP_DIR"} = "/tmp/ktest";
31 $default{"SLEEP_TIME"} = 60; # sleep time between tests
32 $default{"BUILD_NOCLEAN"} = 0;
33 $default{"REBOOT_ON_ERROR"} = 0;
34 $default{"POWEROFF_ON_ERROR"} = 0;
35 $default{"REBOOT_ON_SUCCESS"} = 1;
36 $default{"POWEROFF_ON_SUCCESS"} = 0;
37 $default{"BUILD_OPTIONS"} = "";
38 $default{"BISECT_SLEEP_TIME"} = 60; # sleep time between bisects
39 $default{"CLEAR_LOG"} = 0;
40 $default{"SUCCESS_LINE"} = "login:";
41 $default{"BOOTED_TIMEOUT"} = 1;
42 $default{"DIE_ON_FAILURE"} = 1;
56 my $poweroff_on_error;
58 my $powercycle_after_reboot;
59 my $poweroff_after_halt;
72 my $in_patchcheck = 0;
81 my $bisect_sleep_time;
93 my ($lvalue, $rvalue) = @_;
95 if (defined($opt{$lvalue})) {
96 die "Error: Option $lvalue defined more than once!\n";
98 $opt{$lvalue} = $rvalue;
104 open(IN
, $config) || die "can't read file $config";
107 $name =~ s
,.*/(.*),$1,;
112 my $num_tests_set = 0;
118 # ignore blank lines and comments
119 next if (/^\s*$/ || /\s*\#/);
121 if (/^\s*TEST_START(.*)/) {
125 if ($num_tests_set) {
126 die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n";
129 my $old_test_num = $test_num;
131 $test_num += $repeat;
135 if ($rest =~ /\s+SKIP(.*)/) {
142 if ($rest =~ /\s+ITERATE\s+(\d+)(.*)$/) {
145 $repeat_tests{"$test_num"} = $repeat;
148 if ($rest =~ /\s+SKIP(.*)/) {
153 if ($rest !~ /^\s*$/) {
154 die "$name: $.: Gargbage found after TEST_START\n$_";
158 $test_num = $old_test_num;
162 } elsif (/^\s*DEFAULTS(.*)$/) {
167 if ($rest =~ /\s+SKIP(.*)/) {
174 if ($rest !~ /^\s*$/) {
175 die "$name: $.: Gargbage found after DEFAULTS\n$_";
178 } elsif (/^\s*([A-Z_\[\]\d]+)\s*=\s*(.*?)\s*$/) {
186 ($lvalue eq "NUM_TESTS" ||
187 $lvalue eq "LOG_FILE" ||
188 $lvalue eq "CLEAR_LOG")) {
189 die "$name: $.: $lvalue must be set in DEFAULTS section\n";
192 if ($lvalue eq "NUM_TESTS") {
194 die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n";
197 die "$name: $.: NUM_TESTS must be set in default section\n";
202 if ($default || $lvalue =~ /\[\d+\]$/) {
203 set_value
($lvalue, $rvalue);
205 my $val = "$lvalue\[$test_num\]";
206 set_value
($val, $rvalue);
209 $repeats{$val} = $repeat;
213 die "$name: $.: Garbage found in config\n$_";
220 $test_num += $repeat - 1;
221 $opt{"NUM_TESTS"} = $test_num;
226 foreach my $default (keys %default) {
227 if (!defined($opt{$default})) {
228 $opt{$default} = $default{$default};
234 if (defined($opt{"LOG_FILE"})) {
235 open(OUT
, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}";
242 if (defined($opt{"LOG_FILE"})) {
257 # try to reboot normally
258 if (run_command
"ssh $target reboot") {
259 if (defined($powercycle_after_reboot)) {
260 sleep $powercycle_after_reboot;
261 run_command
"$power_cycle";
264 # nope? power cycle it.
265 run_command
"$power_cycle";
272 return $test_type eq "build" ||
273 ($test_type eq "patchcheck" && $opt{"PATCHCHECK_TYPE[$i]"} eq "build") ||
274 ($test_type eq "bisect" && $opt{"BISECT_TYPE[$i]"} eq "build");
278 doprint
"CRITICAL FAILURE... ", @_, "\n";
282 if ($reboot_on_error && !do_not_reboot
) {
284 doprint
"REBOOTING\n";
287 } elsif ($poweroff_on_error && defined($power_off)) {
288 doprint
"POWERING OFF\n";
300 my $pid = open($fp, "$console|") or
301 dodie
"Can't open console $console";
303 $flags = fcntl($fp, F_GETFL
, 0) or
304 dodie
"Can't get flags for the socket: $!";
305 $flags = fcntl($fp, F_SETFL
, $flags | O_NONBLOCK
) or
306 dodie
"Can't set flags for the socket: $!";
314 doprint
"kill child process $pid\n";
322 if ($monitor_cnt++) {
325 $monitor_fp = \
*MONFD
;
326 $monitor_pid = open_console
$monitor_fp;
330 open(MONFD
, "Stop perl from warning about single use of MONFD");
334 if (--$monitor_cnt) {
337 close_console
($monitor_fp, $monitor_pid);
340 sub wait_for_monitor
{
344 doprint
"** Wait for monitor to settle down **\n";
346 # read the monitor and wait for the system to calm down
348 $line = wait_for_input
($monitor_fp, $time);
349 print "$line" if (defined($line));
350 } while (defined($line));
351 print "** Monitor flushed **\n";
356 if ($die_on_failure) {
364 # no need to reboot for just building.
365 if (!do_not_reboot
) {
366 doprint
"REBOOTING\n";
369 wait_for_monitor
$sleep_time;
373 doprint
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
374 doprint
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
375 doprint
"**** Failed: ", @_, " ****\n";
376 doprint
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
377 doprint
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
379 return 1 if (!defined($store_failures));
382 my $date = sprintf "%04d%02d%02d%02d%02d%02d",
383 1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0];
385 my $dir = "$machine-$test_type-$build_type-fail-$date";
386 my $faildir = "$store_failures/$dir";
390 die "can't create $faildir";
392 if (-f
"$outputdir/.config") {
393 cp
"$outputdir/.config", "$faildir/config" or
394 die "failed to copy .config";
397 cp
$buildlog, "$faildir/buildlog" or
398 die "failed to move $buildlog";
401 cp
$dmesg, "$faildir/dmesg" or
402 die "failed to move $dmesg";
405 doprint
"*** Saved info to $faildir ***\n";
416 doprint
("$command ... ");
418 $pid = open(CMD
, "$command 2>&1 |") or
419 (fail
"unable to exec $command" and return 0);
421 if (defined($opt{"LOG_FILE"})) {
422 open(LOG
, ">>$opt{LOG_FILE}") or
423 dodie
"failed to write to log";
427 if (defined($redirect)) {
428 open (RD
, ">$redirect") or
429 dodie
"failed to write to redirect $redirect";
434 print LOG
if ($dolog);
442 close(LOG
) if ($dolog);
443 close(RD
) if ($dord);
456 if ($reboot_type ne "grub") {
459 return if (defined($grub_number));
461 doprint
"Find grub menu ... ";
463 open(IN
, "ssh $target cat /boot/grub/menu.lst |")
464 or die "unable to get menu.lst";
466 if (/^\s*title\s+$grub_menu\s*$/) {
469 } elsif (/^\s*title\s/) {
475 die "Could not find '$grub_menu' in /boot/grub/menu on $machine"
476 if ($grub_number < 0);
477 doprint
"$grub_number\n";
482 my ($fp, $time) = @_;
488 if (!defined($time)) {
493 vec($rin, fileno($fp), 1) = 1;
494 $ready = select($rin, undef, undef, $time);
498 # try to read one char at a time
499 while (sysread $fp, $ch, 1) {
501 last if ($ch eq "\n");
504 if (!length($line)) {
512 if ($reboot_type eq "grub") {
513 run_command
"ssh $target '(echo \"savedefault --default=$grub_number --once\" | grub --batch; reboot)'";
517 run_command
"$reboot_script";
523 doprint
"git rev-list --max-count=1 $commit ... ";
524 my $sha1 = `git rev-list --max-count=1 $commit`;
531 dodie
"Failed to get git $commit";
544 my $skip_call_trace = 0;
552 open(DMESG
, "> $dmesg") or
553 die "unable to write to $dmesg";
560 $line = wait_for_input
($monitor_fp, $booted_timeout);
562 $line = wait_for_input
($monitor_fp);
565 last if (!defined($line));
570 # we are not guaranteed to get a full line
573 if ($full_line =~ /$success_line/) {
577 if ($full_line =~ /\[ backtrace testing \]/) {
578 $skip_call_trace = 1;
581 if ($full_line =~ /call trace:/i) {
582 $bug = 1 if (!$skip_call_trace);
585 if ($full_line =~ /\[ end of backtrace testing \]/) {
586 $skip_call_trace = 0;
589 if ($full_line =~ /Kernel panic -/) {
601 return 0 if ($in_bisect);
602 fail
"failed - got a bug report" and return 0;
606 return 0 if ($in_bisect);
607 fail
"failed - never got a boot prompt." and return 0;
615 run_command
"scp $outputdir/$build_target $target:$target_image" or
616 dodie
"failed to copy image";
618 my $install_mods = 0;
620 # should we process modules?
622 open(IN
, "$outputdir/.config") or dodie
("Can't read config file");
624 if (/CONFIG_MODULES(=y)?/) {
625 $install_mods = 1 if (defined($1));
631 if (!$install_mods) {
632 doprint
"No modules needed\n";
636 run_command
"$make INSTALL_MOD_PATH=$tmpdir modules_install" or
637 dodie
"Failed to install modules";
639 my $modlib = "/lib/modules/$version";
640 my $modtar = "ktest-mods.tar.bz2";
642 run_command
"ssh $target rm -rf $modlib" or
643 dodie
"failed to remove old mods: $modlib";
645 # would be nice if scp -r did not follow symbolic links
646 run_command
"cd $tmpdir && tar -cjf $modtar lib/modules/$version" or
647 dodie
"making tarball";
649 run_command
"scp $tmpdir/$modtar $target:/tmp" or
650 dodie
"failed to copy modules";
652 unlink "$tmpdir/$modtar";
654 run_command
"ssh $target '(cd / && tar xf /tmp/$modtar)'" or
655 dodie
"failed to tar modules";
657 run_command
"ssh $target rm -f /tmp/$modtar";
659 return if (!defined($post_install));
661 my $save_env = $ENV{KERNEL_VERSION
};
663 $ENV{KERNEL_VERSION
} = $version;
664 run_command
"$post_install" or
665 dodie
"Failed to run post install";
667 $ENV{KERNEL_VERSION
} = $save_env;
673 my @files = `git show $patch | diffstat -l`;
675 open(IN
, "git show $patch |") or
676 dodie
"failed to show $patch";
678 if (m
,^--- a
/(.*),) {
680 $files[$#files] = $1;
685 open(IN
, $buildlog) or dodie
"Can't open $buildlog";
687 if (/^\s*(.*?):.*(warning|error)/) {
689 foreach my $file (@files) {
690 my $fullpath = "$builddir/$file";
691 if ($file eq $err || $fullpath eq $err) {
692 fail
"$file built with warnings" and return 0;
708 if ($type =~ /^useconfig:(.*)/) {
709 run_command
"cp $1 $outputdir/.config" or
710 dodie
"could not copy $1 to .config";
715 # old config can ask questions
716 if ($type eq "oldconfig") {
717 $type = "oldnoconfig";
719 # allow for empty configs
720 run_command
"touch $outputdir/.config";
722 run_command
"mv $outputdir/.config $outputdir/config_temp" or
723 dodie
"moving .config";
725 if (!$noclean && !run_command
"$make mrproper") {
726 dodie
"make mrproper";
729 run_command
"mv $outputdir/config_temp $outputdir/.config" or
730 dodie
"moving config_temp";
732 } elsif (!$noclean) {
733 unlink "$outputdir/.config";
734 run_command
"$make mrproper" or
735 dodie
"make mrproper";
738 # add something to distinguish this build
739 open(OUT
, "> $outputdir/localversion") or dodie
("Can't make localversion file");
740 print OUT
"$localversion\n";
743 if (defined($minconfig)) {
744 $defconfig = "KCONFIG_ALLCONFIG=$minconfig";
747 run_command
"$defconfig $make $type" or
748 dodie
"failed make config";
750 $redirect = "$buildlog";
751 if (!run_command
"$make $build_options") {
753 # bisect may need this to pass
754 return 0 if ($in_bisect);
755 fail
"failed build" and return 0;
763 if (!run_command
"ssh $target halt" or defined($power_off)) {
764 if (defined($poweroff_after_halt)) {
765 sleep $poweroff_after_halt;
766 run_command
"$power_off";
770 run_command
"$power_off";
777 doprint
"\n\n*******************************************\n";
778 doprint
"*******************************************\n";
779 doprint
"** TEST $i SUCCESS!!!! **\n";
780 doprint
"*******************************************\n";
781 doprint
"*******************************************\n";
783 if ($i != $opt{"NUM_TESTS"} && !do_not_reboot
) {
784 doprint
"Reboot and wait $sleep_time seconds\n";
787 wait_for_monitor
$sleep_time;
793 # get the release name
794 doprint
"$make kernelrelease ... ";
795 $version = `$make kernelrelease | tail -1`;
797 doprint
"$version\n";
803 # child should have no power
804 $reboot_on_error = 0;
805 $poweroff_on_error = 0;
808 run_command
$run_test or $failed = 1;
827 doprint
"run test $run_test\n";
831 $SIG{CHLD
} = qw(child_finished);
835 child_run_test
if (!$child_pid);
840 $line = wait_for_input
($monitor_fp, 1);
841 if (defined($line)) {
843 # we are not guaranteed to get a full line
846 if ($full_line =~ /call trace:/i) {
850 if ($full_line =~ /Kernel panic -/) {
858 } while (!$child_done && !$bug);
861 doprint
"Detected kernel crash!\n";
862 # kill the child with extreme prejudice
866 waitpid $child_pid, 0;
869 if ($bug || $child_exit) {
870 return 0 if $in_bisect;
871 fail
"test failed" and return 0;
879 doprint
"$command ... ";
881 my $output = `$command 2>&1`;
888 dodie
"Failed to git bisect";
892 if ($output =~ m/^(Bisecting: .*\(roughly \d+ steps?\))\s+\[([[:xdigit:]]+)\]/) {
894 } elsif ($output =~ m/^([[:xdigit:]]+) is the first bad commit/) {
896 doprint
"Found bad commit... $1\n";
899 # we already logged it, just print it now.
914 if (defined($minconfig)) {
915 build
"useconfig:$minconfig" or $failed = 1;
917 # ?? no config to use?
918 build
"oldconfig" or $failed = 1;
921 if ($type ne "build") {
922 dodie
"Failed on build" if $failed;
930 monitor
or $failed = 1;
932 if ($type ne "boot") {
933 dodie
"Failed on boot" if $failed;
935 do_run_test
or $failed = 1;
943 # reboot the box to a good kernel
944 if ($type ne "build") {
945 doprint
"Reboot and sleep $bisect_sleep_time seconds\n";
948 wait_for_monitor
$bisect_sleep_time;
955 # Are we looking for where it worked, not failed?
956 if ($reverse_bisect) {
972 die "BISECT_GOOD[$i] not defined\n" if (!defined($opt{"BISECT_GOOD[$i]"}));
973 die "BISECT_BAD[$i] not defined\n" if (!defined($opt{"BISECT_BAD[$i]"}));
974 die "BISECT_TYPE[$i] not defined\n" if (!defined($opt{"BISECT_TYPE[$i]"}));
976 my $good = $opt{"BISECT_GOOD[$i]"};
977 my $bad = $opt{"BISECT_BAD[$i]"};
978 my $type = $opt{"BISECT_TYPE[$i]"};
979 my $start = $opt{"BISECT_START[$i]"};
980 my $replay = $opt{"BISECT_REPLAY[$i]"};
982 # convert to true sha1's
983 $good = get_sha1
($good);
984 $bad = get_sha1
($bad);
986 if (defined($opt{"BISECT_REVERSE[$i]"}) &&
987 $opt{"BISECT_REVERSE[$i]"} == 1) {
988 doprint
"Performing a reverse bisect (bad is good, good is bad!)\n";
996 # Can't have a test without having a test to run
997 if ($type eq "test" && !defined($run_test)) {
1001 my $check = $opt{"BISECT_CHECK[$i]"};
1002 if (defined($check) && $check ne "0") {
1005 my $head = get_sha1
("HEAD");
1007 if ($check ne "good") {
1008 doprint
"TESTING BISECT BAD [$bad]\n";
1009 run_command
"git checkout $bad" or
1010 die "Failed to checkout $bad";
1012 $result = run_bisect
$type;
1014 if ($result ne "bad") {
1015 fail
"Tested BISECT_BAD [$bad] and it succeeded" and return 0;
1019 if ($check ne "bad") {
1020 doprint
"TESTING BISECT GOOD [$good]\n";
1021 run_command
"git checkout $good" or
1022 die "Failed to checkout $good";
1024 $result = run_bisect
$type;
1026 if ($result ne "good") {
1027 fail
"Tested BISECT_GOOD [$good] and it failed" and return 0;
1031 # checkout where we started
1032 run_command
"git checkout $head" or
1033 die "Failed to checkout $head";
1036 run_command
"git bisect start" or
1037 dodie
"could not start bisect";
1039 run_command
"git bisect good $good" or
1040 dodie
"could not set bisect good to $good";
1042 run_git_bisect
"git bisect bad $bad" or
1043 dodie
"could not set bisect bad to $bad";
1045 if (defined($replay)) {
1046 run_command
"git bisect replay $replay" or
1047 dodie
"failed to run replay";
1050 if (defined($start)) {
1051 run_command
"git checkout $start" or
1052 dodie
"failed to checkout $start";
1057 $result = run_bisect
$type;
1058 $test = run_git_bisect
"git bisect $result";
1061 run_command
"git bisect log" or
1062 dodie
"could not capture git bisect log";
1064 run_command
"git bisect reset" or
1065 dodie
"could not reset git bisect";
1067 doprint
"Bad commit was [$bisect_bad]\n";
1077 die "PATCHCHECK_START[$i] not defined\n"
1078 if (!defined($opt{"PATCHCHECK_START[$i]"}));
1079 die "PATCHCHECK_TYPE[$i] not defined\n"
1080 if (!defined($opt{"PATCHCHECK_TYPE[$i]"}));
1082 my $start = $opt{"PATCHCHECK_START[$i]"};
1085 if (defined($opt{"PATCHCHECK_END[$i]"})) {
1086 $end = $opt{"PATCHCHECK_END[$i]"};
1089 # Get the true sha1's since we can use things like HEAD~3
1090 $start = get_sha1
($start);
1091 $end = get_sha1
($end);
1093 my $type = $opt{"PATCHCHECK_TYPE[$i]"};
1095 # Can't have a test without having a test to run
1096 if ($type eq "test" && !defined($run_test)) {
1100 open (IN
, "git log --pretty=oneline $end|") or
1101 dodie
"could not get git list";
1107 $list[$#list+1] = $_;
1108 last if (/^$start/);
1112 if ($list[$#list] !~ /^$start/) {
1113 fail
"SHA1 $start not found";
1116 # go backwards in the list
1117 @list = reverse @list;
1119 my $save_clean = $noclean;
1122 foreach my $item (@list) {
1124 $sha1 =~ s/^([[:xdigit:]]+).*/$1/;
1126 doprint
"\nProcessing commit $item\n\n";
1128 run_command
"git checkout $sha1" or
1129 die "Failed to checkout $sha1";
1131 # only clean on the first and last patch
1132 if ($item eq $list[0] ||
1133 $item eq $list[$#list]) {
1134 $noclean = $save_clean;
1139 if (defined($minconfig)) {
1140 build
"useconfig:$minconfig" or return 0;
1142 # ?? no config to use?
1143 build
"oldconfig" or return 0;
1146 check_buildlog
$sha1 or return 0;
1148 next if ($type eq "build");
1157 monitor
or $failed = 1;
1159 if (!$failed && $type ne "boot"){
1160 do_run_test
or $failed = 1;
1163 return 0 if ($failed);
1172 read_config
$ARGV[0];
1175 die "MACHINE not defined\n" if (!defined($opt{"MACHINE"}));
1176 die "SSH_USER not defined\n" if (!defined($opt{"SSH_USER"}));
1177 die "BUILD_DIR not defined\n" if (!defined($opt{"BUILD_DIR"}));
1178 die "OUTPUT_DIR not defined\n" if (!defined($opt{"OUTPUT_DIR"}));
1179 die "BUILD_TARGET not defined\n" if (!defined($opt{"BUILD_TARGET"}));
1180 die "TARGET_IMAGE not defined\n" if (!defined($opt{"TARGET_IMAGE"}));
1181 die "POWER_CYCLE not defined\n" if (!defined($opt{"POWER_CYCLE"}));
1182 die "CONSOLE not defined\n" if (!defined($opt{"CONSOLE"}));
1183 die "LOCALVERSION not defined\n" if (!defined($opt{"LOCALVERSION"}));
1185 if ($opt{"CLEAR_LOG"} && defined($opt{"LOG_FILE"})) {
1186 unlink $opt{"LOG_FILE"};
1189 doprint
"\n\nSTARTING AUTOMATED TESTS\n\n";
1191 for (my $i = 0, my $repeat = 1; $i <= $opt{"NUM_TESTS"}; $i += $repeat) {
1194 doprint
"DEFAULT OPTIONS:\n";
1196 doprint
"\nTEST $i OPTIONS";
1197 if (defined($repeat_tests{$i})) {
1198 $repeat = $repeat_tests{$i};
1199 doprint
" ITERATE $repeat";
1204 foreach my $option (sort keys %opt) {
1206 if ($option =~ /\[(\d+)\]$/) {
1212 doprint
"$option = $opt{$option}\n";
1216 sub set_test_option
{
1217 my ($name, $i) = @_;
1219 my $option = "$name\[$i\]";
1221 if (defined($opt{$option})) {
1222 return $opt{$option};
1225 foreach my $test (keys %repeat_tests) {
1227 $i < $test + $repeat_tests{$test}) {
1228 $option = "$name\[$test\]";
1229 if (defined($opt{$option})) {
1230 return $opt{$option};
1235 if (defined($opt{$name})) {
1242 # First we need to do is the builds
1243 for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
1247 my $ssh_user = set_test_option
("SSH_USER", $i);
1248 my $makecmd = set_test_option
("MAKE_CMD", $i);
1250 $machine = set_test_option
("MACHINE", $i);
1251 $tmpdir = set_test_option
("TMP_DIR", $i);
1252 $outputdir = set_test_option
("OUTPUT_DIR", $i);
1253 $builddir = set_test_option
("BUILD_DIR", $i);
1254 $test_type = set_test_option
("TEST_TYPE", $i);
1255 $build_type = set_test_option
("BUILD_TYPE", $i);
1256 $build_options = set_test_option
("BUILD_OPTIONS", $i);
1257 $power_cycle = set_test_option
("POWER_CYCLE", $i);
1258 $noclean = set_test_option
("BUILD_NOCLEAN", $i);
1259 $minconfig = set_test_option
("MIN_CONFIG", $i);
1260 $run_test = set_test_option
("TEST", $i);
1261 $addconfig = set_test_option
("ADD_CONFIG", $i);
1262 $reboot_type = set_test_option
("REBOOT_TYPE", $i);
1263 $grub_menu = set_test_option
("GRUB_MENU", $i);
1264 $post_install = set_test_option
("POST_INSTALL", $i);
1265 $reboot_script = set_test_option
("REBOOT_SCRIPT", $i);
1266 $reboot_on_error = set_test_option
("REBOOT_ON_ERROR", $i);
1267 $poweroff_on_error = set_test_option
("POWEROFF_ON_ERROR", $i);
1268 $die_on_failure = set_test_option
("DIE_ON_FAILURE", $i);
1269 $power_off = set_test_option
("POWER_OFF", $i);
1270 $powercycle_after_reboot = set_test_option
("POWERCYCLE_AFTER_REBOOT", $i);
1271 $poweroff_after_halt = set_test_option
("POWEROFF_AFTER_HALT", $i);
1272 $sleep_time = set_test_option
("SLEEP_TIME", $i);
1273 $bisect_sleep_time = set_test_option
("BISECT_SLEEP_TIME", $i);
1274 $store_failures = set_test_option
("STORE_FAILURES", $i);
1275 $timeout = set_test_option
("TIMEOUT", $i);
1276 $booted_timeout = set_test_option
("BOOTED_TIMEOUT", $i);
1277 $console = set_test_option
("CONSOLE", $i);
1278 $success_line = set_test_option
("SUCCESS_LINE", $i);
1279 $build_target = set_test_option
("BUILD_TARGET", $i);
1280 $target_image = set_test_option
("TARGET_IMAGE", $i);
1281 $localversion = set_test_option
("LOCALVERSION", $i);
1283 chdir $builddir || die "can't change directory to $builddir";
1287 die "can't create $tmpdir";
1290 $target = "$ssh_user\@$machine";
1292 $buildlog = "$tmpdir/buildlog-$machine";
1293 $dmesg = "$tmpdir/dmesg-$machine";
1294 $make = "$makecmd O=$outputdir";
1296 if ($reboot_type eq "grub") {
1297 dodie
"GRUB_MENU not defined" if (!defined($grub_menu));
1298 } elsif (!defined($reboot_script)) {
1299 dodie
"REBOOT_SCRIPT not defined"
1302 my $run_type = $build_type;
1303 if ($test_type eq "patchcheck") {
1304 $run_type = $opt{"PATCHCHECK_TYPE[$i]"};
1305 } elsif ($test_type eq "bisect") {
1306 $run_type = $opt{"BISECT_TYPE[$i]"};
1309 # mistake in config file?
1310 if (!defined($run_type)) {
1311 $run_type = "ERROR";
1315 doprint
"RUNNING TEST $i of $opt{NUM_TESTS} with option $test_type $run_type\n\n";
1320 if (!defined($minconfig)) {
1321 $minconfig = $addconfig;
1323 } elsif (defined($addconfig)) {
1324 run_command
"cat $addconfig $minconfig > $tmpdir/use_config" or
1325 dodie
"Failed to create temp config";
1326 $minconfig = "$tmpdir/use_config";
1329 my $checkout = $opt{"CHECKOUT[$i]"};
1330 if (defined($checkout)) {
1331 run_command
"git checkout $checkout" or
1332 die "failed to checkout $checkout";
1335 if ($test_type eq "bisect") {
1338 } elsif ($test_type eq "patchcheck") {
1343 if ($build_type ne "nobuild") {
1344 build
$build_type or next;
1347 if ($test_type ne "build") {
1354 monitor
or $failed = 1;;
1356 if (!$failed && $test_type ne "boot" && defined($run_test)) {
1357 do_run_test
or $failed = 1;
1366 if ($opt{"POWEROFF_ON_SUCCESS"}) {
1368 } elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot
) {