From f983a2bc9d355fb04932b38fee2533114c204cce Mon Sep 17 00:00:00 2001 From: Satoru Takeuchi Date: Sun, 2 Mar 2014 21:20:31 +0900 Subject: ktest: add 2nd parameter of run_command() to set the redirect target file If we'd like to set the redirect target file of run_command(), we should define $redirect before calling this function and should undef it after calling this function. Since it's user-unfriendly, add 2nd parameter of run_command() for this purpose. Link: http://lkml.kernel.org/r/87vbvwokq8.wl%satoru.takeuchi@gmail.com Signed-off-by: Satoru Takeuchi Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'tools/testing') diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 40631569a0fd..f731ef69aed2 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -149,7 +149,6 @@ my $bisect_ret_abort; my $bisect_ret_default; my $in_patchcheck = 0; my $run_test; -my $redirect; my $buildlog; my $testlog; my $dmesg; @@ -1529,7 +1528,7 @@ sub fail { } sub run_command { - my ($command) = @_; + my ($command, $redirect) = @_; my $dolog = 0; my $dord = 0; my $pid; @@ -2265,9 +2264,7 @@ sub build { # Run old config regardless, to enforce min configurations make_oldconfig; - $redirect = "$buildlog"; - my $build_ret = run_command "$make $build_options"; - undef $redirect; + my $build_ret = run_command "$make $build_options", $buildlog; if (defined($post_build)) { # Because a post build may change the kernel version @@ -2360,9 +2357,7 @@ sub child_run_test { $poweroff_on_error = 0; $die_on_failure = 1; - $redirect = "$testlog"; - run_command $run_test or $failed = 1; - undef $redirect; + run_command $run_test, $testlog or $failed = 1; exit $failed; } -- cgit v1.2.3-55-g7522 From 5269faad27f8ed8df1c7ba520a8de628fd248362 Mon Sep 17 00:00:00 2001 From: Satoru Takeuchi Date: Sun, 9 Mar 2014 23:32:04 +0900 Subject: ktest: Some cleanup for improving readability Some cleanup for improving readability as follows. - Initialize $ktest_config at its definition. - Put parentheses around the `config-file' argument in the usage message because it's a optional one. - Rename get_ktest_config{,s} to more descriptive get_mandatory_config{,s}. Link: http://lkml.kernel.org/r/87fvmr30kb.wl%satoru.takeuchi@gmail.com Signed-off-by: Satoru Takeuchi Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'tools/testing') diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index f731ef69aed2..c34f0dedad2d 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -72,7 +72,7 @@ my %default = ( "IGNORE_UNUSED" => 0, ); -my $ktest_config; +my $ktest_config = "ktest.conf"; my $version; my $have_version = 0; my $machine; @@ -521,7 +521,7 @@ sub read_ync { return read_prompt 1, $prompt; } -sub get_ktest_config { +sub get_mandatory_config { my ($config) = @_; my $ans; @@ -552,29 +552,29 @@ sub get_ktest_config { } } -sub get_ktest_configs { - get_ktest_config("MACHINE"); - get_ktest_config("BUILD_DIR"); - get_ktest_config("OUTPUT_DIR"); +sub get_mandatory_configs { + get_mandatory_config("MACHINE"); + get_mandatory_config("BUILD_DIR"); + get_mandatory_config("OUTPUT_DIR"); if ($newconfig) { - get_ktest_config("BUILD_OPTIONS"); + get_mandatory_config("BUILD_OPTIONS"); } # options required for other than just building a kernel if (!$buildonly) { - get_ktest_config("POWER_CYCLE"); - get_ktest_config("CONSOLE"); + get_mandatory_config("POWER_CYCLE"); + get_mandatory_config("CONSOLE"); } # options required for install and more if ($buildonly != 1) { - get_ktest_config("SSH_USER"); - get_ktest_config("BUILD_TARGET"); - get_ktest_config("TARGET_IMAGE"); + get_mandatory_config("SSH_USER"); + get_mandatory_config("BUILD_TARGET"); + get_mandatory_config("TARGET_IMAGE"); } - get_ktest_config("LOCALVERSION"); + get_mandatory_config("LOCALVERSION"); return if ($buildonly); @@ -582,7 +582,7 @@ sub get_ktest_configs { if (!defined($rtype)) { if (!defined($opt{"GRUB_MENU"})) { - get_ktest_config("REBOOT_TYPE"); + get_mandatory_config("REBOOT_TYPE"); $rtype = $entered_configs{"REBOOT_TYPE"}; } else { $rtype = "grub"; @@ -590,16 +590,16 @@ sub get_ktest_configs { } if ($rtype eq "grub") { - get_ktest_config("GRUB_MENU"); + get_mandatory_config("GRUB_MENU"); } if ($rtype eq "grub2") { - get_ktest_config("GRUB_MENU"); - get_ktest_config("GRUB_FILE"); + get_mandatory_config("GRUB_MENU"); + get_mandatory_config("GRUB_FILE"); } if ($rtype eq "syslinux") { - get_ktest_config("SYSLINUX_LABEL"); + get_mandatory_config("SYSLINUX_LABEL"); } } @@ -1089,7 +1089,7 @@ sub read_config { $test_case = __read_config $config, \$test_num; # make sure we have all mandatory configs - get_ktest_configs; + get_mandatory_configs; # was a test specified? if (!$test_case) { @@ -3858,7 +3858,7 @@ sub make_warnings_file { success $i; } -$#ARGV < 1 or die "ktest.pl version: $VERSION\n usage: ktest.pl config-file\n"; +$#ARGV < 1 or die "ktest.pl version: $VERSION\n usage: ktest.pl [config-file]\n"; if ($#ARGV == 0) { $ktest_config = $ARGV[0]; @@ -3868,8 +3868,6 @@ if ($#ARGV == 0) { exit 0; } } -} else { - $ktest_config = "ktest.conf"; } if (! -f $ktest_config) { -- cgit v1.2.3-55-g7522 From 6071c22e17552a88562182cd3ad21fcb8bd37130 Mon Sep 17 00:00:00 2001 From: Steven Rostedt (Red Hat) Date: Wed, 23 Apr 2014 15:24:04 -0400 Subject: ktest: Rewrite the config-bisect to actually work I never liked the way config-bisect worked. I would assume the bad config had some config that broke the system. But it would not work if the bad config just happened to be missing something that the good config had. I rewrote the config-bisect to do this properly. It does a diff of the two configs, and sets half of the configs that are in one and not the other. The way it works is that when it "sets", it really just makes one copy what the other has. That is, a "set" can be setting a: # CONFIG_FOO is not set Basically, it looks at the differences between the two files and makes them similar until it comes down to one config that makes it work or not work depending on if it is set or not. Note, if more than one config change makes the bad config not work, it will only find one of them. But this is true with all bisect logic. Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 452 +++++++++++++++++++++---------------------- 1 file changed, 226 insertions(+), 226 deletions(-) (limited to 'tools/testing') diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index c34f0dedad2d..52f558efdb0a 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -2784,12 +2784,17 @@ my %dependency; sub assign_configs { my ($hash, $config) = @_; + doprint "Reading configs from $config\n"; + open (IN, $config) or dodie "Failed to read $config"; while () { + chomp; if (/^((CONFIG\S*)=.*)/) { ${$hash}{$2} = $1; + } elsif (/^(# (CONFIG\S*) is not set)/) { + ${$hash}{$2} = $1; } } @@ -2841,53 +2846,97 @@ sub get_dependencies { return @deps; } +sub save_config { + my ($pc, $file) = @_; + + my %configs = %{$pc}; + + doprint "Saving configs into $file\n"; + + open(OUT, ">$file") or dodie "Can not write to $file"; + + foreach my $config (keys %configs) { + print OUT "$configs{$config}\n"; + } + close(OUT); +} + sub create_config { - my @configs = @_; + my ($name, $pc) = @_; - open(OUT, ">$output_config") or dodie "Can not write to $output_config"; + doprint "Creating old config from $name configs\n"; - foreach my $config (@configs) { - print OUT "$config_set{$config}\n"; - my @deps = get_dependencies $config; - foreach my $dep (@deps) { - print OUT "$config_set{$dep}\n"; + save_config $pc, $output_config; + + make_oldconfig; +} + +# compare two config hashes, and return configs with different vals. +# It returns B's config values, but you can use A to see what A was. +sub diff_config_vals { + my ($pa, $pb) = @_; + + # crappy Perl way to pass in hashes. + my %a = %{$pa}; + my %b = %{$pb}; + + my %ret; + + foreach my $item (keys %a) { + if (defined($b{$item}) && $b{$item} ne $a{$item}) { + $ret{$item} = $b{$item}; } } - # turn off configs to keep off - foreach my $config (keys %config_off) { - print OUT "# $config is not set\n"; - } + return %ret; +} - # turn off configs that should be off for now - foreach my $config (@config_off_tmp) { - print OUT "# $config is not set\n"; - } +# compare two config hashes and return the configs in B but not A +sub diff_configs { + my ($pa, $pb) = @_; + + my %ret; + + # crappy Perl way to pass in hashes. + my %a = %{$pa}; + my %b = %{$pb}; - foreach my $config (keys %config_ignore) { - print OUT "$config_ignore{$config}\n"; + foreach my $item (keys %b) { + if (!defined($a{$item})) { + $ret{$item} = $b{$item}; + } } - close(OUT); - make_oldconfig; + return %ret; } +# return if two configs are equal or not +# 0 is equal +1 b has something a does not +# +1 if a and b have a different item. +# -1 if a has something b does not sub compare_configs { - my (%a, %b) = @_; + my ($pa, $pb) = @_; - foreach my $item (keys %a) { - if (!defined($b{$item})) { - print "diff $item\n"; + my %ret; + + # crappy Perl way to pass in hashes. + my %a = %{$pa}; + my %b = %{$pb}; + + foreach my $item (keys %b) { + if (!defined($a{$item})) { + return 1; + } + if ($a{$item} ne $b{$item}) { return 1; } - delete $b{$item}; } - my @keys = keys %b; - if ($#keys) { - print "diff2 $keys[0]\n"; + foreach my $item (keys %a) { + if (!defined($b{$item})) { + return -1; + } } - return -1 if ($#keys >= 0); return 0; } @@ -2923,253 +2972,204 @@ sub process_failed { doprint "***************************************\n\n"; } -sub run_config_bisect { +# used for config bisecting +my $good_config; +my $bad_config; - my @start_list = keys %config_list; +sub process_new_config { + my ($tc, $nc, $gc, $bc) = @_; - if ($#start_list < 0) { - doprint "No more configs to test!!!\n"; - return -1; - } + my %tmp_config = %{$tc}; + my %good_configs = %{$gc}; + my %bad_configs = %{$bc}; - doprint "***** RUN TEST ***\n"; - my $type = $config_bisect_type; - my $ret; - my %current_config; + my %new_configs; - my $count = $#start_list + 1; - doprint " $count configs to test\n"; + my $runtest = 1; + my $ret; - my $half = int($#start_list / 2); + create_config "tmp_configs", \%tmp_config; + assign_configs \%new_configs, $output_config; - do { - my @tophalf = @start_list[0 .. $half]; + $ret = compare_configs \%new_configs, \%bad_configs; + if (!$ret) { + doprint "New config equals bad config, try next test\n"; + $runtest = 0; + } - # keep the bottom half off - if ($half < $#start_list) { - @config_off_tmp = @start_list[$half + 1 .. $#start_list]; - } else { - @config_off_tmp = (); + if ($runtest) { + $ret = compare_configs \%new_configs, \%good_configs; + if (!$ret) { + doprint "New config equals good config, try next test\n"; + $runtest = 0; } + } - create_config @tophalf; - read_current_config \%current_config; - - $count = $#tophalf + 1; - doprint "Testing $count configs\n"; - my $found = 0; - # make sure we test something - foreach my $config (@tophalf) { - if (defined($current_config{$config})) { - logit " $config\n"; - $found = 1; - } - } - if (!$found) { - # try the other half - doprint "Top half produced no set configs, trying bottom half\n"; - - # keep the top half off - @config_off_tmp = @tophalf; - @tophalf = @start_list[$half + 1 .. $#start_list]; - - create_config @tophalf; - read_current_config \%current_config; - foreach my $config (@tophalf) { - if (defined($current_config{$config})) { - logit " $config\n"; - $found = 1; - } - } - if (!$found) { - doprint "Failed: Can't make new config with current configs\n"; - foreach my $config (@start_list) { - doprint " CONFIG: $config\n"; - } - return -1; - } - $count = $#tophalf + 1; - doprint "Testing $count configs\n"; - } + %{$nc} = %new_configs; - $ret = run_config_bisect_test $type; - if ($bisect_manual) { - $ret = answer_bisect; - } - if ($ret) { - process_passed %current_config; - return 0; - } + return $runtest; +} - doprint "This config had a failure.\n"; - doprint "Removing these configs that were not set in this config:\n"; - doprint "config copied to $outputdir/config_bad\n"; - run_command "cp -f $output_config $outputdir/config_bad"; +sub run_config_bisect { + my ($pgood, $pbad) = @_; - # A config exists in this group that was bad. - foreach my $config (keys %config_list) { - if (!defined($current_config{$config})) { - doprint " removing $config\n"; - delete $config_list{$config}; - } - } + my $type = $config_bisect_type; - @start_list = @tophalf; + my %good_configs = %{$pgood}; + my %bad_configs = %{$pbad}; - if ($#start_list == 0) { - process_failed $start_list[0]; - return 1; - } + my %diff_configs = diff_config_vals \%good_configs, \%bad_configs; + my %b_configs = diff_configs \%good_configs, \%bad_configs; + my %g_configs = diff_configs \%bad_configs, \%good_configs; - # remove half the configs we are looking at and see if - # they are good. - $half = int($#start_list / 2); - } while ($#start_list > 0); + my @diff_arr = keys %diff_configs; + my $len_diff = $#diff_arr + 1; - # we found a single config, try it again unless we are running manually + my @b_arr = keys %b_configs; + my $len_b = $#b_arr + 1; - if ($bisect_manual) { - process_failed $start_list[0]; - return 1; - } + my @g_arr = keys %g_configs; + my $len_g = $#g_arr + 1; - my @tophalf = @start_list[0 .. 0]; + my $runtest = 1; + my %new_configs; + my $ret; - $ret = run_config_bisect_test $type; - if ($ret) { - process_passed %current_config; - return 0; - } + # First, lets get it down to a single subset. + # Is the problem with a difference in values? + # Is the problem with a missing config? + # Is the problem with a config that breaks things? - process_failed $start_list[0]; - return 1; -} + # Enable all of one set and see if we get a new bad + # or good config. -sub config_bisect { - my ($i) = @_; + # first set the good config to the bad values. - my $start_config = $config_bisect; + doprint "d=$len_diff g=$len_g b=$len_b\n"; - my $tmpconfig = "$tmpdir/use_config"; + # first lets enable things in bad config that are enabled in good config - if (defined($config_bisect_good)) { - process_config_ignore $config_bisect_good; - } + if ($len_diff > 0) { + if ($len_b > 0 || $len_g > 0) { + my %tmp_config = %bad_configs; - # Make the file with the bad config and the min config - if (defined($minconfig)) { - # read the min config for things to ignore - run_command "cp $minconfig $tmpconfig" or - dodie "failed to copy $minconfig to $tmpconfig"; - } else { - unlink $tmpconfig; - } + doprint "Set tmp config to be bad config with good config values\n"; + foreach my $item (@diff_arr) { + $tmp_config{$item} = $good_configs{$item}; + } - if (-f $tmpconfig) { - load_force_config($tmpconfig); - process_config_ignore $tmpconfig; + $runtest = process_new_config \%tmp_config, \%new_configs, + \%good_configs, \%bad_configs; + } } - # now process the start config - run_command "cp $start_config $output_config" or - dodie "failed to copy $start_config to $output_config"; + if (!$runtest && $len_diff > 0) { - # read directly what we want to check - my %config_check; - open (IN, $output_config) - or dodie "failed to open $output_config"; + if ($len_diff == 1) { + doprint "The bad config setting is: $diff_arr[0]\n"; + return 1; + } + my %tmp_config = %bad_configs; - while () { - if (/^((CONFIG\S*)=.*)/) { - $config_check{$2} = $1; + my $half = int($#diff_arr / 2); + my @tophalf = @diff_arr[0 .. $half]; + + doprint "Settings bisect with top half:\n"; + doprint "Set tmp config to be bad config with some good config values\n"; + foreach my $item (@tophalf) { + $tmp_config{$item} = $good_configs{$item}; } - } - close(IN); - # Now run oldconfig with the minconfig - make_oldconfig; + $runtest = process_new_config \%tmp_config, \%new_configs, + \%good_configs, \%bad_configs; - # check to see what we lost (or gained) - open (IN, $output_config) - or dodie "Failed to read $start_config"; + if (!$runtest) { + my %tmp_config = %bad_configs; - my %removed_configs; - my %added_configs; + doprint "Try bottom half\n"; - while () { - if (/^((CONFIG\S*)=.*)/) { - # save off all options - $config_set{$2} = $1; - if (defined($config_check{$2})) { - if (defined($config_ignore{$2})) { - $removed_configs{$2} = $1; - } else { - $config_list{$2} = $1; - } - } elsif (!defined($config_ignore{$2})) { - $added_configs{$2} = $1; - $config_list{$2} = $1; + my @bottomhalf = @diff_arr[$half+1 .. $#diff_arr]; + + foreach my $item (@bottomhalf) { + $tmp_config{$item} = $good_configs{$item}; } - } elsif (/^# ((CONFIG\S*).*)/) { - # Keep these configs disabled - $config_set{$2} = $1; - $config_off{$2} = $1; - } - } - close(IN); - my @confs = keys %removed_configs; - if ($#confs >= 0) { - doprint "Configs overridden by default configs and removed from check:\n"; - foreach my $config (@confs) { - doprint " $config\n"; + $runtest = process_new_config \%tmp_config, \%new_configs, + \%good_configs, \%bad_configs; } } - @confs = keys %added_configs; - if ($#confs >= 0) { - doprint "Configs appearing in make oldconfig and added:\n"; - foreach my $config (@confs) { - doprint " $config\n"; + + if ($runtest) { + $ret = run_config_bisect_test $type; + if ($ret) { + doprint "NEW GOOD CONFIG\n"; + %good_configs = %new_configs; + run_command "mv $good_config ${good_config}.last"; + save_config \%good_configs, $good_config; + %{$pgood} = %good_configs; + } else { + doprint "NEW BAD CONFIG\n"; + %bad_configs = %new_configs; + run_command "mv $bad_config ${bad_config}.last"; + save_config \%bad_configs, $bad_config; + %{$pbad} = %bad_configs; } + return 0; } - my %config_test; - my $once = 0; + fail "Hmm, need to do a mix match?\n"; + return -1; +} - @config_off_tmp = (); +sub config_bisect { + my ($i) = @_; - # Sometimes kconfig does weird things. We must make sure - # that the config we autocreate has everything we need - # to test, otherwise we may miss testing configs, or - # may not be able to create a new config. - # Here we create a config with everything set. - create_config (keys %config_list); - read_current_config \%config_test; - foreach my $config (keys %config_list) { - if (!defined($config_test{$config})) { - if (!$once) { - $once = 1; - doprint "Configs not produced by kconfig (will not be checked):\n"; - } - doprint " $config\n"; - delete $config_list{$config}; - } - } - my $ret; + my $type = $config_bisect_type; - if (defined($config_bisect_check) && $config_bisect_check) { - doprint " Checking to make sure bad config with min config fails\n"; - create_config keys %config_list; - $ret = run_config_bisect_test $config_bisect_type; - if ($ret) { - doprint " FAILED! Bad config with min config boots fine\n"; - return -1; + $bad_config = $config_bisect; + + if (defined($config_bisect_good)) { + $good_config = $config_bisect_good; + } elsif (defined($minconfig)) { + $good_config = $minconfig; + } else { + doprint "No config specified, checking if defconfig works"; + my $ret = run_bisect_test $type, "defconfig"; + if (!$ret) { + fail "Have no good config to compare with, please set CONFIG_BISECT_GOOD"; + return 1; } - doprint " Bad config with min config fails as expected\n"; + $good_config = $output_config; } + # we don't want min configs to cause issues here. + doprint "Disabling 'MIN_CONFIG' for this test\n"; + undef $minconfig; + + my %good_configs; + my %bad_configs; + my %tmp_configs; + + doprint "Run good configs through make oldconfig\n"; + assign_configs \%tmp_configs, $good_config; + create_config "$good_config", \%tmp_configs; + assign_configs \%good_configs, $output_config; + + doprint "Run bad configs through make oldconfig\n"; + assign_configs \%tmp_configs, $bad_config; + create_config "$bad_config", \%tmp_configs; + assign_configs \%bad_configs, $output_config; + + $good_config = "$tmpdir/good_config"; + $bad_config = "$tmpdir/bad_config"; + + save_config \%good_configs, $good_config; + save_config \%bad_configs, $bad_config; + + my $ret; + do { - $ret = run_config_bisect; + $ret = run_config_bisect \%good_configs, \%bad_configs; } while (!$ret); return $ret if ($ret < 0); -- cgit v1.2.3-55-g7522 From c4d1d11f3b669847b261eacab123fe8b98a91d13 Mon Sep 17 00:00:00 2001 From: Steven Rostedt (Red Hat) Date: Wed, 23 Apr 2014 22:04:56 -0400 Subject: ktest: Put back in the CONFIG_BISECT_CHECK The new rewrite left out the CONFIG_BISECT_CHECK, which allows the user to test that their "bad" config still is bad and their "good" config still is good. This is especially important as the configs are passed through a "make oldconfig" to update them with the lastest kernel. Things could change that causes a bad config to work, or a good config to break. The check is done after the configs have run through the oldconfig processing. Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'tools/testing') diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 52f558efdb0a..59697ead9dfc 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -3125,6 +3125,7 @@ sub config_bisect { my ($i) = @_; my $type = $config_bisect_type; + my $ret; $bad_config = $config_bisect; @@ -3134,7 +3135,7 @@ sub config_bisect { $good_config = $minconfig; } else { doprint "No config specified, checking if defconfig works"; - my $ret = run_bisect_test $type, "defconfig"; + $ret = run_bisect_test $type, "defconfig"; if (!$ret) { fail "Have no good config to compare with, please set CONFIG_BISECT_GOOD"; return 1; @@ -3166,7 +3167,27 @@ sub config_bisect { save_config \%good_configs, $good_config; save_config \%bad_configs, $bad_config; - my $ret; + + if (defined($config_bisect_check) && $config_bisect_check ne "0") { + if ($config_bisect_check ne "good") { + doprint "Testing bad config\n"; + + $ret = run_bisect_test $type, "useconfig:$bad_config"; + if ($ret) { + fail "Bad config succeeded when expected to fail!"; + return 0; + } + } + if ($config_bisect_check ne "bad") { + doprint "Testing good config\n"; + + $ret = run_bisect_test $type, "useconfig:$good_config"; + if (!$ret) { + fail "Good config failed when expected to succeed!"; + return 0; + } + } + } do { $ret = run_config_bisect \%good_configs, \%bad_configs; -- cgit v1.2.3-55-g7522 From 4186cb45183fc84331aec7413053dc7dcac386d1 Mon Sep 17 00:00:00 2001 From: Steven Rostedt (Red Hat) Date: Wed, 23 Apr 2014 22:09:59 -0400 Subject: ktest: Remove unused functions After the rewrite of the config bisect, there were several unused functions that can be removed. One of the unused functions printed out the failed config nicer than what the rewrite did, so I kept that and used it to output the bad config. Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 63 +------------------------------------------- 1 file changed, 1 insertion(+), 62 deletions(-) (limited to 'tools/testing') diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 59697ead9dfc..880566803431 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -2807,27 +2807,6 @@ sub process_config_ignore { assign_configs \%config_ignore, $config; } -sub read_current_config { - my ($config_ref) = @_; - - %{$config_ref} = (); - undef %{$config_ref}; - - my @key = keys %{$config_ref}; - if ($#key >= 0) { - print "did not delete!\n"; - exit; - } - open (IN, "$output_config"); - - while () { - if (/^(CONFIG\S+)=(.*)/) { - ${$config_ref}{$1} = $2; - } - } - close(IN); -} - sub get_dependencies { my ($config) = @_; @@ -2947,23 +2926,6 @@ sub run_config_bisect_test { return run_bisect_test $type, "oldconfig"; } -sub process_passed { - my (%configs) = @_; - - doprint "These configs had no failure: (Enabling them for further compiles)\n"; - # Passed! All these configs are part of a good compile. - # Add them to the min options. - foreach my $config (keys %configs) { - if (defined($config_list{$config})) { - doprint " removing $config\n"; - $config_ignore{$config} = $config_list{$config}; - delete $config_list{$config}; - } - } - doprint "config copied to $outputdir/config_good\n"; - run_command "cp -f $output_config $outputdir/config_good"; -} - sub process_failed { my ($config) = @_; @@ -3066,7 +3028,7 @@ sub run_config_bisect { if (!$runtest && $len_diff > 0) { if ($len_diff == 1) { - doprint "The bad config setting is: $diff_arr[0]\n"; + process_failed $diff_arr[0]; return 1; } my %tmp_config = %bad_configs; @@ -3471,29 +3433,6 @@ sub read_depends { read_kconfig($kconfig); } -sub read_config_list { - my ($config) = @_; - - open (IN, $config) - or dodie "Failed to read $config"; - - while () { - if (/^((CONFIG\S*)=.*)/) { - if (!defined($config_ignore{$2})) { - $config_list{$2} = $1; - } - } - } - - close(IN); -} - -sub read_output_config { - my ($config) = @_; - - assign_configs \%config_ignore, $config; -} - sub make_new_config { my @configs = @_; -- cgit v1.2.3-55-g7522 From 4cc559bd1d6a24aa0581f64d8cdb0cb54e7d5f8c Mon Sep 17 00:00:00 2001 From: Steven Rostedt (Red Hat) Date: Wed, 23 Apr 2014 22:27:27 -0400 Subject: ktest: Add the config bisect manual back After the rewrite of the config bisect, the bisect manual was removed. Add it back. Signed-off-by: Steven Rostedt --- tools/testing/ktest/ktest.pl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tools/testing') diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 880566803431..55ab700f6ba5 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -2923,7 +2923,13 @@ sub compare_configs { sub run_config_bisect_test { my ($type) = @_; - return run_bisect_test $type, "oldconfig"; + my $ret = run_bisect_test $type, "oldconfig"; + + if ($bisect_manual) { + $ret = answer_bisect; + } + + return $ret; } sub process_failed { -- cgit v1.2.3-55-g7522 From 4c16b1d6d5e0ca0612de65596a3d1ead8a3372fb Mon Sep 17 00:00:00 2001 From: Steven Rostedt (Red Hat) Date: Wed, 23 Apr 2014 22:30:00 -0400 Subject: ktest: Update documentation on config_bisect With the more robust config_bisect, the documentation is out of date and needs to be updated. The new rewrite allows for finding missing configs and such, and is much more robust to use. Signed-off-by: Steven Rostedt --- tools/testing/ktest/sample.conf | 65 +++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 38 deletions(-) (limited to 'tools/testing') 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 @@ # # The way it works is this: # -# First it finds a config to work with. Since a different version, or -# MIN_CONFIG may cause different dependecies, it must run through this -# preparation. +# You can specify a good config with CONFIG_BISECT_GOOD, otherwise it +# will use the MIN_CONFIG, and if that's not specified, it will use +# the config that comes with "make defconfig". # -# Overwrites any config set in the bad config with a config set in -# either the MIN_CONFIG or ADD_CONFIG. Thus, make sure these configs -# are minimal and do not disable configs you want to test: -# (ie. # CONFIG_FOO is not set). +# It runs both the good and bad configs through a make oldconfig to +# make sure that they are set up for the kernel that is checked out. # -# An oldconfig is run on the bad config and any new config that -# appears will be added to the configs to test. +# It then reads the configs that are set, as well as the ones that are +# not set for both the good and bad configs, and then compares them. +# It will set half of the good configs within the bad config (note, +# "set" means to make the bad config match the good config, a config +# in the good config that is off, will be turned off in the bad +# config. That is considered a "set"). # -# Finally, it generates a config with the above result and runs it -# again through make oldconfig to produce a config that should be -# satisfied by kconfig. +# It tests this new config and if it works, it becomes the new good +# config, otherwise it becomes the new bad config. It continues this +# process until there's only one config left and it will report that +# config. # -# Then it starts the bisect. +# The "bad config" can also be a config that is needed to boot but was +# disabled because it depended on something that wasn't set. # -# The configs to test are cut in half. If all the configs in this -# half depend on a config in the other half, then the other half -# is tested instead. If no configs are enabled by either half, then -# this means a circular dependency exists and the test fails. +# During this process, it saves the current good and bad configs in +# ${TMP_DIR}/good_config and ${TMP_DIR}/bad_config respectively. +# If you stop the test, you can copy them to a new location to +# reuse them again. # -# A config is created with the test half, and the bisect test is run. -# -# If the bisect succeeds, then all configs in the generated config -# are removed from the configs to test and added to the configs that -# will be enabled for all builds (they will be enabled, but not be part -# of the configs to examine). -# -# If the bisect fails, then all test configs that were not enabled by -# the config file are removed from the test. These configs will not -# be enabled in future tests. Since current config failed, we consider -# this to be a subset of the config that we started with. -# -# When we are down to one config, it is considered the bad config. -# -# Note, the config chosen may not be the true bad config. Due to -# dependencies and selections of the kbuild system, mulitple -# configs may be needed to cause a failure. If you disable the -# config that was found and restart the test, if the test fails -# again, it is recommended to rerun the config_bisect with a new -# bad config without the found config enabled. +# Although the MIN_CONFIG may be the config it starts with, the +# MIN_CONFIG is ignored. # # The option BUILD_TYPE will be ignored. # @@ -1160,13 +1146,16 @@ # CONFIG_BISECT_GOOD (optional) # If you have a good config to start with, then you # can specify it with CONFIG_BISECT_GOOD. Otherwise -# the MIN_CONFIG is the base. +# the MIN_CONFIG is the base, if MIN_CONFIG is not set +# It will build a config with "make defconfig" # # CONFIG_BISECT_CHECK (optional) # Set this to 1 if you want to confirm that the config ktest # generates (the bad config with the min config) is still bad. # It may be that the min config fixes what broke the bad config # and the test will not return a result. +# Set it to "good" to test only the good config and set it +# to "bad" to only test the bad config. # # Example: # TEST_START -- cgit v1.2.3-55-g7522