public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 05/19] ktest: Implement our own force min config
Date: Mon, 25 Jul 2011 21:22:43 -0400	[thread overview]
Message-ID: <20110726012425.555745364@goodmis.org> (raw)
In-Reply-To: 20110726012238.271008621@goodmis.org

[-- Attachment #1: 0005-ktest-Implement-our-own-force-min-config.patch --]
[-- Type: text/plain, Size: 4056 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

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>
---
 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 579569f..aa442a9 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -119,6 +119,7 @@ my $successes = 0;
 my %entered_configs;
 my %config_help;
 my %variable;
+my %force_config;
 
 $config_help{"MACHINE"} = << "EOF"
  The machine hostname that you will test.
@@ -1044,21 +1045,69 @@ sub check_buildlog {
     return 1;
 }
 
+sub apply_min_config {
+    my $outconfig = "$output_config.new";
+
+    # Read the config file and remove anything that
+    # is in the force_config hash (from minconfig and others)
+    # then add the force config back.
+
+    doprint "Applying minimum configurations into $output_config.new\n";
+
+    open (OUT, ">$outconfig") or
+	dodie "Can't create $outconfig";
+
+    if (-f $output_config) {
+	open (IN, $output_config) or
+	    dodie "Failed to open $output_config";
+	while (<IN>) {
+	    if (/^(# )?(CONFIG_[^\s=]*)/) {
+		next if (defined($force_config{$2}));
+	    }
+	    print OUT;
+	}
+	close IN;
+    }
+    foreach my $config (keys %force_config) {
+	print OUT "$force_config{$config}\n";
+    }
+    close OUT;
+
+    run_command "mv $outconfig $output_config";
+}
+
 sub make_oldconfig {
-    my ($defconfig) = @_;
 
-    if (!run_command "$defconfig $make oldnoconfig") {
+    apply_min_config;
+
+    if (!run_command "$make oldnoconfig") {
 	# Perhaps oldnoconfig doesn't exist in this version of the kernel
 	# try a yes '' | oldconfig
 	doprint "oldnoconfig failed, trying yes '' | make oldconfig\n";
-	run_command "yes '' | $defconfig $make oldconfig" or
+	run_command "yes '' | $make oldconfig" or
 	    dodie "failed make config oldconfig";
     }
 }
 
+# read a config file and use this to force new configs.
+sub load_force_config {
+    my ($config) = @_;
+
+    open(IN, $config) or
+	dodie "failed to read $config";
+    while (<IN>) {
+	chomp;
+	if (/^(CONFIG[^\s=]*)(\s*=.*)/) {
+	    $force_config{$1} = $_;
+	} elsif (/^# (CONFIG_\S*) is not set/) {
+	    $force_config{$1} = $_;
+	}
+    }
+    close IN;
+}
+
 sub build {
     my ($type) = @_;
-    my $defconfig = "";
 
     unlink $buildlog;
 
@@ -1098,15 +1147,15 @@ sub build {
     close(OUT);
 
     if (defined($minconfig)) {
-	$defconfig = "KCONFIG_ALLCONFIG=$minconfig";
+	load_force_config($minconfig);
     }
 
-    if ($type eq "oldnoconfig") {
-	make_oldconfig $defconfig;
-    } else {
-	run_command "$defconfig $make $type" or
+    if ($type ne "oldnoconfig") {
+	run_command "$make $type" or
 	    dodie "failed make config";
     }
+    # Run old config regardless, to enforce min configurations
+    make_oldconfig;
 
     $redirect = "$buildlog";
     if (!run_command "$make $build_options") {
@@ -1587,7 +1636,7 @@ sub create_config {
     close(OUT);
 
 #    exit;
-    make_oldconfig "";
+    make_oldconfig;
 }
 
 sub compare_configs {
@@ -1778,9 +1827,8 @@ sub config_bisect {
 	    dodie "failed to append $addconfig";
     }
 
-    my $defconfig = "";
     if (-f $tmpconfig) {
-	$defconfig = "KCONFIG_ALLCONFIG=$tmpconfig";
+	load_force_config($tmpconfig);
 	process_config_ignore $tmpconfig;
     }
 
@@ -1801,7 +1849,7 @@ sub config_bisect {
     close(IN);
 
     # Now run oldconfig with the minconfig (and addconfigs)
-    make_oldconfig $defconfig;
+    make_oldconfig;
 
     # check to see what we lost (or gained)
     open (IN, $output_config)
-- 
1.7.5.4



  parent reply	other threads:[~2011-07-26  1:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-26  1:22 [PATCH 00/19] [GIT PULL] ktest: new features and fixes Steven Rostedt
2011-07-26  1:22 ` [PATCH 01/19] ktest: Notify reason to break out of monitoring boot Steven Rostedt
2011-07-26  1:22 ` [PATCH 02/19] ktest: Add detection of triple faults Steven Rostedt
2011-07-26  1:22 ` [PATCH 03/19] ktest: Add CONFIG_BISECT_GOOD option Steven Rostedt
2011-07-26  1:22 ` [PATCH 04/19] ktest: Add TEST_NAME option Steven Rostedt
2011-07-26  1:22 ` Steven Rostedt [this message]
2011-07-26  1:22 ` [PATCH 06/19] ktest: Have wait on stdio honor bug timeout Steven Rostedt
2011-07-26  1:22 ` [PATCH 07/19] ktest: Have LOG_FILE evaluate options as well Steven Rostedt
2011-07-26  1:22 ` [PATCH 08/19] ktest: Allow initrd processing without modules defined Steven Rostedt
2011-07-26  1:22 ` [PATCH 09/19] ktest: Add POST/PRE_BUILD options Steven Rostedt
2011-07-26  1:22 ` [PATCH 10/19] ktest: Have the testing tmp dir include machine name Steven Rostedt
2011-07-26  1:22 ` [PATCH 11/19] ktest: Fix tar extracting of modules to target Steven Rostedt
2011-07-26  1:22 ` [PATCH 12/19] ktest: Add IGNORE_WARNINGS to ignore warnings in some patches Steven Rostedt
2011-07-26  1:22 ` [PATCH 13/19] ktest: Add helper function to avoid duplicate code Steven Rostedt
2011-07-26  1:22 ` [PATCH 14/19] ktest: Require one TEST_START in config file Steven Rostedt
2011-07-26  1:22 ` [PATCH 15/19] ktest: Add test type make_min_config Steven Rostedt
2011-07-26  1:22 ` [PATCH 16/19] ktest: Use Kconfig dependencies to shorten time to make min_config Steven Rostedt
2011-07-26  1:22 ` [PATCH 17/19] ktest: Add prompt to use OUTPUT_MIN_CONFIG Steven Rostedt
2011-07-26  1:22 ` [PATCH 18/19] ktest: Keep fonud configs separate from default configs Steven Rostedt
2011-07-26  1:22 ` [PATCH 19/19] ktest: Fix bug when ADD_CONFIG is set but MIN_CONFIG is not Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110726012425.555745364@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox