aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-10-04 09:40:17 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-10-17 11:54:12 -0400
commitac6974c76e66c2f9b8b8a23b974c5f3d94302e81 (patch)
tree24307cfee6c449f171a4356ec328be838227f88e /tools
parent9900b5dc067551fcdcaec63d013b1d95b36835ae (diff)
ktest: Sort make_min_config configs by dependecies
The make_min_config test will turn off one config at a time and check if the config boots or not, and if it does, it will remove that config plus any config that depended on that config. ktest already looks if a config has a dependency and will try the dependency config first. But by sorting the configs and trying the config with the most configs dependent on it, we can shrink the minconfig faster. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/testing/ktest/ktest.pl71
1 files changed, 49 insertions, 22 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 76a5964595da..2a9d04207174 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -2372,12 +2372,31 @@ sub patchcheck {
2372} 2372}
2373 2373
2374my %depends; 2374my %depends;
2375my %depcount;
2375my $iflevel = 0; 2376my $iflevel = 0;
2376my @ifdeps; 2377my @ifdeps;
2377 2378
2378# prevent recursion 2379# prevent recursion
2379my %read_kconfigs; 2380my %read_kconfigs;
2380 2381
2382sub add_dep {
2383 # $config depends on $dep
2384 my ($config, $dep) = @_;
2385
2386 if (defined($depends{$config})) {
2387 $depends{$config} .= " " . $dep;
2388 } else {
2389 $depends{$config} = $dep;
2390 }
2391
2392 # record the number of configs depending on $dep
2393 if (defined $depcount{$dep}) {
2394 $depcount{$dep}++;
2395 } else {
2396 $depcount{$dep} = 1;
2397 }
2398}
2399
2381# taken from streamline_config.pl 2400# taken from streamline_config.pl
2382sub read_kconfig { 2401sub read_kconfig {
2383 my ($kconfig) = @_; 2402 my ($kconfig) = @_;
@@ -2424,30 +2443,19 @@ sub read_kconfig {
2424 $config = $2; 2443 $config = $2;
2425 2444
2426 for (my $i = 0; $i < $iflevel; $i++) { 2445 for (my $i = 0; $i < $iflevel; $i++) {
2427 if ($i) { 2446 add_dep $config, $ifdeps[$i];
2428 $depends{$config} .= " " . $ifdeps[$i];
2429 } else {
2430 $depends{$config} = $ifdeps[$i];
2431 }
2432 $state = "DEP";
2433 } 2447 }
2434 2448
2435 # collect the depends for the config 2449 # collect the depends for the config
2436 } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) { 2450 } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
2437 2451
2438 if (defined($depends{$1})) { 2452 add_dep $config, $1;
2439 $depends{$config} .= " " . $1;
2440 } else {
2441 $depends{$config} = $1;
2442 }
2443 2453
2444 # Get the configs that select this config 2454 # Get the configs that select this config
2445 } elsif ($state ne "NONE" && /^\s*select\s+(\S+)/) { 2455 } elsif ($state eq "NEW" && /^\s*select\s+(\S+)/) {
2446 if (defined($depends{$1})) { 2456
2447 $depends{$1} .= " " . $config; 2457 # selected by depends on config
2448 } else { 2458 add_dep $1, $config;
2449 $depends{$1} = $config;
2450 }
2451 2459
2452 # Check for if statements 2460 # Check for if statements
2453 } elsif (/^if\s+(.*\S)\s*$/) { 2461 } elsif (/^if\s+(.*\S)\s*$/) {
@@ -2559,11 +2567,18 @@ sub make_new_config {
2559 close OUT; 2567 close OUT;
2560} 2568}
2561 2569
2570sub chomp_config {
2571 my ($config) = @_;
2572
2573 $config =~ s/CONFIG_//;
2574
2575 return $config;
2576}
2577
2562sub get_depends { 2578sub get_depends {
2563 my ($dep) = @_; 2579 my ($dep) = @_;
2564 2580
2565 my $kconfig = $dep; 2581 my $kconfig = chomp_config $dep;
2566 $kconfig =~ s/CONFIG_//;
2567 2582
2568 $dep = $depends{"$kconfig"}; 2583 $dep = $depends{"$kconfig"};
2569 2584
@@ -2613,8 +2628,7 @@ sub test_this_config {
2613 return undef; 2628 return undef;
2614 } 2629 }
2615 2630
2616 my $kconfig = $config; 2631 my $kconfig = chomp_config $config;
2617 $kconfig =~ s/CONFIG_//;
2618 2632
2619 # Test dependencies first 2633 # Test dependencies first
2620 if (defined($depends{"$kconfig"})) { 2634 if (defined($depends{"$kconfig"})) {
@@ -2704,6 +2718,14 @@ sub make_min_config {
2704 2718
2705 my @config_keys = keys %min_configs; 2719 my @config_keys = keys %min_configs;
2706 2720
2721 # All configs need a depcount
2722 foreach my $config (@config_keys) {
2723 my $kconfig = chomp_config $config;
2724 if (!defined $depcount{$kconfig}) {
2725 $depcount{$kconfig} = 0;
2726 }
2727 }
2728
2707 # Remove anything that was set by the make allnoconfig 2729 # Remove anything that was set by the make allnoconfig
2708 # we shouldn't need them as they get set for us anyway. 2730 # we shouldn't need them as they get set for us anyway.
2709 foreach my $config (@config_keys) { 2731 foreach my $config (@config_keys) {
@@ -2742,8 +2764,13 @@ sub make_min_config {
2742 # Now disable each config one by one and do a make oldconfig 2764 # Now disable each config one by one and do a make oldconfig
2743 # till we find a config that changes our list. 2765 # till we find a config that changes our list.
2744 2766
2745 # Put configs that did not modify the config at the end.
2746 my @test_configs = keys %min_configs; 2767 my @test_configs = keys %min_configs;
2768
2769 # Sort keys by who is most dependent on
2770 @test_configs = sort { $depcount{chomp_config($b)} <=> $depcount{chomp_config($a)} }
2771 @test_configs ;
2772
2773 # Put configs that did not modify the config at the end.
2747 my $reset = 1; 2774 my $reset = 1;
2748 for (my $i = 0; $i < $#test_configs; $i++) { 2775 for (my $i = 0; $i < $#test_configs; $i++) {
2749 if (!defined($nochange_config{$test_configs[0]})) { 2776 if (!defined($nochange_config{$test_configs[0]})) {