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;
854 if ($bug && defined($stop_after_failure) &&
855 $stop_after_failure >= 0) {
856 my $time = $stop_after_failure - (time - $failure_start);
857 $line = wait_for_input($monitor_fp, $time);
858 if (!defined($line)) {
859 doprint "bug timed out after $booted_timeout seconds\n";
860 doprint "Test forced to stop after $stop_after_failure seconds after failure\n";
864 $line = wait_for_input($monitor_fp, $booted_timeout);
865 if (!defined($line)) {
866 my $s = $booted_timeout == 1 ? "" : "s";
867 doprint "Successful boot found: break after $booted_timeout second$s\n";
871 $line = wait_for_input($monitor_fp);
872 if (!defined($line)) {
873 my $s = $timeout == 1 ? "" : "s";
874 doprint "Timed out after $timeout second$s\n";
882 # we are not guaranteed to get a full line
885 if ($full_line =~ /$success_line/) {
887 $success_start = time;
890 if ($booted && defined($stop_after_success) &&
891 $stop_after_success >= 0) {
893 if ($now - $success_start >= $stop_after_success) {
894 doprint "Test forced to stop after $stop_after_success seconds after success\n";
899 if ($full_line =~ /\[ backtrace testing \]/) {
900 $skip_call_trace = 1;
903 if ($full_line =~ /call trace:/i) {
904 if (!$bug && !$skip_call_trace) {
906 $failure_start = time;
910 if ($bug && defined($stop_after_failure) &&
911 $stop_after_failure >= 0) {
913 if ($now - $failure_start >= $stop_after_failure) {
914 doprint "Test forced to stop after $stop_after_failure seconds after failure\n";
919 if ($full_line =~ /\[ end of backtrace testing \]/) {
920 $skip_call_trace = 0;
923 if ($full_line =~ /Kernel panic -/) {
924 $failure_start = time;
928 # Detect triple faults by testing the banner
929 if ($full_line =~ /\bLinux version (\S+).*\n/) {
930 if ($1 eq $version) {
932 } elsif ($version_found && $detect_triplefault) {
933 # We already booted into the kernel we are testing,
934 # but now we booted into another kernel?
935 # Consider this a triple fault.
936 doprint "Aleady booted in Linux kernel $version, but now\n";
937 doprint "we booted into Linux kernel $1.\n";
938 doprint "Assuming that this is a triple fault.\n";
939 doprint "To disable this: set DETECT_TRIPLE_FAULT to 0\n";
948 if ($stop_test_after > 0 && !$booted && !$bug) {
949 if (time - $monitor_start > $stop_test_after) {
950 doprint "STOP_TEST_AFTER ($stop_test_after seconds) timed out\n";
959 return 0 if ($in_bisect);
960 fail "failed - got a bug report" and return 0;
964 return 0 if ($in_bisect);
965 fail "failed - never got a boot prompt." and return 0;
973 run_scp "$outputdir/$build_target", "$target_image" or
974 dodie "failed to copy image";
976 my $install_mods = 0;
978 # should we process modules?
980 open(IN, "$output_config") or dodie("Can't read config file");
982 if (/CONFIG_MODULES(=y)?/) {
983 $install_mods = 1 if (defined($1));
989 if (!$install_mods) {
990 doprint "No modules needed\n";
994 run_command "$make INSTALL_MOD_PATH=$tmpdir modules_install" or
995 dodie "Failed to install modules";
997 my $modlib = "/lib/modules/$version";
998 my $modtar = "ktest-mods.tar.bz2";
1000 run_ssh "rm -rf $modlib" or
1001 dodie "failed to remove old mods: $modlib";
1003 # would be nice if scp -r did not follow symbolic links
1004 run_command "cd $tmpdir && tar -cjf $modtar lib/modules/$version" or
1005 dodie "making tarball";
1007 run_scp "$tmpdir/$modtar", "/tmp" or
1008 dodie "failed to copy modules";
1010 unlink "$tmpdir/$modtar";
1012 run_ssh "'(cd / && tar xf /tmp/$modtar)'" or
1013 dodie "failed to tar modules";
1015 run_ssh "rm -f /tmp/$modtar";
1017 return if (!defined($post_install));
1019 my $cp_post_install = $post_install;
1020 $cp_post_install =~ s/\$KERNEL_VERSION/$version/g;
1021 run_command "$cp_post_install" or
1022 dodie "Failed to run post install";
1025 sub check_buildlog {
1028 my @files = `git show $patch | diffstat -l`;
1030 open(IN, "git show $patch |") or
1031 dodie "failed to show $patch";
1033 if (m,^--- a/(.*),) {
1035 $files[$#files] = $1;
1040 open(IN, $buildlog) or dodie "Can't open $buildlog";
1042 if (/^\s*(.*?):.*(warning|error)/) {
1044 foreach my $file (@files) {
1045 my $fullpath = "$builddir/$file";
1046 if ($file eq $err || $fullpath eq $err) {
1047 fail "$file built with warnings" and return 0;
1057 sub apply_min_config {
1058 my $outconfig = "$output_config.new";
1060 # Read the config file and remove anything that
1061 # is in the force_config hash (from minconfig and others)
1062 # then add the force config back.
1064 doprint "Applying minimum configurations into $output_config.new\n";
1066 open (OUT, ">$outconfig") or
1067 dodie "Can't create $outconfig";
1069 if (-f $output_config) {
1070 open (IN, $output_config) or
1071 dodie "Failed to open $output_config";
1073 if (/^(# )?(CONFIG_[^\s=]*)/) {
1074 next if (defined($force_config{$2}));
1080 foreach my $config (keys %force_config) {
1081 print OUT "$force_config{$config}\n";
1085 run_command "mv $outconfig $output_config";
1088 sub make_oldconfig {
1092 if (!run_command "$make oldnoconfig") {
1093 # Perhaps oldnoconfig doesn't exist in this version of the kernel
1094 # try a yes '' | oldconfig
1095 doprint "oldnoconfig failed, trying yes '' | make oldconfig\n";
1096 run_command "yes '' | $make oldconfig" or
1097 dodie "failed make config oldconfig";
1101 # read a config file and use this to force new configs.
1102 sub load_force_config {
1105 open(IN, $config) or
1106 dodie "failed to read $config";
1109 if (/^(CONFIG[^\s=]*)(\s*=.*)/) {
1110 $force_config{$1} = $_;
1111 } elsif (/^# (CONFIG_\S*) is not set/) {
1112 $force_config{$1} = $_;
1123 if ($type =~ /^useconfig:(.*)/) {
1124 run_command "cp $1 $output_config" or
1125 dodie "could not copy $1 to .config";
1127 $type = "oldconfig";
1130 # old config can ask questions
1131 if ($type eq "oldconfig") {
1132 $type = "oldnoconfig";
1134 # allow for empty configs
1135 run_command "touch $output_config";
1137 run_command "mv $output_config $outputdir/config_temp" or
1138 dodie "moving .config";
1140 if (!$noclean && !run_command "$make mrproper") {
1141 dodie "make mrproper";
1144 run_command "mv $outputdir/config_temp $output_config" or
1145 dodie "moving config_temp";
1147 } elsif (!$noclean) {
1148 unlink "$output_config";
1149 run_command "$make mrproper" or
1150 dodie "make mrproper";
1153 # add something to distinguish this build
1154 open(OUT, "> $outputdir/localversion") or dodie("Can't make localversion file");
1155 print OUT "$localversion\n";
1158 if (defined($minconfig)) {
1159 load_force_config($minconfig);
1162 if ($type ne "oldnoconfig") {
1163 run_command "$make $type" or
1164 dodie "failed make config";
1166 # Run old config regardless, to enforce min configurations
1169 $redirect = "$buildlog";
1170 if (!run_command "$make $build_options") {
1172 # bisect may need this to pass
1173 return 0 if ($in_bisect);
1174 fail "failed build" and return 0;
1182 if (!run_ssh "halt" or defined($power_off)) {
1183 if (defined($poweroff_after_halt)) {
1184 sleep $poweroff_after_halt;
1185 run_command "$power_off";
1189 run_command "$power_off";
1200 if (defined($test_name)) {
1201 $name = " ($test_name)";
1204 doprint "\n\n*******************************************\n";
1205 doprint "*******************************************\n";
1206 doprint "KTEST RESULT: TEST $i$name SUCCESS!!!! **\n";
1207 doprint "*******************************************\n";
1208 doprint "*******************************************\n";
1210 if ($i != $opt{"NUM_TESTS"} && !do_not_reboot) {
1211 doprint "Reboot and wait $sleep_time seconds\n";
1214 wait_for_monitor $sleep_time;
1220 # get the release name
1221 doprint "$make kernelrelease ... ";
1222 $version = `$make kernelrelease | tail -1`;
1224 doprint "$version\n";
1229 doprint "Pass or fail? [p/f]";
1232 if ($ans eq "p" || $ans eq "P") {
1234 } elsif ($ans eq "f" || $ans eq "F") {
1237 print "Please answer 'P' or 'F'\n";
1242 sub child_run_test {
1245 # child should have no power
1246 $reboot_on_error = 0;
1247 $poweroff_on_error = 0;
1248 $die_on_failure = 1;
1250 run_command $run_test or $failed = 1;
1256 sub child_finished {
1269 doprint "run test $run_test\n";
1273 $SIG{CHLD} = qw(child_finished);
1277 child_run_test if (!$child_pid);
1282 $line = wait_for_input($monitor_fp, 1);
1283 if (defined($line)) {
1285 # we are not guaranteed to get a full line
1286 $full_line .= $line;
1289 if ($full_line =~ /call trace:/i) {
1293 if ($full_line =~ /Kernel panic -/) {
1297 if ($line =~ /\n/) {
1301 } while (!$child_done && !$bug);
1304 my $failure_start = time;
1307 $line = wait_for_input($monitor_fp, 1);
1308 if (defined($line)) {
1312 if ($now - $failure_start >= $stop_after_failure) {
1315 } while (defined($line));
1317 doprint "Detected kernel crash!\n";
1318 # kill the child with extreme prejudice
1322 waitpid $child_pid, 0;
1325 if ($bug || $child_exit) {
1326 return 0 if $in_bisect;
1327 fail "test failed" and return 0;
1332 sub run_git_bisect {
1335 doprint "$command ... ";
1337 my $output = `$command 2>&1`;
1344 dodie "Failed to git bisect";
1347 doprint "SUCCESS\n";
1348 if ($output =~ m/^(Bisecting: .*\(roughly \d+ steps?\))\s+\[([[:xdigit:]]+)\]/) {
1349 doprint "$1 [$2]\n";
1350 } elsif ($output =~ m/^([[:xdigit:]]+) is the first bad commit/) {
1352 doprint "Found bad commit... $1\n";
1355 # we already logged it, just print it now.
1363 doprint "Reboot and sleep $bisect_sleep_time seconds\n";
1366 wait_for_monitor $bisect_sleep_time;
1370 # returns 1 on success, 0 on failure, -1 on skip
1371 sub run_bisect_test {
1372 my ($type, $buildtype) = @_;
1381 build $buildtype or $failed = 1;
1383 if ($type ne "build") {
1384 if ($failed && $bisect_skip) {
1388 dodie "Failed on build" if $failed;
1396 monitor or $failed = 1;
1398 if ($type ne "boot") {
1399 if ($failed && $bisect_skip) {
1405 dodie "Failed on boot" if $failed;
1407 do_run_test or $failed = 1;
1418 # reboot the box to a kernel we can ssh to
1419 if ($type ne "build") {
1429 my $buildtype = "oldconfig";
1431 # We should have a minconfig to use?
1432 if (defined($minconfig)) {
1433 $buildtype = "useconfig:$minconfig";
1436 my $ret = run_bisect_test $type, $buildtype;
1438 if ($bisect_manual) {
1439 $ret = answer_bisect;
1442 # Are we looking for where it worked, not failed?
1443 if ($reverse_bisect) {
1449 } elsif ($ret == 0) {
1451 } elsif ($bisect_skip) {
1452 doprint "HIT A BAD COMMIT ... SKIPPING\n";
1462 die "BISECT_GOOD[$i] not defined\n" if (!defined($opt{"BISECT_GOOD[$i]"}));
1463 die "BISECT_BAD[$i] not defined\n" if (!defined($opt{"BISECT_BAD[$i]"}));
1464 die "BISECT_TYPE[$i] not defined\n" if (!defined($opt{"BISECT_TYPE[$i]"}));
1466 my $good = $opt{"BISECT_GOOD[$i]"};
1467 my $bad = $opt{"BISECT_BAD[$i]"};
1468 my $type = $opt{"BISECT_TYPE[$i]"};
1469 my $start = $opt{"BISECT_START[$i]"};
1470 my $replay = $opt{"BISECT_REPLAY[$i]"};
1471 my $start_files = $opt{"BISECT_FILES[$i]"};
1473 if (defined($start_files)) {
1474 $start_files = " -- " . $start_files;
1479 # convert to true sha1's
1480 $good = get_sha1($good);
1481 $bad = get_sha1($bad);
1483 if (defined($opt{"BISECT_REVERSE[$i]"}) &&
1484 $opt{"BISECT_REVERSE[$i]"} == 1) {
1485 doprint "Performing a reverse bisect (bad is good, good is bad!)\n";
1486 $reverse_bisect = 1;
1488 $reverse_bisect = 0;
1491 # Can't have a test without having a test to run
1492 if ($type eq "test" && !defined($run_test)) {
1496 my $check = $opt{"BISECT_CHECK[$i]"};
1497 if (defined($check) && $check ne "0") {
1500 my $head = get_sha1("HEAD");
1502 if ($check ne "good") {
1503 doprint "TESTING BISECT BAD [$bad]\n";
1504 run_command "git checkout $bad" or
1505 die "Failed to checkout $bad";
1507 $result = run_bisect $type;
1509 if ($result ne "bad") {
1510 fail "Tested BISECT_BAD [$bad] and it succeeded" and return 0;
1514 if ($check ne "bad") {
1515 doprint "TESTING BISECT GOOD [$good]\n";
1516 run_command "git checkout $good" or
1517 die "Failed to checkout $good";
1519 $result = run_bisect $type;
1521 if ($result ne "good") {
1522 fail "Tested BISECT_GOOD [$good] and it failed" and return 0;
1526 # checkout where we started
1527 run_command "git checkout $head" or
1528 die "Failed to checkout $head";
1531 run_command "git bisect start$start_files" or
1532 dodie "could not start bisect";
1534 run_command "git bisect good $good" or
1535 dodie "could not set bisect good to $good";
1537 run_git_bisect "git bisect bad $bad" or
1538 dodie "could not set bisect bad to $bad";
1540 if (defined($replay)) {
1541 run_command "git bisect replay $replay" or
1542 dodie "failed to run replay";
1545 if (defined($start)) {
1546 run_command "git checkout $start" or
1547 dodie "failed to checkout $start";
1552 $result = run_bisect $type;
1553 $test = run_git_bisect "git bisect $result";
1556 run_command "git bisect log" or
1557 dodie "could not capture git bisect log";
1559 run_command "git bisect reset" or
1560 dodie "could not reset git bisect";
1562 doprint "Bad commit was [$bisect_bad]\n";
1575 sub process_config_ignore {
1579 or dodie "Failed to read $config";
1582 if (/^((CONFIG\S*)=.*)/) {
1583 $config_ignore{$2} = $1;
1590 sub read_current_config {
1591 my ($config_ref) = @_;
1593 %{$config_ref} = ();
1594 undef %{$config_ref};
1596 my @key = keys %{$config_ref};
1598 print "did not delete!\n";
1601 open (IN, "$output_config");
1604 if (/^(CONFIG\S+)=(.*)/) {
1605 ${$config_ref}{$1} = $2;
1611 sub get_dependencies {
1614 my $arr = $dependency{$config};
1615 if (!defined($arr)) {
1621 foreach my $dep (@{$arr}) {
1622 print "ADD DEP $dep\n";
1623 @deps = (@deps, get_dependencies $dep);
1632 open(OUT, ">$output_config") or dodie "Can not write to $output_config";
1634 foreach my $config (@configs) {
1635 print OUT "$config_set{$config}\n";
1636 my @deps = get_dependencies $config;
1637 foreach my $dep (@deps) {
1638 print OUT "$config_set{$dep}\n";
1642 foreach my $config (keys %config_ignore) {
1643 print OUT "$config_ignore{$config}\n";
1651 sub compare_configs {
1654 foreach my $item (keys %a) {
1655 if (!defined($b{$item})) {
1656 print "diff $item\n";
1664 print "diff2 $keys[0]\n";
1666 return -1 if ($#keys >= 0);
1671 sub run_config_bisect_test {
1674 return run_bisect_test $type, "oldconfig";
1677 sub process_passed {
1680 doprint "These configs had no failure: (Enabling them for further compiles)\n";
1681 # Passed! All these configs are part of a good compile.
1682 # Add them to the min options.
1683 foreach my $config (keys %configs) {
1684 if (defined($config_list{$config})) {
1685 doprint " removing $config\n";
1686 $config_ignore{$config} = $config_list{$config};
1687 delete $config_list{$config};
1690 doprint "config copied to $outputdir/config_good\n";
1691 run_command "cp -f $output_config $outputdir/config_good";
1694 sub process_failed {
1697 doprint "\n\n***************************************\n";
1698 doprint "Found bad config: $config\n";
1699 doprint "***************************************\n\n";
1702 sub run_config_bisect {
1704 my @start_list = keys %config_list;
1706 if ($#start_list < 0) {
1707 doprint "No more configs to test!!!\n";
1711 doprint "***** RUN TEST ***\n";
1712 my $type = $opt{"CONFIG_BISECT_TYPE[$iteration]"};
1716 my $count = $#start_list + 1;
1717 doprint " $count configs to test\n";
1719 my $half = int($#start_list / 2);
1722 my @tophalf = @start_list[0 .. $half];
1724 create_config @tophalf;
1725 read_current_config \%current_config;
1727 $count = $#tophalf + 1;
1728 doprint "Testing $count configs\n";
1730 # make sure we test something
1731 foreach my $config (@tophalf) {
1732 if (defined($current_config{$config})) {
1738 # try the other half
1739 doprint "Top half produced no set configs, trying bottom half\n";
1740 @tophalf = @start_list[$half + 1 .. $#start_list];
1741 create_config @tophalf;
1742 read_current_config \%current_config;
1743 foreach my $config (@tophalf) {
1744 if (defined($current_config{$config})) {
1750 doprint "Failed: Can't make new config with current configs\n";
1751 foreach my $config (@start_list) {
1752 doprint " CONFIG: $config\n";
1756 $count = $#tophalf + 1;
1757 doprint "Testing $count configs\n";
1760 $ret = run_config_bisect_test $type;
1761 if ($bisect_manual) {
1762 $ret = answer_bisect;
1765 process_passed %current_config;
1769 doprint "This config had a failure.\n";
1770 doprint "Removing these configs that were not set in this config:\n";
1771 doprint "config copied to $outputdir/config_bad\n";
1772 run_command "cp -f $output_config $outputdir/config_bad";
1774 # A config exists in this group that was bad.
1775 foreach my $config (keys %config_list) {
1776 if (!defined($current_config{$config})) {
1777 doprint " removing $config\n";
1778 delete $config_list{$config};
1782 @start_list = @tophalf;
1784 if ($#start_list == 0) {
1785 process_failed $start_list[0];
1789 # remove half the configs we are looking at and see if
1791 $half = int($#start_list / 2);
1792 } while ($#start_list > 0);
1794 # we found a single config, try it again unless we are running manually
1796 if ($bisect_manual) {
1797 process_failed $start_list[0];
1801 my @tophalf = @start_list[0 .. 0];
1803 $ret = run_config_bisect_test $type;
1805 process_passed %current_config;
1809 process_failed $start_list[0];
1816 my $start_config = $opt{"CONFIG_BISECT[$i]"};
1818 my $tmpconfig = "$tmpdir/use_config";
1820 if (defined($config_bisect_good)) {
1821 process_config_ignore $config_bisect_good;
1824 # Make the file with the bad config and the min config
1825 if (defined($minconfig)) {
1826 # read the min config for things to ignore
1827 run_command "cp $minconfig $tmpconfig" or
1828 dodie "failed to copy $minconfig to $tmpconfig";
1834 if (defined($addconfig)) {
1835 run_command "cat $addconfig >> $tmpconfig" or
1836 dodie "failed to append $addconfig";
1839 if (-f $tmpconfig) {
1840 load_force_config($tmpconfig);
1841 process_config_ignore $tmpconfig;
1844 # now process the start config
1845 run_command "cp $start_config $output_config" or
1846 dodie "failed to copy $start_config to $output_config";
1848 # read directly what we want to check
1850 open (IN, $output_config)
1851 or dodie "faied to open $output_config";
1854 if (/^((CONFIG\S*)=.*)/) {
1855 $config_check{$2} = $1;
1860 # Now run oldconfig with the minconfig (and addconfigs)
1863 # check to see what we lost (or gained)
1864 open (IN, $output_config)
1865 or dodie "Failed to read $start_config";
1867 my %removed_configs;
1871 if (/^((CONFIG\S*)=.*)/) {
1872 # save off all options
1873 $config_set{$2} = $1;
1874 if (defined($config_check{$2})) {
1875 if (defined($config_ignore{$2})) {
1876 $removed_configs{$2} = $1;
1878 $config_list{$2} = $1;
1880 } elsif (!defined($config_ignore{$2})) {
1881 $added_configs{$2} = $1;
1882 $config_list{$2} = $1;
1888 my @confs = keys %removed_configs;
1890 doprint "Configs overridden by default configs and removed from check:\n";
1891 foreach my $config (@confs) {
1892 doprint " $config\n";
1895 @confs = keys %added_configs;
1897 doprint "Configs appearing in make oldconfig and added:\n";
1898 foreach my $config (@confs) {
1899 doprint " $config\n";
1906 # Sometimes kconfig does weird things. We must make sure
1907 # that the config we autocreate has everything we need
1908 # to test, otherwise we may miss testing configs, or
1909 # may not be able to create a new config.
1910 # Here we create a config with everything set.
1911 create_config (keys %config_list);
1912 read_current_config \%config_test;
1913 foreach my $config (keys %config_list) {
1914 if (!defined($config_test{$config})) {
1917 doprint "Configs not produced by kconfig (will not be checked):\n";
1919 doprint " $config\n";
1920 delete $config_list{$config};
1925 $ret = run_config_bisect;
1928 return $ret if ($ret < 0);
1933 sub patchcheck_reboot {
1934 doprint "Reboot and sleep $patchcheck_sleep_time seconds\n";
1937 wait_for_monitor $patchcheck_sleep_time;
1944 die "PATCHCHECK_START[$i] not defined\n"
1945 if (!defined($opt{"PATCHCHECK_START[$i]"}));
1946 die "PATCHCHECK_TYPE[$i] not defined\n"
1947 if (!defined($opt{"PATCHCHECK_TYPE[$i]"}));
1949 my $start = $opt{"PATCHCHECK_START[$i]"};
1952 if (defined($opt{"PATCHCHECK_END[$i]"})) {
1953 $end = $opt{"PATCHCHECK_END[$i]"};
1956 # Get the true sha1's since we can use things like HEAD~3
1957 $start = get_sha1($start);
1958 $end = get_sha1($end);
1960 my $type = $opt{"PATCHCHECK_TYPE[$i]"};
1962 # Can't have a test without having a test to run
1963 if ($type eq "test" && !defined($run_test)) {
1967 open (IN, "git log --pretty=oneline $end|") or
1968 dodie "could not get git list";
1974 $list[$#list+1] = $_;
1975 last if (/^$start/);
1979 if ($list[$#list] !~ /^$start/) {
1980 fail "SHA1 $start not found";
1983 # go backwards in the list
1984 @list = reverse @list;
1986 my $save_clean = $noclean;
1989 foreach my $item (@list) {
1991 $sha1 =~ s/^([[:xdigit:]]+).*/$1/;
1993 doprint "\nProcessing commit $item\n\n";
1995 run_command "git checkout $sha1" or
1996 die "Failed to checkout $sha1";
1998 # only clean on the first and last patch
1999 if ($item eq $list[0] ||
2000 $item eq $list[$#list]) {
2001 $noclean = $save_clean;
2006 if (defined($minconfig)) {
2007 build "useconfig:$minconfig" or return 0;
2009 # ?? no config to use?
2010 build "oldconfig" or return 0;
2013 check_buildlog $sha1 or return 0;
2015 next if ($type eq "build");
2024 monitor or $failed = 1;
2026 if (!$failed && $type ne "boot"){
2027 do_run_test or $failed = 1;
2030 return 0 if ($failed);
2041 $#ARGV < 1 or die "ktest.pl version: $VERSION\n usage: ktest.pl config-file\n";
2044 $ktest_config = $ARGV[0];
2045 if (! -f $ktest_config) {
2046 print "$ktest_config does not exist.\n";
2049 print "Create it? [Y/n] ";
2052 if ($ans =~ /^\s*$/) {
2055 last if ($ans =~ /^y$/i || $ans =~ /^n$/i);
2056 print "Please answer either 'y' or 'n'.\n";
2058 if ($ans !~ /^y$/i) {
2063 $ktest_config = "ktest.conf";
2066 if (! -f $ktest_config) {
2067 open(OUT, ">$ktest_config") or die "Can not create $ktest_config";
2069 # Generated by ktest.pl
2071 # Define each test with TEST_START
2072 # The config options below it will override the defaults
2080 read_config $ktest_config;
2082 # Append any configs entered in manually to the config file.
2083 my @new_configs = keys %entered_configs;
2084 if ($#new_configs >= 0) {
2085 print "\nAppending entered in configs to $ktest_config\n";
2086 open(OUT, ">>$ktest_config") or die "Can not append to $ktest_config";
2087 foreach my $config (@new_configs) {
2088 print OUT "$config = $entered_configs{$config}\n";
2089 $opt{$config} = $entered_configs{$config};
2093 if ($opt{"CLEAR_LOG"} && defined($opt{"LOG_FILE"})) {
2094 unlink $opt{"LOG_FILE"};
2097 doprint "\n\nSTARTING AUTOMATED TESTS\n\n";
2099 for (my $i = 0, my $repeat = 1; $i <= $opt{"NUM_TESTS"}; $i += $repeat) {
2102 doprint "DEFAULT OPTIONS:\n";
2104 doprint "\nTEST $i OPTIONS";
2105 if (defined($repeat_tests{$i})) {
2106 $repeat = $repeat_tests{$i};
2107 doprint " ITERATE $repeat";
2112 foreach my $option (sort keys %opt) {
2114 if ($option =~ /\[(\d+)\]$/) {
2120 doprint "$option = $opt{$option}\n";
2124 sub __set_test_option {
2125 my ($name, $i) = @_;
2127 my $option = "$name\[$i\]";
2129 if (defined($opt{$option})) {
2130 return $opt{$option};
2133 foreach my $test (keys %repeat_tests) {
2135 $i < $test + $repeat_tests{$test}) {
2136 $option = "$name\[$test\]";
2137 if (defined($opt{$option})) {
2138 return $opt{$option};
2143 if (defined($opt{$name})) {
2151 my ($option, $i) = @_;
2153 # Add space to evaluate the character before $
2154 $option = " $option";
2157 while ($option =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) {
2162 # Append beginning of line
2163 $retval = "$retval$start";
2165 # If the iteration option OPT[$i] exists, then use that.
2166 # otherwise see if the default OPT (without [$i]) exists.
2168 my $o = "$var\[$i\]";
2170 if (defined($opt{$o})) {
2172 $retval = "$retval$o";
2173 } elsif (defined($opt{$var})) {
2175 $retval = "$retval$o";
2177 $retval = "$retval\$\{$var\}";
2183 $retval = "$retval$option";
2190 sub set_test_option {
2191 my ($name, $i) = @_;
2193 my $option = __set_test_option($name, $i);
2194 return $option if (!defined($option));
2198 # Since an option can evaluate to another option,
2199 # keep iterating until we do not evaluate any more
2202 while ($prev ne $option) {
2203 # Check for recursive evaluations.
2204 # 100 deep should be more than enough.
2206 die "Over 100 evaluations accurred with $name\n" .
2207 "Check for recursive variables\n";
2210 $option = eval_option($option, $i);
2216 # First we need to do is the builds
2217 for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
2221 my $makecmd = set_test_option("MAKE_CMD", $i);
2223 $machine = set_test_option("MACHINE", $i);
2224 $ssh_user = set_test_option("SSH_USER", $i);
2225 $tmpdir = set_test_option("TMP_DIR", $i);
2226 $outputdir = set_test_option("OUTPUT_DIR", $i);
2227 $builddir = set_test_option("BUILD_DIR", $i);
2228 $test_type = set_test_option("TEST_TYPE", $i);
2229 $build_type = set_test_option("BUILD_TYPE", $i);
2230 $build_options = set_test_option("BUILD_OPTIONS", $i);
2231 $power_cycle = set_test_option("POWER_CYCLE", $i);
2232 $reboot = set_test_option("REBOOT", $i);
2233 $noclean = set_test_option("BUILD_NOCLEAN", $i);
2234 $minconfig = set_test_option("MIN_CONFIG", $i);
2235 $run_test = set_test_option("TEST", $i);
2236 $addconfig = set_test_option("ADD_CONFIG", $i);
2237 $reboot_type = set_test_option("REBOOT_TYPE", $i);
2238 $grub_menu = set_test_option("GRUB_MENU", $i);
2239 $post_install = set_test_option("POST_INSTALL", $i);
2240 $reboot_script = set_test_option("REBOOT_SCRIPT", $i);
2241 $reboot_on_error = set_test_option("REBOOT_ON_ERROR", $i);
2242 $poweroff_on_error = set_test_option("POWEROFF_ON_ERROR", $i);
2243 $die_on_failure = set_test_option("DIE_ON_FAILURE", $i);
2244 $power_off = set_test_option("POWER_OFF", $i);
2245 $powercycle_after_reboot = set_test_option("POWERCYCLE_AFTER_REBOOT", $i);
2246 $poweroff_after_halt = set_test_option("POWEROFF_AFTER_HALT", $i);
2247 $sleep_time = set_test_option("SLEEP_TIME", $i);
2248 $bisect_sleep_time = set_test_option("BISECT_SLEEP_TIME", $i);
2249 $patchcheck_sleep_time = set_test_option("PATCHCHECK_SLEEP_TIME", $i);
2250 $bisect_manual = set_test_option("BISECT_MANUAL", $i);
2251 $bisect_skip = set_test_option("BISECT_SKIP", $i);
2252 $config_bisect_good = set_test_option("CONFIG_BISECT_GOOD", $i);
2253 $store_failures = set_test_option("STORE_FAILURES", $i);
2254 $test_name = set_test_option("TEST_NAME", $i);
2255 $timeout = set_test_option("TIMEOUT", $i);
2256 $booted_timeout = set_test_option("BOOTED_TIMEOUT", $i);
2257 $console = set_test_option("CONSOLE", $i);
2258 $detect_triplefault = set_test_option("DETECT_TRIPLE_FAULT", $i);
2259 $success_line = set_test_option("SUCCESS_LINE", $i);
2260 $stop_after_success = set_test_option("STOP_AFTER_SUCCESS", $i);
2261 $stop_after_failure = set_test_option("STOP_AFTER_FAILURE", $i);
2262 $stop_test_after = set_test_option("STOP_TEST_AFTER", $i);
2263 $build_target = set_test_option("BUILD_TARGET", $i);
2264 $ssh_exec = set_test_option("SSH_EXEC", $i);
2265 $scp_to_target = set_test_option("SCP_TO_TARGET", $i);
2266 $target_image = set_test_option("TARGET_IMAGE", $i);
2267 $localversion = set_test_option("LOCALVERSION", $i);
2269 chdir $builddir || die "can't change directory to $builddir";
2273 die "can't create $tmpdir";
2276 $ENV{"SSH_USER"} = $ssh_user;
2277 $ENV{"MACHINE"} = $machine;
2279 $target = "$ssh_user\@$machine";
2281 $buildlog = "$tmpdir/buildlog-$machine";
2282 $dmesg = "$tmpdir/dmesg-$machine";
2283 $make = "$makecmd O=$outputdir";
2284 $output_config = "$outputdir/.config";
2286 if ($reboot_type eq "grub") {
2287 dodie "GRUB_MENU not defined" if (!defined($grub_menu));
2288 } elsif (!defined($reboot_script)) {
2289 dodie "REBOOT_SCRIPT not defined"
2292 my $run_type = $build_type;
2293 if ($test_type eq "patchcheck") {
2294 $run_type = $opt{"PATCHCHECK_TYPE[$i]"};
2295 } elsif ($test_type eq "bisect") {
2296 $run_type = $opt{"BISECT_TYPE[$i]"};
2297 } elsif ($test_type eq "config_bisect") {
2298 $run_type = $opt{"CONFIG_BISECT_TYPE[$i]"};
2301 # mistake in config file?
2302 if (!defined($run_type)) {
2303 $run_type = "ERROR";
2307 doprint "RUNNING TEST $i of $opt{NUM_TESTS} with option $test_type $run_type\n\n";
2312 if (!defined($minconfig)) {
2313 $minconfig = $addconfig;
2315 } elsif (defined($addconfig)) {
2316 run_command "cat $addconfig $minconfig > $tmpdir/add_config" or
2317 dodie "Failed to create temp config";
2318 $minconfig = "$tmpdir/add_config";
2321 my $checkout = $opt{"CHECKOUT[$i]"};
2322 if (defined($checkout)) {
2323 run_command "git checkout $checkout" or
2324 die "failed to checkout $checkout";
2327 if ($test_type eq "bisect") {
2330 } elsif ($test_type eq "config_bisect") {
2333 } elsif ($test_type eq "patchcheck") {
2338 if ($build_type ne "nobuild") {
2339 build $build_type or next;
2342 if ($test_type ne "build") {
2349 monitor or $failed = 1;;
2351 if (!$failed && $test_type ne "boot" && defined($run_test)) {
2352 do_run_test or $failed = 1;
2361 if ($opt{"POWEROFF_ON_SUCCESS"}) {
2363 } elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot) {
2367 doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n";