diff options
author | Steven Rostedt <srostedt@redhat.com> | 2011-07-15 21:57:25 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2011-07-15 21:57:25 -0400 |
commit | 35ce5952e62bc72520e6a7dbcfa4baf8c9f9eedb (patch) | |
tree | 8a9e88044c8ae0d3a2286c063d3c46e4e31664c5 /tools | |
parent | b9066f6c0e215386d4b888eaedd739397b987421 (diff) |
ktest: Add prompt to use OUTPUT_MIN_CONFIG
If the defined OUTPUT_MIN_CONFIG in the make_min_config test exists,
then give a prompt to ask the user if they want to use that config
instead, as it is very often the case, especially when the test has been
interrupted. The OUTPUT_MIN_CONFIG is usually the config that one wants
to use to continue the test where they left off.
But if START_MIN_CONFIG is defined (thus the MIN_CONFIG is not the
default), then do not prompt, as it will be annoying if the user has
this as one of many tests, and the test pauses waiting for input, while
the user is sleeping.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 70 | ||||
-rw-r--r-- | tools/testing/ktest/sample.conf | 3 |
2 files changed, 59 insertions, 14 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index a9f2e10fc16..cf45f58f8fd 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -87,6 +87,7 @@ my $post_install; my $noclean; my $minconfig; my $start_minconfig; +my $start_minconfig_defined; my $output_minconfig; my $ignore_config; my $addconfig; @@ -217,6 +218,26 @@ $config_help{"REBOOT_SCRIPT"} = << "EOF" EOF ; +sub read_yn { + my ($prompt) = @_; + + my $ans; + + for (;;) { + print "$prompt [Y/n] "; + $ans = <STDIN>; + chomp $ans; + if ($ans =~ /^\s*$/) { + $ans = "y"; + } + last if ($ans =~ /^y$/i || $ans =~ /^n$/i); + print "Please answer either 'y' or 'n'.\n"; + } + if ($ans !~ /^y$/i) { + return 0; + } + return 1; +} sub get_ktest_config { my ($config) = @_; @@ -2445,10 +2466,23 @@ sub make_min_config { if (!defined($output_minconfig)) { fail "OUTPUT_MIN_CONFIG not defined" and return; } + + # If output_minconfig exists, and the start_minconfig + # came from min_config, than ask if we should use + # that instead. + if (-f $output_minconfig && !$start_minconfig_defined) { + print "$output_minconfig exists\n"; + if (read_yn " Use it as minconfig?") { + $start_minconfig = $output_minconfig; + } + } + if (!defined($start_minconfig)) { fail "START_MIN_CONFIG or MIN_CONFIG not defined" and return; } + my $temp_config = "$tmpdir/temp_config"; + # First things first. We build an allnoconfig to find # out what the defaults are that we can't touch. # Some are selections, but we really can't handle selections. @@ -2581,6 +2615,19 @@ sub make_min_config { # this config is needed, add it to the ignore list. $keep_configs{$config} = $min_configs{$config}; delete $min_configs{$config}; + + # update new ignore configs + if (defined($ignore_config)) { + open (OUT, ">$temp_config") + or die "Can't write to $temp_config"; + foreach my $config (keys %keep_configs) { + print OUT "$keep_configs{$config}\n"; + } + close OUT; + run_command "mv $temp_config $ignore_config" or + dodie "failed to copy update to $ignore_config"; + } + } else { # We booted without this config, remove it from the minconfigs. doprint "$config is not needed, disabling\n"; @@ -2599,8 +2646,8 @@ sub make_min_config { } # Save off all the current mandidory configs - open (OUT, ">$output_minconfig") - or die "Can't write to $output_minconfig"; + open (OUT, ">$temp_config") + or die "Can't write to $temp_config"; foreach my $config (keys %keep_configs) { print OUT "$keep_configs{$config}\n"; } @@ -2608,6 +2655,9 @@ sub make_min_config { print OUT "$min_configs{$config}\n"; } close OUT; + + run_command "mv $temp_config $output_minconfig" or + dodie "failed to copy update to $output_minconfig"; } doprint "Reboot and wait $sleep_time seconds\n"; @@ -2627,18 +2677,7 @@ if ($#ARGV == 0) { $ktest_config = $ARGV[0]; if (! -f $ktest_config) { print "$ktest_config does not exist.\n"; - my $ans; - for (;;) { - print "Create it? [Y/n] "; - $ans = <STDIN>; - chomp $ans; - if ($ans =~ /^\s*$/) { - $ans = "y"; - } - last if ($ans =~ /^y$/i || $ans =~ /^n$/i); - print "Please answer either 'y' or 'n'.\n"; - } - if ($ans !~ /^y$/i) { + if (!read_yn "Create it?") { exit 0; } } @@ -2804,7 +2843,10 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { $target_image = set_test_option("TARGET_IMAGE", $i); $localversion = set_test_option("LOCALVERSION", $i); + $start_minconfig_defined = 1; + if (!defined($start_minconfig)) { + $start_minconfig_defined = 0; $start_minconfig = $minconfig; } diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf index d096a0c8040..b8bcd14b5a4 100644 --- a/tools/testing/ktest/sample.conf +++ b/tools/testing/ktest/sample.conf @@ -854,6 +854,9 @@ # this file as your new min config, and use it to continue the test. # This file does not need to exist on start of test. # This file is not created until a config is found that can be removed. +# If this file exists, you will be prompted if you want to use it +# as the min_config (overriding MIN_CONFIG) if START_MIN_CONFIG +# is not defined. # (required field) # # START_MIN_CONFIG is the config to use to start the test with. |