1818my %opt ;
1919my %repeat_tests ;
2020my %repeats ;
21+ my %evals ;
2122
2223# default opts
2324my %default = (
2425 " NUM_TESTS" => 1,
2526 " TEST_TYPE" => " build" ,
2627 " BUILD_TYPE" => " randconfig" ,
2728 " MAKE_CMD" => " make" ,
29+ " CLOSE_CONSOLE_SIGNAL" => " INT" ,
2830 " TIMEOUT" => 120,
2931 " TMP_DIR" => " /tmp/ktest/\$ {MACHINE}" ,
3032 " SLEEP_TIME" => 60, # sleep time between tests
3941 " CLEAR_LOG" => 0,
4042 " BISECT_MANUAL" => 0,
4143 " BISECT_SKIP" => 1,
44+ " BISECT_TRIES" => 1,
4245 " MIN_CONFIG_TYPE" => " boot" ,
4346 " SUCCESS_LINE" => " login:" ,
4447 " DETECT_TRIPLE_FAULT" => 1,
137140my $reverse_bisect ;
138141my $bisect_manual ;
139142my $bisect_skip ;
143+ my $bisect_tries ;
140144my $config_bisect_good ;
141145my $bisect_ret_good ;
142146my $bisect_ret_bad ;
163167my $booted_timeout ;
164168my $detect_triplefault ;
165169my $console ;
170+ my $close_console_signal ;
166171my $reboot_success_line ;
167172my $success_line ;
168173my $stop_after_success ;
273278 " IGNORE_ERRORS" => \$ignore_errors ,
274279 " BISECT_MANUAL" => \$bisect_manual ,
275280 " BISECT_SKIP" => \$bisect_skip ,
281+ " BISECT_TRIES" => \$bisect_tries ,
276282 " CONFIG_BISECT_GOOD" => \$config_bisect_good ,
277283 " BISECT_RET_GOOD" => \$bisect_ret_good ,
278284 " BISECT_RET_BAD" => \$bisect_ret_bad ,
285291 " TIMEOUT" => \$timeout ,
286292 " BOOTED_TIMEOUT" => \$booted_timeout ,
287293 " CONSOLE" => \$console ,
294+ " CLOSE_CONSOLE_SIGNAL" => \$close_console_signal ,
288295 " DETECT_TRIPLE_FAULT" => \$detect_triplefault ,
289296 " SUCCESS_LINE" => \$success_line ,
290297 " REBOOT_SUCCESS_LINE" => \$reboot_success_line ,
445452EOF
446453 ;
447454
455+ sub _logit {
456+ if (defined ($opt {" LOG_FILE" })) {
457+ open (OUT, " >> $opt {LOG_FILE}" ) or die " Can't write to $opt {LOG_FILE}" ;
458+ print OUT @_ ;
459+ close (OUT);
460+ }
461+ }
462+
463+ sub logit {
464+ if (defined ($opt {" LOG_FILE" })) {
465+ _logit @_ ;
466+ } else {
467+ print @_ ;
468+ }
469+ }
470+
471+ sub doprint {
472+ print @_ ;
473+ _logit @_ ;
474+ }
475+
448476sub read_prompt {
449477 my ($cancel , $prompt ) = @_ ;
450478
@@ -662,6 +690,22 @@ sub set_value {
662690 }
663691}
664692
693+ sub set_eval {
694+ my ($lvalue , $rvalue , $name ) = @_ ;
695+
696+ my $prvalue = process_variables($rvalue );
697+ my $arr ;
698+
699+ if (defined ($evals {$lvalue })) {
700+ $arr = $evals {$lvalue };
701+ } else {
702+ $arr = [];
703+ $evals {$lvalue } = $arr ;
704+ }
705+
706+ push @{$arr }, $rvalue ;
707+ }
708+
665709sub set_variable {
666710 my ($lvalue , $rvalue ) = @_ ;
667711
@@ -947,6 +991,20 @@ sub __read_config {
947991 $test_case = 1;
948992 }
949993
994+ } elsif (/ ^\s *([A-Z_\[\]\d ]+)\s *=~\s *(.*?)\s *$ / ) {
995+
996+ next if ($skip );
997+
998+ my $lvalue = $1 ;
999+ my $rvalue = $2 ;
1000+
1001+ if ($default || $lvalue =~ / \[\d +\] $ / ) {
1002+ set_eval($lvalue , $rvalue , $name );
1003+ } else {
1004+ my $val = " $lvalue \[ $test_num \] " ;
1005+ set_eval($val , $rvalue , $name );
1006+ }
1007+
9501008 } elsif (/ ^\s *([A-Z_\[\]\d ]+)\s *=\s *(.*?)\s *$ / ) {
9511009
9521010 next if ($skip );
@@ -1126,6 +1184,10 @@ sub __eval_option {
11261184 } elsif (defined ($opt {$var })) {
11271185 $o = $opt {$var };
11281186 $retval = " $retval$o " ;
1187+ } elsif ($var eq " KERNEL_VERSION" && defined ($make )) {
1188+ # special option KERNEL_VERSION uses kernel version
1189+ get_version();
1190+ $retval = " $retval$version " ;
11291191 } else {
11301192 $retval = " $retval \$\{ $var \} " ;
11311193 }
@@ -1140,6 +1202,33 @@ sub __eval_option {
11401202 return $retval ;
11411203}
11421204
1205+ sub process_evals {
1206+ my ($name , $option , $i ) = @_ ;
1207+
1208+ my $option_name = " $name \[ $i \] " ;
1209+ my $ev ;
1210+
1211+ my $old_option = $option ;
1212+
1213+ if (defined ($evals {$option_name })) {
1214+ $ev = $evals {$option_name };
1215+ } elsif (defined ($evals {$name })) {
1216+ $ev = $evals {$name };
1217+ } else {
1218+ return $option ;
1219+ }
1220+
1221+ for my $e (@{$ev }) {
1222+ eval " \$ option =~ $e " ;
1223+ }
1224+
1225+ if ($option ne $old_option ) {
1226+ doprint(" $name changed from '$old_option ' to '$option '\n " );
1227+ }
1228+
1229+ return $option ;
1230+ }
1231+
11431232sub eval_option {
11441233 my ($name , $option , $i ) = @_ ;
11451234
@@ -1160,28 +1249,9 @@ sub eval_option {
11601249 $option = __eval_option($name , $option , $i );
11611250 }
11621251
1163- return $option ;
1164- }
1252+ $option = process_evals($name , $option , $i );
11651253
1166- sub _logit {
1167- if (defined ($opt {" LOG_FILE" })) {
1168- open (OUT, " >> $opt {LOG_FILE}" ) or die " Can't write to $opt {LOG_FILE}" ;
1169- print OUT @_ ;
1170- close (OUT);
1171- }
1172- }
1173-
1174- sub logit {
1175- if (defined ($opt {" LOG_FILE" })) {
1176- _logit @_ ;
1177- } else {
1178- print @_ ;
1179- }
1180- }
1181-
1182- sub doprint {
1183- print @_ ;
1184- _logit @_ ;
1254+ return $option ;
11851255}
11861256
11871257sub run_command ;
@@ -1296,7 +1366,7 @@ sub close_console {
12961366 my ($fp , $pid ) = @_ ;
12971367
12981368 doprint " kill child process $pid \n " ;
1299- kill 2 , $pid ;
1369+ kill $close_console_signal , $pid ;
13001370
13011371 print " closing!\n " ;
13021372 close ($fp );
@@ -2517,12 +2587,29 @@ sub run_bisect {
25172587 $buildtype = " useconfig:$minconfig " ;
25182588 }
25192589
2520- my $ret = run_bisect_test $type , $buildtype ;
2590+ # If the user sets bisect_tries to less than 1, then no tries
2591+ # is a success.
2592+ my $ret = 1;
25212593
2522- if ($bisect_manual ) {
2594+ # Still let the user manually decide that though.
2595+ if ($bisect_tries < 1 && $bisect_manual ) {
25232596 $ret = answer_bisect;
25242597 }
25252598
2599+ for (my $i = 0; $i < $bisect_tries ; $i ++) {
2600+ if ($bisect_tries > 1) {
2601+ my $t = $i + 1;
2602+ doprint(" Running bisect trial $t of $bisect_tries :\n " );
2603+ }
2604+ $ret = run_bisect_test $type , $buildtype ;
2605+
2606+ if ($bisect_manual ) {
2607+ $ret = answer_bisect;
2608+ }
2609+
2610+ last if (!$ret );
2611+ }
2612+
25262613 # Are we looking for where it worked, not failed?
25272614 if ($reverse_bisect && $ret >= 0) {
25282615 $ret = !$ret ;
@@ -3916,6 +4003,18 @@ sub set_test_option {
39164003
39174004 my $makecmd = set_test_option(" MAKE_CMD" , $i );
39184005
4006+ $outputdir = set_test_option(" OUTPUT_DIR" , $i );
4007+ $builddir = set_test_option(" BUILD_DIR" , $i );
4008+
4009+ chdir $builddir || die " can't change directory to $builddir " ;
4010+
4011+ if (!-d $outputdir ) {
4012+ mkpath($outputdir ) or
4013+ die " can't create $outputdir " ;
4014+ }
4015+
4016+ $make = " $makecmd O=$outputdir " ;
4017+
39194018 # Load all the options into their mapped variable names
39204019 foreach my $opt (keys %option_map ) {
39214020 ${$option_map {$opt }} = set_test_option($opt , $i );
@@ -3940,13 +4039,9 @@ sub set_test_option {
39404039 $start_minconfig = $minconfig ;
39414040 }
39424041
3943- chdir $builddir || die " can't change directory to $builddir " ;
3944-
3945- foreach my $dir ($tmpdir , $outputdir ) {
3946- if (!-d $dir ) {
3947- mkpath($dir ) or
3948- die " can't create $dir " ;
3949- }
4042+ if (!-d $tmpdir ) {
4043+ mkpath($tmpdir ) or
4044+ die " can't create $tmpdir " ;
39504045 }
39514046
39524047 $ENV {" SSH_USER" } = $ssh_user ;
@@ -3955,7 +4050,6 @@ sub set_test_option {
39554050 $buildlog = " $tmpdir /buildlog-$machine " ;
39564051 $testlog = " $tmpdir /testlog-$machine " ;
39574052 $dmesg = " $tmpdir /dmesg-$machine " ;
3958- $make = " $makecmd O=$outputdir " ;
39594053 $output_config = " $outputdir /.config" ;
39604054
39614055 if (!$buildonly ) {
0 commit comments