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

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

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