18
18
my %opt ;
19
19
my %repeat_tests ;
20
20
my %repeats ;
21
+ my %evals ;
21
22
22
23
# default opts
23
24
my %default = (
24
25
" NUM_TESTS" => 1,
25
26
" TEST_TYPE" => " build" ,
26
27
" BUILD_TYPE" => " randconfig" ,
27
28
" MAKE_CMD" => " make" ,
29
+ " CLOSE_CONSOLE_SIGNAL" => " INT" ,
28
30
" TIMEOUT" => 120,
29
31
" TMP_DIR" => " /tmp/ktest/\$ {MACHINE}" ,
30
32
" SLEEP_TIME" => 60, # sleep time between tests
39
41
" CLEAR_LOG" => 0,
40
42
" BISECT_MANUAL" => 0,
41
43
" BISECT_SKIP" => 1,
44
+ " BISECT_TRIES" => 1,
42
45
" MIN_CONFIG_TYPE" => " boot" ,
43
46
" SUCCESS_LINE" => " login:" ,
44
47
" DETECT_TRIPLE_FAULT" => 1,
137
140
my $reverse_bisect ;
138
141
my $bisect_manual ;
139
142
my $bisect_skip ;
143
+ my $bisect_tries ;
140
144
my $config_bisect_good ;
141
145
my $bisect_ret_good ;
142
146
my $bisect_ret_bad ;
163
167
my $booted_timeout ;
164
168
my $detect_triplefault ;
165
169
my $console ;
170
+ my $close_console_signal ;
166
171
my $reboot_success_line ;
167
172
my $success_line ;
168
173
my $stop_after_success ;
273
278
" IGNORE_ERRORS" => \$ignore_errors ,
274
279
" BISECT_MANUAL" => \$bisect_manual ,
275
280
" BISECT_SKIP" => \$bisect_skip ,
281
+ " BISECT_TRIES" => \$bisect_tries ,
276
282
" CONFIG_BISECT_GOOD" => \$config_bisect_good ,
277
283
" BISECT_RET_GOOD" => \$bisect_ret_good ,
278
284
" BISECT_RET_BAD" => \$bisect_ret_bad ,
285
291
" TIMEOUT" => \$timeout ,
286
292
" BOOTED_TIMEOUT" => \$booted_timeout ,
287
293
" CONSOLE" => \$console ,
294
+ " CLOSE_CONSOLE_SIGNAL" => \$close_console_signal ,
288
295
" DETECT_TRIPLE_FAULT" => \$detect_triplefault ,
289
296
" SUCCESS_LINE" => \$success_line ,
290
297
" REBOOT_SUCCESS_LINE" => \$reboot_success_line ,
445
452
EOF
446
453
;
447
454
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
+
448
476
sub read_prompt {
449
477
my ($cancel , $prompt ) = @_ ;
450
478
@@ -662,6 +690,22 @@ sub set_value {
662
690
}
663
691
}
664
692
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
+
665
709
sub set_variable {
666
710
my ($lvalue , $rvalue ) = @_ ;
667
711
@@ -947,6 +991,20 @@ sub __read_config {
947
991
$test_case = 1;
948
992
}
949
993
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
+
950
1008
} elsif (/ ^\s *([A-Z_\[\]\d ]+)\s *=\s *(.*?)\s *$ / ) {
951
1009
952
1010
next if ($skip );
@@ -1126,6 +1184,10 @@ sub __eval_option {
1126
1184
} elsif (defined ($opt {$var })) {
1127
1185
$o = $opt {$var };
1128
1186
$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 " ;
1129
1191
} else {
1130
1192
$retval = " $retval \$\{ $var \} " ;
1131
1193
}
@@ -1140,6 +1202,33 @@ sub __eval_option {
1140
1202
return $retval ;
1141
1203
}
1142
1204
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
+
1143
1232
sub eval_option {
1144
1233
my ($name , $option , $i ) = @_ ;
1145
1234
@@ -1160,28 +1249,9 @@ sub eval_option {
1160
1249
$option = __eval_option($name , $option , $i );
1161
1250
}
1162
1251
1163
- return $option ;
1164
- }
1252
+ $option = process_evals($name , $option , $i );
1165
1253
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 ;
1185
1255
}
1186
1256
1187
1257
sub run_command ;
@@ -1296,7 +1366,7 @@ sub close_console {
1296
1366
my ($fp , $pid ) = @_ ;
1297
1367
1298
1368
doprint " kill child process $pid \n " ;
1299
- kill 2 , $pid ;
1369
+ kill $close_console_signal , $pid ;
1300
1370
1301
1371
print " closing!\n " ;
1302
1372
close ($fp );
@@ -2517,12 +2587,29 @@ sub run_bisect {
2517
2587
$buildtype = " useconfig:$minconfig " ;
2518
2588
}
2519
2589
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;
2521
2593
2522
- if ($bisect_manual ) {
2594
+ # Still let the user manually decide that though.
2595
+ if ($bisect_tries < 1 && $bisect_manual ) {
2523
2596
$ret = answer_bisect;
2524
2597
}
2525
2598
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
+
2526
2613
# Are we looking for where it worked, not failed?
2527
2614
if ($reverse_bisect && $ret >= 0) {
2528
2615
$ret = !$ret ;
@@ -3916,6 +4003,18 @@ sub set_test_option {
3916
4003
3917
4004
my $makecmd = set_test_option(" MAKE_CMD" , $i );
3918
4005
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
+
3919
4018
# Load all the options into their mapped variable names
3920
4019
foreach my $opt (keys %option_map ) {
3921
4020
${$option_map {$opt }} = set_test_option($opt , $i );
@@ -3940,13 +4039,9 @@ sub set_test_option {
3940
4039
$start_minconfig = $minconfig ;
3941
4040
}
3942
4041
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 " ;
3950
4045
}
3951
4046
3952
4047
$ENV {" SSH_USER" } = $ssh_user ;
@@ -3955,7 +4050,6 @@ sub set_test_option {
3955
4050
$buildlog = " $tmpdir /buildlog-$machine " ;
3956
4051
$testlog = " $tmpdir /testlog-$machine " ;
3957
4052
$dmesg = " $tmpdir /dmesg-$machine " ;
3958
- $make = " $makecmd O=$outputdir " ;
3959
4053
$output_config = " $outputdir /.config" ;
3960
4054
3961
4055
if (!$buildonly ) {
0 commit comments