3 # Copyright 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);
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{"PATCHCHECK_SLEEP_TIME"} = 60; # sleep time between patch checks
40 $default{"CLEAR_LOG"} = 0;
41 $default{"BISECT_MANUAL"} = 0;
42 $default{"BISECT_SKIP"} = 1;
43 $default{"SUCCESS_LINE"} = "login:";
44 $default{"DETECT_TRIPLE_FAULT"} = 1;
45 $default{"BOOTED_TIMEOUT"} = 1;
46 $default{"DIE_ON_FAILURE"} = 1;
47 $default{"SSH_EXEC"} = "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND";
48 $default{"SCP_TO_TARGET"} = "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE";
49 $default{"REBOOT"} = "ssh \$SSH_USER\@\$MACHINE reboot";
50 $default{"STOP_AFTER_SUCCESS"} = 10;
51 $default{"STOP_AFTER_FAILURE"} = 60;
52 $default{"STOP_TEST_AFTER"} = 600;
53 $default{"LOCALVERSION"} = "-test";
71 my $poweroff_on_error;
73 my $powercycle_after_reboot;
74 my $poweroff_after_halt;
91 my $config_bisect_good;
92 my $in_patchcheck = 0;
101 my $bisect_sleep_time;
102 my $patchcheck_sleep_time;
107 my $detect_triplefault;
110 my $stop_after_success;
111 my $stop_after_failure;
124 $config_help{"MACHINE"} = << "EOF"
125 The machine hostname that you will test.
128 $config_help{"SSH_USER"} = << "EOF"
129 The box is expected to have ssh on normal bootup, provide the user
130 (most likely root, since you need privileged operations)
133 $config_help{"BUILD_DIR"} = << "EOF"
134 The directory that contains the Linux source code (full path).
137 $config_help{"OUTPUT_DIR"} = << "EOF"
138 The directory that the objects will be built (full path).
139 (can not be same as BUILD_DIR)
142 $config_help{"BUILD_TARGET"} = << "EOF"
143 The location of the compiled file to copy to the target.
144 (relative to OUTPUT_DIR)
147 $config_help{"TARGET_IMAGE"} = << "EOF"
148 The place to put your image on the test machine.
151 $config_help{"POWER_CYCLE"} = << "EOF"
152 A script or command to reboot the box.
154 Here is a digital loggers power switch example
155 POWER_CYCLE = wget --no-proxy -O /dev/null -q --auth-no-challenge 'http://admin:admin\@power/outlet?5=CCL'
157 Here is an example to reboot a virtual box on the current host
158 with the name "Guest".
159 POWER_CYCLE = virsh destroy Guest; sleep 5; virsh start Guest
162 $config_help{"CONSOLE"} = << "EOF"
163 The script or command that reads the console
165 If you use ttywatch server, something like the following would work.
166 CONSOLE = nc -d localhost 3001
168 For a virtual machine with guest name "Guest".
169 CONSOLE = virsh console Guest
172 $config_help{"LOCALVERSION"} = << "EOF"
173 Required version ending to differentiate the test
174 from other linux builds on the system.
177 $config_help{"REBOOT_TYPE"} = << "EOF"
178 Way to reboot the box to the test kernel.
179 Only valid options so far are "grub" and "script".
181 If you specify grub, it will assume grub version 1
182 and will search in /boot/grub/menu.lst for the title \$GRUB_MENU
183 and select that target to reboot to the kernel. If this is not
184 your setup, then specify "script" and have a command or script
185 specified in REBOOT_SCRIPT to boot to the target.
187 The entry in /boot/grub/menu.lst must be entered in manually.
188 The test will not modify that file.
191 $config_help{"GRUB_MENU"} = << "EOF"
192 The grub title name for the test kernel to boot
193 (Only mandatory if REBOOT_TYPE = grub)
195 Note, ktest.pl will not update the grub menu.lst, you need to
196 manually add an option for the test. ktest.pl will search
197 the grub menu.lst for this option to find what kernel to
200 For example, if in the /boot/grub/menu.lst the test kernel title has:
203 GRUB_MENU = Test Kernel
206 $config_help{"REBOOT_SCRIPT"} = << "EOF"
207 A script to reboot the target into the test kernel
208 (Only mandatory if REBOOT_TYPE = script)
213 sub get_ktest_config {
216 return if (defined($opt{$config}));
218 if (defined($config_help{$config})) {
220 print $config_help{$config};
225 if (defined($default{$config})) {
226 print "\[$default{$config}\] ";
228 $entered_configs{$config} = <STDIN>;
229 $entered_configs{$config} =~ s/^\s*(.*\S)\s*$/$1/;
230 if ($entered_configs{$config} =~ /^\s*$/) {
231 if ($default{$config}) {
232 $entered_configs{$config} = $default{$config};
234 print "Your answer can not be blank\n";
242 sub get_ktest_configs {
243 get_ktest_config("MACHINE");
244 get_ktest_config("SSH_USER");
245 get_ktest_config("BUILD_DIR");
246 get_ktest_config("OUTPUT_DIR");
247 get_ktest_config("BUILD_TARGET");
248 get_ktest_config("TARGET_IMAGE");
249 get_ktest_config("POWER_CYCLE");
250 get_ktest_config("CONSOLE");
251 get_ktest_config("LOCALVERSION");
253 my $rtype = $opt{"REBOOT_TYPE"};
255 if (!defined($rtype)) {
256 if (!defined($opt{"GRUB_MENU"})) {
257 get_ktest_config("REBOOT_TYPE");
258 $rtype = $entered_configs{"REBOOT_TYPE"};
264 if ($rtype eq "grub") {
265 get_ktest_config("GRUB_MENU");
267 get_ktest_config("REBOOT_SCRIPT");
271 sub process_variables {
275 # We want to check for '\', and it is just easier
276 # to check the previous characet of '$' and not need
277 # to worry if '$' is the first character. By adding
278 # a space to $value, we can just check [^\\]\$ and
279 # it will still work.
282 while ($value =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) {
286 # append beginning of value to retval
287 $retval = "$retval$begin";
288 if (defined($variable{$var})) {
289 $retval = "$retval$variable{$var}";
291 # put back the origin piece.
292 $retval = "$retval\$\{$var\}";
296 $retval = "$retval$value";
298 # remove the space added in the beginning
305 my ($lvalue, $rvalue) = @_;
307 if (defined($opt{$lvalue})) {
308 die "Error: Option $lvalue defined more than once!\n";
310 if ($rvalue =~ /^\s*$/) {
311 delete $opt{$lvalue};
313 $rvalue = process_variables($rvalue);
314 $opt{$lvalue} = $rvalue;
319 my ($lvalue, $rvalue) = @_;
321 if ($rvalue =~ /^\s*$/) {
322 delete $variable{$lvalue};
324 $rvalue = process_variables($rvalue);
325 $variable{$lvalue} = $rvalue;
332 open(IN, $config) || die "can't read file $config";
335 $name =~ s,.*/(.*),$1,;
340 my $num_tests_set = 0;
346 # ignore blank lines and comments
347 next if (/^\s*$/ || /\s*\#/);
349 if (/^\s*TEST_START(.*)/) {
353 if ($num_tests_set) {
354 die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n";
357 my $old_test_num = $test_num;
358 my $old_repeat = $repeat;
360 $test_num += $repeat;
364 if ($rest =~ /\s+SKIP(.*)/) {
371 if ($rest =~ /\s+ITERATE\s+(\d+)(.*)$/) {
374 $repeat_tests{"$test_num"} = $repeat;
377 if ($rest =~ /\s+SKIP(.*)/) {
382 if ($rest !~ /^\s*$/) {
383 die "$name: $.: Gargbage found after TEST_START\n$_";
387 $test_num = $old_test_num;
388 $repeat = $old_repeat;
391 } elsif (/^\s*DEFAULTS(.*)$/) {
396 if ($rest =~ /\s+SKIP(.*)/) {
403 if ($rest !~ /^\s*$/) {
404 die "$name: $.: Gargbage found after DEFAULTS\n$_";
407 } elsif (/^\s*([A-Z_\[\]\d]+)\s*=\s*(.*?)\s*$/) {
415 ($lvalue eq "NUM_TESTS" ||
416 $lvalue eq "LOG_FILE" ||
417 $lvalue eq "CLEAR_LOG")) {
418 die "$name: $.: $lvalue must be set in DEFAULTS section\n";
421 if ($lvalue eq "NUM_TESTS") {
423 die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n";
426 die "$name: $.: NUM_TESTS must be set in default section\n";
431 if ($default || $lvalue =~ /\[\d+\]$/) {
432 set_value($lvalue, $rvalue);
434 my $val = "$lvalue\[$test_num\]";
435 set_value($val, $rvalue);
438 $repeats{$val} = $repeat;
441 } elsif (/^\s*([A-Z_\[\]\d]+)\s*:=\s*(.*?)\s*$/) {
447 # process config variables.
448 # Config variables are only active while reading the
449 # config and can be defined anywhere. They also ignore
450 # TEST_START and DEFAULTS, but are skipped if they are in
451 # on of these sections that have SKIP defined.
452 # The save variable can be
453 # defined multiple times and the new one simply overrides
455 set_variable($lvalue, $rvalue);
458 die "$name: $.: Garbage found in config\n$_";
465 $test_num += $repeat - 1;
466 $opt{"NUM_TESTS"} = $test_num;
469 # make sure we have all mandatory configs
474 foreach my $default (keys %default) {
475 if (!defined($opt{$default})) {
476 $opt{$default} = $default{$default};
482 if (defined($opt{"LOG_FILE"})) {
483 open(OUT, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}";
490 if (defined($opt{"LOG_FILE"})) {
505 # try to reboot normally
506 if (run_command $reboot) {
507 if (defined($powercycle_after_reboot)) {
508 sleep $powercycle_after_reboot;
509 run_command "$power_cycle";
512 # nope? power cycle it.
513 run_command "$power_cycle";
520 return $test_type eq "build" ||
521 ($test_type eq "patchcheck" && $opt{"PATCHCHECK_TYPE[$i]"} eq "build") ||
522 ($test_type eq "bisect" && $opt{"BISECT_TYPE[$i]"} eq "build");
526 doprint "CRITICAL FAILURE... ", @_, "\n";
530 if ($reboot_on_error && !do_not_reboot) {
532 doprint "REBOOTING\n";
535 } elsif ($poweroff_on_error && defined($power_off)) {
536 doprint "POWERING OFF\n";
540 if (defined($opt{"LOG_FILE"})) {
541 print " See $opt{LOG_FILE} for more info.\n";
552 my $pid = open($fp, "$console|") or
553 dodie "Can't open console $console";
555 $flags = fcntl($fp, F_GETFL, 0) or
556 dodie "Can't get flags for the socket: $!";
557 $flags = fcntl($fp, F_SETFL, $flags | O_NONBLOCK) or
558 dodie "Can't set flags for the socket: $!";
566 doprint "kill child process $pid\n";
574 if ($monitor_cnt++) {
577 $monitor_fp = \*MONFD;
578 $monitor_pid = open_console $monitor_fp;
582 open(MONFD, "Stop perl from warning about single use of MONFD");
586 if (--$monitor_cnt) {
589 close_console($monitor_fp, $monitor_pid);
592 sub wait_for_monitor {
596 doprint "** Wait for monitor to settle down **\n";
598 # read the monitor and wait for the system to calm down
600 $line = wait_for_input($monitor_fp, $time);
601 print "$line" if (defined($line));
602 } while (defined($line));
603 print "** Monitor flushed **\n";
608 if ($die_on_failure) {
616 # no need to reboot for just building.
617 if (!do_not_reboot) {
618 doprint "REBOOTING\n";
621 wait_for_monitor $sleep_time;
627 if (defined($test_name)) {
628 $name = " ($test_name)";
631 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
632 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
633 doprint "KTEST RESULT: TEST $i$name Failed: ", @_, "\n";
634 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
635 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
637 return 1 if (!defined($store_failures));
640 my $date = sprintf "%04d%02d%02d%02d%02d%02d",
641 1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0];
643 my $type = $build_type;
644 if ($type =~ /useconfig/) {
648 my $dir = "$machine-$test_type-$type-fail-$date";
649 my $faildir = "$store_failures/$dir";
653 die "can't create $faildir";
655 if (-f "$output_config") {
656 cp "$output_config", "$faildir/config" or
657 die "failed to copy .config";
660 cp $buildlog, "$faildir/buildlog" or
661 die "failed to move $buildlog";
664 cp $dmesg, "$faildir/dmesg" or
665 die "failed to move $dmesg";
668 doprint "*** Saved info to $faildir ***\n";
679 $command =~ s/\$SSH_USER/$ssh_user/g;
680 $command =~ s/\$MACHINE/$machine/g;
682 doprint("$command ... ");
684 $pid = open(CMD, "$command 2>&1 |") or
685 (fail "unable to exec $command" and return 0);
687 if (defined($opt{"LOG_FILE"})) {
688 open(LOG, ">>$opt{LOG_FILE}") or
689 dodie "failed to write to log";
693 if (defined($redirect)) {
694 open (RD, ">$redirect") or
695 dodie "failed to write to redirect $redirect";
700 print LOG if ($dolog);
708 close(LOG) if ($dolog);
709 close(RD) if ($dord);
722 my $cp_exec = $ssh_exec;
724 $cp_exec =~ s/\$SSH_COMMAND/$cmd/g;
725 return run_command "$cp_exec";
729 my ($src, $dst) = @_;
730 my $cp_scp = $scp_to_target;
732 $cp_scp =~ s/\$SRC_FILE/$src/g;
733 $cp_scp =~ s/\$DST_FILE/$dst/g;
735 return run_command "$cp_scp";
740 if ($reboot_type ne "grub") {
743 return if (defined($grub_number));
745 doprint "Find grub menu ... ";
748 my $ssh_grub = $ssh_exec;
749 $ssh_grub =~ s,\$SSH_COMMAND,cat /boot/grub/menu.lst,g;
751 open(IN, "$ssh_grub |")
752 or die "unable to get menu.lst";
755 if (/^\s*title\s+$grub_menu\s*$/) {
758 } elsif (/^\s*title\s/) {
764 die "Could not find '$grub_menu' in /boot/grub/menu on $machine"
765 if ($grub_number < 0);
766 doprint "$grub_number\n";
771 my ($fp, $time) = @_;
777 if (!defined($time)) {
782 vec($rin, fileno($fp), 1) = 1;
783 $ready = select($rin, undef, undef, $time);
787 # try to read one char at a time
788 while (sysread $fp, $ch, 1) {
790 last if ($ch eq "\n");
793 if (!length($line)) {
801 if ($reboot_type eq "grub") {
802 run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch && reboot)'";
806 run_command "$reboot_script";
812 doprint "git rev-list --max-count=1 $commit ... ";
813 my $sha1 = `git rev-list --max-count=1 $commit`;
820 dodie "Failed to get git $commit";
833 my $skip_call_trace = 0;
841 open(DMESG, "> $dmesg") or
842 die "unable to write to $dmesg";
848 my $monitor_start = time;
850 my $version_found = 0;
855 $line = wait_for_input($monitor_fp, $booted_timeout);
856 if (!defined($line)) {
857 my $s = $booted_timeout == 1 ? "" : "s";
858 doprint "Successful boot found: break after $booted_timeout second$s\n";
862 $line = wait_for_input($monitor_fp);
863 if (!defined($line)) {
864 my $s = $timeout == 1 ? "" : "s";
865 doprint "Timed out after $timeout second$s\n";
873 # we are not guaranteed to get a full line
876 if ($full_line =~ /$success_line/) {
878 $success_start = time;
881 if ($booted && defined($stop_after_success) &&
882 $stop_after_success >= 0) {
884 if ($now - $success_start >= $stop_after_success) {
885 doprint "Test forced to stop after $stop_after_success seconds after success\n";
890 if ($full_line =~ /\[ backtrace testing \]/) {
891 $skip_call_trace = 1;
894 if ($full_line =~ /call trace:/i) {
895 if (!$bug && !$skip_call_trace) {
897 $failure_start = time;
901 if ($bug && defined($stop_after_failure) &&
902 $stop_after_failure >= 0) {
904 if ($now - $failure_start >= $stop_after_failure) {
905 doprint "Test forced to stop after $stop_after_failure seconds after failure\n";
910 if ($full_line =~ /\[ end of backtrace testing \]/) {
911 $skip_call_trace = 0;
914 if ($full_line =~ /Kernel panic -/) {
915 $failure_start = time;
919 # Detect triple faults by testing the banner
920 if ($full_line =~ /\bLinux version (\S+).*\n/) {
921 if ($1 eq $version) {
923 } elsif ($version_found && $detect_triplefault) {
924 # We already booted into the kernel we are testing,
925 # but now we booted into another kernel?
926 # Consider this a triple fault.
927 doprint "Aleady booted in Linux kernel $version, but now\n";
928 doprint "we booted into Linux kernel $1.\n";
929 doprint "Assuming that this is a triple fault.\n";
930 doprint "To disable this: set DETECT_TRIPLE_FAULT to 0\n";
939 if ($stop_test_after > 0 && !$booted && !$bug) {
940 if (time - $monitor_start > $stop_test_after) {
941 doprint "STOP_TEST_AFTER ($stop_test_after seconds) timed out\n";
950 return 0 if ($in_bisect);
951 fail "failed - got a bug report" and return 0;
955 return 0 if ($in_bisect);
956 fail "failed - never got a boot prompt." and return 0;
964 run_scp "$outputdir/$build_target", "$target_image" or
965 dodie "failed to copy image";
967 my $install_mods = 0;
969 # should we process modules?
971 open(IN, "$output_config") or dodie("Can't read config file");
973 if (/CONFIG_MODULES(=y)?/) {
974 $install_mods = 1 if (defined($1));
980 if (!$install_mods) {
981 doprint "No modules needed\n";
985 run_command "$make INSTALL_MOD_PATH=$tmpdir modules_install" or
986 dodie "Failed to install modules";
988 my $modlib = "/lib/modules/$version";
989 my $modtar = "ktest-mods.tar.bz2";
991 run_ssh "rm -rf $modlib" or
992 dodie "failed to remove old mods: $modlib";
994 # would be nice if scp -r did not follow symbolic links
995 run_command "cd $tmpdir && tar -cjf $modtar lib/modules/$version" or
996 dodie "making tarball";
998 run_scp "$tmpdir/$modtar", "/tmp" or
999 dodie "failed to copy modules";
1001 unlink "$tmpdir/$modtar";
1003 run_ssh "'(cd / && tar xf /tmp/$modtar)'" or
1004 dodie "failed to tar modules";
1006 run_ssh "rm -f /tmp/$modtar";
1008 return if (!defined($post_install));
1010 my $cp_post_install = $post_install;
1011 $cp_post_install =~ s/\$KERNEL_VERSION/$version/g;
1012 run_command "$cp_post_install" or
1013 dodie "Failed to run post install";
1016 sub check_buildlog {
1019 my @files = `git show $patch | diffstat -l`;
1021 open(IN, "git show $patch |") or
1022 dodie "failed to show $patch";
1024 if (m,^--- a/(.*),) {
1026 $files[$#files] = $1;
1031 open(IN, $buildlog) or dodie "Can't open $buildlog";
1033 if (/^\s*(.*?):.*(warning|error)/) {
1035 foreach my $file (@files) {
1036 my $fullpath = "$builddir/$file";
1037 if ($file eq $err || $fullpath eq $err) {
1038 fail "$file built with warnings" and return 0;
1048 sub apply_min_config {
1049 my $outconfig = "$output_config.new";
1051 # Read the config file and remove anything that
1052 # is in the force_config hash (from minconfig and others)
1053 # then add the force config back.
1055 doprint "Applying minimum configurations into $output_config.new\n";
1057 open (OUT, ">$outconfig") or
1058 dodie "Can't create $outconfig";
1060 if (-f $output_config) {
1061 open (IN, $output_config) or
1062 dodie "Failed to open $output_config";
1064 if (/^(# )?(CONFIG_[^\s=]*)/) {
1065 next if (defined($force_config{$2}));
1071 foreach my $config (keys %force_config) {
1072 print OUT "$force_config{$config}\n";
1076 run_command "mv $outconfig $output_config";
1079 sub make_oldconfig {
1083 if (!run_command "$make oldnoconfig") {
1084 # Perhaps oldnoconfig doesn't exist in this version of the kernel
1085 # try a yes '' | oldconfig
1086 doprint "oldnoconfig failed, trying yes '' | make oldconfig\n";
1087 run_command "yes '' | $make oldconfig" or
1088 dodie "failed make config oldconfig";
1092 # read a config file and use this to force new configs.
1093 sub load_force_config {
1096 open(IN, $config) or
1097 dodie "failed to read $config";
1100 if (/^(CONFIG[^\s=]*)(\s*=.*)/) {
1101 $force_config{$1} = $_;
1102 } elsif (/^# (CONFIG_\S*) is not set/) {
1103 $force_config{$1} = $_;
1114 if ($type =~ /^useconfig:(.*)/) {
1115 run_command "cp $1 $output_config" or
1116 dodie "could not copy $1 to .config";
1118 $type = "oldconfig";
1121 # old config can ask questions
1122 if ($type eq "oldconfig") {
1123 $type = "oldnoconfig";
1125 # allow for empty configs
1126 run_command "touch $output_config";
1128 run_command "mv $output_config $outputdir/config_temp" or
1129 dodie "moving .config";
1131 if (!$noclean && !run_command "$make mrproper") {
1132 dodie "make mrproper";
1135 run_command "mv $outputdir/config_temp $output_config" or
1136 dodie "moving config_temp";
1138 } elsif (!$noclean) {
1139 unlink "$output_config";
1140 run_command "$make mrproper" or
1141 dodie "make mrproper";
1144 # add something to distinguish this build
1145 open(OUT, "> $outputdir/localversion") or dodie("Can't make localversion file");
1146 print OUT "$localversion\n";
1149 if (defined($minconfig)) {
1150 load_force_config($minconfig);
1153 if ($type ne "oldnoconfig") {
1154 run_command "$make $type" or
1155 dodie "failed make config";
1157 # Run old config regardless, to enforce min configurations
1160 $redirect = "$buildlog";
1161 if (!run_command "$make $build_options") {
1163 # bisect may need this to pass
1164 return 0 if ($in_bisect);
1165 fail "failed build" and return 0;
1173 if (!run_ssh "halt" or defined($power_off)) {
1174 if (defined($poweroff_after_halt)) {
1175 sleep $poweroff_after_halt;
1176 run_command "$power_off";
1180 run_command "$power_off";
1191 if (defined($test_name)) {
1192 $name = " ($test_name)";
1195 doprint "\n\n*******************************************\n";
1196 doprint "*******************************************\n";
1197 doprint "KTEST RESULT: TEST $i$name SUCCESS!!!! **\n";
1198 doprint "*******************************************\n";
1199 doprint "*******************************************\n";
1201 if ($i != $opt{"NUM_TESTS"} && !do_not_reboot) {
1202 doprint "Reboot and wait $sleep_time seconds\n";
1205 wait_for_monitor $sleep_time;
1211 # get the release name
1212 doprint "$make kernelrelease ... ";
1213 $version = `$make kernelrelease | tail -1`;
1215 doprint "$version\n";
1220 doprint "Pass or fail? [p/f]";
1223 if ($ans eq "p" || $ans eq "P") {
1225 } elsif ($ans eq "f" || $ans eq "F") {
1228 print "Please answer 'P' or 'F'\n";
1233 sub child_run_test {
1236 # child should have no power
1237 $reboot_on_error = 0;
1238 $poweroff_on_error = 0;
1239 $die_on_failure = 1;
1241 run_command $run_test or $failed = 1;
1247 sub child_finished {
1260 doprint "run test $run_test\n";
1264 $SIG{CHLD} = qw(child_finished);
1268 child_run_test if (!$child_pid);
1273 $line = wait_for_input($monitor_fp, 1);
1274 if (defined($line)) {
1276 # we are not guaranteed to get a full line
1277 $full_line .= $line;
1280 if ($full_line =~ /call trace:/i) {
1284 if ($full_line =~ /Kernel panic -/) {
1288 if ($line =~ /\n/) {
1292 } while (!$child_done && !$bug);
1295 my $failure_start = time;
1298 $line = wait_for_input($monitor_fp, 1);
1299 if (defined($line)) {
1303 if ($now - $failure_start >= $stop_after_failure) {
1306 } while (defined($line));
1308 doprint "Detected kernel crash!\n";
1309 # kill the child with extreme prejudice
1313 waitpid $child_pid, 0;
1316 if ($bug || $child_exit) {
1317 return 0 if $in_bisect;
1318 fail "test failed" and return 0;
1323 sub run_git_bisect {
1326 doprint "$command ... ";
1328 my $output = `$command 2>&1`;
1335 dodie "Failed to git bisect";
1338 doprint "SUCCESS\n";
1339 if ($output =~ m/^(Bisecting: .*\(roughly \d+ steps?\))\s+\[([[:xdigit:]]+)\]/) {
1340 doprint "$1 [$2]\n";
1341 } elsif ($output =~ m/^([[:xdigit:]]+) is the first bad commit/) {
1343 doprint "Found bad commit... $1\n";
1346 # we already logged it, just print it now.
1354 doprint "Reboot and sleep $bisect_sleep_time seconds\n";
1357 wait_for_monitor $bisect_sleep_time;
1361 # returns 1 on success, 0 on failure, -1 on skip
1362 sub run_bisect_test {
1363 my ($type, $buildtype) = @_;
1372 build $buildtype or $failed = 1;
1374 if ($type ne "build") {
1375 if ($failed && $bisect_skip) {
1379 dodie "Failed on build" if $failed;
1387 monitor or $failed = 1;
1389 if ($type ne "boot") {
1390 if ($failed && $bisect_skip) {
1396 dodie "Failed on boot" if $failed;
1398 do_run_test or $failed = 1;
1409 # reboot the box to a kernel we can ssh to
1410 if ($type ne "build") {
1420 my $buildtype = "oldconfig";
1422 # We should have a minconfig to use?
1423 if (defined($minconfig)) {
1424 $buildtype = "useconfig:$minconfig";
1427 my $ret = run_bisect_test $type, $buildtype;
1429 if ($bisect_manual) {
1430 $ret = answer_bisect;
1433 # Are we looking for where it worked, not failed?
1434 if ($reverse_bisect) {
1440 } elsif ($ret == 0) {
1442 } elsif ($bisect_skip) {
1443 doprint "HIT A BAD COMMIT ... SKIPPING\n";
1453 die "BISECT_GOOD[$i] not defined\n" if (!defined($opt{"BISECT_GOOD[$i]"}));
1454 die "BISECT_BAD[$i] not defined\n" if (!defined($opt{"BISECT_BAD[$i]"}));
1455 die "BISECT_TYPE[$i] not defined\n" if (!defined($opt{"BISECT_TYPE[$i]"}));
1457 my $good = $opt{"BISECT_GOOD[$i]"};
1458 my $bad = $opt{"BISECT_BAD[$i]"};
1459 my $type = $opt{"BISECT_TYPE[$i]"};
1460 my $start = $opt{"BISECT_START[$i]"};
1461 my $replay = $opt{"BISECT_REPLAY[$i]"};
1462 my $start_files = $opt{"BISECT_FILES[$i]"};
1464 if (defined($start_files)) {
1465 $start_files = " -- " . $start_files;
1470 # convert to true sha1's
1471 $good = get_sha1($good);
1472 $bad = get_sha1($bad);
1474 if (defined($opt{"BISECT_REVERSE[$i]"}) &&
1475 $opt{"BISECT_REVERSE[$i]"} == 1) {
1476 doprint "Performing a reverse bisect (bad is good, good is bad!)\n";
1477 $reverse_bisect = 1;
1479 $reverse_bisect = 0;
1482 # Can't have a test without having a test to run
1483 if ($type eq "test" && !defined($run_test)) {
1487 my $check = $opt{"BISECT_CHECK[$i]"};
1488 if (defined($check) && $check ne "0") {
1491 my $head = get_sha1("HEAD");
1493 if ($check ne "good") {
1494 doprint "TESTING BISECT BAD [$bad]\n";
1495 run_command "git checkout $bad" or
1496 die "Failed to checkout $bad";
1498 $result = run_bisect $type;
1500 if ($result ne "bad") {
1501 fail "Tested BISECT_BAD [$bad] and it succeeded" and return 0;
1505 if ($check ne "bad") {
1506 doprint "TESTING BISECT GOOD [$good]\n";
1507 run_command "git checkout $good" or
1508 die "Failed to checkout $good";
1510 $result = run_bisect $type;
1512 if ($result ne "good") {
1513 fail "Tested BISECT_GOOD [$good] and it failed" and return 0;
1517 # checkout where we started
1518 run_command "git checkout $head" or
1519 die "Failed to checkout $head";
1522 run_command "git bisect start$start_files" or
1523 dodie "could not start bisect";
1525 run_command "git bisect good $good" or
1526 dodie "could not set bisect good to $good";
1528 run_git_bisect "git bisect bad $bad" or
1529 dodie "could not set bisect bad to $bad";
1531 if (defined($replay)) {
1532 run_command "git bisect replay $replay" or
1533 dodie "failed to run replay";
1536 if (defined($start)) {
1537 run_command "git checkout $start" or
1538 dodie "failed to checkout $start";
1543 $result = run_bisect $type;
1544 $test = run_git_bisect "git bisect $result";
1547 run_command "git bisect log" or
1548 dodie "could not capture git bisect log";
1550 run_command "git bisect reset" or
1551 dodie "could not reset git bisect";
1553 doprint "Bad commit was [$bisect_bad]\n";
1566 sub process_config_ignore {
1570 or dodie "Failed to read $config";
1573 if (/^((CONFIG\S*)=.*)/) {
1574 $config_ignore{$2} = $1;
1581 sub read_current_config {
1582 my ($config_ref) = @_;
1584 %{$config_ref} = ();
1585 undef %{$config_ref};
1587 my @key = keys %{$config_ref};
1589 print "did not delete!\n";
1592 open (IN, "$output_config");
1595 if (/^(CONFIG\S+)=(.*)/) {
1596 ${$config_ref}{$1} = $2;
1602 sub get_dependencies {
1605 my $arr = $dependency{$config};
1606 if (!defined($arr)) {
1612 foreach my $dep (@{$arr}) {
1613 print "ADD DEP $dep\n";
1614 @deps = (@deps, get_dependencies $dep);
1623 open(OUT, ">$output_config") or dodie "Can not write to $output_config";
1625 foreach my $config (@configs) {
1626 print OUT "$config_set{$config}\n";
1627 my @deps = get_dependencies $config;
1628 foreach my $dep (@deps) {
1629 print OUT "$config_set{$dep}\n";
1633 foreach my $config (keys %config_ignore) {
1634 print OUT "$config_ignore{$config}\n";
1642 sub compare_configs {
1645 foreach my $item (keys %a) {
1646 if (!defined($b{$item})) {
1647 print "diff $item\n";
1655 print "diff2 $keys[0]\n";
1657 return -1 if ($#keys >= 0);
1662 sub run_config_bisect_test {
1665 return run_bisect_test $type, "oldconfig";
1668 sub process_passed {
1671 doprint "These configs had no failure: (Enabling them for further compiles)\n";
1672 # Passed! All these configs are part of a good compile.
1673 # Add them to the min options.
1674 foreach my $config (keys %configs) {
1675 if (defined($config_list{$config})) {
1676 doprint " removing $config\n";
1677 $config_ignore{$config} = $config_list{$config};
1678 delete $config_list{$config};
1681 doprint "config copied to $outputdir/config_good\n";
1682 run_command "cp -f $output_config $outputdir/config_good";
1685 sub process_failed {
1688 doprint "\n\n***************************************\n";
1689 doprint "Found bad config: $config\n";
1690 doprint "***************************************\n\n";
1693 sub run_config_bisect {
1695 my @start_list = keys %config_list;
1697 if ($#start_list < 0) {
1698 doprint "No more configs to test!!!\n";
1702 doprint "***** RUN TEST ***\n";
1703 my $type = $opt{"CONFIG_BISECT_TYPE[$iteration]"};
1707 my $count = $#start_list + 1;
1708 doprint " $count configs to test\n";
1710 my $half = int($#start_list / 2);
1713 my @tophalf = @start_list[0 .. $half];
1715 create_config @tophalf;
1716 read_current_config \%current_config;
1718 $count = $#tophalf + 1;
1719 doprint "Testing $count configs\n";
1721 # make sure we test something
1722 foreach my $config (@tophalf) {
1723 if (defined($current_config{$config})) {
1729 # try the other half
1730 doprint "Top half produced no set configs, trying bottom half\n";
1731 @tophalf = @start_list[$half + 1 .. $#start_list];
1732 create_config @tophalf;
1733 read_current_config \%current_config;
1734 foreach my $config (@tophalf) {
1735 if (defined($current_config{$config})) {
1741 doprint "Failed: Can't make new config with current configs\n";
1742 foreach my $config (@start_list) {
1743 doprint " CONFIG: $config\n";
1747 $count = $#tophalf + 1;
1748 doprint "Testing $count configs\n";
1751 $ret = run_config_bisect_test $type;
1752 if ($bisect_manual) {
1753 $ret = answer_bisect;
1756 process_passed %current_config;
1760 doprint "This config had a failure.\n";
1761 doprint "Removing these configs that were not set in this config:\n";
1762 doprint "config copied to $outputdir/config_bad\n";
1763 run_command "cp -f $output_config $outputdir/config_bad";
1765 # A config exists in this group that was bad.
1766 foreach my $config (keys %config_list) {
1767 if (!defined($current_config{$config})) {
1768 doprint " removing $config\n";
1769 delete $config_list{$config};
1773 @start_list = @tophalf;
1775 if ($#start_list == 0) {
1776 process_failed $start_list[0];
1780 # remove half the configs we are looking at and see if
1782 $half = int($#start_list / 2);
1783 } while ($#start_list > 0);
1785 # we found a single config, try it again unless we are running manually
1787 if ($bisect_manual) {
1788 process_failed $start_list[0];
1792 my @tophalf = @start_list[0 .. 0];
1794 $ret = run_config_bisect_test $type;
1796 process_passed %current_config;
1800 process_failed $start_list[0];
1807 my $start_config = $opt{"CONFIG_BISECT[$i]"};
1809 my $tmpconfig = "$tmpdir/use_config";
1811 if (defined($config_bisect_good)) {
1812 process_config_ignore $config_bisect_good;
1815 # Make the file with the bad config and the min config
1816 if (defined($minconfig)) {
1817 # read the min config for things to ignore
1818 run_command "cp $minconfig $tmpconfig" or
1819 dodie "failed to copy $minconfig to $tmpconfig";
1825 if (defined($addconfig)) {
1826 run_command "cat $addconfig >> $tmpconfig" or
1827 dodie "failed to append $addconfig";
1830 if (-f $tmpconfig) {
1831 load_force_config($tmpconfig);
1832 process_config_ignore $tmpconfig;
1835 # now process the start config
1836 run_command "cp $start_config $output_config" or
1837 dodie "failed to copy $start_config to $output_config";
1839 # read directly what we want to check
1841 open (IN, $output_config)
1842 or dodie "faied to open $output_config";
1845 if (/^((CONFIG\S*)=.*)/) {
1846 $config_check{$2} = $1;
1851 # Now run oldconfig with the minconfig (and addconfigs)
1854 # check to see what we lost (or gained)
1855 open (IN, $output_config)
1856 or dodie "Failed to read $start_config";
1858 my %removed_configs;
1862 if (/^((CONFIG\S*)=.*)/) {
1863 # save off all options
1864 $config_set{$2} = $1;
1865 if (defined($config_check{$2})) {
1866 if (defined($config_ignore{$2})) {
1867 $removed_configs{$2} = $1;
1869 $config_list{$2} = $1;
1871 } elsif (!defined($config_ignore{$2})) {
1872 $added_configs{$2} = $1;
1873 $config_list{$2} = $1;
1879 my @confs = keys %removed_configs;
1881 doprint "Configs overridden by default configs and removed from check:\n";
1882 foreach my $config (@confs) {
1883 doprint " $config\n";
1886 @confs = keys %added_configs;
1888 doprint "Configs appearing in make oldconfig and added:\n";
1889 foreach my $config (@confs) {
1890 doprint " $config\n";
1897 # Sometimes kconfig does weird things. We must make sure
1898 # that the config we autocreate has everything we need
1899 # to test, otherwise we may miss testing configs, or
1900 # may not be able to create a new config.
1901 # Here we create a config with everything set.
1902 create_config (keys %config_list);
1903 read_current_config \%config_test;
1904 foreach my $config (keys %config_list) {
1905 if (!defined($config_test{$config})) {
1908 doprint "Configs not produced by kconfig (will not be checked):\n";
1910 doprint " $config\n";
1911 delete $config_list{$config};
1916 $ret = run_config_bisect;
1919 return $ret if ($ret < 0);
1924 sub patchcheck_reboot {
1925 doprint "Reboot and sleep $patchcheck_sleep_time seconds\n";
1928 wait_for_monitor $patchcheck_sleep_time;
1935 die "PATCHCHECK_START[$i] not defined\n"
1936 if (!defined($opt{"PATCHCHECK_START[$i]"}));
1937 die "PATCHCHECK_TYPE[$i] not defined\n"
1938 if (!defined($opt{"PATCHCHECK_TYPE[$i]"}));
1940 my $start = $opt{"PATCHCHECK_START[$i]"};
1943 if (defined($opt{"PATCHCHECK_END[$i]"})) {
1944 $end = $opt{"PATCHCHECK_END[$i]"};
1947 # Get the true sha1's since we can use things like HEAD~3
1948 $start = get_sha1($start);
1949 $end = get_sha1($end);
1951 my $type = $opt{"PATCHCHECK_TYPE[$i]"};
1953 # Can't have a test without having a test to run
1954 if ($type eq "test" && !defined($run_test)) {
1958 open (IN, "git log --pretty=oneline $end|") or
1959 dodie "could not get git list";
1965 $list[$#list+1] = $_;
1966 last if (/^$start/);
1970 if ($list[$#list] !~ /^$start/) {
1971 fail "SHA1 $start not found";
1974 # go backwards in the list
1975 @list = reverse @list;
1977 my $save_clean = $noclean;
1980 foreach my $item (@list) {
1982 $sha1 =~ s/^([[:xdigit:]]+).*/$1/;
1984 doprint "\nProcessing commit $item\n\n";
1986 run_command "git checkout $sha1" or
1987 die "Failed to checkout $sha1";
1989 # only clean on the first and last patch
1990 if ($item eq $list[0] ||
1991 $item eq $list[$#list]) {
1992 $noclean = $save_clean;
1997 if (defined($minconfig)) {
1998 build "useconfig:$minconfig" or return 0;
2000 # ?? no config to use?
2001 build "oldconfig" or return 0;
2004 check_buildlog $sha1 or return 0;
2006 next if ($type eq "build");
2015 monitor or $failed = 1;
2017 if (!$failed && $type ne "boot"){
2018 do_run_test or $failed = 1;
2021 return 0 if ($failed);
2032 $#ARGV < 1 or die "ktest.pl version: $VERSION\n usage: ktest.pl config-file\n";
2035 $ktest_config = $ARGV[0];
2036 if (! -f $ktest_config) {
2037 print "$ktest_config does not exist.\n";
2040 print "Create it? [Y/n] ";
2043 if ($ans =~ /^\s*$/) {
2046 last if ($ans =~ /^y$/i || $ans =~ /^n$/i);
2047 print "Please answer either 'y' or 'n'.\n";
2049 if ($ans !~ /^y$/i) {
2054 $ktest_config = "ktest.conf";
2057 if (! -f $ktest_config) {
2058 open(OUT, ">$ktest_config") or die "Can not create $ktest_config";
2060 # Generated by ktest.pl
2062 # Define each test with TEST_START
2063 # The config options below it will override the defaults
2071 read_config $ktest_config;
2073 # Append any configs entered in manually to the config file.
2074 my @new_configs = keys %entered_configs;
2075 if ($#new_configs >= 0) {
2076 print "\nAppending entered in configs to $ktest_config\n";
2077 open(OUT, ">>$ktest_config") or die "Can not append to $ktest_config";
2078 foreach my $config (@new_configs) {
2079 print OUT "$config = $entered_configs{$config}\n";
2080 $opt{$config} = $entered_configs{$config};
2084 if ($opt{"CLEAR_LOG"} && defined($opt{"LOG_FILE"})) {
2085 unlink $opt{"LOG_FILE"};
2088 doprint "\n\nSTARTING AUTOMATED TESTS\n\n";
2090 for (my $i = 0, my $repeat = 1; $i <= $opt{"NUM_TESTS"}; $i += $repeat) {
2093 doprint "DEFAULT OPTIONS:\n";
2095 doprint "\nTEST $i OPTIONS";
2096 if (defined($repeat_tests{$i})) {
2097 $repeat = $repeat_tests{$i};
2098 doprint " ITERATE $repeat";
2103 foreach my $option (sort keys %opt) {
2105 if ($option =~ /\[(\d+)\]$/) {
2111 doprint "$option = $opt{$option}\n";
2115 sub __set_test_option {
2116 my ($name, $i) = @_;
2118 my $option = "$name\[$i\]";
2120 if (defined($opt{$option})) {
2121 return $opt{$option};
2124 foreach my $test (keys %repeat_tests) {
2126 $i < $test + $repeat_tests{$test}) {
2127 $option = "$name\[$test\]";
2128 if (defined($opt{$option})) {
2129 return $opt{$option};
2134 if (defined($opt{$name})) {
2142 my ($option, $i) = @_;
2144 # Add space to evaluate the character before $
2145 $option = " $option";
2148 while ($option =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) {
2153 # Append beginning of line
2154 $retval = "$retval$start";
2156 # If the iteration option OPT[$i] exists, then use that.
2157 # otherwise see if the default OPT (without [$i]) exists.
2159 my $o = "$var\[$i\]";
2161 if (defined($opt{$o})) {
2163 $retval = "$retval$o";
2164 } elsif (defined($opt{$var})) {
2166 $retval = "$retval$o";
2168 $retval = "$retval\$\{$var\}";
2174 $retval = "$retval$option";
2181 sub set_test_option {
2182 my ($name, $i) = @_;
2184 my $option = __set_test_option($name, $i);
2185 return $option if (!defined($option));
2189 # Since an option can evaluate to another option,
2190 # keep iterating until we do not evaluate any more
2193 while ($prev ne $option) {
2194 # Check for recursive evaluations.
2195 # 100 deep should be more than enough.
2197 die "Over 100 evaluations accurred with $name\n" .
2198 "Check for recursive variables\n";
2201 $option = eval_option($option, $i);
2207 # First we need to do is the builds
2208 for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
2212 my $makecmd = set_test_option("MAKE_CMD", $i);
2214 $machine = set_test_option("MACHINE", $i);
2215 $ssh_user = set_test_option("SSH_USER", $i);
2216 $tmpdir = set_test_option("TMP_DIR", $i);
2217 $outputdir = set_test_option("OUTPUT_DIR", $i);
2218 $builddir = set_test_option("BUILD_DIR", $i);
2219 $test_type = set_test_option("TEST_TYPE", $i);
2220 $build_type = set_test_option("BUILD_TYPE", $i);
2221 $build_options = set_test_option("BUILD_OPTIONS", $i);
2222 $power_cycle = set_test_option("POWER_CYCLE", $i);
2223 $reboot = set_test_option("REBOOT", $i);
2224 $noclean = set_test_option("BUILD_NOCLEAN", $i);
2225 $minconfig = set_test_option("MIN_CONFIG", $i);
2226 $run_test = set_test_option("TEST", $i);
2227 $addconfig = set_test_option("ADD_CONFIG", $i);
2228 $reboot_type = set_test_option("REBOOT_TYPE", $i);
2229 $grub_menu = set_test_option("GRUB_MENU", $i);
2230 $post_install = set_test_option("POST_INSTALL", $i);
2231 $reboot_script = set_test_option("REBOOT_SCRIPT", $i);
2232 $reboot_on_error = set_test_option("REBOOT_ON_ERROR", $i);
2233 $poweroff_on_error = set_test_option("POWEROFF_ON_ERROR", $i);
2234 $die_on_failure = set_test_option("DIE_ON_FAILURE", $i);
2235 $power_off = set_test_option("POWER_OFF", $i);
2236 $powercycle_after_reboot = set_test_option("POWERCYCLE_AFTER_REBOOT", $i);
2237 $poweroff_after_halt = set_test_option("POWEROFF_AFTER_HALT", $i);
2238 $sleep_time = set_test_option("SLEEP_TIME", $i);
2239 $bisect_sleep_time = set_test_option("BISECT_SLEEP_TIME", $i);
2240 $patchcheck_sleep_time = set_test_option("PATCHCHECK_SLEEP_TIME", $i);
2241 $bisect_manual = set_test_option("BISECT_MANUAL", $i);
2242 $bisect_skip = set_test_option("BISECT_SKIP", $i);
2243 $config_bisect_good = set_test_option("CONFIG_BISECT_GOOD", $i);
2244 $store_failures = set_test_option("STORE_FAILURES", $i);
2245 $test_name = set_test_option("TEST_NAME", $i);
2246 $timeout = set_test_option("TIMEOUT", $i);
2247 $booted_timeout = set_test_option("BOOTED_TIMEOUT", $i);
2248 $console = set_test_option("CONSOLE", $i);
2249 $detect_triplefault = set_test_option("DETECT_TRIPLE_FAULT", $i);
2250 $success_line = set_test_option("SUCCESS_LINE", $i);
2251 $stop_after_success = set_test_option("STOP_AFTER_SUCCESS", $i);
2252 $stop_after_failure = set_test_option("STOP_AFTER_FAILURE", $i);
2253 $stop_test_after = set_test_option("STOP_TEST_AFTER", $i);
2254 $build_target = set_test_option("BUILD_TARGET", $i);
2255 $ssh_exec = set_test_option("SSH_EXEC", $i);
2256 $scp_to_target = set_test_option("SCP_TO_TARGET", $i);
2257 $target_image = set_test_option("TARGET_IMAGE", $i);
2258 $localversion = set_test_option("LOCALVERSION", $i);
2260 chdir $builddir || die "can't change directory to $builddir";
2264 die "can't create $tmpdir";
2267 $ENV{"SSH_USER"} = $ssh_user;
2268 $ENV{"MACHINE"} = $machine;
2270 $target = "$ssh_user\@$machine";
2272 $buildlog = "$tmpdir/buildlog-$machine";
2273 $dmesg = "$tmpdir/dmesg-$machine";
2274 $make = "$makecmd O=$outputdir";
2275 $output_config = "$outputdir/.config";
2277 if ($reboot_type eq "grub") {
2278 dodie "GRUB_MENU not defined" if (!defined($grub_menu));
2279 } elsif (!defined($reboot_script)) {
2280 dodie "REBOOT_SCRIPT not defined"
2283 my $run_type = $build_type;
2284 if ($test_type eq "patchcheck") {
2285 $run_type = $opt{"PATCHCHECK_TYPE[$i]"};
2286 } elsif ($test_type eq "bisect") {
2287 $run_type = $opt{"BISECT_TYPE[$i]"};
2288 } elsif ($test_type eq "config_bisect") {
2289 $run_type = $opt{"CONFIG_BISECT_TYPE[$i]"};
2292 # mistake in config file?
2293 if (!defined($run_type)) {
2294 $run_type = "ERROR";
2298 doprint "RUNNING TEST $i of $opt{NUM_TESTS} with option $test_type $run_type\n\n";
2303 if (!defined($minconfig)) {
2304 $minconfig = $addconfig;
2306 } elsif (defined($addconfig)) {
2307 run_command "cat $addconfig $minconfig > $tmpdir/add_config" or
2308 dodie "Failed to create temp config";
2309 $minconfig = "$tmpdir/add_config";
2312 my $checkout = $opt{"CHECKOUT[$i]"};
2313 if (defined($checkout)) {
2314 run_command "git checkout $checkout" or
2315 die "failed to checkout $checkout";
2318 if ($test_type eq "bisect") {
2321 } elsif ($test_type eq "config_bisect") {
2324 } elsif ($test_type eq "patchcheck") {
2329 if ($build_type ne "nobuild") {
2330 build $build_type or next;
2333 if ($test_type ne "build") {
2340 monitor or $failed = 1;;
2342 if (!$failed && $test_type ne "boot" && defined($run_test)) {
2343 do_run_test or $failed = 1;
2352 if ($opt{"POWEROFF_ON_SUCCESS"}) {
2354 } elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot) {
2358 doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n";