diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2011-07-15 21:16:17 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2011-07-15 21:19:44 -0400 |
| commit | 4c4ab1204fe4e201ece94c3062aa6b5eed670457 (patch) | |
| tree | 7317f1cf06600e5cd14a849d4875e764af4b3c3e | |
| parent | 0df213ca31f43faf0b1d6c7108e190ff198b42d3 (diff) | |
ktest: Add test type make_min_config
After doing a make localyesconfig, your kernel configuration may
not be the most useful minimum configuration. Having a true minimum
config that you can use against other configs is very useful if
someone else has a config that breaks on your code. By only forcing
those configurations that are truly required to boot your machine
will give you less of a chance that one of your set configurations
will make the bug go away. This will give you a better chance to
be able to reproduce the reported bug matching the broken config.
Note, this does take some time, and may require you to run the
test over night, or perhaps over the weekend. But it also allows
you to interrupt it, and gives you the current minimum config
that was found till that time.
Note, this test automatically assumes a BUILD_TYPE of oldconfig
and its test type acts like boot.
TODO: add a test version that makes the config do more than just
boot, like having network access.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rwxr-xr-x | tools/testing/ktest/ktest.pl | 255 | ||||
| -rw-r--r-- | tools/testing/ktest/sample.conf | 50 |
2 files changed, 301 insertions, 4 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 6166f3a0f2ea..5323c6f9bf9b 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
| @@ -86,6 +86,9 @@ my $make; | |||
| 86 | my $post_install; | 86 | my $post_install; |
| 87 | my $noclean; | 87 | my $noclean; |
| 88 | my $minconfig; | 88 | my $minconfig; |
| 89 | my $start_minconfig; | ||
| 90 | my $output_minconfig; | ||
| 91 | my $ignore_config; | ||
| 89 | my $addconfig; | 92 | my $addconfig; |
| 90 | my $in_bisect = 0; | 93 | my $in_bisect = 0; |
| 91 | my $bisect_bad = ""; | 94 | my $bisect_bad = ""; |
| @@ -1189,7 +1192,11 @@ sub apply_min_config { | |||
| 1189 | 1192 | ||
| 1190 | sub make_oldconfig { | 1193 | sub make_oldconfig { |
| 1191 | 1194 | ||
| 1192 | apply_min_config; | 1195 | my @force_list = keys %force_config; |
| 1196 | |||
| 1197 | if ($#force_list >= 0) { | ||
| 1198 | apply_min_config; | ||
| 1199 | } | ||
| 1193 | 1200 | ||
| 1194 | if (!run_command "$make oldnoconfig") { | 1201 | if (!run_command "$make oldnoconfig") { |
| 1195 | # Perhaps oldnoconfig doesn't exist in this version of the kernel | 1202 | # Perhaps oldnoconfig doesn't exist in this version of the kernel |
| @@ -1678,21 +1685,27 @@ my %null_config; | |||
| 1678 | 1685 | ||
| 1679 | my %dependency; | 1686 | my %dependency; |
| 1680 | 1687 | ||
| 1681 | sub process_config_ignore { | 1688 | sub assign_configs { |
| 1682 | my ($config) = @_; | 1689 | my ($hash, $config) = @_; |
| 1683 | 1690 | ||
| 1684 | open (IN, $config) | 1691 | open (IN, $config) |
| 1685 | or dodie "Failed to read $config"; | 1692 | or dodie "Failed to read $config"; |
| 1686 | 1693 | ||
| 1687 | while (<IN>) { | 1694 | while (<IN>) { |
| 1688 | if (/^((CONFIG\S*)=.*)/) { | 1695 | if (/^((CONFIG\S*)=.*)/) { |
| 1689 | $config_ignore{$2} = $1; | 1696 | ${$hash}{$2} = $1; |
| 1690 | } | 1697 | } |
| 1691 | } | 1698 | } |
| 1692 | 1699 | ||
| 1693 | close(IN); | 1700 | close(IN); |
| 1694 | } | 1701 | } |
| 1695 | 1702 | ||
| 1703 | sub process_config_ignore { | ||
| 1704 | my ($config) = @_; | ||
| 1705 | |||
| 1706 | assign_configs \%config_ignore, $config; | ||
| 1707 | } | ||
| 1708 | |||
| 1696 | sub read_current_config { | 1709 | sub read_current_config { |
| 1697 | my ($config_ref) = @_; | 1710 | my ($config_ref) = @_; |
| 1698 | 1711 | ||
| @@ -2149,6 +2162,226 @@ sub patchcheck { | |||
| 2149 | return 1; | 2162 | return 1; |
| 2150 | } | 2163 | } |
| 2151 | 2164 | ||
| 2165 | sub read_config_list { | ||
| 2166 | my ($config) = @_; | ||
| 2167 | |||
| 2168 | open (IN, $config) | ||
| 2169 | or dodie "Failed to read $config"; | ||
| 2170 | |||
| 2171 | while (<IN>) { | ||
| 2172 | if (/^((CONFIG\S*)=.*)/) { | ||
| 2173 | if (!defined($config_ignore{$2})) { | ||
| 2174 | $config_list{$2} = $1; | ||
| 2175 | } | ||
| 2176 | } | ||
| 2177 | } | ||
| 2178 | |||
| 2179 | close(IN); | ||
| 2180 | } | ||
| 2181 | |||
| 2182 | sub read_output_config { | ||
| 2183 | my ($config) = @_; | ||
| 2184 | |||
| 2185 | assign_configs \%config_ignore, $config; | ||
| 2186 | } | ||
| 2187 | |||
| 2188 | sub make_new_config { | ||
| 2189 | my @configs = @_; | ||
| 2190 | |||
| 2191 | open (OUT, ">$output_config") | ||
| 2192 | or dodie "Failed to write $output_config"; | ||
| 2193 | |||
| 2194 | foreach my $config (@configs) { | ||
| 2195 | print OUT "$config\n"; | ||
| 2196 | } | ||
| 2197 | close OUT; | ||
| 2198 | } | ||
| 2199 | |||
| 2200 | sub make_min_config { | ||
| 2201 | my ($i) = @_; | ||
| 2202 | |||
| 2203 | if (!defined($output_minconfig)) { | ||
| 2204 | fail "OUTPUT_MIN_CONFIG not defined" and return; | ||
| 2205 | } | ||
| 2206 | if (!defined($start_minconfig)) { | ||
| 2207 | fail "START_MIN_CONFIG or MIN_CONFIG not defined" and return; | ||
| 2208 | } | ||
| 2209 | |||
| 2210 | # First things first. We build an allnoconfig to find | ||
| 2211 | # out what the defaults are that we can't touch. | ||
| 2212 | # Some are selections, but we really can't handle selections. | ||
| 2213 | |||
| 2214 | my $save_minconfig = $minconfig; | ||
| 2215 | undef $minconfig; | ||
| 2216 | |||
| 2217 | run_command "$make allnoconfig" or return 0; | ||
| 2218 | |||
| 2219 | process_config_ignore $output_config; | ||
| 2220 | my %keep_configs; | ||
| 2221 | |||
| 2222 | if (defined($ignore_config)) { | ||
| 2223 | # make sure the file exists | ||
| 2224 | `touch $ignore_config`; | ||
| 2225 | assign_configs \%keep_configs, $ignore_config; | ||
| 2226 | } | ||
| 2227 | |||
| 2228 | doprint "Load initial configs from $start_minconfig\n"; | ||
| 2229 | |||
| 2230 | # Look at the current min configs, and save off all the | ||
| 2231 | # ones that were set via the allnoconfig | ||
| 2232 | my %min_configs; | ||
| 2233 | assign_configs \%min_configs, $start_minconfig; | ||
| 2234 | |||
| 2235 | my @config_keys = keys %min_configs; | ||
| 2236 | |||
| 2237 | # Remove anything that was set by the make allnoconfig | ||
| 2238 | # we shouldn't need them as they get set for us anyway. | ||
| 2239 | foreach my $config (@config_keys) { | ||
| 2240 | # Remove anything in the ignore_config | ||
| 2241 | if (defined($keep_configs{$config})) { | ||
| 2242 | my $file = $ignore_config; | ||
| 2243 | $file =~ s,.*/(.*?)$,$1,; | ||
| 2244 | doprint "$config set by $file ... ignored\n"; | ||
| 2245 | delete $min_configs{$config}; | ||
| 2246 | next; | ||
| 2247 | } | ||
| 2248 | # But make sure the settings are the same. If a min config | ||
| 2249 | # sets a selection, we do not want to get rid of it if | ||
| 2250 | # it is not the same as what we have. Just move it into | ||
| 2251 | # the keep configs. | ||
| 2252 | if (defined($config_ignore{$config})) { | ||
| 2253 | if ($config_ignore{$config} ne $min_configs{$config}) { | ||
| 2254 | doprint "$config is in allnoconfig as '$config_ignore{$config}'"; | ||
| 2255 | doprint " but it is '$min_configs{$config}' in minconfig .. keeping\n"; | ||
| 2256 | $keep_configs{$config} = $min_configs{$config}; | ||
| 2257 | } else { | ||
| 2258 | doprint "$config set by allnoconfig ... ignored\n"; | ||
| 2259 | } | ||
| 2260 | delete $min_configs{$config}; | ||
| 2261 | } | ||
| 2262 | } | ||
| 2263 | |||
| 2264 | my %nochange_config; | ||
| 2265 | |||
| 2266 | my $done = 0; | ||
| 2267 | |||
| 2268 | while (!$done) { | ||
| 2269 | |||
| 2270 | my $config; | ||
| 2271 | my $found; | ||
| 2272 | |||
| 2273 | # Now disable each config one by one and do a make oldconfig | ||
| 2274 | # till we find a config that changes our list. | ||
| 2275 | |||
| 2276 | # Put configs that did not modify the config at the end. | ||
| 2277 | my @test_configs = keys %min_configs; | ||
| 2278 | my $reset = 1; | ||
| 2279 | for (my $i = 0; $i < $#test_configs; $i++) { | ||
| 2280 | if (!defined($nochange_config{$test_configs[0]})) { | ||
| 2281 | $reset = 0; | ||
| 2282 | last; | ||
| 2283 | } | ||
| 2284 | # This config didn't change the .config last time. | ||
| 2285 | # Place it at the end | ||
| 2286 | my $config = shift @test_configs; | ||
| 2287 | push @test_configs, $config; | ||
| 2288 | } | ||
| < | |||
