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

+161 -20
+119 -20
tools/testing/ktest/ktest.pl
··· 37 37 $default{"BUILD_OPTIONS"} = ""; 38 38 $default{"BISECT_SLEEP_TIME"} = 60; # sleep time between bisects 39 39 $default{"CLEAR_LOG"} = 0; 40 + $default{"BISECT_MANUAL"} = 0; 41 + $default{"BISECT_SKIP"} = 1; 40 42 $default{"SUCCESS_LINE"} = "login:"; 41 43 $default{"BOOTED_TIMEOUT"} = 1; 42 44 $default{"DIE_ON_FAILURE"} = 1; ··· 47 45 $default{"REBOOT"} = "ssh \$SSH_USER\@\$MACHINE reboot"; 48 46 $default{"STOP_AFTER_SUCCESS"} = 10; 49 47 $default{"STOP_AFTER_FAILURE"} = 60; 48 + $default{"STOP_TEST_AFTER"} = 600; 50 49 $default{"LOCALVERSION"} = "-test"; 51 50 52 51 my $ktest_config; ··· 84 81 my $in_bisect = 0; 85 82 my $bisect_bad = ""; 86 83 my $reverse_bisect; 84 + my $bisect_manual; 85 + my $bisect_skip; 87 86 my $in_patchcheck = 0; 88 87 my $run_test; 89 88 my $redirect; ··· 103 98 my $success_line; 104 99 my $stop_after_success; 105 100 my $stop_after_failure; 101 + my $stop_test_after; 106 102 my $build_target; 107 103 my $target_image; 108 104 my $localversion; ··· 468 462 `$power_off`; 469 463 } 470 464 465 + if (defined($opt{"LOG_FILE"})) { 466 + print " See $opt{LOG_FILE} for more info.\n"; 467 + } 468 + 471 469 die @_, "\n"; 472 470 } 473 471 ··· 770 760 771 761 my $success_start; 772 762 my $failure_start; 763 + my $monitor_start = time; 764 + my $done = 0; 773 765 774 - for (;;) { 766 + while (!$done) { 775 767 776 768 if ($booted) { 777 769 $line = wait_for_input($monitor_fp, $booted_timeout); ··· 808 796 } 809 797 810 798 if ($full_line =~ /call trace:/i) { 811 - if (!$skip_call_trace) { 799 + if (!$bug && !$skip_call_trace) { 812 800 $bug = 1; 813 801 $failure_start = time; 814 802 } ··· 828 816 } 829 817 830 818 if ($full_line =~ /Kernel panic -/) { 819 + $failure_start = time; 831 820 $bug = 1; 832 821 } 833 822 834 823 if ($line =~ /\n/) { 835 824 $full_line = ""; 825 + } 826 + 827 + if ($stop_test_after > 0 && !$booted && !$bug) { 828 + if (time - $monitor_start > $stop_test_after) { 829 + $done = 1; 830 + } 836 831 } 837 832 } 838 833 ··· 944 925 return 1; 945 926 } 946 927 928 + sub make_oldconfig { 929 + my ($defconfig) = @_; 930 + 931 + if (!run_command "$defconfig $make oldnoconfig") { 932 + # Perhaps oldnoconfig doesn't exist in this version of the kernel 933 + # try a yes '' | oldconfig 934 + doprint "oldnoconfig failed, trying yes '' | make oldconfig\n"; 935 + run_command "yes '' | $defconfig $make oldconfig" or 936 + dodie "failed make config oldconfig"; 937 + } 938 + } 939 + 947 940 sub build { 948 941 my ($type) = @_; 949 942 my $defconfig = ""; ··· 1001 970 $defconfig = "KCONFIG_ALLCONFIG=$minconfig"; 1002 971 } 1003 972 1004 - run_command "$defconfig $make $type" or 1005 - dodie "failed make config"; 973 + if ($type eq "oldnoconfig") { 974 + make_oldconfig $defconfig; 975 + } else { 976 + run_command "$defconfig $make $type" or 977 + dodie "failed make config"; 978 + } 1006 979 1007 980 $redirect = "$buildlog"; 1008 981 if (!run_command "$make $build_options") { ··· 1060 1025 doprint "$version\n"; 1061 1026 } 1062 1027 1028 + sub answer_bisect { 1029 + for (;;) { 1030 + doprint "Pass or fail? [p/f]"; 1031 + my $ans = <STDIN>; 1032 + chomp $ans; 1033 + if ($ans eq "p" || $ans eq "P") { 1034 + return 1; 1035 + } elsif ($ans eq "f" || $ans eq "F") { 1036 + return 0; 1037 + } else { 1038 + print "Please answer 'P' or 'F'\n"; 1039 + } 1040 + } 1041 + } 1042 + 1063 1043 sub child_run_test { 1064 1044 my $failed = 0; 1065 1045 ··· 1120 1070 1121 1071 # we are not guaranteed to get a full line 1122 1072 $full_line .= $line; 1073 + doprint $line; 1123 1074 1124 1075 if ($full_line =~ /call trace:/i) { 1125 1076 $bug = 1; ··· 1137 1086 } while (!$child_done && !$bug); 1138 1087 1139 1088 if ($bug) { 1089 + my $failure_start = time; 1090 + my $now; 1091 + do { 1092 + $line = wait_for_input($monitor_fp, 1); 1093 + if (defined($line)) { 1094 + doprint $line; 1095 + } 1096 + $now = time; 1097 + if ($now - $failure_start >= $stop_after_failure) { 1098 + last; 1099 + } 1100 + } while (defined($line)); 1101 + 1140 1102 doprint "Detected kernel crash!\n"; 1141 1103 # kill the child with extreme prejudice 1142 1104 kill 9, $child_pid; ··· 1195 1131 return 1; 1196 1132 } 1197 1133 1198 - # returns 1 on success, 0 on failure 1134 + sub bisect_reboot { 1135 + doprint "Reboot and sleep $bisect_sleep_time seconds\n"; 1136 + reboot; 1137 + start_monitor; 1138 + wait_for_monitor $bisect_sleep_time; 1139 + end_monitor; 1140 + } 1141 + 1142 + # returns 1 on success, 0 on failure, -1 on skip 1199 1143 sub run_bisect_test { 1200 1144 my ($type, $buildtype) = @_; 1201 1145 ··· 1217 1145 build $buildtype or $failed = 1; 1218 1146 1219 1147 if ($type ne "build") { 1148 + if ($failed && $bisect_skip) { 1149 + $in_bisect = 0; 1150 + return -1; 1151 + } 1220 1152 dodie "Failed on build" if $failed; 1221 1153 1222 1154 # Now boot the box ··· 1232 1156 monitor or $failed = 1; 1233 1157 1234 1158 if ($type ne "boot") { 1159 + if ($failed && $bisect_skip) { 1160 + end_monitor; 1161 + bisect_reboot; 1162 + $in_bisect = 0; 1163 + return -1; 1164 + } 1235 1165 dodie "Failed on boot" if $failed; 1236 1166 1237 1167 do_run_test or $failed = 1; ··· 1250 1168 1251 1169 # reboot the box to a good kernel 1252 1170 if ($type ne "build") { 1253 - doprint "Reboot and sleep $bisect_sleep_time seconds\n"; 1254 - reboot; 1255 - start_monitor; 1256 - wait_for_monitor $bisect_sleep_time; 1257 - end_monitor; 1171 + bisect_reboot; 1258 1172 } 1259 1173 } else { 1260 1174 $result = 1; ··· 1271 1193 1272 1194 my $ret = run_bisect_test $type, $buildtype; 1273 1195 1196 + if ($bisect_manual) { 1197 + $ret = answer_bisect; 1198 + } 1274 1199 1275 1200 # Are we looking for where it worked, not failed? 1276 1201 if ($reverse_bisect) { 1277 1202 $ret = !$ret; 1278 1203 } 1279 1204 1280 - if ($ret) { 1205 + if ($ret > 0) { 1281 1206 return "good"; 1282 - } else { 1207 + } elsif ($ret == 0) { 1283 1208 return "bad"; 1209 + } elsif ($bisect_skip) { 1210 + doprint "HIT A BAD COMMIT ... SKIPPING\n"; 1211 + return "skip"; 1284 1212 } 1285 1213 } 1286 1214 ··· 1304 1220 my $type = $opt{"BISECT_TYPE[$i]"}; 1305 1221 my $start = $opt{"BISECT_START[$i]"}; 1306 1222 my $replay = $opt{"BISECT_REPLAY[$i]"}; 1223 + my $start_files = $opt{"BISECT_FILES[$i]"}; 1224 + 1225 + if (defined($start_files)) { 1226 + $start_files = " -- " . $start_files; 1227 + } else { 1228 + $start_files = ""; 1229 + } 1307 1230 1308 1231 # convert to true sha1's 1309 1232 $good = get_sha1($good); ··· 1364 1273 die "Failed to checkout $head"; 1365 1274 } 1366 1275 1367 - run_command "git bisect start" or 1276 + run_command "git bisect start$start_files" or 1368 1277 dodie "could not start bisect"; 1369 1278 1370 1279 run_command "git bisect good $good" or ··· 1481 1390 close(OUT); 1482 1391 1483 1392 # exit; 1484 - run_command "$make oldnoconfig" or 1485 - dodie "failed make config oldconfig"; 1486 - 1393 + make_oldconfig ""; 1487 1394 } 1488 1395 1489 1396 sub compare_configs { ··· 1594 1505 } 1595 1506 1596 1507 $ret = run_config_bisect_test $type; 1597 - 1508 + if ($bisect_manual) { 1509 + $ret = answer_bisect; 1510 + } 1598 1511 if ($ret) { 1599 1512 process_passed %current_config; 1600 1513 return 0; ··· 1627 1536 $half = int($#start_list / 2); 1628 1537 } while ($half > 0); 1629 1538 1630 - # we found a single config, try it again 1539 + # we found a single config, try it again unless we are running manually 1540 + 1541 + if ($bisect_manual) { 1542 + process_failed $start_list[0]; 1543 + return 1; 1544 + } 1545 + 1631 1546 my @tophalf = @start_list[0 .. 0]; 1632 1547 1633 1548 $ret = run_config_bisect_test $type; ··· 1691 1594 close(IN); 1692 1595 1693 1596 # Now run oldconfig with the minconfig (and addconfigs) 1694 - run_command "$defconfig $make oldnoconfig" or 1695 - dodie "failed make config oldconfig"; 1597 + make_oldconfig $defconfig; 1696 1598 1697 1599 # check to see what we lost (or gained) 1698 1600 open (IN, $output_config) ··· 2003 1907 $poweroff_after_halt = set_test_option("POWEROFF_AFTER_HALT", $i); 2004 1908 $sleep_time = set_test_option("SLEEP_TIME", $i); 2005 1909 $bisect_sleep_time = set_test_option("BISECT_SLEEP_TIME", $i); 1910 + $bisect_manual = set_test_option("BISECT_MANUAL", $i); 1911 + $bisect_skip = set_test_option("BISECT_SKIP", $i); 2006 1912 $store_failures = set_test_option("STORE_FAILURES", $i); 2007 1913 $timeout = set_test_option("TIMEOUT", $i); 2008 1914 $booted_timeout = set_test_option("BOOTED_TIMEOUT", $i); ··· 2012 1914 $success_line = set_test_option("SUCCESS_LINE", $i); 2013 1915 $stop_after_success = set_test_option("STOP_AFTER_SUCCESS", $i); 2014 1916 $stop_after_failure = set_test_option("STOP_AFTER_FAILURE", $i); 1917 + $stop_test_after = set_test_option("STOP_TEST_AFTER", $i); 2015 1918 $build_target = set_test_option("BUILD_TARGET", $i); 2016 1919 $ssh_exec = set_test_option("SSH_EXEC", $i); 2017 1920 $scp_to_target = set_test_option("SCP_TO_TARGET", $i);
+42
tools/testing/ktest/sample.conf
··· 306 306 # (default 60) 307 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 317 # Stop testing if a build fails. If set, the script will end if 310 318 # a failure is detected, otherwise it will save off the .config, 311 319 # dmesg and bootlog in a directory called ··· 527 519 # git bisect good, git bisect bad, and running the git bisect replay 528 520 # if the BISECT_REPLAY is set. 529 521 # 522 + # BISECT_SKIP = 1 (optional, default 0) 523 + # 524 + # If BISECT_TYPE is set to test but the build fails, ktest will 525 + # simply fail the test and end their. You could use BISECT_REPLAY 526 + # and BISECT_START to resume after you found a new starting point, 527 + # or you could set BISECT_SKIP to 1. If BISECT_SKIP is set to 1, 528 + # when something other than the BISECT_TYPE fails, ktest.pl will 529 + # run "git bisect skip" and try again. 530 + # 531 + # BISECT_FILES = <path> (optional, default undefined) 532 + # 533 + # To just run the git bisect on a specific path, set BISECT_FILES. 534 + # For example: 535 + # 536 + # BISECT_FILES = arch/x86 kernel/time 537 + # 538 + # Will run the bisect with "git bisect start -- arch/x86 kernel/time" 539 + # 530 540 # BISECT_REVERSE = 1 (optional, default 0) 531 541 # 532 542 # In those strange instances where it was broken forever ··· 553 527 # Set BISECT_BAD to the commit that is known to start working. 554 528 # With BISECT_REVERSE = 1, The test will consider failures as 555 529 # good, and success as bad. 530 + # 531 + # BISECT_MANUAL = 1 (optional, default 0) 532 + # 533 + # In case there's a problem with automating the bisect for 534 + # whatever reason. (Can't reboot, want to inspect each iteration) 535 + # Doing a BISECT_MANUAL will have the test wait for you to 536 + # tell it if the test passed or failed after each iteration. 537 + # This is basicall the same as running git bisect yourself 538 + # but ktest will rebuild and install the kernel for you. 556 539 # 557 540 # BISECT_CHECK = 1 (optional, default 0) 558 541 # ··· 648 613 # 649 614 # CONFIG_BISECT is the config that failed to boot 650 615 # 616 + # If BISECT_MANUAL is set, it will pause between iterations. 617 + # This is useful to use just ktest.pl just for the config bisect. 618 + # If you set it to build, it will run the bisect and you can 619 + # control what happens in between iterations. It will ask you if 620 + # the test succeeded or not and continue the config bisect. 621 + # 651 622 # Example: 652 623 # TEST_START 653 624 # TEST_TYPE = config_bisect 654 625 # CONFIG_BISECT_TYPE = build 655 626 # CONFIG_BISECT = /home/test/�onfig-bad 656 627 # MIN_CONFIG = /home/test/config-min 628 + # BISECT_MANUAL = 1 657 629 #