Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'ktest-v3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest

Pull ktest updates from Steven Rostedt:
"Here's some basic updates to ktest.pl. They include:

- add config to modify the signal to terminate console
- update to documentation (missing some config options)
- add KERNEL_VERSION variable to use for other configs
- add '=~' to let configs eval other configs
- add BISECT_TRIES to run multiple tests per git bisect good"

* tag 'ktest-v3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest:
ktest: Add BISECT_TRIES to bisect test
ktest: Add eval '=~' command to modify variables in config file
ktest: Add special variable ${KERNEL_VERSION}
ktest: Add documentation of CLOSE_CONSOLE_SIGNAL
ktest: Make the signal to terminate the console configurable

+147 -32
+126 -32
tools/testing/ktest/ktest.pl
··· 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 = ( ··· 26 25 "TEST_TYPE" => "build", 27 26 "BUILD_TYPE" => "randconfig", 28 27 "MAKE_CMD" => "make", 28 + "CLOSE_CONSOLE_SIGNAL" => "INT", 29 29 "TIMEOUT" => 120, 30 30 "TMP_DIR" => "/tmp/ktest/\${MACHINE}", 31 31 "SLEEP_TIME" => 60, # sleep time between tests ··· 41 39 "CLEAR_LOG" => 0, 42 40 "BISECT_MANUAL" => 0, 43 41 "BISECT_SKIP" => 1, 42 + "BISECT_TRIES" => 1, 44 43 "MIN_CONFIG_TYPE" => "boot", 45 44 "SUCCESS_LINE" => "login:", 46 45 "DETECT_TRIPLE_FAULT" => 1, ··· 140 137 my $reverse_bisect; 141 138 my $bisect_manual; 142 139 my $bisect_skip; 140 + my $bisect_tries; 143 141 my $config_bisect_good; 144 142 my $bisect_ret_good; 145 143 my $bisect_ret_bad; ··· 167 163 my $booted_timeout; 168 164 my $detect_triplefault; 169 165 my $console; 166 + my $close_console_signal; 170 167 my $reboot_success_line; 171 168 my $success_line; 172 169 my $stop_after_success; ··· 278 273 "IGNORE_ERRORS" => \$ignore_errors, 279 274 "BISECT_MANUAL" => \$bisect_manual, 280 275 "BISECT_SKIP" => \$bisect_skip, 276 + "BISECT_TRIES" => \$bisect_tries, 281 277 "CONFIG_BISECT_GOOD" => \$config_bisect_good, 282 278 "BISECT_RET_GOOD" => \$bisect_ret_good, 283 279 "BISECT_RET_BAD" => \$bisect_ret_bad, ··· 291 285 "TIMEOUT" => \$timeout, 292 286 "BOOTED_TIMEOUT" => \$booted_timeout, 293 287 "CONSOLE" => \$console, 288 + "CLOSE_CONSOLE_SIGNAL" => \$close_console_signal, 294 289 "DETECT_TRIPLE_FAULT" => \$detect_triplefault, 295 290 "SUCCESS_LINE" => \$success_line, 296 291 "REBOOT_SUCCESS_LINE" => \$reboot_success_line, ··· 451 444 (Only mandatory if REBOOT_TYPE = script) 452 445 EOF 453 446 ; 447 + 448 + sub _logit { 449 + if (defined($opt{"LOG_FILE"})) { 450 + open(OUT, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}"; 451 + print OUT @_; 452 + close(OUT); 453 + } 454 + } 455 + 456 + sub logit { 457 + if (defined($opt{"LOG_FILE"})) { 458 + _logit @_; 459 + } else { 460 + print @_; 461 + } 462 + } 463 + 464 + sub doprint { 465 + print @_; 466 + _logit @_; 467 + } 454 468 455 469 sub read_prompt { 456 470 my ($cancel, $prompt) = @_; ··· 688 660 } else { 689 661 $opt{$lvalue} = $prvalue; 690 662 } 663 + } 664 + 665 + sub set_eval { 666 + my ($lvalue, $rvalue, $name) = @_; 667 + 668 + my $prvalue = process_variables($rvalue); 669 + my $arr; 670 + 671 + if (defined($evals{$lvalue})) { 672 + $arr = $evals{$lvalue}; 673 + } else { 674 + $arr = []; 675 + $evals{$lvalue} = $arr; 676 + } 677 + 678 + push @{$arr}, $rvalue; 691 679 } 692 680 693 681 sub set_variable { ··· 991 947 $test_case = 1; 992 948 } 993 949 950 + } elsif (/^\s*([A-Z_\[\]\d]+)\s*=~\s*(.*?)\s*$/) { 951 + 952 + next if ($skip); 953 + 954 + my $lvalue = $1; 955 + my $rvalue = $2; 956 + 957 + if ($default || $lvalue =~ /\[\d+\]$/) { 958 + set_eval($lvalue, $rvalue, $name); 959 + } else { 960 + my $val = "$lvalue\[$test_num\]"; 961 + set_eval($val, $rvalue, $name); 962 + } 963 + 994 964 } elsif (/^\s*([A-Z_\[\]\d]+)\s*=\s*(.*?)\s*$/) { 995 965 996 966 next if ($skip); ··· 1184 1126 } elsif (defined($opt{$var})) { 1185 1127 $o = $opt{$var}; 1186 1128 $retval = "$retval$o"; 1129 + } elsif ($var eq "KERNEL_VERSION" && defined($make)) { 1130 + # special option KERNEL_VERSION uses kernel version 1131 + get_version(); 1132 + $retval = "$retval$version"; 1187 1133 } else { 1188 1134 $retval = "$retval\$\{$var\}"; 1189 1135 } ··· 1200 1138 $retval =~ s/^ //; 1201 1139 1202 1140 return $retval; 1141 + } 1142 + 1143 + sub process_evals { 1144 + my ($name, $option, $i) = @_; 1145 + 1146 + my $option_name = "$name\[$i\]"; 1147 + my $ev; 1148 + 1149 + my $old_option = $option; 1150 + 1151 + if (defined($evals{$option_name})) { 1152 + $ev = $evals{$option_name}; 1153 + } elsif (defined($evals{$name})) { 1154 + $ev = $evals{$name}; 1155 + } else { 1156 + return $option; 1157 + } 1158 + 1159 + for my $e (@{$ev}) { 1160 + eval "\$option =~ $e"; 1161 + } 1162 + 1163 + if ($option ne $old_option) { 1164 + doprint("$name changed from '$old_option' to '$option'\n"); 1165 + } 1166 + 1167 + return $option; 1203 1168 } 1204 1169 1205 1170 sub eval_option { ··· 1249 1160 $option = __eval_option($name, $option, $i); 1250 1161 } 1251 1162 1163 + $option = process_evals($name, $option, $i); 1164 + 1252 1165 return $option; 1253 - } 1254 - 1255 - sub _logit { 1256 - if (defined($opt{"LOG_FILE"})) { 1257 - open(OUT, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}"; 1258 - print OUT @_; 1259 - close(OUT); 1260 - } 1261 - } 1262 - 1263 - sub logit { 1264 - if (defined($opt{"LOG_FILE"})) { 1265 - _logit @_; 1266 - } else { 1267 - print @_; 1268 - } 1269 - } 1270 - 1271 - sub doprint { 1272 - print @_; 1273 - _logit @_; 1274 1166 } 1275 1167 1276 1168 sub run_command; ··· 1366 1296 my ($fp, $pid) = @_; 1367 1297 1368 1298 doprint "kill child process $pid\n"; 1369 - kill 2, $pid; 1299 + kill $close_console_signal, $pid; 1370 1300 1371 1301 print "closing!\n"; 1372 1302 close($fp); ··· 2587 2517 $buildtype = "useconfig:$minconfig"; 2588 2518 } 2589 2519 2590 - my $ret = run_bisect_test $type, $buildtype; 2520 + # If the user sets bisect_tries to less than 1, then no tries 2521 + # is a success. 2522 + my $ret = 1; 2591 2523 2592 - if ($bisect_manual) { 2524 + # Still let the user manually decide that though. 2525 + if ($bisect_tries < 1 && $bisect_manual) { 2593 2526 $ret = answer_bisect; 2527 + } 2528 + 2529 + for (my $i = 0; $i < $bisect_tries; $i++) { 2530 + if ($bisect_tries > 1) { 2531 + my $t = $i + 1; 2532 + doprint("Running bisect trial $t of $bisect_tries:\n"); 2533 + } 2534 + $ret = run_bisect_test $type, $buildtype; 2535 + 2536 + if ($bisect_manual) { 2537 + $ret = answer_bisect; 2538 + } 2539 + 2540 + last if (!$ret); 2594 2541 } 2595 2542 2596 2543 # Are we looking for where it worked, not failed? ··· 4003 3916 4004 3917 my $makecmd = set_test_option("MAKE_CMD", $i); 4005 3918 3919 + $outputdir = set_test_option("OUTPUT_DIR", $i); 3920 + $builddir = set_test_option("BUILD_DIR", $i); 3921 + 3922 + chdir $builddir || die "can't change directory to $builddir"; 3923 + 3924 + if (!-d $outputdir) { 3925 + mkpath($outputdir) or 3926 + die "can't create $outputdir"; 3927 + } 3928 + 3929 + $make = "$makecmd O=$outputdir"; 3930 + 4006 3931 # Load all the options into their mapped variable names 4007 3932 foreach my $opt (keys %option_map) { 4008 3933 ${$option_map{$opt}} = set_test_option($opt, $i); ··· 4039 3940 $start_minconfig = $minconfig; 4040 3941 } 4041 3942 4042 - chdir $builddir || die "can't change directory to $builddir"; 4043 - 4044 - foreach my $dir ($tmpdir, $outputdir) { 4045 - if (!-d $dir) { 4046 - mkpath($dir) or 4047 - die "can't create $dir"; 4048 - } 3943 + if (!-d $tmpdir) { 3944 + mkpath($tmpdir) or 3945 + die "can't create $tmpdir"; 4049 3946 } 4050 3947 4051 3948 $ENV{"SSH_USER"} = $ssh_user; ··· 4050 3955 $buildlog = "$tmpdir/buildlog-$machine"; 4051 3956 $testlog = "$tmpdir/testlog-$machine"; 4052 3957 $dmesg = "$tmpdir/dmesg-$machine"; 4053 - $make = "$makecmd O=$outputdir"; 4054 3958 $output_config = "$outputdir/.config"; 4055 3959 4056 3960 if (!$buildonly) {
+21
tools/testing/ktest/sample.conf
··· 328 328 # For a virtual machine with guest name "Guest". 329 329 #CONSOLE = virsh console Guest 330 330 331 + # Signal to send to kill console. 332 + # ktest.pl will create a child process to monitor the console. 333 + # When the console is finished, ktest will kill the child process 334 + # with this signal. 335 + # (default INT) 336 + #CLOSE_CONSOLE_SIGNAL = HUP 337 + 331 338 # Required version ending to differentiate the test 332 339 # from other linux builds on the system. 333 340 #LOCALVERSION = -test ··· 1027 1020 # You can limit the test to just check BISECT_GOOD or 1028 1021 # BISECT_BAD with BISECT_CHECK = good or 1029 1022 # BISECT_CHECK = bad, respectively. 1023 + # 1024 + # BISECT_TRIES = 5 (optional, default 1) 1025 + # 1026 + # For those cases that it takes several tries to hit a bug, 1027 + # the BISECT_TRIES is useful. It is the number of times the 1028 + # test is ran before it says the kernel is good. The first failure 1029 + # will stop trying and mark the current SHA1 as bad. 1030 + # 1031 + # Note, as with all race bugs, there's no guarantee that if 1032 + # it succeeds, it is really a good bisect. But it helps in case 1033 + # the bug is some what reliable. 1034 + # 1035 + # You can set BISECT_TRIES to zero, and all tests will be considered 1036 + # good, unless you also set BISECT_MANUAL. 1030 1037 # 1031 1038 # BISECT_RET_GOOD = 0 (optional, default undefined) 1032 1039 #