[for-next][PATCH 08/23] ktest: Use config-bisect.pl in ktest.pl
From: Scott WoodReduce code duplication and take advantage of bisection logic improvements by calling config-bisect.pl. The output of make oldconfig is now copied directly to the desired file, rather than doing assign_configs+save_config, in order to preserve the ordering so that diffing the configs at the end will provide useful output. Link: http://lkml.kernel.org/r/20170717001630.10518-8-sw...@redhat.com Signed-off-by: Scott Wood [ Modified to use with new version of config-bisect.pl ] Signed-off-by: Steven Rostedt (VMware) --- tools/testing/ktest/ktest.pl | 264 +++ 1 file changed, 42 insertions(+), 222 deletions(-) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index f597f9b4e8d5..ad00ce699749 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -3092,76 +3092,6 @@ sub create_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}; - } -} - -return %ret; -} - -# 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 $item (keys %b) { - if (!defined($a{$item})) { - $ret{$item} = $b{$item}; - } -} - -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 ($pa, $pb) = @_; - -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; - } -} - -foreach my $item (keys %a) { - if (!defined($b{$item})) { - return -1; - } -} - -return 0; -} - sub run_config_bisect_test { my ($type) = @_; @@ -3174,166 +3104,49 @@ sub run_config_bisect_test { return $ret; } -sub process_failed { -my ($config) = @_; +sub config_bisect_end { +my ($good, $bad) = @_; doprint "\n\n***\n"; -doprint "Found bad config: $config\n"; +doprint "No more config bisecting possible.\n"; +doprint `diff -u $good $bad`; doprint "***\n\n"; } -# used for config bisecting -my $good_config; -my $bad_config; - -sub process_new_config { -my ($tc, $nc, $gc, $bc) = @_; - -my %tmp_config = %{$tc}; -my %good_configs = %{$gc}; -my %bad_configs = %{$bc}; - -my %new_configs; - -my $runtest = 1; -my $ret; - -create_config "tmp_configs", \%tmp_config; -assign_configs \%new_configs, $output_config; - -$ret = compare_configs \%new_configs, \%bad_configs; -if (!$ret) { - doprint "New config equals bad config, try next test\n"; - $runtest = 0; -} - -if ($runtest) { - $ret = compare_configs \%new_configs, \%good_configs; - if (!$ret) { - doprint "New config equals good config, try next test\n"; - $runtest = 0; - } -} - -%{$nc} = %new_configs; - -return $runtest; -} - sub run_config_bisect { -my ($pgood, $pbad) = @_; - -my $type = $config_bisect_type; - -my %good_configs = %{$pgood}; -my %bad_configs = %{$pbad}; - -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; - -my @diff_arr = keys %diff_configs; -my $len_diff = $#diff_arr + 1; - -my @b_arr = keys %b_configs; -my $len_b = $#b_arr + 1; - -my @g_arr = keys %g_configs; -my $len_g = $#g_arr + 1; - -my $runtest = 1; -my %new_configs; +my ($good, $bad, $last_result) = @_; +my $cmd; my $ret; -# 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? - -# Enable all of one set and see if we get a new bad -# or good config. - -# first set the good config to the bad values. - -doprint "d=$len_diff g=$len_g b=$len_b\n"; - -# first lets enable things in bad config that are enabled in good config - -if ($len_diff > 0) { - if ($len_b > 0 || $len_g > 0)
[for-next][PATCH 08/23] ktest: Use config-bisect.pl in ktest.pl
From: Scott Wood Reduce code duplication and take advantage of bisection logic improvements by calling config-bisect.pl. The output of make oldconfig is now copied directly to the desired file, rather than doing assign_configs+save_config, in order to preserve the ordering so that diffing the configs at the end will provide useful output. Link: http://lkml.kernel.org/r/20170717001630.10518-8-sw...@redhat.com Signed-off-by: Scott Wood [ Modified to use with new version of config-bisect.pl ] Signed-off-by: Steven Rostedt (VMware) --- tools/testing/ktest/ktest.pl | 264 +++ 1 file changed, 42 insertions(+), 222 deletions(-) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index f597f9b4e8d5..ad00ce699749 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -3092,76 +3092,6 @@ sub create_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}; - } -} - -return %ret; -} - -# 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 $item (keys %b) { - if (!defined($a{$item})) { - $ret{$item} = $b{$item}; - } -} - -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 ($pa, $pb) = @_; - -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; - } -} - -foreach my $item (keys %a) { - if (!defined($b{$item})) { - return -1; - } -} - -return 0; -} - sub run_config_bisect_test { my ($type) = @_; @@ -3174,166 +3104,49 @@ sub run_config_bisect_test { return $ret; } -sub process_failed { -my ($config) = @_; +sub config_bisect_end { +my ($good, $bad) = @_; doprint "\n\n***\n"; -doprint "Found bad config: $config\n"; +doprint "No more config bisecting possible.\n"; +doprint `diff -u $good $bad`; doprint "***\n\n"; } -# used for config bisecting -my $good_config; -my $bad_config; - -sub process_new_config { -my ($tc, $nc, $gc, $bc) = @_; - -my %tmp_config = %{$tc}; -my %good_configs = %{$gc}; -my %bad_configs = %{$bc}; - -my %new_configs; - -my $runtest = 1; -my $ret; - -create_config "tmp_configs", \%tmp_config; -assign_configs \%new_configs, $output_config; - -$ret = compare_configs \%new_configs, \%bad_configs; -if (!$ret) { - doprint "New config equals bad config, try next test\n"; - $runtest = 0; -} - -if ($runtest) { - $ret = compare_configs \%new_configs, \%good_configs; - if (!$ret) { - doprint "New config equals good config, try next test\n"; - $runtest = 0; - } -} - -%{$nc} = %new_configs; - -return $runtest; -} - sub run_config_bisect { -my ($pgood, $pbad) = @_; - -my $type = $config_bisect_type; - -my %good_configs = %{$pgood}; -my %bad_configs = %{$pbad}; - -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; - -my @diff_arr = keys %diff_configs; -my $len_diff = $#diff_arr + 1; - -my @b_arr = keys %b_configs; -my $len_b = $#b_arr + 1; - -my @g_arr = keys %g_configs; -my $len_g = $#g_arr + 1; - -my $runtest = 1; -my %new_configs; +my ($good, $bad, $last_result) = @_; +my $cmd; my $ret; -# 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? - -# Enable all of one set and see if we get a new bad -# or good config. - -# first set the good config to the bad values. - -doprint "d=$len_diff g=$len_g b=$len_b\n"; - -# first lets enable things in bad config that are enabled in good config - -if ($len_diff > 0) { - if ($len_b > 0 || $len_g > 0) { - my %tmp_config = %bad_configs; - -