diff options
author | Steven Rostedt <srostedt@redhat.com> | 2011-06-13 10:40:58 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2011-06-13 10:40:58 -0400 |
commit | fcb3f16a4f4bf4e667ae4c68b1d5401824058efb (patch) | |
tree | ddba32878a33ea011fb677c91862f3ee7f4b9f78 /tools/testing | |
parent | 9064af5206c26ce0d47621fef216b0c43d65d693 (diff) |
ktest: Implement our own force min config
Using the build KCONFIG_ALLCONFIG environment variable to force
the min config may not always work properly. Since ktest is
written in perl, it is trivial to read and replace the current
config with the configs specified by the min config.
Now the min config (and add configs) are read by perl and before
a make is done, these configs in the .config file are replaced
by the version in the min config.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing')
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 74 |
1 files changed, 61 insertions, 13 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 579569f57b06..aa442a9075db 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
@@ -119,6 +119,7 @@ my $successes = 0; | |||
119 | my %entered_configs; | 119 | my %entered_configs; |
120 | my %config_help; | 120 | my %config_help; |
121 | my %variable; | 121 | my %variable; |
122 | my %force_config; | ||
122 | 123 | ||
123 | $config_help{"MACHINE"} = << "EOF" | 124 | $config_help{"MACHINE"} = << "EOF" |
124 | The machine hostname that you will test. | 125 | The machine hostname that you will test. |
@@ -1044,21 +1045,69 @@ sub check_buildlog { | |||
1044 | return 1; | 1045 | return 1; |
1045 | } | 1046 | } |
1046 | 1047 | ||
1048 | sub apply_min_config { | ||
1049 | my $outconfig = "$output_config.new"; | ||
1050 | |||
1051 | # Read the config file and remove anything that | ||
1052 | # is in the force_config hash (from minconfig and others) | ||
1053 | # then add the force config back. | ||
1054 | |||
1055 | doprint "Applying minimum configurations into $output_config.new\n"; | ||
1056 | |||
1057 | open (OUT, ">$outconfig") or | ||
1058 | dodie "Can't create $outconfig"; | ||
1059 | |||
1060 | if (-f $output_config) { | ||
1061 | open (IN, $output_config) or | ||
1062 | dodie "Failed to open $output_config"; | ||
1063 | while (<IN>) { | ||
1064 | if (/^(# )?(CONFIG_[^\s=]*)/) { | ||
1065 | next if (defined($force_config{$2})); | ||
1066 | } | ||
1067 | print OUT; | ||
1068 | } | ||
1069 | close IN; | ||
1070 | } | ||
1071 | foreach my $config (keys %force_config) { | ||
1072 | print OUT "$force_config{$config}\n"; | ||
1073 | } | ||
1074 | close OUT; | ||
1075 | |||
1076 | run_command "mv $outconfig $output_config"; | ||
1077 | } | ||
1078 | |||
1047 | sub make_oldconfig { | 1079 | sub make_oldconfig { |
1048 | my ($defconfig) = @_; | ||
1049 | 1080 | ||
1050 | if (!run_command "$defconfig $make oldnoconfig") { | 1081 | apply_min_config; |
1082 | |||
1083 | if (!run_command "$make oldnoconfig") { | ||
1051 | # Perhaps oldnoconfig doesn't exist in this version of the kernel | 1084 | # Perhaps oldnoconfig doesn't exist in this version of the kernel |
1052 | # try a yes '' | oldconfig | 1085 | # try a yes '' | oldconfig |
1053 | doprint "oldnoconfig failed, trying yes '' | make oldconfig\n"; | 1086 | doprint "oldnoconfig failed, trying yes '' | make oldconfig\n"; |
1054 | run_command "yes '' | $defconfig $make oldconfig" or | 1087 | run_command "yes '' | $make oldconfig" or |
1055 | dodie "failed make config oldconfig"; | 1088 | dodie "failed make config oldconfig"; |
1056 | } | 1089 | } |
1057 | } | 1090 | } |
1058 | 1091 | ||
1092 | # read a config file and use this to force new configs. | ||
1093 | sub load_force_config { | ||
1094 | my ($config) = @_; | ||
1095 | |||
1096 | open(IN, $config) or | ||
1097 | dodie "failed to read $config"; | ||
1098 | while (<IN>) { | ||
1099 | chomp; | ||
1100 | if (/^(CONFIG[^\s=]*)(\s*=.*)/) { | ||
1101 | $force_config{$1} = $_; | ||
1102 | } elsif (/^# (CONFIG_\S*) is not set/) { | ||
1103 | $force_config{$1} = $_; | ||
1104 | } | ||
1105 | } | ||
1106 | close IN; | ||
1107 | } | ||
1108 | |||
1059 | sub build { | 1109 | sub build { |
1060 | my ($type) = @_; | 1110 | my ($type) = @_; |
1061 | my $defconfig = ""; | ||
1062 | 1111 | ||
1063 | unlink $buildlog; | 1112 | unlink $buildlog; |
1064 | 1113 | ||
@@ -1098,15 +1147,15 @@ sub build { | |||
1098 | close(OUT); | 1147 | close(OUT); |
1099 | 1148 | ||
1100 | if (defined($minconfig)) { | 1149 | if (defined($minconfig)) { |
1101 | $defconfig = "KCONFIG_ALLCONFIG=$minconfig"; | 1150 | load_force_config($minconfig); |
1102 | } | 1151 | } |
1103 | 1152 | ||
1104 | if ($type eq "oldnoconfig") { | 1153 | if ($type ne "oldnoconfig") { |
1105 | make_oldconfig $defconfig; | 1154 | run_command "$make $type" or |
1106 | } else { | ||
1107 | run_command "$defconfig $make $type" or | ||
1108 | dodie "failed make config"; | 1155 | dodie "failed make config"; |
1109 | } | 1156 | } |
1157 | # Run old config regardless, to enforce min configurations | ||
1158 | make_oldconfig; | ||
1110 | 1159 | ||
1111 | $redirect = "$buildlog"; | 1160 | $redirect = "$buildlog"; |
1112 | if (!run_command "$make $build_options") { | 1161 | if (!run_command "$make $build_options") { |
@@ -1587,7 +1636,7 @@ sub create_config { | |||
1587 | close(OUT); | 1636 | close(OUT); |
1588 | 1637 | ||
1589 | # exit; | 1638 | # exit; |
1590 | make_oldconfig ""; | 1639 | make_oldconfig; |
1591 | } | 1640 | } |
1592 | 1641 | ||
1593 | sub compare_configs { | 1642 | sub compare_configs { |
@@ -1778,9 +1827,8 @@ sub config_bisect { | |||
1778 | dodie "failed to append $addconfig"; | 1827 | dodie "failed to append $addconfig"; |
1779 | } | 1828 | } |
1780 | 1829 | ||
1781 | my $defconfig = ""; | ||
1782 | if (-f $tmpconfig) { | 1830 | if (-f $tmpconfig) { |
1783 | $defconfig = "KCONFIG_ALLCONFIG=$tmpconfig"; | 1831 | load_force_config($tmpconfig); |
1784 | process_config_ignore $tmpconfig; | 1832 | process_config_ignore $tmpconfig; |
1785 | } | 1833 | } |
1786 | 1834 | ||
@@ -1801,7 +1849,7 @@ sub config_bisect { | |||
1801 | close(IN); | 1849 | close(IN); |
1802 | 1850 | ||
1803 | # Now run oldconfig with the minconfig (and addconfigs) | 1851 | # Now run oldconfig with the minconfig (and addconfigs) |
1804 | make_oldconfig $defconfig; | 1852 | make_oldconfig; |
1805 | 1853 | ||
1806 | # check to see what we lost (or gained) | 1854 | # check to see what we lost (or gained) |
1807 | open (IN, $output_config) | 1855 | open (IN, $output_config) |