aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-08-04 14:48:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-04 14:48:26 -0400
commitc7ed326fa7cafb83ced5a8b02517a61672fe9e90 (patch)
treecc5420796d61b205c5cc908a8e363222b5beb4a7
parente4ca4308c055c7bfb82f6756297346760d697953 (diff)
parent4c16b1d6d5e0ca0612de65596a3d1ead8a3372fb (diff)
Merge tag 'ktest-v3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest
Pull config-bisect changes from Steven Rostedt: "The big change here is the rewrite of config-bisect. The old way never worked properly as it assumed the bad config was a subset of the good config, and just found the config that would break the build. The new way does a diff of the bad config verses the good config and makes the similar until it finds that one config works and the other does not and reports the config that makes that difference. The two configs do not need to be related. It is much more useful now: * tag 'ktest-v3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest: ktest: Update documentation on config_bisect ktest: Add the config bisect manual back ktest: Remove unused functions ktest: Put back in the CONFIG_BISECT_CHECK ktest: Rewrite the config-bisect to actually work ktest: Some cleanup for improving readability ktest: add 2nd parameter of run_command() to set the redirect target file
-rwxr-xr-xtools/testing/ktest/ktest.pl581
-rw-r--r--tools/testing/ktest/sample.conf65
2 files changed, 297 insertions, 349 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 40631569a0fd..55ab700f6ba5 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -72,7 +72,7 @@ my %default = (
72 "IGNORE_UNUSED" => 0, 72 "IGNORE_UNUSED" => 0,
73); 73);
74 74
75my $ktest_config; 75my $ktest_config = "ktest.conf";
76my $version; 76my $version;
77my $have_version = 0; 77my $have_version = 0;
78my $machine; 78my $machine;
@@ -149,7 +149,6 @@ my $bisect_ret_abort;
149my $bisect_ret_default; 149my $bisect_ret_default;
150my $in_patchcheck = 0; 150my $in_patchcheck = 0;
151my $run_test; 151my $run_test;
152my $redirect;
153my $buildlog; 152my $buildlog;
154my $testlog; 153my $testlog;
155my $dmesg; 154my $dmesg;
@@ -522,7 +521,7 @@ sub read_ync {
522 return read_prompt 1, $prompt; 521 return read_prompt 1, $prompt;
523} 522}
524 523
525sub get_ktest_config { 524sub get_mandatory_config {
526 my ($config) = @_; 525 my ($config) = @_;
527 my $ans; 526 my $ans;
528 527
@@ -553,29 +552,29 @@ sub get_ktest_config {
553 } 552 }
554} 553}
555 554
556sub get_ktest_configs { 555sub get_mandatory_configs {
557 get_ktest_config("MACHINE"); 556 get_mandatory_config("MACHINE");
558 get_ktest_config("BUILD_DIR"); 557 get_mandatory_config("BUILD_DIR");
559 get_ktest_config("OUTPUT_DIR"); 558 get_mandatory_config("OUTPUT_DIR");
560 559
561 if ($newconfig) { 560 if ($newconfig) {
562 get_ktest_config("BUILD_OPTIONS"); 561 get_mandatory_config("BUILD_OPTIONS");
563 } 562 }
564 563
565 # options required for other than just building a kernel 564 # options required for other than just building a kernel
566 if (!$buildonly) { 565 if (!$buildonly) {
567 get_ktest_config("POWER_CYCLE"); 566 get_mandatory_config("POWER_CYCLE");
568 get_ktest_config("CONSOLE"); 567 get_mandatory_config("CONSOLE");
569 } 568 }
570 569
571 # options required for install and more 570 # options required for install and more
572 if ($buildonly != 1) { 571 if ($buildonly != 1) {
573 get_ktest_config("SSH_USER"); 572 get_mandatory_config("SSH_USER");
574 get_ktest_config("BUILD_TARGET"); 573 get_mandatory_config("BUILD_TARGET");
575 get_ktest_config("TARGET_IMAGE"); 574 get_mandatory_config("TARGET_IMAGE");
576 } 575 }
577 576
578 get_ktest_config("LOCALVERSION"); 577 get_mandatory_config("LOCALVERSION");
579 578
580 return if ($buildonly); 579 return if ($buildonly);
581 580
@@ -583,7 +582,7 @@ sub get_ktest_configs {
583 582
584 if (!defined($rtype)) { 583 if (!defined($rtype)) {
585 if (!defined($opt{"GRUB_MENU"})) { 584 if (!defined($opt{"GRUB_MENU"})) {
586 get_ktest_config("REBOOT_TYPE"); 585 get_mandatory_config("REBOOT_TYPE");
587 $rtype = $entered_configs{"REBOOT_TYPE"}; 586 $rtype = $entered_configs{"REBOOT_TYPE"};
588 } else { 587 } else {
589 $rtype = "grub"; 588 $rtype = "grub";
@@ -591,16 +590,16 @@ sub get_ktest_configs {
591 } 590 }
592 591
593 if ($rtype eq "grub") { 592 if ($rtype eq "grub") {
594 get_ktest_config("GRUB_MENU"); 593 get_mandatory_config("GRUB_MENU");
595 } 594 }
596 595
597 if ($rtype eq "grub2") { 596 if ($rtype eq "grub2") {
598 get_ktest_config("GRUB_MENU"); 597 get_mandatory_config("GRUB_MENU");
599 get_ktest_config("GRUB_FILE"); 598 get_mandatory_config("GRUB_FILE");
600 } 599 }
601 600
602 if ($rtype eq "syslinux") { 601 if ($rtype eq "syslinux") {
603 get_ktest_config("SYSLINUX_LABEL"); 602 get_mandatory_config("SYSLINUX_LABEL");
604 } 603 }
605} 604}
606 605
@@ -1090,7 +1089,7 @@ sub read_config {
1090 $test_case = __read_config $config, \$test_num; 1089 $test_case = __read_config $config, \$test_num;
1091 1090
1092 # make sure we have all mandatory configs 1091 # make sure we have all mandatory configs
1093 get_ktest_configs; 1092 get_mandatory_configs;
1094 1093
1095 # was a test specified? 1094 # was a test specified?
1096 if (!$test_case) { 1095 if (!$test_case) {
@@ -1529,7 +1528,7 @@ sub fail {
1529} 1528}
1530 1529
1531sub run_command { 1530sub run_command {
1532 my ($command) = @_; 1531 my ($command, $redirect) = @_;
1533 my $dolog = 0; 1532 my $dolog = 0;
1534 my $dord = 0; 1533 my $dord = 0;
1535 my $pid; 1534 my $pid;
@@ -2265,9 +2264,7 @@ sub build {
2265 # Run old config regardless, to enforce min configurations 2264 # Run old config regardless, to enforce min configurations
2266 make_oldconfig; 2265 make_oldconfig;
2267 2266
2268 $redirect = "$buildlog"; 2267 my $build_ret = run_command "$make $build_options", $buildlog;
2269 my $build_ret = run_command "$make $build_options";
2270 undef $redirect;
2271 2268
2272 if (defined($post_build)) { 2269 if (defined($post_build)) {
2273 # Because a post build may change the kernel version 2270 # Because a post build may change the kernel version
@@ -2360,9 +2357,7 @@ sub child_run_test {
2360 $poweroff_on_error = 0; 2357 $poweroff_on_error = 0;
2361 $die_on_failure = 1; 2358 $die_on_failure = 1;
2362 2359
2363 $redirect = "$testlog"; 2360 run_command $run_test, $testlog or $failed = 1;
2364 run_command $run_test or $failed = 1;
2365 undef $redirect;
2366 2361
2367 exit $failed; 2362 exit $failed;
2368} 2363}
@@ -2789,12 +2784,17 @@ my %dependency;
2789sub assign_configs { 2784sub assign_configs {
2790 my ($hash, $config) = @_; 2785 my ($hash, $config) = @_;
2791 2786
2787 doprint "Reading configs from $config\n";
2788
2792 open (IN, $config) 2789 open (IN, $config)
2793 or dodie "Failed to read $config"; 2790 or dodie "Failed to read $config";
2794 2791
2795 while (<IN>) { 2792 while (<IN>) {
2793 chomp;
2796 if (/^((CONFIG\S*)=.*)/) { 2794 if (/^((CONFIG\S*)=.*)/) {
2797 ${$hash}{$2} = $1; 2795 ${$hash}{$2} = $1;
2796 } elsif (/^(# (CONFIG\S*) is not set)/) {
2797 ${$hash}{$2} = $1;
2798 } 2798 }
2799 } 2799 }
2800 2800
@@ -2807,27 +2807,6 @@ sub process_config_ignore {
2807 assign_configs \%config_ignore, $config; 2807 assign_configs \%config_ignore, $config;
2808} 2808}
2809 2809
2810sub read_current_config {
2811 my ($config_ref) = @_;
2812
2813 %{$config_ref} = ();
2814 undef %{$config_ref};
2815
2816 my @key = keys %{$config_ref};
2817 if ($#key >= 0) {
2818 print "did not delete!\n";
2819 exit;
2820 }
2821 open (IN, "$output_config");
2822
2823 while (<IN>) {
2824 if (/^(CONFIG\S+)=(.*)/) {
2825 ${$config_ref}{$1} = $2;
2826 }
2827 }
2828 close(IN);
2829}
2830
2831sub get_dependencies { 2810sub get_dependencies {
2832 my ($config) = @_; 2811 my ($config) = @_;
2833 2812
@@ -2846,53 +2825,97 @@ sub get_dependencies {
2846 return @deps; 2825 return @deps;
2847} 2826}
2848 2827
2828sub save_config {
2829 my ($pc, $file) = @_;
2830
2831 my %configs = %{$pc};
2832
2833 doprint "Saving configs into $file\n";
2834
2835 open(OUT, ">$file") or dodie "Can not write to $file";
2836
2837 foreach my $config (keys %configs) {
2838 print OUT "$configs{$config}\n";
2839 }
2840 close(OUT);
2841}
2842
2849sub create_config { 2843sub create_config {
2850 my @configs = @_; 2844 my ($name, $pc) = @_;
2851 2845
2852 open(OUT, ">$output_config") or dodie "Can not write to $output_config"; 2846 doprint "Creating old config from $name configs\n";
2853 2847
2854 foreach my $config (@configs) { 2848 save_config $pc, $output_config;
2855 print OUT "$config_set{$config}\n"; 2849
2856 my @deps = get_dependencies $config; 2850 make_oldconfig;
2857 foreach my $dep (@deps) { 2851}
2858 print OUT "$config_set{$dep}\n"; 2852
2853# compare two config hashes, and return configs with different vals.
2854# It returns B's config values, but you can use A to see what A was.
2855sub diff_config_vals {
2856 my ($pa, $pb) = @_;
2857
2858 # crappy Perl way to pass in hashes.
2859 my %a = %{$pa};
2860 my %b = %{$pb};
2861
2862 my %ret;
2863
2864 foreach my $item (keys %a) {
2865 if (defined($b{$item}) && $b{$item} ne $a{$item}) {
2866 $ret{$item} = $b{$item};
2859 } 2867 }
2860 } 2868 }
2861 2869
2862 # turn off configs to keep off 2870 return %ret;
2863 foreach my $config (keys %config_off) { 2871}
2864 print OUT "# $config is not set\n";
2865 }
2866 2872
2867 # turn off configs that should be off for now 2873# compare two config hashes and return the configs in B but not A
2868 foreach my $config (@config_off_tmp) { 2874sub diff_configs {
2869 print OUT "# $config is not set\n"; 2875 my ($pa, $pb) = @_;
2870 } 2876
2877 my %ret;
2878
2879 # crappy Perl way to pass in hashes.
2880 my %a = %{$pa};
2881 my %b = %{$pb};
2871 2882
2872 foreach my $config (keys %config_ignore) { 2883 foreach my $item (keys %b) {
2873 print OUT "$config_ignore{$config}\n"; 2884 if (!defined($a{$item})) {
2885 $ret{$item} = $b{$item};
2886 }
2874 } 2887 }
2875 close(OUT);
2876 2888
2877 make_oldconfig; 2889 return %ret;
2878} 2890}
2879 2891
2892# return if two configs are equal or not
2893# 0 is equal +1 b has something a does not
2894# +1 if a and b have a different item.
2895# -1 if a has something b does not
2880sub compare_configs { 2896sub compare_configs {
2881 my (%a, %b) = @_; 2897 my ($pa, $pb) = @_;
2882 2898
2883 foreach my $item (keys %a) { 2899 my %ret;
2884 if (!defined($b{$item})) { 2900
2885 print "diff $item\n"; 2901 # crappy Perl way to pass in hashes.
2902 my %a = %{$pa};
2903 my %b = %{$pb};
2904
2905 foreach my $item (keys %b) {
2906 if (!defined($a{$item})) {
2907 return 1;
2908 }
2909 if ($a{$item} ne $b{$item}) {
2886 return 1; 2910 return 1;
2887 } 2911 }
2888 delete $b{$item};
2889 } 2912 }
2890 2913
2891 my @keys = keys %b; 2914 foreach my $item (keys %a) {
2892 if ($#keys) { 2915 if (!defined($b{$item})) {
2893 print "diff2 $keys[0]\n"; 2916 return -1;
2917 }
2894 } 2918 }
2895 return -1 if ($#keys >= 0);
2896 2919
2897 return 0; 2920 return 0;
2898} 2921}
@@ -2900,24 +2923,13 @@ sub compare_configs {
2900sub run_config_bisect_test { 2923sub run_config_bisect_test {
2901 my ($type) = @_; 2924 my ($type) = @_;
2902 2925
2903 return run_bisect_test $type, "oldconfig"; 2926 my $ret = run_bisect_test $type, "oldconfig";
2904}
2905 2927
2906sub process_passed { 2928 if ($bisect_manual) {
2907 my (%configs) = @_; 2929 $ret = answer_bisect;
2908
2909 doprint "These configs had no failure: (Enabling them for further compiles)\n";
2910 # Passed! All these configs are part of a good compile.
2911 # Add them to the min options.
2912 foreach my $config (keys %configs) {
2913 if (defined($config_list{$config})) {
2914 doprint " removing $config\n";
2915 $config_ignore{$config} = $config_list{$config};
2916 delete $config_list{$config};
2917 }
2918 } 2930 }
2919 doprint "config copied to $outputdir/config_good\n"; 2931
2920 run_command "cp -f $output_config $outputdir/config_good"; 2932 return $ret;
2921} 2933}
2922 2934
2923sub process_failed { 2935sub process_failed {
@@ -2928,253 +2940,225 @@ sub process_failed {
2928 doprint "***************************************\n\n"; 2940 doprint "***************************************\n\n";
2929} 2941}
2930 2942
2931sub run_config_bisect { 2943# used for config bisecting
2944my $good_config;
2945my $bad_config;
2932 2946
2933 my @start_list = keys %config_list; 2947sub process_new_config {
2948 my ($tc, $nc, $gc, $bc) = @_;
2934 2949
2935 if ($#start_list < 0) { 2950 my %tmp_config = %{$tc};
2936 doprint "No more configs to test!!!\n"; 2951 my %good_configs = %{$gc};
2937 return -1; 2952 my %bad_configs = %{$bc};
2953
2954 my %new_configs;
2955
2956 my $runtest = 1;
2957 my $ret;
2958
2959 create_config "tmp_configs", \%tmp_config;
2960 assign_configs \%new_configs, $output_config;
2961
2962 $ret = compare_configs \%new_configs, \%bad_configs;
2963 if (!$ret) {
2964 doprint "New config equals bad config, try next test\n";
2965 $runtest = 0;
2966 }
2967
2968 if ($runtest) {
2969 $ret = compare_configs \%new_configs, \%good_configs;
2970 if (!$ret) {
2971 doprint "New config equals good config, try next test\n";
2972 $runtest = 0;
2973 }
2938 } 2974 }
2939 2975
2940 doprint "***** RUN TEST ***\n"; 2976 %{$nc} = %new_configs;
2977
2978 return $runtest;
2979}
2980
2981sub run_config_bisect {
2982 my ($pgood, $pbad) = @_;
2983
2941 my $type = $config_bisect_type; 2984 my $type = $config_bisect_type;
2985
2986 my %good_configs = %{$pgood};
2987 my %bad_configs = %{$pbad};
2988
2989 my %diff_configs = diff_config_vals \%good_configs, \%bad_configs;
2990 my %b_configs = diff_configs \%good_configs, \%bad_configs;
2991 my %g_configs = diff_configs \%bad_configs, \%good_configs;
2992
2993 my @diff_arr = keys %diff_configs;
2994 my $len_diff = $#diff_arr + 1;
2995
2996 my @b_arr = keys %b_configs;
2997 my $len_b = $#b_arr + 1;
2998
2999 my @g_arr = keys %g_configs;
3000 my $len_g = $#g_arr + 1;
3001
3002 my $runtest = 1;
3003 my %new_configs;
2942 my $ret; 3004 my $ret;
2943 my %current_config;
2944 3005
2945 my $count = $#start_list + 1; 3006 # First, lets get it down to a single subset.
2946 doprint " $count configs to test\n"; 3007 # Is the problem with a difference in values?
3008 # Is the problem with a missing config?
3009 # Is the problem with a config that breaks things?
2947 3010
2948 my $half = int($#start_list / 2); 3011 # Enable all of one set and see if we get a new bad
3012 # or good config.
2949 3013
2950 do { 3014 # first set the good config to the bad values.
2951 my @tophalf = @start_list[0 .. $half];
2952 3015
2953 # keep the bottom half off 3016 doprint "d=$len_diff g=$len_g b=$len_b\n";
2954 if ($half < $#start_list) {
2955 @config_off_tmp = @start_list[$half + 1 .. $#start_list];
2956 } else {
2957 @config_off_tmp = ();
2958 }
2959 3017
2960 create_config @tophalf; 3018 # first lets enable things in bad config that are enabled in good config
2961 read_current_config \%current_config; 3019
2962 3020 if ($len_diff > 0) {
2963 $count = $#tophalf + 1; 3021 if ($len_b > 0 || $len_g > 0) {
2964 doprint "Testing $count configs\n"; 3022 my %tmp_config = %bad_configs;
2965 my $found = 0; 3023
2966 # make sure we test something 3024 doprint "Set tmp config to be bad config with good config values\n";
2967 foreach my $config (@tophalf) { 3025 foreach my $item (@diff_arr) {
2968 if (defined($current_config{$config})) { 3026 $tmp_config{$item} = $good_configs{$item};
2969 logit " $config\n";
2970 $found = 1;
2971 }
2972 }
2973 if (!$found) {
2974 # try the other half
2975 doprint "Top half produced no set configs, trying bottom half\n";
2976
2977 # keep the top half off
2978 @config_off_tmp = @tophalf;
2979 @tophalf = @start_list[$half + 1 .. $#start_list];
2980
2981 create_config @tophalf;
2982 read_current_config \%current_config;
2983 foreach my $config (@tophalf) {
2984 if (defined($current_config{$config})) {
2985 logit " $config\n";
2986 $found = 1;
2987 }
2988 }
2989 if (!$found) {
2990 doprint "Failed: Can't make new config with current configs\n";
2991 foreach my $config (@start_list) {
2992 doprint " CONFIG: $config\n";
2993 }
2994 return -1;
2995 } 3027 }
2996 $count = $#tophalf + 1;
2997 doprint "Testing $count configs\n";
2998 }
2999 3028
3000 $ret = run_config_bisect_test $type; 3029 $runtest = process_new_config \%tmp_config, \%new_configs,
3001 if ($bisect_manual) { 3030 \%good_configs, \%bad_configs;
3002 $ret = answer_bisect;
3003 }
3004 if ($ret) {
3005 process_passed %current_config;
3006 return 0;
3007 } 3031 }
3032 }
3008 3033
3009 doprint "This config had a failure.\n"; 3034 if (!$runtest && $len_diff > 0) {
3010 doprint "Removing these configs that were not set in this config:\n";
3011 doprint "config copied to $outputdir/config_bad\n";
3012 run_command "cp -f $output_config $outputdir/config_bad";
3013 3035
3014 # A config exists in this group that was bad. 3036 if ($len_diff == 1) {
3015 foreach my $config (keys %config_list) { 3037 process_failed $diff_arr[0];
3016 if (!defined($current_config{$config})) { 3038 return 1;
3017 doprint " removing $config\n";
3018 delete $config_list{$config};
3019 }
3020 } 3039 }
3040 my %tmp_config = %bad_configs;
3021 3041
3022 @start_list = @tophalf; 3042 my $half = int($#diff_arr / 2);
3043 my @tophalf = @diff_arr[0 .. $half];
3023 3044
3024 if ($#start_list == 0) { 3045 doprint "Settings bisect with top half:\n";
3025 process_failed $start_list[0]; 3046 doprint "Set tmp config to be bad config with some good config values\n";
3026 return 1; 3047 foreach my $item (@tophalf) {
3048 $tmp_config{$item} = $good_configs{$item};
3027 } 3049 }
3028 3050
3029 # remove half the configs we are looking at and see if 3051 $runtest = process_new_config \%tmp_config, \%new_configs,
3030 # they are good. 3052 \%good_configs, \%bad_configs;
3031 $half = int($#start_list / 2);
3032 } while ($#start_list > 0);
3033 3053
3034 # we found a single config, try it again unless we are running manually 3054 if (!$runtest) {
3055 my %tmp_config = %bad_configs;
3035 3056
3036 if ($bisect_manual) { 3057 doprint "Try bottom half\n";
3037 process_failed $start_list[0];
3038 return 1;
3039 }
3040 3058
3041 my @tophalf = @start_list[0 .. 0]; 3059 my @bottomhalf = @diff_arr[$half+1 .. $#diff_arr];
3042 3060
3043 $ret = run_config_bisect_test $type; 3061 foreach my $item (@bottomhalf) {
3044 if ($ret) { 3062 $tmp_config{$item} = $good_configs{$item};
3045 process_passed %current_config; 3063 }
3064
3065 $runtest = process_new_config \%tmp_config, \%new_configs,
3066 \%good_configs, \%bad_configs;
3067 }
3068 }
3069
3070 if ($runtest) {
3071 $ret = run_config_bisect_test $type;
3072 if ($ret) {
3073 doprint "NEW GOOD CONFIG\n";
3074 %good_configs = %new_configs;
3075 run_command "mv $good_config ${good_config}.last";
3076 save_config \%good_configs, $good_config;
3077 %{$pgood} = %good_configs;
3078 } else {
3079 doprint "NEW BAD CONFIG\n";
3080 %bad_configs = %new_configs;
3081 run_command "mv $bad_config ${bad_config}.last";
3082 save_config \%bad_configs, $bad_config;
3083 %{$pbad} = %bad_configs;
3084 }
3046 return 0; 3085 return 0;
3047 } 3086 }
3048 3087
3049 process_failed $start_list[0]; 3088 fail "Hmm, need to do a mix match?\n";
3050 return 1; 3089 return -1;
3051} 3090}
3052 3091
3053sub config_bisect { 3092sub config_bisect {
3054 my ($i) = @_; 3093 my ($i) = @_;
3055 3094
3056 my $start_config = $config_bisect; 3095 my $type = $config_bisect_type;
3096 my $ret;
3057 3097
3058 my $tmpconfig = "$tmpdir/use_config"; 3098 $bad_config = $config_bisect;
3059 3099
3060 if (defined($config_bisect_good)) { 3100 if (defined($config_bisect_good)) {
3061 process_config_ignore $config_bisect_good; 3101 $good_config = $config_bisect_good;
3062 } 3102 } elsif (defined($minconfig)) {
3063 3103 $good_config = $minconfig;
3064 # Make the file with the bad config and the min config
3065 if (defined($minconfig)) {
3066 # read the min config for things to ignore
3067 run_command "cp $minconfig $tmpconfig" or
3068 dodie "failed to copy $minconfig to $tmpconfig";
3069 } else { 3104 } else {
3070 unlink $tmpconfig; 3105 doprint "No config specified, checking if defconfig works";
3071 } 3106 $ret = run_bisect_test $type, "defconfig";
3072 3107 if (!$ret) {
3073 if (-f $tmpconfig) { 3108 fail "Have no good config to compare with, please set CONFIG_BISECT_GOOD";
3074 load_force_config($tmpconfig); 3109 return 1;
3075 process_config_ignore $tmpconfig;
3076 }
3077
3078 # now process the start config
3079 run_command "cp $start_config $output_config" or
3080 dodie "failed to copy $start_config to $output_config";
3081
3082 # read directly what we want to check
3083 my %config_check;
3084 open (IN, $output_config)
3085 or dodie "failed to open $output_config";
3086
3087 while (<IN>) {
3088 if (/^((CONFIG\S*)=.*)/) {
3089 $config_check{$2} = $1;
3090 } 3110 }
3111 $good_config = $output_config;
3091 } 3112 }
3092 close(IN);
3093 3113
3094 # Now run oldconfig with the minconfig 3114 # we don't want min configs to cause issues here.
3095 make_oldconfig; 3115 doprint "Disabling 'MIN_CONFIG' for this test\n";
3116 undef $minconfig;
3096 3117
3097 # check to see what we lost (or gained) 3118 my %good_configs;
3098 open (IN, $output_config) 3119 my %bad_configs;
3099 or dodie "Failed to read $start_config"; 3120 my %tmp_configs;
3100 3121
3101 my %removed_configs; 3122 doprint "Run good configs through make oldconfig\n";
3102 my %added_configs; 3123 assign_configs \%tmp_configs, $good_config;
3124 create_config "$good_config", \%tmp_configs;
3125 assign_configs \%good_configs, $output_config;
3103 3126
3104 while (<IN>) { 3127 doprint "Run bad configs through make oldconfig\n";
3105 if (/^((CONFIG\S*)=.*)/) { 3128 assign_configs \%tmp_configs, $bad_config;
3106 # save off all options 3129 create_config "$bad_config", \%tmp_configs;
3107 $config_set{$2} = $1; 3130 assign_configs \%bad_configs, $output_config;
3108 if (defined($config_check{$2})) {
3109 if (defined($config_ignore{$2})) {
3110 $removed_configs{$2} = $1;
3111 } else {
3112 $config_list{$2} = $1;
3113 }
3114 } elsif (!defined($config_ignore{$2})) {
3115 $added_configs{$2} = $1;
3116 $config_list{$2} = $1;
3117 }
3118 } elsif (/^# ((CONFIG\S*).*)/) {
3119 # Keep these configs disabled
3120 $config_set{$2} = $1;
3121 $config_off{$2} = $1;
3122 }
3123 }
3124 close(IN);
3125 3131
3126 my @confs = keys %removed_configs; 3132 $good_config = "$tmpdir/good_config";
3127 if ($#confs >= 0) { 3133 $bad_config = "$tmpdir/bad_config";
3128 doprint "Configs overridden by default configs and removed from check:\n"; 3134
3129 foreach my $config (@confs) { 3135 save_config \%good_configs, $good_config;
3130 doprint " $config\n"; 3136 save_config \%bad_configs, $bad_config;
3131 }
3132 }
3133 @confs = keys %added_configs;
3134 if ($#confs >= 0) {
3135 doprint "Configs appearing in make oldconfig and added:\n";
3136 foreach my $config (@confs) {
3137 doprint " $config\n";
3138 }
3139 }
3140 3137
3141 my %config_test;
3142 my $once = 0;
3143 3138
3144 @config_off_tmp = (); 3139 if (defined($config_bisect_check) && $config_bisect_check ne "0") {
3140 if ($config_bisect_check ne "good") {
3141 doprint "Testing bad config\n";
3145 3142
3146 # Sometimes kconfig does weird things. We must make sure 3143 $ret = run_bisect_test $type, "useconfig:$bad_config";
3147 # that the config we autocreate has everything we need 3144 if ($ret) {
3148 # to test, otherwise we may miss testing configs, or 3145 fail "Bad config succeeded when expected to fail!";
3149 # may not be able to create a new config. 3146 return 0;
3150 # Here we create a config with everything set.
3151 create_config (keys %config_list);
3152 read_current_config \%config_test;
3153 foreach my $config (keys %config_list) {
3154 if (!defined($config_test{$config})) {
3155 if (!$once) {
3156 $once = 1;
3157 doprint "Configs not produced by kconfig (will not be checked):\n";
3158 } 3147 }
3159 doprint " $config\n";
3160 delete $config_list{$config};
3161 } 3148 }
3162 } 3149 if ($config_bisect_check ne "bad") {
3163 my $ret; 3150 doprint "Testing good config\n";
3164 3151
3165 if (defined($config_bisect_check) && $config_bisect_check) { 3152 $ret = run_bisect_test $type, "useconfig:$good_config";
3166 doprint " Checking to make sure bad config with min config fails\n"; 3153 if (!$ret) {
3167 create_config keys %config_list; 3154 fail "Good config failed when expected to succeed!";
3168 $ret = run_config_bisect_test $config_bisect_type; 3155 return 0;
3169 if ($ret) { 3156 }
3170 doprint " FAILED! Bad config with min config boots fine\n";
3171 return -1;
3172 } 3157 }
3173 doprint " Bad config with min config fails as expected\n";
3174 } 3158 }
3175 3159
3176 do { 3160 do {
3177 $ret = run_config_bisect; 3161 $ret = run_config_bisect \%good_configs, \%bad_configs;
3178 } while (!$ret); 3162 } while (!$ret);
3179 3163
3180 return $ret if ($ret < 0); 3164 return $ret if ($ret < 0);
@@ -3455,29 +3439,6 @@ sub read_depends {
3455 read_kconfig($kconfig); 3439 read_kconfig($kconfig);
3456} 3440}
3457 3441
3458sub read_config_list {
3459 my ($config) = @_;
3460
3461 open (IN, $config)
3462 or dodie "Failed to read $config";
3463
3464 while (<IN>) {
3465 if (/^((CONFIG\S*)=.*)/) {
3466 if (!defined($config_ignore{$2})) {
3467 $config_list{$2} = $1;
3468 }
3469 }
3470 }
3471
3472 close(IN);
3473}
3474
3475sub read_output_config {
3476 my ($config) = @_;
3477
3478 assign_configs \%config_ignore, $config;
3479}
3480
3481sub make_new_config { 3442sub make_new_config {
3482 my @configs = @_; 3443 my @configs = @_;
3483 3444
@@ -3863,7 +3824,7 @@ sub make_warnings_file {
3863 success $i; 3824 success $i;
3864} 3825}
3865 3826
3866$#ARGV < 1 or die "ktest.pl version: $VERSION\n usage: ktest.pl config-file\n"; 3827$#ARGV < 1 or die "ktest.pl version: $VERSION\n usage: ktest.pl [config-file]\n";
3867 3828
3868if ($#ARGV == 0) { 3829if ($#ARGV == 0) {
3869 $ktest_config = $ARGV[0]; 3830 $ktest_config = $ARGV[0];
@@ -3873,8 +3834,6 @@ if ($#ARGV == 0) {
3873 exit 0; 3834 exit 0;
3874 } 3835 }
3875 } 3836 }
3876} else {
3877 $ktest_config = "ktest.conf";
3878} 3837}
3879 3838
3880if (! -f $ktest_config) { 3839if (! -f $ktest_config) {
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index 172eec4517fb..911e45ad657a 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -1098,49 +1098,35 @@
1098# 1098#
1099# The way it works is this: 1099# The way it works is this:
1100# 1100#
1101# First it finds a config to work with. Since a different version, or 1101# You can specify a good config with CONFIG_BISECT_GOOD, otherwise it
1102# MIN_CONFIG may cause different dependecies, it must run through this 1102# will use the MIN_CONFIG, and if that's not specified, it will use
1103# preparation. 1103# the config that comes with "make defconfig".
1104# 1104#
1105# Overwrites any config set in the bad config with a config set in 1105# It runs both the good and bad configs through a make oldconfig to
1106# either the MIN_CONFIG or ADD_CONFIG. Thus, make sure these configs 1106# make sure that they are set up for the kernel that is checked out.
1107# are minimal and do not disable configs you want to test:
1108# (ie. # CONFIG_FOO is not set).
1109# 1107#
1110# An oldconfig is run on the bad config and any new config that 1108# It then reads the configs that are set, as well as the ones that are
1111# appears will be added to the configs to test. 1109# not set for both the good and bad configs, and then compares them.
1110# It will set half of the good configs within the bad config (note,
1111# "set" means to make the bad config match the good config, a config
1112# in the good config that is off, will be turned off in the bad
1113# config. That is considered a "set").
1112# 1114#
1113# Finally, it generates a config with the above result and runs it 1115# It tests this new config and if it works, it becomes the new good
1114# again through make oldconfig to produce a config that should be 1116# config, otherwise it becomes the new bad config. It continues this
1115# satisfied by kconfig. 1117# process until there's only one config left and it will report that
1118# config.
1116# 1119#
1117# Then it starts the bisect. 1120# The "bad config" can also be a config that is needed to boot but was
1121# disabled because it depended on something that wasn't set.
1118# 1122#
1119# The configs to test are cut in half. If all the configs in this 1123# During this process, it saves the current good and bad configs in
1120# half depend on a config in the other half, then the other half 1124# ${TMP_DIR}/good_config and ${TMP_DIR}/bad_config respectively.
1121# is tested instead. If no configs are enabled by either half, then 1125# If you stop the test, you can copy them to a new location to
1122# this means a circular dependency exists and the test fails. 1126# reuse them again.
1123# 1127#
1124# A config is created with the test half, and the bisect test is run. 1128# Although the MIN_CONFIG may be the config it starts with, the
1125# 1129# MIN_CONFIG is ignored.
1126# If the bisect succeeds, then all configs in the generated config
1127# are removed from the configs to test and added to the configs that
1128# will be enabled for all builds (they will be enabled, but not be part
1129# of the configs to examine).
1130#
1131# If the bisect fails, then all test configs that were not enabled by
1132# the config file are removed from the test. These configs will not
1133# be enabled in future tests. Since current config failed, we consider
1134# this to be a subset of the config that we started with.
1135#
1136# When we are down to one config, it is considered the bad config.
1137#
1138# Note, the config chosen may not be the true bad config. Due to
1139# dependencies and selections of the kbuild system, mulitple
1140# configs may be needed to cause a failure. If you disable the
1141# config that was found and restart the test, if the test fails
1142# again, it is recommended to rerun the config_bisect with a new
1143# bad config without the found config enabled.
1144# 1130#
1145# The option BUILD_TYPE will be ignored. 1131# The option BUILD_TYPE will be ignored.
1146# 1132#
@@ -1160,13 +1146,16 @@
1160# CONFIG_BISECT_GOOD (optional) 1146# CONFIG_BISECT_GOOD (optional)
1161# If you have a good config to start with, then you 1147# If you have a good config to start with, then you
1162# can specify it with CONFIG_BISECT_GOOD. Otherwise 1148# can specify it with CONFIG_BISECT_GOOD. Otherwise
1163# the MIN_CONFIG is the base. 1149# the MIN_CONFIG is the base, if MIN_CONFIG is not set
1150# It will build a config with "make defconfig"
1164# 1151#
1165# CONFIG_BISECT_CHECK (optional) 1152# CONFIG_BISECT_CHECK (optional)
1166# Set this to 1 if you want to confirm that the config ktest 1153# Set this to 1 if you want to confirm that the config ktest
1167# generates (the bad config with the min config) is still bad. 1154# generates (the bad config with the min config) is still bad.
1168# It may be that the min config fixes what broke the bad config 1155# It may be that the min config fixes what broke the bad config
1169# and the test will not return a result. 1156# and the test will not return a result.
1157# Set it to "good" to test only the good config and set it
1158# to "bad" to only test the bad config.
1170# 1159#
1171# Example: 1160# Example:
1172# TEST_START 1161# TEST_START