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);
25 "TEST_TYPE" => "build",
26 "BUILD_TYPE" => "randconfig",
29 "TMP_DIR" => "/tmp/ktest/\${MACHINE}",
30 "SLEEP_TIME" => 60, # sleep time between tests
32 "REBOOT_ON_ERROR" => 0,
33 "POWEROFF_ON_ERROR" => 0,
34 "REBOOT_ON_SUCCESS" => 1,
35 "POWEROFF_ON_SUCCESS" => 0,
36 "BUILD_OPTIONS" => "",
37 "BISECT_SLEEP_TIME" => 60, # sleep time between bisects
38 "PATCHCHECK_SLEEP_TIME" => 60, # sleep time between patch checks
42 "SUCCESS_LINE" => "login:",
43 "DETECT_TRIPLE_FAULT" => 1,
45 "BOOTED_TIMEOUT" => 1,
46 "DIE_ON_FAILURE" => 1,
47 "SSH_EXEC" => "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND",
48 "SCP_TO_TARGET" => "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE",
49 "SCP_TO_TARGET_INSTALL" => "\${SCP_TO_TARGET}",
50 "REBOOT" => "ssh \$SSH_USER\@\$MACHINE reboot",
51 "STOP_AFTER_SUCCESS" => 10,
52 "STOP_AFTER_FAILURE" => 60,
53 "STOP_TEST_AFTER" => 600,
55 # required, and we will ask users if they don't have them but we keep the default
56 # value something that is common.
57 "REBOOT_TYPE" => "grub",
58 "LOCALVERSION" => "-test",
60 "BUILD_TARGET" => "arch/x86/boot/bzImage",
61 "TARGET_IMAGE" => "/boot/vmlinuz-test",
89 my $poweroff_on_error;
90 my $reboot_on_success;
92 my $powercycle_after_reboot;
93 my $poweroff_after_halt;
96 my $scp_to_target_install;
107 my $start_minconfig_defined;
108 my $output_minconfig;
113 my $bisect_bad_commit = "";
117 my $config_bisect_good;
121 my $bisect_ret_abort;
122 my $bisect_ret_default;
123 my $in_patchcheck = 0;
133 my $bisect_sleep_time;
134 my $patchcheck_sleep_time;
141 my $detect_triplefault;
143 my $reboot_success_line;
145 my $stop_after_success;
146 my $stop_after_failure;
165 my $config_bisect_type;
168 my $patchcheck_start;
171 # set when a test is something other that just building or install
172 # which would require more options.
175 # set when creating a new config
183 # do not force reboots on config problems
187 my $reboot_success = 0;
190 "MACHINE" => \$machine,
191 "SSH_USER" => \$ssh_user,
192 "TMP_DIR" => \$tmpdir,
193 "OUTPUT_DIR" => \$outputdir,
194 "BUILD_DIR" => \$builddir,
195 "TEST_TYPE" => \$test_type,
196 "BUILD_TYPE" => \$build_type,
197 "BUILD_OPTIONS" => \$build_options,
198 "PRE_BUILD" => \$pre_build,
199 "POST_BUILD" => \$post_build,
200 "PRE_BUILD_DIE" => \$pre_build_die,
201 "POST_BUILD_DIE" => \$post_build_die,
202 "POWER_CYCLE" => \$power_cycle,
203 "REBOOT" => \$reboot,
204 "BUILD_NOCLEAN" => \$noclean,
205 "MIN_CONFIG" => \$minconfig,
206 "OUTPUT_MIN_CONFIG" => \$output_minconfig,
207 "START_MIN_CONFIG" => \$start_minconfig,
208 "IGNORE_CONFIG" => \$ignore_config,
209 "TEST" => \$run_test,
210 "ADD_CONFIG" => \$addconfig,
211 "REBOOT_TYPE" => \$reboot_type,
212 "GRUB_MENU" => \$grub_menu,
213 "POST_INSTALL" => \$post_install,
214 "NO_INSTALL" => \$no_install,
215 "REBOOT_SCRIPT" => \$reboot_script,
216 "REBOOT_ON_ERROR" => \$reboot_on_error,
217 "SWITCH_TO_GOOD" => \$switch_to_good,
218 "SWITCH_TO_TEST" => \$switch_to_test,
219 "POWEROFF_ON_ERROR" => \$poweroff_on_error,
220 "REBOOT_ON_SUCCESS" => \$reboot_on_success,
221 "DIE_ON_FAILURE" => \$die_on_failure,
222 "POWER_OFF" => \$power_off,
223 "POWERCYCLE_AFTER_REBOOT" => \$powercycle_after_reboot,
224 "POWEROFF_AFTER_HALT" => \$poweroff_after_halt,
225 "SLEEP_TIME" => \$sleep_time,
226 "BISECT_SLEEP_TIME" => \$bisect_sleep_time,
227 "PATCHCHECK_SLEEP_TIME" => \$patchcheck_sleep_time,
228 "IGNORE_WARNINGS" => \$ignore_warnings,
229 "IGNORE_ERRORS" => \$ignore_errors,
230 "BISECT_MANUAL" => \$bisect_manual,
231 "BISECT_SKIP" => \$bisect_skip,
232 "CONFIG_BISECT_GOOD" => \$config_bisect_good,
233 "BISECT_RET_GOOD" => \$bisect_ret_good,
234 "BISECT_RET_BAD" => \$bisect_ret_bad,
235 "BISECT_RET_SKIP" => \$bisect_ret_skip,
236 "BISECT_RET_ABORT" => \$bisect_ret_abort,
237 "BISECT_RET_DEFAULT" => \$bisect_ret_default,
238 "STORE_FAILURES" => \$store_failures,
239 "STORE_SUCCESSES" => \$store_successes,
240 "TEST_NAME" => \$test_name,
241 "TIMEOUT" => \$timeout,
242 "BOOTED_TIMEOUT" => \$booted_timeout,
243 "CONSOLE" => \$console,
244 "DETECT_TRIPLE_FAULT" => \$detect_triplefault,
245 "SUCCESS_LINE" => \$success_line,
246 "REBOOT_SUCCESS_LINE" => \$reboot_success_line,
247 "STOP_AFTER_SUCCESS" => \$stop_after_success,
248 "STOP_AFTER_FAILURE" => \$stop_after_failure,
249 "STOP_TEST_AFTER" => \$stop_test_after,
250 "BUILD_TARGET" => \$build_target,
251 "SSH_EXEC" => \$ssh_exec,
252 "SCP_TO_TARGET" => \$scp_to_target,
253 "SCP_TO_TARGET_INSTALL" => \$scp_to_target_install,
254 "CHECKOUT" => \$checkout,
255 "TARGET_IMAGE" => \$target_image,
256 "LOCALVERSION" => \$localversion,
258 "BISECT_GOOD" => \$bisect_good,
259 "BISECT_BAD" => \$bisect_bad,
260 "BISECT_TYPE" => \$bisect_type,
261 "BISECT_START" => \$bisect_start,
262 "BISECT_REPLAY" => \$bisect_replay,
263 "BISECT_FILES" => \$bisect_files,
264 "BISECT_REVERSE" => \$bisect_reverse,
265 "BISECT_CHECK" => \$bisect_check,
267 "CONFIG_BISECT" => \$config_bisect,
268 "CONFIG_BISECT_TYPE" => \$config_bisect_type,
270 "PATCHCHECK_TYPE" => \$patchcheck_type,
271 "PATCHCHECK_START" => \$patchcheck_start,
272 "PATCHCHECK_END" => \$patchcheck_end,
275 # Options may be used by other options, record them.
278 # default variables that can be used
279 chomp ($variable{"PWD"} = `pwd`);
281 $config_help{"MACHINE"} = << "EOF"
282 The machine hostname that you will test.
283 For build only tests, it is still needed to differentiate log files.
286 $config_help{"SSH_USER"} = << "EOF"
287 The box is expected to have ssh on normal bootup, provide the user
288 (most likely root, since you need privileged operations)
291 $config_help{"BUILD_DIR"} = << "EOF"
292 The directory that contains the Linux source code (full path).
293 You can use \${PWD} that will be the path where ktest.pl is run, or use
294 \${THIS_DIR} which is assigned \${PWD} but may be changed later.
297 $config_help{"OUTPUT_DIR"} = << "EOF"
298 The directory that the objects will be built (full path).
299 (can not be same as BUILD_DIR)
300 You can use \${PWD} that will be the path where ktest.pl is run, or use
301 \${THIS_DIR} which is assigned \${PWD} but may be changed later.
304 $config_help{"BUILD_TARGET"} = << "EOF"
305 The location of the compiled file to copy to the target.
306 (relative to OUTPUT_DIR)
309 $config_help{"BUILD_OPTIONS"} = << "EOF"
310 Options to add to \"make\" when building.
314 $config_help{"TARGET_IMAGE"} = << "EOF"
315 The place to put your image on the test machine.
318 $config_help{"POWER_CYCLE"} = << "EOF"
319 A script or command to reboot the box.
321 Here is a digital loggers power switch example
322 POWER_CYCLE = wget --no-proxy -O /dev/null -q --auth-no-challenge 'http://admin:admin\@power/outlet?5=CCL'
324 Here is an example to reboot a virtual box on the current host
325 with the name "Guest".
326 POWER_CYCLE = virsh destroy Guest; sleep 5; virsh start Guest
329 $config_help{"CONSOLE"} = << "EOF"
330 The script or command that reads the console
332 If you use ttywatch server, something like the following would work.
333 CONSOLE = nc -d localhost 3001
335 For a virtual machine with guest name "Guest".
336 CONSOLE = virsh console Guest
339 $config_help{"LOCALVERSION"} = << "EOF"
340 Required version ending to differentiate the test
341 from other linux builds on the system.
344 $config_help{"REBOOT_TYPE"} = << "EOF"
345 Way to reboot the box to the test kernel.
346 Only valid options so far are "grub" and "script".
348 If you specify grub, it will assume grub version 1
349 and will search in /boot/grub/menu.lst for the title \$GRUB_MENU
350 and select that target to reboot to the kernel. If this is not
351 your setup, then specify "script" and have a command or script
352 specified in REBOOT_SCRIPT to boot to the target.
354 The entry in /boot/grub/menu.lst must be entered in manually.
355 The test will not modify that file.
358 $config_help{"GRUB_MENU"} = << "EOF"
359 The grub title name for the test kernel to boot
360 (Only mandatory if REBOOT_TYPE = grub)
362 Note, ktest.pl will not update the grub menu.lst, you need to
363 manually add an option for the test. ktest.pl will search
364 the grub menu.lst for this option to find what kernel to
367 For example, if in the /boot/grub/menu.lst the test kernel title has:
370 GRUB_MENU = Test Kernel
373 $config_help{"REBOOT_SCRIPT"} = << "EOF"
374 A script to reboot the target into the test kernel
375 (Only mandatory if REBOOT_TYPE = script)
380 my ($cancel, $prompt) = @_;
386 print "$prompt [y/n/C] ";
388 print "$prompt [Y/n] ";
392 if ($ans =~ /^\s*$/) {
399 last if ($ans =~ /^y$/i || $ans =~ /^n$/i);
401 last if ($ans =~ /^c$/i);
402 print "Please answer either 'y', 'n' or 'c'.\n";
404 print "Please answer either 'y' or 'n'.\n";
410 if ($ans !~ /^y$/i) {
419 return read_prompt 0, $prompt;
425 return read_prompt 1, $prompt;
428 sub get_ktest_config {
432 return if (defined($opt{$config}));
434 if (defined($config_help{$config})) {
436 print $config_help{$config};
441 if (defined($default{$config}) && length($default{$config})) {
442 print "\[$default{$config}\] ";
445 $ans =~ s/^\s*(.*\S)\s*$/$1/;
446 if ($ans =~ /^\s*$/) {
447 if ($default{$config}) {
448 $ans = $default{$config};
450 print "Your answer can not be blank\n";
454 $entered_configs{$config} = ${ans};
459 sub get_ktest_configs {
460 get_ktest_config("MACHINE");
461 get_ktest_config("BUILD_DIR");
462 get_ktest_config("OUTPUT_DIR");
465 get_ktest_config("BUILD_OPTIONS");
468 # options required for other than just building a kernel
470 get_ktest_config("POWER_CYCLE");
471 get_ktest_config("CONSOLE");
474 # options required for install and more
475 if ($buildonly != 1) {
476 get_ktest_config("SSH_USER");
477 get_ktest_config("BUILD_TARGET");
478 get_ktest_config("TARGET_IMAGE");
481 get_ktest_config("LOCALVERSION");
483 return if ($buildonly);
485 my $rtype = $opt{"REBOOT_TYPE"};
487 if (!defined($rtype)) {
488 if (!defined($opt{"GRUB_MENU"})) {
489 get_ktest_config("REBOOT_TYPE");
490 $rtype = $entered_configs{"REBOOT_TYPE"};
496 if ($rtype eq "grub") {
497 get_ktest_config("GRUB_MENU");
501 sub process_variables {
502 my ($value, $remove_undef) = @_;
505 # We want to check for '\', and it is just easier
506 # to check the previous characet of '$' and not need
507 # to worry if '$' is the first character. By adding
508 # a space to $value, we can just check [^\\]\$ and
509 # it will still work.
512 while ($value =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) {
516 # append beginning of value to retval
517 $retval = "$retval$begin";
518 if (defined($variable{$var})) {
519 $retval = "$retval$variable{$var}";
520 } elsif (defined($remove_undef) && $remove_undef) {
521 # for if statements, any variable that is not defined,
522 # we simple convert to 0
523 $retval = "${retval}0";
525 # put back the origin piece.
526 $retval = "$retval\$\{$var\}";
527 # This could be an option that is used later, save
528 # it so we don't warn if this option is not one of
530 $used_options{$var} = 1;
534 $retval = "$retval$value";
536 # remove the space added in the beginning
543 my ($lvalue, $rvalue, $override, $overrides, $name) = @_;
545 my $prvalue = process_variables($rvalue);
547 if ($buildonly && $lvalue =~ /^TEST_TYPE(\[.*\])?$/ && $prvalue ne "build") {
548 # Note if a test is something other than build, then we
549 # will need other manditory options.
550 if ($prvalue ne "install") {
553 # install still limits some manditory options.
558 if (defined($opt{$lvalue})) {
559 if (!$override || defined(${$overrides}{$lvalue})) {
562 $extra = "In the same override section!\n";
564 die "$name: $.: Option $lvalue defined more than once!\n$extra";
566 ${$overrides}{$lvalue} = $prvalue;
568 if ($rvalue =~ /^\s*$/) {
569 delete $opt{$lvalue};
571 $opt{$lvalue} = $prvalue;
576 my ($lvalue, $rvalue) = @_;
578 if ($rvalue =~ /^\s*$/) {
579 delete $variable{$lvalue};
581 $rvalue = process_variables($rvalue);
582 $variable{$lvalue} = $rvalue;
586 sub process_compare {
587 my ($lval, $cmp, $rval) = @_;
598 return $lval eq $rval;
599 } elsif ($cmp eq "!=") {
600 return $lval ne $rval;
603 my $statement = "$lval $cmp $rval";
604 my $ret = eval $statement;
606 # $@ stores error of eval
617 return defined($variable{$2}) ||
622 sub process_expression {
623 my ($name, $val) = @_;
627 while ($val =~ s/\(([^\(]*?)\)/\&\&\&\&VAL\&\&\&\&/) {
630 if (process_expression($name, $express)) {
631 $val =~ s/\&\&\&\&VAL\&\&\&\&/ 1 /;
633 $val =~ s/\&\&\&\&VAL\&\&\&\&/ 0 /;
641 while ($val =~ s/^(.*?)($OR|$AND)//) {
645 if (process_expression($name, $express)) {
656 if ($val =~ /(.*)(==|\!=|>=|<=|>|<)(.*)/) {
657 my $ret = process_compare($1, $2, $3);
659 die "$name: $.: Unable to process comparison\n";
664 if ($val =~ /^\s*(NOT\s*)?DEFINED\s+(\S+)\s*$/) {
666 return !value_defined($2);
668 return value_defined($2);
672 if ($val =~ /^\s*0\s*$/) {
674 } elsif ($val =~ /^\s*\d+\s*$/) {
678 die ("$name: $.: Undefined content $val in if statement\n");
682 my ($name, $value) = @_;
684 # Convert variables and replace undefined ones with 0
685 my $val = process_variables($value, 1);
686 my $ret = process_expression $name, $val;
692 my ($config, $current_test_num) = @_;
695 open($in, $config) || die "can't read file $config";
698 $name =~ s,.*/(.*),$1,;
700 my $test_num = $$current_test_num;
703 my $num_tests_set = 0;
716 # ignore blank lines and comments
717 next if (/^\s*$/ || /\s*\#/);
719 if (/^\s*(TEST_START|DEFAULTS)\b(.*)/) {
729 if ($type eq "TEST_START") {
731 if ($num_tests_set) {
732 die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n";
735 $old_test_num = $test_num;
736 $old_repeat = $repeat;
738 $test_num += $repeat;
745 # If SKIP is anywhere in the line, the command will be skipped
746 if ($rest =~ s/\s+SKIP\b//) {
753 if ($rest =~ s/\sELSE\b//) {
755 die "$name: $.: ELSE found with out matching IF section\n$_";
766 if ($rest =~ s/\sIF\s+(.*)//) {
767 if (process_if($name, $1)) {
779 if ($type eq "TEST_START") {
780 if ($rest =~ s/\s+ITERATE\s+(\d+)//) {
782 $repeat_tests{"$test_num"} = $repeat;
784 } elsif ($rest =~ s/\sOVERRIDE\b//) {
787 # Clear previous overrides
792 if (!$skip && $rest !~ /^\s*$/) {
793 die "$name: $.: Gargbage found after $type\n$_";
796 if ($skip && $type eq "TEST_START") {
797 $test_num = $old_test_num;
798 $repeat = $old_repeat;
801 } elsif (/^\s*ELSE\b(.*)$/) {
803 die "$name: $.: ELSE found with out matching IF section\n$_";
812 if ($rest =~ /\sIF\s+(.*)/) {
813 # May be a ELSE IF section.
814 if (!process_if($name, $1)) {
823 if ($rest !~ /^\s*$/) {
824 die "$name: $.: Gargbage found after DEFAULTS\n$_";
827 } elsif (/^\s*INCLUDE\s+(\S+)/) {
832 die "$name: $.: INCLUDE can only be done in default sections\n$_";
835 my $file = process_variables($1);
837 if ($file !~ m,^/,) {
838 # check the path of the config file first
839 if ($config =~ m,(.*)/,) {
847 die "$name: $.: Can't read file $file\n$_";
850 if (__read_config($file, \$test_num)) {
854 } elsif (/^\s*([A-Z_\[\]\d]+)\s*=\s*(.*?)\s*$/) {
862 ($lvalue eq "NUM_TESTS" ||
863 $lvalue eq "LOG_FILE" ||
864 $lvalue eq "CLEAR_LOG")) {
865 die "$name: $.: $lvalue must be set in DEFAULTS section\n";
868 if ($lvalue eq "NUM_TESTS") {
870 die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n";
873 die "$name: $.: NUM_TESTS must be set in default section\n";
878 if ($default || $lvalue =~ /\[\d+\]$/) {
879 set_value($lvalue, $rvalue, $override, \%overrides, $name);
881 my $val = "$lvalue\[$test_num\]";
882 set_value($val, $rvalue, $override, \%overrides, $name);
885 $repeats{$val} = $repeat;
888 } elsif (/^\s*([A-Z_\[\]\d]+)\s*:=\s*(.*?)\s*$/) {
894 # process config variables.
895 # Config variables are only active while reading the
896 # config and can be defined anywhere. They also ignore
897 # TEST_START and DEFAULTS, but are skipped if they are in
898 # on of these sections that have SKIP defined.
899 # The save variable can be
900 # defined multiple times and the new one simply overrides
902 set_variable($lvalue, $rvalue);
905 die "$name: $.: Garbage found in config\n$_";
910 $test_num += $repeat - 1;
911 $opt{"NUM_TESTS"} = $test_num;
916 $$current_test_num = $test_num;
922 print "What test case would you like to run?\n";
923 print " (build, install or boot)\n";
924 print " Other tests are available but require editing the config file\n";
927 $default{"TEST_TYPE"} = $ans;
936 $test_case = __read_config $config, \$test_num;
938 # make sure we have all mandatory configs
941 # was a test specified?
943 print "No test case specified.\n";
949 foreach my $default (keys %default) {
950 if (!defined($opt{$default})) {
951 $opt{$default} = $default{$default};
955 if ($opt{"IGNORE_UNUSED"} == 1) {
961 # check if there are any stragglers (typos?)
962 foreach my $option (keys %opt) {
964 # remove per test labels.
966 if (!exists($option_map{$op}) &&
967 !exists($default{$op}) &&
968 !exists($used_options{$op})) {
975 $s = " is" if (keys %not_used == 1);
976 print "The following option$s not used; could be a typo:\n";
977 foreach my $option (keys %not_used) {
980 print "Set IGRNORE_UNUSED = 1 to have ktest ignore unused variables\n";
981 if (!read_yn "Do you want to continue?") {
988 my ($option, $i) = @_;
990 # Add space to evaluate the character before $
991 $option = " $option";
996 foreach my $test (keys %repeat_tests) {
998 $i < $test + $repeat_tests{$test}) {
1006 while ($option =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) {
1011 # Append beginning of line
1012 $retval = "$retval$start";
1014 # If the iteration option OPT[$i] exists, then use that.
1015 # otherwise see if the default OPT (without [$i]) exists.
1017 my $o = "$var\[$i\]";
1018 my $parento = "$var\[$parent\]";
1020 if (defined($opt{$o})) {
1022 $retval = "$retval$o";
1023 } elsif ($repeated && defined($opt{$parento})) {
1024 $o = $opt{$parento};
1025 $retval = "$retval$o";
1026 } elsif (defined($opt{$var})) {
1028 $retval = "$retval$o";
1030 $retval = "$retval\$\{$var\}";
1036 $retval = "$retval$option";
1044 my ($option, $i) = @_;
1048 # Since an option can evaluate to another option,
1049 # keep iterating until we do not evaluate any more
1052 while ($prev ne $option) {
1053 # Check for recursive evaluations.
1054 # 100 deep should be more than enough.
1056 die "Over 100 evaluations accurred with $option\n" .
1057 "Check for recursive variables\n";
1060 $option = __eval_option($option, $i);
1067 if (defined($opt{"LOG_FILE"})) {
1068 open(OUT, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}";
1075 if (defined($opt{"LOG_FILE"})) {
1090 sub wait_for_monitor;
1095 if (defined($time)) {
1097 # flush out current monitor
1098 # May contain the reboot success line
1102 # try to reboot normally
1103 if (run_command $reboot) {
1104 if (defined($powercycle_after_reboot)) {
1105 sleep $powercycle_after_reboot;
1106 run_command "$power_cycle";
1109 # nope? power cycle it.
1110 run_command "$power_cycle";
1113 if (defined($time)) {
1114 wait_for_monitor($time, $reboot_success_line);
1119 sub reboot_to_good {
1122 if (defined($switch_to_good)) {
1123 run_command $switch_to_good;
1132 return $test_type eq "build" || $no_reboot ||
1133 ($test_type eq "patchcheck" && $opt{"PATCHCHECK_TYPE[$i]"} eq "build") ||
1134 ($test_type eq "bisect" && $opt{"BISECT_TYPE[$i]"} eq "build");
1138 doprint "CRITICAL FAILURE... ", @_, "\n";
1142 if ($reboot_on_error && !do_not_reboot) {
1144 doprint "REBOOTING\n";
1147 } elsif ($poweroff_on_error && defined($power_off)) {
1148 doprint "POWERING OFF\n";
1152 if (defined($opt{"LOG_FILE"})) {
1153 print " See $opt{LOG_FILE} for more info.\n";
1164 my $pid = open($fp, "$console|") or
1165 dodie "Can't open console $console";
1167 $flags = fcntl($fp, F_GETFL, 0) or
1168 dodie "Can't get flags for the socket: $!";
1169 $flags = fcntl($fp, F_SETFL, $flags | O_NONBLOCK) or
1170 dodie "Can't set flags for the socket: $!";
1176 my ($fp, $pid) = @_;
1178 doprint "kill child process $pid\n";
1186 if ($monitor_cnt++) {
1189 $monitor_fp = \*MONFD;
1190 $monitor_pid = open_console $monitor_fp;
1194 open(MONFD, "Stop perl from warning about single use of MONFD");
1198 if (--$monitor_cnt) {
1201 close_console($monitor_fp, $monitor_pid);
1204 sub wait_for_monitor {
1205 my ($time, $stop) = @_;
1210 doprint "** Wait for monitor to settle down **\n";
1212 # read the monitor and wait for the system to calm down
1214 $line = wait_for_input($monitor_fp, $time);
1215 last if (!defined($line));
1217 $full_line .= $line;
1219 if (defined($stop) && $full_line =~ /$stop/) {
1220 doprint "wait for monitor detected $stop\n";
1224 if ($line =~ /\n/) {
1228 print "** Monitor flushed **\n";
1232 my ($result, $basedir) = @_;
1234 my $date = sprintf "%04d%02d%02d%02d%02d%02d",
1235 1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0];
1237 my $type = $build_type;
1238 if ($type =~ /useconfig/) {
1239 $type = "useconfig";
1242 my $dir = "$machine-$test_type-$type-$result-$date";
1244 $dir = "$basedir/$dir";
1248 die "can't create $dir";
1252 "config" => $output_config,
1253 "buildlog" => $buildlog,
1255 "testlog" => $testlog,
1258 while (my ($name, $source) = each(%files)) {
1260 cp "$source", "$dir/$name" or
1261 die "failed to copy $source";
1265 doprint "*** Saved info to $dir ***\n";
1270 if ($die_on_failure) {
1278 # no need to reboot for just building.
1279 if (!do_not_reboot) {
1280 doprint "REBOOTING\n";
1281 reboot_to_good $sleep_time;
1286 if (defined($test_name)) {
1287 $name = " ($test_name)";
1290 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
1291 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
1292 doprint "KTEST RESULT: TEST $i$name Failed: ", @_, "\n";
1293 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
1294 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
1296 if (defined($store_failures)) {
1297 save_logs "fail", $store_failures;
1309 $command =~ s/\$SSH_USER/$ssh_user/g;
1310 $command =~ s/\$MACHINE/$machine/g;
1312 doprint("$command ... ");
1314 $pid = open(CMD, "$command 2>&1 |") or
1315 (fail "unable to exec $command" and return 0);
1317 if (defined($opt{"LOG_FILE"})) {
1318 open(LOG, ">>$opt{LOG_FILE}") or
1319 dodie "failed to write to log";
1323 if (defined($redirect)) {
1324 open (RD, ">$redirect") or
1325 dodie "failed to write to redirect $redirect";
1330 print LOG if ($dolog);
1331 print RD if ($dord);
1338 close(LOG) if ($dolog);
1339 close(RD) if ($dord);
1342 doprint "FAILED!\n";
1344 doprint "SUCCESS\n";
1352 my $cp_exec = $ssh_exec;
1354 $cp_exec =~ s/\$SSH_COMMAND/$cmd/g;
1355 return run_command "$cp_exec";
1359 my ($src, $dst, $cp_scp) = @_;
1361 $cp_scp =~ s/\$SRC_FILE/$src/g;
1362 $cp_scp =~ s/\$DST_FILE/$dst/g;
1364 return run_command "$cp_scp";
1367 sub run_scp_install {
1368 my ($src, $dst) = @_;
1370 my $cp_scp = $scp_to_target_install;
1372 return run_scp($src, $dst, $cp_scp);
1376 my ($src, $dst) = @_;
1378 my $cp_scp = $scp_to_target;
1380 return run_scp($src, $dst, $cp_scp);
1383 sub get_grub_index {
1385 if ($reboot_type ne "grub") {
1388 return if (defined($grub_number));
1390 doprint "Find grub menu ... ";
1393 my $ssh_grub = $ssh_exec;
1394 $ssh_grub =~ s,\$SSH_COMMAND,cat /boot/grub/menu.lst,g;
1396 open(IN, "$ssh_grub |")
1397 or die "unable to get menu.lst";
1402 if (/^\s*title\s+$grub_menu\s*$/) {
1406 } elsif (/^\s*title\s/) {
1412 die "Could not find '$grub_menu' in /boot/grub/menu on $machine"
1414 doprint "$grub_number\n";
1419 my ($fp, $time) = @_;
1425 if (!defined($time)) {
1430 vec($rin, fileno($fp), 1) = 1;
1431 $ready = select($rin, undef, undef, $time);
1435 # try to read one char at a time
1436 while (sysread $fp, $ch, 1) {
1438 last if ($ch eq "\n");
1441 if (!length($line)) {
1449 if (defined($switch_to_test)) {
1450 run_command $switch_to_test;
1453 if ($reboot_type eq "grub") {
1454 run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch)'";
1455 } elsif (defined $reboot_script) {
1456 run_command "$reboot_script";
1464 doprint "git rev-list --max-count=1 $commit ... ";
1465 my $sha1 = `git rev-list --max-count=1 $commit`;
1472 dodie "Failed to get git $commit";
1485 my $bug_ignored = 0;
1486 my $skip_call_trace = 0;
1494 open(DMESG, "> $dmesg") or
1495 die "unable to write to $dmesg";
1501 my $monitor_start = time;
1503 my $version_found = 0;
1507 if ($bug && defined($stop_after_failure) &&
1508 $stop_after_failure >= 0) {
1509 my $time = $stop_after_failure - (time - $failure_start);
1510 $line = wait_for_input($monitor_fp, $time);
1511 if (!defined($line)) {
1512 doprint "bug timed out after $booted_timeout seconds\n";
1513 doprint "Test forced to stop after $stop_after_failure seconds after failure\n";
1517 $line = wait_for_input($monitor_fp, $booted_timeout);
1518 if (!defined($line)) {
1519 my $s = $booted_timeout == 1 ? "" : "s";
1520 doprint "Successful boot found: break after $booted_timeout second$s\n";
1524 $line = wait_for_input($monitor_fp);
1525 if (!defined($line)) {
1526 my $s = $timeout == 1 ? "" : "s";
1527 doprint "Timed out after $timeout second$s\n";
1535 # we are not guaranteed to get a full line
1536 $full_line .= $line;
1538 if ($full_line =~ /$success_line/) {
1540 $success_start = time;
1543 if ($booted && defined($stop_after_success) &&
1544 $stop_after_success >= 0) {
1546 if ($now - $success_start >= $stop_after_success) {
1547 doprint "Test forced to stop after $stop_after_success seconds after success\n";
1552 if ($full_line =~ /\[ backtrace testing \]/) {
1553 $skip_call_trace = 1;
1556 if ($full_line =~ /call trace:/i) {
1557 if (!$bug && !$skip_call_trace) {
1558 if ($ignore_errors) {
1562 $failure_start = time;
1567 if ($bug && defined($stop_after_failure) &&
1568 $stop_after_failure >= 0) {
1570 if ($now - $failure_start >= $stop_after_failure) {
1571 doprint "Test forced to stop after $stop_after_failure seconds after failure\n";
1576 if ($full_line =~ /\[ end of backtrace testing \]/) {
1577 $skip_call_trace = 0;
1580 if ($full_line =~ /Kernel panic -/) {
1581 $failure_start = time;
1585 # Detect triple faults by testing the banner
1586 if ($full_line =~ /\bLinux version (\S+).*\n/) {
1587 if ($1 eq $version) {
1589 } elsif ($version_found && $detect_triplefault) {
1590 # We already booted into the kernel we are testing,
1591 # but now we booted into another kernel?
1592 # Consider this a triple fault.
1593 doprint "Aleady booted in Linux kernel $version, but now\n";
1594 doprint "we booted into Linux kernel $1.\n";
1595 doprint "Assuming that this is a triple fault.\n";
1596 doprint "To disable this: set DETECT_TRIPLE_FAULT to 0\n";
1601 if ($line =~ /\n/) {
1605 if ($stop_test_after > 0 && !$booted && !$bug) {
1606 if (time - $monitor_start > $stop_test_after) {
1607 doprint "STOP_TEST_AFTER ($stop_test_after seconds) timed out\n";
1616 return 0 if ($in_bisect);
1617 fail "failed - got a bug report" and return 0;
1621 return 0 if ($in_bisect);
1622 fail "failed - never got a boot prompt." and return 0;
1626 doprint "WARNING: Call Trace detected but ignored due to IGNORE_ERRORS=1\n";
1632 sub eval_kernel_version {
1635 $option =~ s/\$KERNEL_VERSION/$version/g;
1640 sub do_post_install {
1642 return if (!defined($post_install));
1644 my $cp_post_install = eval_kernel_version $post_install;
1645 run_command "$cp_post_install" or
1646 dodie "Failed to run post install";
1651 return if ($no_install);
1653 my $cp_target = eval_kernel_version $target_image;
1655 run_scp_install "$outputdir/$build_target", "$cp_target" or
1656 dodie "failed to copy image";
1658 my $install_mods = 0;
1660 # should we process modules?
1662 open(IN, "$output_config") or dodie("Can't read config file");
1664 if (/CONFIG_MODULES(=y)?/) {
1665 $install_mods = 1 if (defined($1));
1671 if (!$install_mods) {
1673 doprint "No modules needed\n";
1677 run_command "$make INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$tmpdir modules_install" or
1678 dodie "Failed to install modules";
1680 my $modlib = "/lib/modules/$version";
1681 my $modtar = "ktest-mods.tar.bz2";
1683 run_ssh "rm -rf $modlib" or
1684 dodie "failed to remove old mods: $modlib";
1686 # would be nice if scp -r did not follow symbolic links
1687 run_command "cd $tmpdir && tar -cjf $modtar lib/modules/$version" or
1688 dodie "making tarball";
1690 run_scp_mod "$tmpdir/$modtar", "/tmp" or
1691 dodie "failed to copy modules";
1693 unlink "$tmpdir/$modtar";
1695 run_ssh "'(cd / && tar xjf /tmp/$modtar)'" or
1696 dodie "failed to tar modules";
1698 run_ssh "rm -f /tmp/$modtar";
1704 # get the release name
1705 doprint "$make kernelrelease ... ";
1706 $version = `$make kernelrelease | tail -1`;
1708 doprint "$version\n";
1711 sub start_monitor_and_boot {
1712 # Make sure the stable kernel has finished booting
1725 sub check_buildlog {
1728 my @files = `git show $patch | diffstat -l`;
1730 open(IN, "git show $patch |") or
1731 dodie "failed to show $patch";
1733 if (m,^--- a/(.*),) {
1735 $files[$#files] = $1;
1740 open(IN, $buildlog) or dodie "Can't open $buildlog";
1742 if (/^\s*(.*?):.*(warning|error)/) {
1744 foreach my $file (@files) {
1745 my $fullpath = "$builddir/$file";
1746 if ($file eq $err || $fullpath eq $err) {
1747 fail "$file built with warnings" and return 0;
1757 sub apply_min_config {
1758 my $outconfig = "$output_config.new";
1760 # Read the config file and remove anything that
1761 # is in the force_config hash (from minconfig and others)
1762 # then add the force config back.
1764 doprint "Applying minimum configurations into $output_config.new\n";
1766 open (OUT, ">$outconfig") or
1767 dodie "Can't create $outconfig";
1769 if (-f $output_config) {
1770 open (IN, $output_config) or
1771 dodie "Failed to open $output_config";
1773 if (/^(# )?(CONFIG_[^\s=]*)/) {
1774 next if (defined($force_config{$2}));
1780 foreach my $config (keys %force_config) {
1781 print OUT "$force_config{$config}\n";
1785 run_command "mv $outconfig $output_config";
1788 sub make_oldconfig {
1790 my @force_list = keys %force_config;
1792 if ($#force_list >= 0) {
1796 if (!run_command "$make oldnoconfig") {
1797 # Perhaps oldnoconfig doesn't exist in this version of the kernel
1798 # try a yes '' | oldconfig
1799 doprint "oldnoconfig failed, trying yes '' | make oldconfig\n";
1800 run_command "yes '' | $make oldconfig" or
1801 dodie "failed make config oldconfig";
1805 # read a config file and use this to force new configs.
1806 sub load_force_config {
1809 open(IN, $config) or
1810 dodie "failed to read $config";
1813 if (/^(CONFIG[^\s=]*)(\s*=.*)/) {
1814 $force_config{$1} = $_;
1815 } elsif (/^# (CONFIG_\S*) is not set/) {
1816 $force_config{$1} = $_;
1827 # Failed builds should not reboot the target
1828 my $save_no_reboot = $no_reboot;
1831 if (defined($pre_build)) {
1832 my $ret = run_command $pre_build;
1833 if (!$ret && defined($pre_build_die) &&
1835 dodie "failed to pre_build\n";
1839 if ($type =~ /^useconfig:(.*)/) {
1840 run_command "cp $1 $output_config" or
1841 dodie "could not copy $1 to .config";
1843 $type = "oldconfig";
1846 # old config can ask questions
1847 if ($type eq "oldconfig") {
1848 $type = "oldnoconfig";
1850 # allow for empty configs
1851 run_command "touch $output_config";
1854 run_command "mv $output_config $outputdir/config_temp" or
1855 dodie "moving .config";
1857 run_command "$make mrproper" or dodie "make mrproper";
1859 run_command "mv $outputdir/config_temp $output_config" or
1860 dodie "moving config_temp";
1863 } elsif (!$noclean) {
1864 unlink "$output_config";
1865 run_command "$make mrproper" or
1866 dodie "make mrproper";
1869 # add something to distinguish this build
1870 open(OUT, "> $outputdir/localversion") or dodie("Can't make localversion file");
1871 print OUT "$localversion\n";
1874 if (defined($minconfig)) {
1875 load_force_config($minconfig);
1878 if ($type ne "oldnoconfig") {
1879 run_command "$make $type" or
1880 dodie "failed make config";
1882 # Run old config regardless, to enforce min configurations
1885 $redirect = "$buildlog";
1886 my $build_ret = run_command "$make $build_options";
1889 if (defined($post_build)) {
1890 my $ret = run_command $post_build;
1891 if (!$ret && defined($post_build_die) &&
1893 dodie "failed to post_build\n";
1898 # bisect may need this to pass
1900 $no_reboot = $save_no_reboot;
1903 fail "failed build" and return 0;
1906 $no_reboot = $save_no_reboot;
1912 if (!run_ssh "halt" or defined($power_off)) {
1913 if (defined($poweroff_after_halt)) {
1914 sleep $poweroff_after_halt;
1915 run_command "$power_off";
1919 run_command "$power_off";
1930 if (defined($test_name)) {
1931 $name = " ($test_name)";
1934 doprint "\n\n*******************************************\n";
1935 doprint "*******************************************\n";
1936 doprint "KTEST RESULT: TEST $i$name SUCCESS!!!! **\n";
1937 doprint "*******************************************\n";
1938 doprint "*******************************************\n";
1940 if (defined($store_successes)) {
1941 save_logs "success", $store_successes;
1944 if ($i != $opt{"NUM_TESTS"} && !do_not_reboot) {
1945 doprint "Reboot and wait $sleep_time seconds\n";
1946 reboot_to_good $sleep_time;
1952 doprint "Pass or fail? [p/f]";
1955 if ($ans eq "p" || $ans eq "P") {
1957 } elsif ($ans eq "f" || $ans eq "F") {
1960 print "Please answer 'P' or 'F'\n";
1965 sub child_run_test {
1968 # child should have no power
1969 $reboot_on_error = 0;
1970 $poweroff_on_error = 0;
1971 $die_on_failure = 1;
1973 $redirect = "$testlog";
1974 run_command $run_test or $failed = 1;
1982 sub child_finished {
1995 doprint "run test $run_test\n";
1999 $SIG{CHLD} = qw(child_finished);
2003 child_run_test if (!$child_pid);
2008 $line = wait_for_input($monitor_fp, 1);
2009 if (defined($line)) {
2011 # we are not guaranteed to get a full line
2012 $full_line .= $line;
2015 if ($full_line =~ /call trace:/i) {
2019 if ($full_line =~ /Kernel panic -/) {
2023 if ($line =~ /\n/) {
2027 } while (!$child_done && !$bug);
2030 my $failure_start = time;
2033 $line = wait_for_input($monitor_fp, 1);
2034 if (defined($line)) {
2038 if ($now - $failure_start >= $stop_after_failure) {
2041 } while (defined($line));
2043 doprint "Detected kernel crash!\n";
2044 # kill the child with extreme prejudice
2048 waitpid $child_pid, 0;
2051 if (!$bug && $in_bisect) {
2052 if (defined($bisect_ret_good)) {
2053 if ($child_exit == $bisect_ret_good) {
2057 if (defined($bisect_ret_skip)) {
2058 if ($child_exit == $bisect_ret_skip) {
2062 if (defined($bisect_ret_abort)) {
2063 if ($child_exit == $bisect_ret_abort) {
2064 fail "test abort" and return -2;
2067 if (defined($bisect_ret_bad)) {
2068 if ($child_exit == $bisect_ret_skip) {
2072 if (defined($bisect_ret_default)) {
2073 if ($bisect_ret_default eq "good") {
2075 } elsif ($bisect_ret_default eq "bad") {
2077 } elsif ($bisect_ret_default eq "skip") {
2079 } elsif ($bisect_ret_default eq "abort") {
2082 fail "unknown default action: $bisect_ret_default"
2088 if ($bug || $child_exit) {
2089 return 0 if $in_bisect;
2090 fail "test failed" and return 0;
2095 sub run_git_bisect {
2098 doprint "$command ... ";
2100 my $output = `$command 2>&1`;
2107 dodie "Failed to git bisect";
2110 doprint "SUCCESS\n";
2111 if ($output =~ m/^(Bisecting: .*\(roughly \d+ steps?\))\s+\[([[:xdigit:]]+)\]/) {
2112 doprint "$1 [$2]\n";
2113 } elsif ($output =~ m/^([[:xdigit:]]+) is the first bad commit/) {
2114 $bisect_bad_commit = $1;
2115 doprint "Found bad commit... $1\n";
2118 # we already logged it, just print it now.
2126 doprint "Reboot and sleep $bisect_sleep_time seconds\n";
2127 reboot_to_good $bisect_sleep_time;
2130 # returns 1 on success, 0 on failure, -1 on skip
2131 sub run_bisect_test {
2132 my ($type, $buildtype) = @_;
2141 build $buildtype or $failed = 1;
2143 if ($type ne "build") {
2144 if ($failed && $bisect_skip) {
2148 dodie "Failed on build" if $failed;
2151 start_monitor_and_boot or $failed = 1;
2153 if ($type ne "boot") {
2154 if ($failed && $bisect_skip) {
2160 dodie "Failed on boot" if $failed;
2162 do_run_test or $failed = 1;
2173 # reboot the box to a kernel we can ssh to
2174 if ($type ne "build") {
2184 my $buildtype = "oldconfig";
2186 # We should have a minconfig to use?
2187 if (defined($minconfig)) {
2188 $buildtype = "useconfig:$minconfig";
2191 my $ret = run_bisect_test $type, $buildtype;
2193 if ($bisect_manual) {
2194 $ret = answer_bisect;
2197 # Are we looking for where it worked, not failed?
2198 if ($reverse_bisect && $ret >= 0) {
2204 } elsif ($ret == 0) {
2206 } elsif ($bisect_skip) {
2207 doprint "HIT A BAD COMMIT ... SKIPPING\n";
2212 sub update_bisect_replay {
2213 my $tmp_log = "$tmpdir/ktest_bisect_log";
2214 run_command "git bisect log > $tmp_log" or
2215 die "can't create bisect log";
2224 die "BISECT_GOOD[$i] not defined\n" if (!defined($bisect_good));
2225 die "BISECT_BAD[$i] not defined\n" if (!defined($bisect_bad));
2226 die "BISECT_TYPE[$i] not defined\n" if (!defined($bisect_type));
2228 my $good = $bisect_good;
2229 my $bad = $bisect_bad;
2230 my $type = $bisect_type;
2231 my $start = $bisect_start;
2232 my $replay = $bisect_replay;
2233 my $start_files = $bisect_files;
2235 if (defined($start_files)) {
2236 $start_files = " -- " . $start_files;
2241 # convert to true sha1's
2242 $good = get_sha1($good);
2243 $bad = get_sha1($bad);
2245 if (defined($bisect_reverse) && $bisect_reverse == 1) {
2246 doprint "Performing a reverse bisect (bad is good, good is bad!)\n";
2247 $reverse_bisect = 1;
2249 $reverse_bisect = 0;
2252 # Can't have a test without having a test to run
2253 if ($type eq "test" && !defined($run_test)) {
2257 # Check if a bisect was running
2258 my $bisect_start_file = "$builddir/.git/BISECT_START";
2260 my $check = $bisect_check;
2261 my $do_check = defined($check) && $check ne "0";
2263 if ( -f $bisect_start_file ) {
2264 print "Bisect in progress found\n";
2266 print " If you say yes, then no checks of good or bad will be done\n";
2268 if (defined($replay)) {
2269 print "** BISECT_REPLAY is defined in config file **";
2270 print " Ignore config option and perform new git bisect log?\n";
2271 if (read_ync " (yes, no, or cancel) ") {
2272 $replay = update_bisect_replay;
2275 } elsif (read_yn "read git log and continue?") {
2276 $replay = update_bisect_replay;
2284 my $head = get_sha1("HEAD");
2286 if ($check ne "good") {
2287 doprint "TESTING BISECT BAD [$bad]\n";
2288 run_command "git checkout $bad" or
2289 die "Failed to checkout $bad";
2291 $result = run_bisect $type;
2293 if ($result ne "bad") {
2294 fail "Tested BISECT_BAD [$bad] and it succeeded" and return 0;
2298 if ($check ne "bad") {
2299 doprint "TESTING BISECT GOOD [$good]\n";
2300 run_command "git checkout $good" or
2301 die "Failed to checkout $good";
2303 $result = run_bisect $type;
2305 if ($result ne "good") {
2306 fail "Tested BISECT_GOOD [$good] and it failed" and return 0;
2310 # checkout where we started
2311 run_command "git checkout $head" or
2312 die "Failed to checkout $head";
2315 run_command "git bisect start$start_files" or
2316 dodie "could not start bisect";
2318 run_command "git bisect good $good" or
2319 dodie "could not set bisect good to $good";
2321 run_git_bisect "git bisect bad $bad" or
2322 dodie "could not set bisect bad to $bad";
2324 if (defined($replay)) {
2325 run_command "git bisect replay $replay" or
2326 dodie "failed to run replay";
2329 if (defined($start)) {
2330 run_command "git checkout $start" or
2331 dodie "failed to checkout $start";
2336 $result = run_bisect $type;
2337 $test = run_git_bisect "git bisect $result";
2340 run_command "git bisect log" or
2341 dodie "could not capture git bisect log";
2343 run_command "git bisect reset" or
2344 dodie "could not reset git bisect";
2346 doprint "Bad commit was [$bisect_bad_commit]\n";
2359 sub assign_configs {
2360 my ($hash, $config) = @_;
2363 or dodie "Failed to read $config";
2366 if (/^((CONFIG\S*)=.*)/) {
2374 sub process_config_ignore {
2377 assign_configs \%config_ignore, $config;
2380 sub read_current_config {
2381 my ($config_ref) = @_;
2383 %{$config_ref} = ();
2384 undef %{$config_ref};
2386 my @key = keys %{$config_ref};
2388 print "did not delete!\n";
2391 open (IN, "$output_config");
2394 if (/^(CONFIG\S+)=(.*)/) {
2395 ${$config_ref}{$1} = $2;
2401 sub get_dependencies {
2404 my $arr = $dependency{$config};
2405 if (!defined($arr)) {
2411 foreach my $dep (@{$arr}) {
2412 print "ADD DEP $dep\n";
2413 @deps = (@deps, get_dependencies $dep);
2422 open(OUT, ">$output_config") or dodie "Can not write to $output_config";
2424 foreach my $config (@configs) {
2425 print OUT "$config_set{$config}\n";
2426 my @deps = get_dependencies $config;
2427 foreach my $dep (@deps) {
2428 print OUT "$config_set{$dep}\n";
2432 foreach my $config (keys %config_ignore) {
2433 print OUT "$config_ignore{$config}\n";
2441 sub compare_configs {
2444 foreach my $item (keys %a) {
2445 if (!defined($b{$item})) {
2446 print "diff $item\n";
2454 print "diff2 $keys[0]\n";
2456 return -1 if ($#keys >= 0);
2461 sub run_config_bisect_test {
2464 return run_bisect_test $type, "oldconfig";
2467 sub process_passed {
2470 doprint "These configs had no failure: (Enabling them for further compiles)\n";
2471 # Passed! All these configs are part of a good compile.
2472 # Add them to the min options.
2473 foreach my $config (keys %configs) {
2474 if (defined($config_list{$config})) {
2475 doprint " removing $config\n";
2476 $config_ignore{$config} = $config_list{$config};
2477 delete $config_list{$config};
2480 doprint "config copied to $outputdir/config_good\n";
2481 run_command "cp -f $output_config $outputdir/config_good";
2484 sub process_failed {
2487 doprint "\n\n***************************************\n";
2488 doprint "Found bad config: $config\n";
2489 doprint "***************************************\n\n";
2492 sub run_config_bisect {
2494 my @start_list = keys %config_list;
2496 if ($#start_list < 0) {
2497 doprint "No more configs to test!!!\n";
2501 doprint "***** RUN TEST ***\n";
2502 my $type = $config_bisect_type;
2506 my $count = $#start_list + 1;
2507 doprint " $count configs to test\n";
2509 my $half = int($#start_list / 2);
2512 my @tophalf = @start_list[0 .. $half];
2514 create_config @tophalf;
2515 read_current_config \%current_config;
2517 $count = $#tophalf + 1;
2518 doprint "Testing $count configs\n";
2520 # make sure we test something
2521 foreach my $config (@tophalf) {
2522 if (defined($current_config{$config})) {
2528 # try the other half
2529 doprint "Top half produced no set configs, trying bottom half\n";
2530 @tophalf = @start_list[$half + 1 .. $#start_list];
2531 create_config @tophalf;
2532 read_current_config \%current_config;
2533 foreach my $config (@tophalf) {
2534 if (defined($current_config{$config})) {
2540 doprint "Failed: Can't make new config with current configs\n";
2541 foreach my $config (@start_list) {
2542 doprint " CONFIG: $config\n";
2546 $count = $#tophalf + 1;
2547 doprint "Testing $count configs\n";
2550 $ret = run_config_bisect_test $type;
2551 if ($bisect_manual) {
2552 $ret = answer_bisect;
2555 process_passed %current_config;
2559 doprint "This config had a failure.\n";
2560 doprint "Removing these configs that were not set in this config:\n";
2561 doprint "config copied to $outputdir/config_bad\n";
2562 run_command "cp -f $output_config $outputdir/config_bad";
2564 # A config exists in this group that was bad.
2565 foreach my $config (keys %config_list) {
2566 if (!defined($current_config{$config})) {
2567 doprint " removing $config\n";
2568 delete $config_list{$config};
2572 @start_list = @tophalf;
2574 if ($#start_list == 0) {
2575 process_failed $start_list[0];
2579 # remove half the configs we are looking at and see if
2581 $half = int($#start_list / 2);
2582 } while ($#start_list > 0);
2584 # we found a single config, try it again unless we are running manually
2586 if ($bisect_manual) {
2587 process_failed $start_list[0];
2591 my @tophalf = @start_list[0 .. 0];
2593 $ret = run_config_bisect_test $type;
2595 process_passed %current_config;
2599 process_failed $start_list[0];
2606 my $start_config = $config_bisect;
2608 my $tmpconfig = "$tmpdir/use_config";
2610 if (defined($config_bisect_good)) {
2611 process_config_ignore $config_bisect_good;
2614 # Make the file with the bad config and the min config
2615 if (defined($minconfig)) {
2616 # read the min config for things to ignore
2617 run_command "cp $minconfig $tmpconfig" or
2618 dodie "failed to copy $minconfig to $tmpconfig";
2623 if (-f $tmpconfig) {
2624 load_force_config($tmpconfig);
2625 process_config_ignore $tmpconfig;
2628 # now process the start config
2629 run_command "cp $start_config $output_config" or
2630 dodie "failed to copy $start_config to $output_config";
2632 # read directly what we want to check
2634 open (IN, $output_config)
2635 or dodie "failed to open $output_config";
2638 if (/^((CONFIG\S*)=.*)/) {
2639 $config_check{$2} = $1;
2644 # Now run oldconfig with the minconfig
2647 # check to see what we lost (or gained)
2648 open (IN, $output_config)
2649 or dodie "Failed to read $start_config";
2651 my %removed_configs;
2655 if (/^((CONFIG\S*)=.*)/) {
2656 # save off all options
2657 $config_set{$2} = $1;
2658 if (defined($config_check{$2})) {
2659 if (defined($config_ignore{$2})) {
2660 $removed_configs{$2} = $1;
2662 $config_list{$2} = $1;
2664 } elsif (!defined($config_ignore{$2})) {
2665 $added_configs{$2} = $1;
2666 $config_list{$2} = $1;
2672 my @confs = keys %removed_configs;
2674 doprint "Configs overridden by default configs and removed from check:\n";
2675 foreach my $config (@confs) {
2676 doprint " $config\n";
2679 @confs = keys %added_configs;
2681 doprint "Configs appearing in make oldconfig and added:\n";
2682 foreach my $config (@confs) {
2683 doprint " $config\n";
2690 # Sometimes kconfig does weird things. We must make sure
2691 # that the config we autocreate has everything we need
2692 # to test, otherwise we may miss testing configs, or
2693 # may not be able to create a new config.
2694 # Here we create a config with everything set.
2695 create_config (keys %config_list);
2696 read_current_config \%config_test;
2697 foreach my $config (keys %config_list) {
2698 if (!defined($config_test{$config})) {
2701 doprint "Configs not produced by kconfig (will not be checked):\n";
2703 doprint " $config\n";
2704 delete $config_list{$config};
2709 $ret = run_config_bisect;
2712 return $ret if ($ret < 0);
2717 sub patchcheck_reboot {
2718 doprint "Reboot and sleep $patchcheck_sleep_time seconds\n";
2719 reboot_to_good $patchcheck_sleep_time;
2725 die "PATCHCHECK_START[$i] not defined\n"
2726 if (!defined($patchcheck_start));
2727 die "PATCHCHECK_TYPE[$i] not defined\n"
2728 if (!defined($patchcheck_type));
2730 my $start = $patchcheck_start;
2733 if (defined($patchcheck_end)) {
2734 $end = $patchcheck_end;
2737 # Get the true sha1's since we can use things like HEAD~3
2738 $start = get_sha1($start);
2739 $end = get_sha1($end);
2741 my $type = $patchcheck_type;
2743 # Can't have a test without having a test to run
2744 if ($type eq "test" && !defined($run_test)) {
2748 open (IN, "git log --pretty=oneline $end|") or
2749 dodie "could not get git list";
2755 $list[$#list+1] = $_;
2756 last if (/^$start/);
2760 if ($list[$#list] !~ /^$start/) {
2761 fail "SHA1 $start not found";
2764 # go backwards in the list
2765 @list = reverse @list;
2767 my $save_clean = $noclean;
2768 my %ignored_warnings;
2770 if (defined($ignore_warnings)) {
2771 foreach my $sha1 (split /\s+/, $ignore_warnings) {
2772 $ignored_warnings{$sha1} = 1;
2777 foreach my $item (@list) {
2779 $sha1 =~ s/^([[:xdigit:]]+).*/$1/;
2781 doprint "\nProcessing commit $item\n\n";
2783 run_command "git checkout $sha1" or
2784 die "Failed to checkout $sha1";
2786 # only clean on the first and last patch
2787 if ($item eq $list[0] ||
2788 $item eq $list[$#list]) {
2789 $noclean = $save_clean;
2794 if (defined($minconfig)) {
2795 build "useconfig:$minconfig" or return 0;
2797 # ?? no config to use?
2798 build "oldconfig" or return 0;
2802 if (!defined($ignored_warnings{$sha1})) {
2803 check_buildlog $sha1 or return 0;
2806 next if ($type eq "build");
2810 start_monitor_and_boot or $failed = 1;
2812 if (!$failed && $type ne "boot"){
2813 do_run_test or $failed = 1;
2816 return 0 if ($failed);
2836 # $config depends on $dep
2837 my ($config, $dep) = @_;
2839 if (defined($depends{$config})) {
2840 $depends{$config} .= " " . $dep;
2842 $depends{$config} = $dep;
2845 # record the number of configs depending on $dep
2846 if (defined $depcount{$dep}) {
2849 $depcount{$dep} = 1;
2853 # taken from streamline_config.pl
2865 if (! -f $kconfig) {
2866 doprint "file $kconfig does not exist, skipping\n";
2870 open(KIN, "$kconfig")
2871 or die "Can't open $kconfig";
2875 # Make sure that lines ending with \ continue
2877 $_ = $line . " " . $_;
2888 # collect any Kconfig sources
2889 if (/^source\s*"(.*)"/) {
2890 $kconfigs[$#kconfigs+1] = $1;
2894 if (/^\s*(menu)?config\s+(\S+)\s*$/) {
2898 for (my $i = 0; $i < $iflevel; $i++) {
2899 add_dep $config, $ifdeps[$i];
2902 # collect the depends for the config
2903 } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
2905 add_dep $config, $1;
2907 # Get the configs that select this config
2908 } elsif ($state eq "NEW" && /^\s*select\s+(\S+)/) {
2910 # selected by depends on config
2911 add_dep $1, $config;
2913 # Check for if statements
2914 } elsif (/^if\s+(.*\S)\s*$/) {
2916 # remove beginning and ending non text
2917 $deps =~ s/^[^a-zA-Z0-9_]*//;
2918 $deps =~ s/[^a-zA-Z0-9_]*$//;
2920 my @deps = split /[^a-zA-Z0-9_]+/, $deps;
2922 $ifdeps[$iflevel++] = join ':', @deps;
2924 } elsif (/^endif/) {
2926 $iflevel-- if ($iflevel);
2929 } elsif (/^\s*help\s*$/) {
2935 # read in any configs that were found.
2936 foreach $kconfig (@kconfigs) {
2937 if (!defined($read_kconfigs{$kconfig})) {
2938 $read_kconfigs{$kconfig} = 1;
2939 read_kconfig("$builddir/$kconfig");
2945 # find out which arch this is by the kconfig file
2946 open (IN, $output_config)
2947 or dodie "Failed to read $output_config";
2950 if (m,Linux/(\S+)\s+\S+\s+Kernel Configuration,) {
2957 if (!defined($arch)) {
2958 doprint "Could not find arch from config file\n";
2959 doprint "no dependencies used\n";
2963 # arch is really the subarch, we need to know
2964 # what directory to look at.
2965 if ($arch eq "i386" || $arch eq "x86_64") {
2967 } elsif ($arch =~ /^tile/) {
2971 my $kconfig = "$builddir/arch/$arch/Kconfig";
2973 if (! -f $kconfig && $arch =~ /\d$/) {
2975 # some subarchs have numbers, truncate them
2977 $kconfig = "$builddir/arch/$arch/Kconfig";
2978 if (! -f $kconfig) {
2979 doprint "No idea what arch dir $orig is for\n";
2980 doprint "no dependencies used\n";
2985 read_kconfig($kconfig);
2988 sub read_config_list {
2992 or dodie "Failed to read $config";
2995 if (/^((CONFIG\S*)=.*)/) {
2996 if (!defined($config_ignore{$2})) {
2997 $config_list{$2} = $1;
3005 sub read_output_config {
3008 assign_configs \%config_ignore, $config;
3011 sub make_new_config {
3014 open (OUT, ">$output_config")
3015 or dodie "Failed to write $output_config";
3017 foreach my $config (@configs) {
3018 print OUT "$config\n";
3026 $config =~ s/CONFIG_//;
3034 my $kconfig = chomp_config $dep;
3036 $dep = $depends{"$kconfig"};
3038 # the dep string we have saves the dependencies as they
3039 # were found, including expressions like ! && ||. We
3040 # want to split this out into just an array of configs.
3042 my $valid = "A-Za-z_0-9";
3046 while ($dep =~ /[$valid]/) {
3048 if ($dep =~ /^[^$valid]*([$valid]+)/) {
3049 my $conf = "CONFIG_" . $1;
3051 $configs[$#configs + 1] = $conf;
3053 $dep =~ s/^[^$valid]*[$valid]+//;
3055 die "this should never happen";
3065 my %processed_configs;
3066 my %nochange_config;
3068 sub test_this_config {
3073 # if we already processed this config, skip it
3074 if (defined($processed_configs{$config})) {
3077 $processed_configs{$config} = 1;
3079 # if this config failed during this round, skip it
3080 if (defined($nochange_config{$config})) {
3084 my $kconfig = chomp_config $config;
3086 # Test dependencies first
3087 if (defined($depends{"$kconfig"})) {
3088 my @parents = get_depends $config;
3089 foreach my $parent (@parents) {
3090 # if the parent is in the min config, check it first
3091 next if (!defined($min_configs{$parent}));
3092 $found = test_this_config($parent);
3093 if (defined($found)) {
3099 # Remove this config from the list of configs
3100 # do a make oldnoconfig and then read the resulting
3101 # .config to make sure it is missing the config that
3103 my %configs = %min_configs;
3104 delete $configs{$config};
3105 make_new_config ((values %configs), (values %keep_configs));
3108 assign_configs \%configs, $output_config;
3110 return $config if (!defined($configs{$config}));
3112 doprint "disabling config $config did not change .config\n";
3114 $nochange_config{$config} = 1;
3119 sub make_min_config {
3122 if (!defined($output_minconfig)) {
3123 fail "OUTPUT_MIN_CONFIG not defined" and return;
3126 # If output_minconfig exists, and the start_minconfig
3127 # came from min_config, than ask if we should use
3129 if (-f $output_minconfig && !$start_minconfig_defined) {
3130 print "$output_minconfig exists\n";
3131 if (read_yn " Use it as minconfig?") {
3132 $start_minconfig = $output_minconfig;
3136 if (!defined($start_minconfig)) {
3137 fail "START_MIN_CONFIG or MIN_CONFIG not defined" and return;
3140 my $temp_config = "$tmpdir/temp_config";
3142 # First things first. We build an allnoconfig to find
3143 # out what the defaults are that we can't touch.
3144 # Some are selections, but we really can't handle selections.
3146 my $save_minconfig = $minconfig;
3149 run_command "$make allnoconfig" or return 0;
3153 process_config_ignore $output_config;
3155 undef %save_configs;
3158 if (defined($ignore_config)) {
3159 # make sure the file exists
3160 `touch $ignore_config`;
3161 assign_configs \%save_configs, $ignore_config;
3164 %keep_configs = %save_configs;
3166 doprint "Load initial configs from $start_minconfig\n";
3168 # Look at the current min configs, and save off all the
3169 # ones that were set via the allnoconfig
3170 assign_configs \%min_configs, $start_minconfig;
3172 my @config_keys = keys %min_configs;
3174 # All configs need a depcount
3175 foreach my $config (@config_keys) {
3176 my $kconfig = chomp_config $config;
3177 if (!defined $depcount{$kconfig}) {
3178 $depcount{$kconfig} = 0;
3182 # Remove anything that was set by the make allnoconfig
3183 # we shouldn't need them as they get set for us anyway.
3184 foreach my $config (@config_keys) {
3185 # Remove anything in the ignore_config
3186 if (defined($keep_configs{$config})) {
3187 my $file = $ignore_config;
3188 $file =~ s,.*/(.*?)$,$1,;
3189 doprint "$config set by $file ... ignored\n";
3190 delete $min_configs{$config};
3193 # But make sure the settings are the same. If a min config
3194 # sets a selection, we do not want to get rid of it if
3195 # it is not the same as what we have. Just move it into
3197 if (defined($config_ignore{$config})) {
3198 if ($config_ignore{$config} ne $min_configs{$config}) {
3199 doprint "$config is in allnoconfig as '$config_ignore{$config}'";
3200 doprint " but it is '$min_configs{$config}' in minconfig .. keeping\n";
3201 $keep_configs{$config} = $min_configs{$config};
3203 doprint "$config set by allnoconfig ... ignored\n";
3205 delete $min_configs{$config};
3217 # Now disable each config one by one and do a make oldconfig
3218 # till we find a config that changes our list.
3220 my @test_configs = keys %min_configs;
3222 # Sort keys by who is most dependent on
3223 @test_configs = sort { $depcount{chomp_config($b)} <=> $depcount{chomp_config($a)} }
3226 # Put configs that did not modify the config at the end.
3228 for (my $i = 0; $i < $#test_configs; $i++) {
3229 if (!defined($nochange_config{$test_configs[0]})) {
3233 # This config didn't change the .config last time.
3234 # Place it at the end
3235 my $config = shift @test_configs;
3236 push @test_configs, $config;
3239 # if every test config has failed to modify the .config file
3240 # in the past, then reset and start over.
3242 undef %nochange_config;
3245 undef %processed_configs;
3247 foreach my $config (@test_configs) {
3249 $found = test_this_config $config;
3251 last if (defined($found));
3253 # oh well, try another config
3256 if (!defined($found)) {
3257 # we could have failed due to the nochange_config hash
3258 # reset and try again
3260 undef %nochange_config;
3264 doprint "No more configs found that we can disable\n";
3272 doprint "Test with $config disabled\n";
3274 # set in_bisect to keep build and monitor from dieing
3278 build "oldconfig" or $failed = 1;
3280 start_monitor_and_boot or $failed = 1;
3287 doprint "$min_configs{$config} is needed to boot the box... keeping\n";
3288 # this config is needed, add it to the ignore list.
3289 $keep_configs{$config} = $min_configs{$config};
3290 $save_configs{$config} = $min_configs{$config};
3291 delete $min_configs{$config};
3293 # update new ignore configs
3294 if (defined($ignore_config)) {
3295 open (OUT, ">$temp_config")
3296 or die "Can't write to $temp_config";
3297 foreach my $config (keys %save_configs) {
3298 print OUT "$save_configs{$config}\n";
3301 run_command "mv $temp_config $ignore_config" or
3302 dodie "failed to copy update to $ignore_config";
3306 # We booted without this config, remove it from the minconfigs.
3307 doprint "$config is not needed, disabling\n";
3309 delete $min_configs{$config};
3311 # Also disable anything that is not enabled in this config
3313 assign_configs \%configs, $output_config;
3314 my @config_keys = keys %min_configs;
3315 foreach my $config (@config_keys) {
3316 if (!defined($configs{$config})) {
3317 doprint "$config is not set, disabling\n";
3318 delete $min_configs{$config};
3322 # Save off all the current mandidory configs
3323 open (OUT, ">$temp_config")
3324 or die "Can't write to $temp_config";
3325 foreach my $config (keys %keep_configs) {
3326 print OUT "$keep_configs{$config}\n";
3328 foreach my $config (keys %min_configs) {
3329 print OUT "$min_configs{$config}\n";
3333 run_command "mv $temp_config $output_minconfig" or
3334 dodie "failed to copy update to $output_minconfig";
3337 doprint "Reboot and wait $sleep_time seconds\n";
3338 reboot_to_good $sleep_time;
3345 $#ARGV < 1 or die "ktest.pl version: $VERSION\n usage: ktest.pl config-file\n";
3348 $ktest_config = $ARGV[0];
3349 if (! -f $ktest_config) {
3350 print "$ktest_config does not exist.\n";
3351 if (!read_yn "Create it?") {
3356 $ktest_config = "ktest.conf";
3359 if (! -f $ktest_config) {
3362 open(OUT, ">$ktest_config") or die "Can not create $ktest_config";
3364 # Generated by ktest.pl
3367 # PWD is a ktest.pl variable that will result in the process working
3368 # directory that ktest.pl is executed in.
3370 # THIS_DIR is automatically assigned the PWD of the path that generated
3371 # the config file. It is best to use this variable when assigning other
3372 # directory paths within this directory. This allows you to easily
3373 # move the test cases to other locations or to other machines.
3375 THIS_DIR := $variable{"PWD"}
3377 # Define each test with TEST_START
3378 # The config options below it will override the defaults
3380 TEST_TYPE = $default{"TEST_TYPE"}
3387 read_config $ktest_config;
3389 if (defined($opt{"LOG_FILE"})) {
3390 $opt{"LOG_FILE"} = eval_option($opt{"LOG_FILE"}, -1);
3393 # Append any configs entered in manually to the config file.
3394 my @new_configs = keys %entered_configs;
3395 if ($#new_configs >= 0) {
3396 print "\nAppending entered in configs to $ktest_config\n";
3397 open(OUT, ">>$ktest_config") or die "Can not append to $ktest_config";
3398 foreach my $config (@new_configs) {
3399 print OUT "$config = $entered_configs{$config}\n";
3400 $opt{$config} = process_variables($entered_configs{$config});
3404 if ($opt{"CLEAR_LOG"} && defined($opt{"LOG_FILE"})) {
3405 unlink $opt{"LOG_FILE"};
3408 doprint "\n\nSTARTING AUTOMATED TESTS\n\n";
3410 for (my $i = 0, my $repeat = 1; $i <= $opt{"NUM_TESTS"}; $i += $repeat) {
3413 doprint "DEFAULT OPTIONS:\n";
3415 doprint "\nTEST $i OPTIONS";
3416 if (defined($repeat_tests{$i})) {
3417 $repeat = $repeat_tests{$i};
3418 doprint " ITERATE $repeat";
3423 foreach my $option (sort keys %opt) {
3425 if ($option =~ /\[(\d+)\]$/) {
3431 doprint "$option = $opt{$option}\n";
3435 sub __set_test_option {
3436 my ($name, $i) = @_;
3438 my $option = "$name\[$i\]";
3440 if (defined($opt{$option})) {
3441 return $opt{$option};
3444 foreach my $test (keys %repeat_tests) {
3446 $i < $test + $repeat_tests{$test}) {
3447 $option = "$name\[$test\]";
3448 if (defined($opt{$option})) {
3449 return $opt{$option};
3454 if (defined($opt{$name})) {
3461 sub set_test_option {
3462 my ($name, $i) = @_;
3464 my $option = __set_test_option($name, $i);
3465 return $option if (!defined($option));
3467 return eval_option($option, $i);
3470 # First we need to do is the builds
3471 for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3473 # Do not reboot on failing test options
3475 $reboot_success = 0;
3479 my $makecmd = set_test_option("MAKE_CMD", $i);
3481 # Load all the options into their mapped variable names
3482 foreach my $opt (keys %option_map) {
3483 ${$option_map{$opt}} = set_test_option($opt, $i);
3486 $start_minconfig_defined = 1;
3488 if (!defined($start_minconfig)) {
3489 $start_minconfig_defined = 0;
3490 $start_minconfig = $minconfig;
3493 chdir $builddir || die "can't change directory to $builddir";
3495 foreach my $dir ($tmpdir, $outputdir) {
3498 die "can't create $dir";
3502 $ENV{"SSH_USER"} = $ssh_user;
3503 $ENV{"MACHINE"} = $machine;
3505 $buildlog = "$tmpdir/buildlog-$machine";
3506 $testlog = "$tmpdir/testlog-$machine";
3507 $dmesg = "$tmpdir/dmesg-$machine";
3508 $make = "$makecmd O=$outputdir";
3509 $output_config = "$outputdir/.config";
3512 $target = "$ssh_user\@$machine";
3513 if ($reboot_type eq "grub") {
3514 dodie "GRUB_MENU not defined" if (!defined($grub_menu));
3518 my $run_type = $build_type;
3519 if ($test_type eq "patchcheck") {
3520 $run_type = $patchcheck_type;
3521 } elsif ($test_type eq "bisect") {
3522 $run_type = $bisect_type;
3523 } elsif ($test_type eq "config_bisect") {
3524 $run_type = $config_bisect_type;
3527 if ($test_type eq "make_min_config") {
3531 # mistake in config file?
3532 if (!defined($run_type)) {
3533 $run_type = "ERROR";
3537 $installme = " no_install" if ($no_install);
3540 doprint "RUNNING TEST $i of $opt{NUM_TESTS} with option $test_type $run_type$installme\n\n";
3546 if (defined($addconfig)) {
3547 my $min = $minconfig;
3548 if (!defined($minconfig)) {
3551 run_command "cat $addconfig $min > $tmpdir/add_config" or
3552 dodie "Failed to create temp config";
3553 $minconfig = "$tmpdir/add_config";
3556 if (defined($checkout)) {
3557 run_command "git checkout $checkout" or
3558 die "failed to checkout $checkout";
3563 # A test may opt to not reboot the box
3564 if ($reboot_on_success) {
3565 $reboot_success = 1;
3568 if ($test_type eq "bisect") {
3571 } elsif ($test_type eq "config_bisect") {
3574 } elsif ($test_type eq "patchcheck") {
3577 } elsif ($test_type eq "make_min_config") {
3582 if ($build_type ne "nobuild") {
3583 build $build_type or next;
3586 if ($test_type eq "install") {
3593 if ($test_type ne "build") {
3595 start_monitor_and_boot or $failed = 1;
3597 if (!$failed && $test_type ne "boot" && defined($run_test)) {
3598 do_run_test or $failed = 1;
3607 if ($opt{"POWEROFF_ON_SUCCESS"}) {
3609 } elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot && $reboot_success) {
3611 } elsif (defined($switch_to_good)) {
3612 # still need to get to the good kernel
3613 run_command $switch_to_good;
3617 doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n";