aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-03-21 17:13:48 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-21 17:13:48 -0400
commitb52307ca144881bf9ef1c2610b3f1911472eb467 (patch)
treed930771ebb591e772446ebc356558f482aa4cc04 /tools
parentafd8c40431cc9e3b468a506cbf9957ffca3466fe (diff)
parent2d01b26a1b14ab248f850d858f2ff3de3ead6d33 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-ktest
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-ktest: ktest: Add STOP_TEST_AFTER to stop the test after a period of time ktest: Monitor kernel while running of user tests ktest: Fix bug where the test would not end after failure ktest: Add BISECT_FILES to run git bisect on paths ktest: Add BISECT_SKIP ktest: Add manual bisect ktest: Handle kernels before make oldnoconfig ktest: Start failure timeout on panic too ktest: Print logfile name on failure
Diffstat (limited to 'tools')
-rwxr-xr-xtools/testing/ktest/ktest.pl139
-rw-r--r--tools/testing/ktest/sample.conf42
2 files changed, 161 insertions, 20 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index ba7c63af6f3b..8ce792ea08e9 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -37,6 +37,8 @@ $default{"POWEROFF_ON_SUCCESS"} = 0;
37$default{"BUILD_OPTIONS"} = ""; 37$default{"BUILD_OPTIONS"} = "";
38$default{"BISECT_SLEEP_TIME"} = 60; # sleep time between bisects 38$default{"BISECT_SLEEP_TIME"} = 60; # sleep time between bisects
39$default{"CLEAR_LOG"} = 0; 39$default{"CLEAR_LOG"} = 0;
40$default{"BISECT_MANUAL"} = 0;
41$default{"BISECT_SKIP"} = 1;
40$default{"SUCCESS_LINE"} = "login:"; 42$default{"SUCCESS_LINE"} = "login:";
41$default{"BOOTED_TIMEOUT"} = 1; 43$default{"BOOTED_TIMEOUT"} = 1;
42$default{"DIE_ON_FAILURE"} = 1; 44$default{"DIE_ON_FAILURE"} = 1;
@@ -45,6 +47,7 @@ $default{"SCP_TO_TARGET"} = "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE";
45$default{"REBOOT"} = "ssh \$SSH_USER\@\$MACHINE reboot"; 47$default{"REBOOT"} = "ssh \$SSH_USER\@\$MACHINE reboot";
46$default{"STOP_AFTER_SUCCESS"} = 10; 48$default{"STOP_AFTER_SUCCESS"} = 10;
47$default{"STOP_AFTER_FAILURE"} = 60; 49$default{"STOP_AFTER_FAILURE"} = 60;
50$default{"STOP_TEST_AFTER"} = 600;
48$default{"LOCALVERSION"} = "-test"; 51$default{"LOCALVERSION"} = "-test";
49 52
50my $ktest_config; 53my $ktest_config;
@@ -81,6 +84,8 @@ my $addconfig;
81my $in_bisect = 0; 84my $in_bisect = 0;
82my $bisect_bad = ""; 85my $bisect_bad = "";
83my $reverse_bisect; 86my $reverse_bisect;
87my $bisect_manual;
88my $bisect_skip;
84my $in_patchcheck = 0; 89my $in_patchcheck = 0;
85my $run_test; 90my $run_test;
86my $redirect; 91my $redirect;
@@ -98,6 +103,7 @@ my $console;
98my $success_line; 103my $success_line;
99my $stop_after_success; 104my $stop_after_success;
100my $stop_after_failure; 105my $stop_after_failure;
106my $stop_test_after;
101my $build_target; 107my $build_target;
102my $target_image; 108my $target_image;
103my $localversion; 109my $localversion;
@@ -462,6 +468,10 @@ sub dodie {
462 `$power_off`; 468 `$power_off`;
463 } 469 }
464 470
471 if (defined($opt{"LOG_FILE"})) {
472 print " See $opt{LOG_FILE} for more info.\n";
473 }
474
465 die @_, "\n"; 475 die @_, "\n";
466} 476}
467 477
@@ -760,8 +770,10 @@ sub monitor {
760 770
761 my $success_start; 771 my $success_start;
762 my $failure_start; 772 my $failure_start;
773 my $monitor_start = time;
774 my $done = 0;
763 775
764 for (;;) { 776 while (!$done) {
765 777
766 if ($booted) { 778 if ($booted) {
767 $line = wait_for_input($monitor_fp, $booted_timeout); 779 $line = wait_for_input($monitor_fp, $booted_timeout);
@@ -796,7 +808,7 @@ sub monitor {
796 } 808 }
797 809
798 if ($full_line =~ /call trace:/i) { 810 if ($full_line =~ /call trace:/i) {
799 if (!$skip_call_trace) { 811 if (!$bug && !$skip_call_trace) {
800 $bug = 1; 812 $bug = 1;
801 $failure_start = time; 813 $failure_start = time;
802 } 814 }
@@ -816,12 +828,19 @@ sub monitor {
816 } 828 }
817 829
818 if ($full_line =~ /Kernel panic -/) { 830 if ($full_line =~ /Kernel panic -/) {
831 $failure_start = time;
819 $bug = 1; 832 $bug = 1;
820 } 833 }
821 834
822 if ($line =~ /\n/) { 835 if ($line =~ /\n/) {
823 $full_line = ""; 836 $full_line = "";
824 } 837 }
838
839 if ($stop_test_after > 0 && !$booted && !$bug) {
840 if (time - $monitor_start > $stop_test_after) {
841 $done = 1;
842 }
843 }
825 } 844 }
826 845
827 close(DMESG); 846 close(DMESG);
@@ -925,6 +944,18 @@ sub check_buildlog {
925 return 1; 944 return 1;
926} 945}
927 946
947sub make_oldconfig {
948 my ($defconfig) = @_;
949
950 if (!run_command "$defconfig $make oldnoconfig") {
951 # Perhaps oldnoconfig doesn't exist in this version of the kernel
952 # try a yes '' | oldconfig
953 doprint "oldnoconfig failed, trying yes '' | make oldconfig\n";
954 run_command "yes '' | $defconfig $make oldconfig" or
955 dodie "failed make config oldconfig";
956 }
957}
958
928sub build { 959sub build {
929 my ($type) = @_; 960 my ($type) = @_;
930 my $defconfig = ""; 961 my $defconfig = "";
@@ -970,8 +1001,12 @@ sub build {
970 $defconfig = "KCONFIG_ALLCONFIG=$minconfig"; 1001 $defconfig = "KCONFIG_ALLCONFIG=$minconfig";
971 } 1002 }
972 1003
973 run_command "$defconfig $make $type" or 1004 if ($type eq "oldnoconfig") {
974 dodie "failed make config"; 1005 make_oldconfig $defconfig;
1006 } else {
1007 run_command "$defconfig $make $type" or
1008 dodie "failed make config";
1009 }
975 1010
976 $redirect = "$buildlog"; 1011 $redirect = "$buildlog";
977 if (!run_command "$make $build_options") { 1012 if (!run_command "$make $build_options") {
@@ -1025,6 +1060,21 @@ sub get_version {
1025 doprint "$version\n"; 1060 doprint "$version\n";
1026} 1061}
1027 1062
1063sub answer_bisect {
1064 for (;;) {
1065 doprint "Pass or fail? [p/f]";
1066 my $ans = <STDIN>;
1067 chomp $ans;
1068 if ($ans eq "p" || $ans eq "P") {
1069 return 1;
1070 } elsif ($ans eq "f" || $ans eq "F") {
1071 return 0;
1072 } else {
1073 print "Please answer 'P' or 'F'\n";
1074 }
1075 }
1076}
1077
1028sub child_run_test { 1078sub child_run_test {
1029 my $failed = 0; 1079 my $failed = 0;
1030 1080
@@ -1070,6 +1120,7 @@ sub do_run_test {
1070 1120
1071 # we are not guaranteed to get a full line 1121 # we are not guaranteed to get a full line
1072 $full_line .= $line; 1122 $full_line .= $line;
1123 doprint $line;
1073 1124
1074 if ($full_line =~ /call trace:/i) { 1125 if ($full_line =~ /call trace:/i) {
1075 $bug = 1; 1126 $bug = 1;
@@ -1086,6 +1137,19 @@ sub do_run_test {
1086 } while (!$child_done && !$bug); 1137 } while (!$child_done && !$bug);
1087 1138
1088 if ($bug) { 1139 if ($bug) {
1140 my $failure_start = time;
1141 my $now;
1142 do {
1143 $line = wait_for_input($monitor_fp, 1);
1144 if (defined($line)) {
1145 doprint $line;
1146 }
1147 $now = time;
1148 if ($now - $failure_start >= $stop_after_failure) {
1149 last;
1150 }
1151 } while (defined($line));
1152
1089 doprint "Detected kernel crash!\n"; 1153 doprint "Detected kernel crash!\n";
1090 # kill the child with extreme prejudice 1154 # kill the child with extreme prejudice
1091 kill 9, $child_pid; 1155 kill 9, $child_pid;
@@ -1131,7 +1195,15 @@ sub run_git_bisect {
1131 return 1; 1195 return 1;
1132} 1196}
1133 1197
1134# returns 1 on success, 0 on failure 1198sub bisect_reboot {
1199 doprint "Reboot and sleep $bisect_sleep_time seconds\n";
1200 reboot;
1201 start_monitor;
1202 wait_for_monitor $bisect_sleep_time;
1203 end_monitor;
1204}
1205
1206# returns 1 on success, 0 on failure, -1 on skip
1135sub run_bisect_test { 1207sub run_bisect_test {
1136 my ($type, $buildtype) = @_; 1208 my ($type, $buildtype) = @_;
1137 1209
@@ -1145,6 +1217,10 @@ sub run_bisect_test {
1145 build $buildtype or $failed = 1; 1217 build $buildtype or $failed = 1;
1146 1218
1147 if ($type ne "build") { 1219 if ($type ne "build") {
1220 if ($failed && $bisect_skip) {
1221 $in_bisect = 0;
1222 return -1;
1223 }
1148 dodie "Failed on build" if $failed; 1224 dodie "Failed on build" if $failed;
1149 1225
1150 # Now boot the box 1226 # Now boot the box
@@ -1156,6 +1232,12 @@ sub run_bisect_test {
1156 monitor or $failed = 1; 1232 monitor or $failed = 1;
1157 1233
1158 if ($type ne "boot") { 1234 if ($type ne "boot") {
1235 if ($failed && $bisect_skip) {
1236 end_monitor;
1237 bisect_reboot;
1238 $in_bisect = 0;
1239 return -1;
1240 }
1159 dodie "Failed on boot" if $failed; 1241 dodie "Failed on boot" if $failed;
1160 1242
1161 do_run_test or $failed = 1; 1243 do_run_test or $failed = 1;
@@ -1168,11 +1250,7 @@ sub run_bisect_test {
1168 1250
1169 # reboot the box to a good kernel 1251 # reboot the box to a good kernel
1170 if ($type ne "build") { 1252 if ($type ne "build") {
1171 doprint "Reboot and sleep $bisect_sleep_time seconds\n"; 1253 bisect_reboot;
1172 reboot;
1173 start_monitor;
1174 wait_for_monitor $bisect_sleep_time;
1175 end_monitor;
1176 } 1254 }
1177 } else { 1255 } else {
1178 $result = 1; 1256 $result = 1;
@@ -1193,16 +1271,22 @@ sub run_bisect {
1193 1271
1194 my $ret = run_bisect_test $type, $buildtype; 1272 my $ret = run_bisect_test $type, $buildtype;
1195 1273
1274 if ($bisect_manual) {
1275 $ret = answer_bisect;
1276 }
1196 1277
1197 # Are we looking for where it worked, not failed? 1278 # Are we looking for where it worked, not failed?
1198 if ($reverse_bisect) { 1279 if ($reverse_bisect) {
1199 $ret = !$ret; 1280 $ret = !$ret;
1200 } 1281 }
1201 1282
1202 if ($ret) { 1283 if ($ret > 0) {
1203 return "good"; 1284 return "good";
1204 } else { 1285 } elsif ($ret == 0) {
1205 return "bad"; 1286 return "bad";
1287 } elsif ($bisect_skip) {
1288 doprint "HIT A BAD COMMIT ... SKIPPING\n";
1289 return "skip";
1206 } 1290 }
1207} 1291}
1208 1292
@@ -1220,6 +1304,13 @@ sub bisect {
1220 my $type = $opt{"BISECT_TYPE[$i]"}; 1304 my $type = $opt{"BISECT_TYPE[$i]"};
1221 my $start = $opt{"BISECT_START[$i]"}; 1305 my $start = $opt{"BISECT_START[$i]"};
1222 my $replay = $opt{"BISECT_REPLAY[$i]"}; 1306 my $replay = $opt{"BISECT_REPLAY[$i]"};
1307 my $start_files = $opt{"BISECT_FILES[$i]"};
1308
1309 if (defined($start_files)) {
1310 $start_files = " -- " . $start_files;
1311 } else {
1312 $start_files = "";
1313 }
1223 1314
1224 # convert to true sha1's 1315 # convert to true sha1's
1225 $good = get_sha1($good); 1316 $good = get_sha1($good);
@@ -1273,7 +1364,7 @@ sub bisect {
1273 die "Failed to checkout $head"; 1364 die "Failed to checkout $head";
1274 } 1365 }
1275 1366
1276 run_command "git bisect start" or 1367 run_command "git bisect start$start_files" or
1277 dodie "could not start bisect"; 1368 dodie "could not start bisect";
1278 1369
1279 run_command "git bisect good $good" or 1370 run_command "git bisect good $good" or
@@ -1390,9 +1481,7 @@ sub create_config {
1390 close(OUT); 1481 close(OUT);
1391 1482
1392# exit; 1483# exit;
1393 run_command "$make oldnoconfig" or 1484 make_oldconfig "";
1394 dodie "failed make config oldconfig";
1395
1396} 1485}
1397 1486
1398sub compare_configs { 1487sub compare_configs {
@@ -1505,7 +1594,9 @@ sub run_config_bisect {
1505 } 1594 }
1506 1595
1507 $ret = run_config_bisect_test $type; 1596 $ret = run_config_bisect_test $type;
1508 1597 if ($bisect_manual) {
1598 $ret = answer_bisect;
1599 }
1509 if ($ret) { 1600 if ($ret) {
1510 process_passed %current_config; 1601 process_passed %current_config;
1511 return 0; 1602 return 0;
@@ -1536,7 +1627,13 @@ sub run_config_bisect {
1536 $half = int($#start_list / 2); 1627 $half = int($#start_list / 2);
1537 } while ($half > 0); 1628 } while ($half > 0);
1538 1629
1539 # we found a single config, try it again 1630 # we found a single config, try it again unless we are running manually
1631
1632 if ($bisect_manual) {
1633 process_failed $start_list[0];
1634 return 1;
1635 }
1636
1540 my @tophalf = @start_list[0 .. 0]; 1637 my @tophalf = @start_list[0 .. 0];
1541 1638
1542 $ret = run_config_bisect_test $type; 1639 $ret = run_config_bisect_test $type;
@@ -1594,8 +1691,7 @@ sub config_bisect {
1594 close(IN); 1691 close(IN);
1595 1692
1596 # Now run oldconfig with the minconfig (and addconfigs) 1693 # Now run oldconfig with the minconfig (and addconfigs)
1597 run_command "$defconfig $make oldnoconfig" or 1694 make_oldconfig $defconfig;
1598 dodie "failed make config oldconfig";
1599 1695
1600 # check to see what we lost (or gained) 1696 # check to see what we lost (or gained)
1601 open (IN, $output_config) 1697 open (IN, $output_config)
@@ -1907,6 +2003,8 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
1907 $poweroff_after_halt = set_test_option("POWEROFF_AFTER_HALT", $i); 2003 $poweroff_after_halt = set_test_option("POWEROFF_AFTER_HALT", $i);
1908 $sleep_time = set_test_option("SLEEP_TIME", $i); 2004 $sleep_time = set_test_option("SLEEP_TIME", $i);
1909 $bisect_sleep_time = set_test_option("BISECT_SLEEP_TIME", $i); 2005 $bisect_sleep_time = set_test_option("BISECT_SLEEP_TIME", $i);
2006 $bisect_manual = set_test_option("BISECT_MANUAL", $i);
2007 $bisect_skip = set_test_option("BISECT_SKIP", $i);
1910 $store_failures = set_test_option("STORE_FAILURES", $i); 2008 $store_failures = set_test_option("STORE_FAILURES", $i);
1911 $timeout = set_test_option("TIMEOUT", $i); 2009 $timeout = set_test_option("TIMEOUT", $i);
1912 $booted_timeout = set_test_option("BOOTED_TIMEOUT", $i); 2010 $booted_timeout = set_test_option("BOOTED_TIMEOUT", $i);
@@ -1914,6 +2012,7 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
1914 $success_line = set_test_option("SUCCESS_LINE", $i); 2012 $success_line = set_test_option("SUCCESS_LINE", $i);
1915 $stop_after_success = set_test_option("STOP_AFTER_SUCCESS", $i); 2013 $stop_after_success = set_test_option("STOP_AFTER_SUCCESS", $i);
1916 $stop_after_failure = set_test_option("STOP_AFTER_FAILURE", $i); 2014 $stop_after_failure = set_test_option("STOP_AFTER_FAILURE", $i);
2015 $stop_test_after = set_test_option("STOP_TEST_AFTER", $i);
1917 $build_target = set_test_option("BUILD_TARGET", $i); 2016 $build_target = set_test_option("BUILD_TARGET", $i);
1918 $ssh_exec = set_test_option("SSH_EXEC", $i); 2017 $ssh_exec = set_test_option("SSH_EXEC", $i);
1919 $scp_to_target = set_test_option("SCP_TO_TARGET", $i); 2018 $scp_to_target = set_test_option("SCP_TO_TARGET", $i);
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index 3408c594b2de..4c5d6bd74a02 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -306,6 +306,14 @@
306# (default 60) 306# (default 60)
307#STOP_AFTER_FAILURE = 60 307#STOP_AFTER_FAILURE = 60
308 308
309# In case the console constantly fills the screen, having
310# a specified time to stop the test if it never succeeds nor fails
311# is recommended.
312# Note: this is ignored if a success or failure is detected.
313# (in seconds)
314# (default 600, -1 is to never stop)
315#STOP_TEST_AFTER = 600
316
309# Stop testing if a build fails. If set, the script will end if 317# Stop testing if a build fails. If set, the script will end if
310# a failure is detected, otherwise it will save off the .config, 318# a failure is detected, otherwise it will save off the .config,
311# dmesg and bootlog in a directory called 319# dmesg and bootlog in a directory called
@@ -519,6 +527,24 @@
519# git bisect good, git bisect bad, and running the git bisect replay 527# git bisect good, git bisect bad, and running the git bisect replay
520# if the BISECT_REPLAY is set. 528# if the BISECT_REPLAY is set.
521# 529#
530# BISECT_SKIP = 1 (optional, default 0)
531#
532# If BISECT_TYPE is set to test but the build fails, ktest will
533# simply fail the test and end their. You could use BISECT_REPLAY
534# and BISECT_START to resume after you found a new starting point,
535# or you could set BISECT_SKIP to 1. If BISECT_SKIP is set to 1,
536# when something other than the BISECT_TYPE fails, ktest.pl will
537# run "git bisect skip" and try again.
538#
539# BISECT_FILES = <path> (optional, default undefined)
540#
541# To just run the git bisect on a specific path, set BISECT_FILES.
542# For example:
543#
544# BISECT_FILES = arch/x86 kernel/time
545#
546# Will run the bisect with "git bisect start -- arch/x86 kernel/time"
547#
522# BISECT_REVERSE = 1 (optional, default 0) 548# BISECT_REVERSE = 1 (optional, default 0)
523# 549#
524# In those strange instances where it was broken forever 550# In those strange instances where it was broken forever
@@ -528,6 +554,15 @@
528# With BISECT_REVERSE = 1, The test will consider failures as 554# With BISECT_REVERSE = 1, The test will consider failures as
529# good, and success as bad. 555# good, and success as bad.
530# 556#
557# BISECT_MANUAL = 1 (optional, default 0)
558#
559# In case there's a problem with automating the bisect for
560# whatever reason. (Can't reboot, want to inspect each iteration)
561# Doing a BISECT_MANUAL will have the test wait for you to
562# tell it if the test passed or failed after each iteration.
563# This is basicall the same as running git bisect yourself
564# but ktest will rebuild and install the kernel for you.
565#
531# BISECT_CHECK = 1 (optional, default 0) 566# BISECT_CHECK = 1 (optional, default 0)
532# 567#
533# Just to be sure the good is good and bad is bad, setting 568# Just to be sure the good is good and bad is bad, setting
@@ -613,10 +648,17 @@
613# 648#
614# CONFIG_BISECT is the config that failed to boot 649# CONFIG_BISECT is the config that failed to boot
615# 650#
651# If BISECT_MANUAL is set, it will pause between iterations.
652# This is useful to use just ktest.pl just for the config bisect.
653# If you set it to build, it will run the bisect and you can
654# control what happens in between iterations. It will ask you if
655# the test succeeded or not and continue the config bisect.
656#
616# Example: 657# Example:
617# TEST_START 658# TEST_START
618# TEST_TYPE = config_bisect 659# TEST_TYPE = config_bisect
619# CONFIG_BISECT_TYPE = build 660# CONFIG_BISECT_TYPE = build
620# CONFIG_BISECT = /home/test/˘onfig-bad 661# CONFIG_BISECT = /home/test/˘onfig-bad
621# MIN_CONFIG = /home/test/config-min 662# MIN_CONFIG = /home/test/config-min
663# BISECT_MANUAL = 1
622# 664#