aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-01-20 12:39:18 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-20 12:39:18 -0500
commit9451ee2d17e6b4bfbc5871f3c86ea744581b0413 (patch)
treee8ad2d396858e1b4a51d5570bf83aeae7150c34d /tools/testing
parentedde1fb8c41d0db7c8ce17fb32886da2e389b0cc (diff)
parent961d9caceea2d5350a15c17b7d3ffc24c08c9b09 (diff)
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
Diffstat (limited to 'tools/testing')
-rwxr-xr-xtools/testing/ktest/ktest.pl158
-rw-r--r--tools/testing/ktest/sample.conf21
2 files changed, 147 insertions, 32 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 999eab1bc64f..40631569a0fd 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -18,6 +18,7 @@ $| = 1;
18my %opt; 18my %opt;
19my %repeat_tests; 19my %repeat_tests;
20my %repeats; 20my %repeats;
21my %evals;
21 22
22#default opts 23#default opts
23my %default = ( 24my %default = (
@@ -25,6 +26,7 @@ my %default = (
25 "TEST_TYPE" => "build", 26 "TEST_TYPE" => "build",
26 "BUILD_TYPE" => "randconfig", 27 "BUILD_TYPE" => "randconfig",
27 "MAKE_CMD" => "make", 28 "MAKE_CMD" => "make",
29 "CLOSE_CONSOLE_SIGNAL" => "INT",
28 "TIMEOUT" => 120, 30 "TIMEOUT" => 120,
29 "TMP_DIR" => "/tmp/ktest/\${MACHINE}", 31 "TMP_DIR" => "/tmp/ktest/\${MACHINE}",
30 "SLEEP_TIME" => 60, # sleep time between tests 32 "SLEEP_TIME" => 60, # sleep time between tests
@@ -39,6 +41,7 @@ my %default = (
39 "CLEAR_LOG" => 0, 41 "CLEAR_LOG" => 0,
40 "BISECT_MANUAL" => 0, 42 "BISECT_MANUAL" => 0,
41 "BISECT_SKIP" => 1, 43 "BISECT_SKIP" => 1,
44 "BISECT_TRIES" => 1,
42 "MIN_CONFIG_TYPE" => "boot", 45 "MIN_CONFIG_TYPE" => "boot",
43 "SUCCESS_LINE" => "login:", 46 "SUCCESS_LINE" => "login:",
44 "DETECT_TRIPLE_FAULT" => 1, 47 "DETECT_TRIPLE_FAULT" => 1,
@@ -137,6 +140,7 @@ my $bisect_bad_commit = "";
137my $reverse_bisect; 140my $reverse_bisect;
138my $bisect_manual; 141my $bisect_manual;
139my $bisect_skip; 142my $bisect_skip;
143my $bisect_tries;
140my $config_bisect_good; 144my $config_bisect_good;
141my $bisect_ret_good; 145my $bisect_ret_good;
142my $bisect_ret_bad; 146my $bisect_ret_bad;
@@ -163,6 +167,7 @@ my $timeout;
163my $booted_timeout; 167my $booted_timeout;
164my $detect_triplefault; 168my $detect_triplefault;
165my $console; 169my $console;
170my $close_console_signal;
166my $reboot_success_line; 171my $reboot_success_line;
167my $success_line; 172my $success_line;
168my $stop_after_success; 173my $stop_after_success;
@@ -273,6 +278,7 @@ my %option_map = (
273 "IGNORE_ERRORS" => \$ignore_errors, 278 "IGNORE_ERRORS" => \$ignore_errors,
274 "BISECT_MANUAL" => \$bisect_manual, 279 "BISECT_MANUAL" => \$bisect_manual,
275 "BISECT_SKIP" => \$bisect_skip, 280 "BISECT_SKIP" => \$bisect_skip,
281 "BISECT_TRIES" => \$bisect_tries,
276 "CONFIG_BISECT_GOOD" => \$config_bisect_good, 282 "CONFIG_BISECT_GOOD" => \$config_bisect_good,
277 "BISECT_RET_GOOD" => \$bisect_ret_good, 283 "BISECT_RET_GOOD" => \$bisect_ret_good,
278 "BISECT_RET_BAD" => \$bisect_ret_bad, 284 "BISECT_RET_BAD" => \$bisect_ret_bad,
@@ -285,6 +291,7 @@ my %option_map = (
285 "TIMEOUT" => \$timeout, 291 "TIMEOUT" => \$timeout,
286 "BOOTED_TIMEOUT" => \$booted_timeout, 292 "BOOTED_TIMEOUT" => \$booted_timeout,
287 "CONSOLE" => \$console, 293 "CONSOLE" => \$console,
294 "CLOSE_CONSOLE_SIGNAL" => \$close_console_signal,
288 "DETECT_TRIPLE_FAULT" => \$detect_triplefault, 295 "DETECT_TRIPLE_FAULT" => \$detect_triplefault,
289 "SUCCESS_LINE" => \$success_line, 296 "SUCCESS_LINE" => \$success_line,
290 "REBOOT_SUCCESS_LINE" => \$reboot_success_line, 297 "REBOOT_SUCCESS_LINE" => \$reboot_success_line,
@@ -445,6 +452,27 @@ $config_help{"REBOOT_SCRIPT"} = << "EOF"
445EOF 452EOF
446 ; 453 ;
447 454
455sub _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
463sub logit {
464 if (defined($opt{"LOG_FILE"})) {
465 _logit @_;
466 } else {
467 print @_;
468 }
469}
470
471sub doprint {
472 print @_;
473 _logit @_;
474}
475
448sub read_prompt { 476sub read_prompt {
449 my ($cancel, $prompt) = @_; 477 my ($cancel, $prompt) = @_;
450 478
@@ -662,6 +690,22 @@ sub set_value {
662 } 690 }
663} 691}
664 692
693sub 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
665sub set_variable { 709sub set_variable {
666 my ($lvalue, $rvalue) = @_; 710 my ($lvalue, $rvalue) = @_;
667 711
@@ -947,6 +991,20 @@ sub __read_config {
947 $test_case = 1; 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 } elsif (/^\s*([A-Z_\[\]\d]+)\s*=\s*(.*?)\s*$/) { 1008 } elsif (/^\s*([A-Z_\[\]\d]+)\s*=\s*(.*?)\s*$/) {
951 1009
952 next if ($skip); 1010 next if ($skip);
@@ -1126,6 +1184,10 @@ sub __eval_option {
1126 } elsif (defined($opt{$var})) { 1184 } elsif (defined($opt{$var})) {
1127 $o = $opt{$var}; 1185 $o = $opt{$var};
1128 $retval = "$retval$o"; 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 } else { 1191 } else {
1130 $retval = "$retval\$\{$var\}"; 1192 $retval = "$retval\$\{$var\}";
1131 } 1193 }
@@ -1140,6 +1202,33 @@ sub __eval_option {
1140 return $retval; 1202 return $retval;
1141} 1203}
1142 1204
1205sub 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
1143sub eval_option { 1232sub eval_option {
1144 my ($name, $option, $i) = @_; 1233 my ($name, $option, $i) = @_;
1145 1234
@@ -1160,28 +1249,9 @@ sub eval_option {
1160 $option = __eval_option($name, $option, $i); 1249 $option = __eval_option($name, $option, $i);
1161 } 1250 }
1162 1251
1163 return $option; 1252 $option = process_evals($name, $option, $i);
1164}
1165 1253
1166sub _logit { 1254 return $option;
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
1174sub logit {
1175 if (defined($opt{"LOG_FILE"})) {
1176 _logit @_;
1177 } else {
1178 print @_;
1179 }
1180}
1181
1182sub doprint {
1183 print @_;
1184 _logit @_;
1185} 1255}
1186 1256
1187sub run_command; 1257sub run_command;
@@ -1296,7 +1366,7 @@ sub close_console {
1296 my ($fp, $pid) = @_; 1366 my ($fp, $pid) = @_;
1297 1367
1298 doprint "kill child process $pid\n"; 1368 doprint "kill child process $pid\n";
1299 kill 2, $pid; 1369 kill $close_console_signal, $pid;
1300 1370
1301 print "closing!\n"; 1371 print "closing!\n";
1302 close($fp); 1372 close($fp);
@@ -2517,12 +2587,29 @@ sub run_bisect {
2517 $buildtype = "useconfig:$minconfig"; 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 $ret = answer_bisect; 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 # Are we looking for where it worked, not failed? 2613 # Are we looking for where it worked, not failed?
2527 if ($reverse_bisect && $ret >= 0) { 2614 if ($reverse_bisect && $ret >= 0) {
2528 $ret = !$ret; 2615 $ret = !$ret;
@@ -3916,6 +4003,18 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3916 4003
3917 my $makecmd = set_test_option("MAKE_CMD", $i); 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 # Load all the options into their mapped variable names 4018 # Load all the options into their mapped variable names
3920 foreach my $opt (keys %option_map) { 4019 foreach my $opt (keys %option_map) {
3921 ${$option_map{$opt}} = set_test_option($opt, $i); 4020 ${$option_map{$opt}} = set_test_option($opt, $i);
@@ -3940,13 +4039,9 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3940 $start_minconfig = $minconfig; 4039 $start_minconfig = $minconfig;
3941 } 4040 }
3942 4041
3943 chdir $builddir || die "can't change directory to $builddir"; 4042 if (!-d $tmpdir) {
3944 4043 mkpath($tmpdir) or
3945 foreach my $dir ($tmpdir, $outputdir) { 4044 die "can't create $tmpdir";
3946 if (!-d $dir) {
3947 mkpath($dir) or
3948 die "can't create $dir";
3949 }
3950 } 4045 }
3951 4046
3952 $ENV{"SSH_USER"} = $ssh_user; 4047 $ENV{"SSH_USER"} = $ssh_user;
@@ -3955,7 +4050,6 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3955 $buildlog = "$tmpdir/buildlog-$machine"; 4050 $buildlog = "$tmpdir/buildlog-$machine";
3956 $testlog = "$tmpdir/testlog-$machine"; 4051 $testlog = "$tmpdir/testlog-$machine";
3957 $dmesg = "$tmpdir/dmesg-$machine"; 4052 $dmesg = "$tmpdir/dmesg-$machine";
3958 $make = "$makecmd O=$outputdir";
3959 $output_config = "$outputdir/.config"; 4053 $output_config = "$outputdir/.config";
3960 4054
3961 if (!$buildonly) { 4055 if (!$buildonly) {
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index 0a290fb4cd5e..172eec4517fb 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -328,6 +328,13 @@
328# For a virtual machine with guest name "Guest". 328# For a virtual machine with guest name "Guest".
329#CONSOLE = virsh console Guest 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# Required version ending to differentiate the test 338# Required version ending to differentiate the test
332# from other linux builds on the system. 339# from other linux builds on the system.
333#LOCALVERSION = -test 340#LOCALVERSION = -test
@@ -1021,6 +1028,20 @@
1021# BISECT_BAD with BISECT_CHECK = good or 1028# BISECT_BAD with BISECT_CHECK = good or
1022# BISECT_CHECK = bad, respectively. 1029# BISECT_CHECK = bad, respectively.
1023# 1030#
1031# BISECT_TRIES = 5 (optional, default 1)
1032#
1033# For those cases that it takes several tries to hit a bug,
1034# the BISECT_TRIES is useful. It is the number of times the
1035# test is ran before it says the kernel is good. The first failure
1036# will stop trying and mark the current SHA1 as bad.
1037#
1038# Note, as with all race bugs, there's no guarantee that if
1039# it succeeds, it is really a good bisect. But it helps in case
1040# the bug is some what reliable.
1041#
1042# You can set BISECT_TRIES to zero, and all tests will be considered
1043# good, unless you also set BISECT_MANUAL.
1044#
1024# BISECT_RET_GOOD = 0 (optional, default undefined) 1045# BISECT_RET_GOOD = 0 (optional, default undefined)
1025# 1046#
1026# In case the specificed test returns something other than just 1047# In case the specificed test returns something other than just