diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 71 |
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 | ||
2374 | my %depends; | 2374 | my %depends; |
2375 | my %depcount; | ||
2375 | my $iflevel = 0; | 2376 | my $iflevel = 0; |
2376 | my @ifdeps; | 2377 | my @ifdeps; |
2377 | 2378 | ||
2378 | # prevent recursion | 2379 | # prevent recursion |
2379 | my %read_kconfigs; | 2380 | my %read_kconfigs; |
2380 | 2381 | ||
2382 | sub 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 |
2382 | sub read_kconfig { | 2401 | sub 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 | ||
2570 | sub chomp_config { | ||
2571 | my ($config) = @_; | ||
2572 | |||
2573 | $config =~ s/CONFIG_//; | ||
2574 | |||
2575 | return $config; | ||
2576 | } | ||
2577 | |||
2562 | sub get_depends { | 2578 | sub 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]})) { |