aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-07-15 21:57:25 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-07-15 21:57:25 -0400
commit35ce5952e62bc72520e6a7dbcfa4baf8c9f9eedb (patch)
tree8a9e88044c8ae0d3a2286c063d3c46e4e31664c5 /tools
parentb9066f6c0e215386d4b888eaedd739397b987421 (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-xtools/testing/ktest/ktest.pl70
-rw-r--r--tools/testing/ktest/sample.conf3
2 files changed, 59 insertions, 14 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index a9f2e10fc16f..cf45f58f8fdf 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -87,6 +87,7 @@ my $post_install;
87my $noclean; 87my $noclean;
88my $minconfig; 88my $minconfig;
89my $start_minconfig; 89my $start_minconfig;
90my $start_minconfig_defined;
90my $output_minconfig; 91my $output_minconfig;
91my $ignore_config; 92my $ignore_config;
92my $addconfig; 93my $addconfig;
@@ -217,6 +218,26 @@ $config_help{"REBOOT_SCRIPT"} = << "EOF"
217EOF 218EOF
218 ; 219 ;
219 220
221sub read_yn {
222 my ($prompt) = @_;
223
224 my $ans;
225
226 for (;;) {
227 print "$prompt [Y/n] ";
228 $ans = <STDIN>;
229 chomp $ans;
230 if ($ans =~ /^\s*$/) {
231 $ans = "y";
232 }
233 last if ($ans =~ /^y$/i || $ans =~ /^n$/i);
234 print "Please answer either 'y' or 'n'.\n";
235 }
236 if ($ans !~ /^y$/i) {
237 return 0;
238 }
239 return 1;
240}
220 241
221sub get_ktest_config { 242sub get_ktest_config {
222 my ($config) = @_; 243 my ($config) = @_;
@@ -2445,10 +2466,23 @@ sub make_min_config {
2445 if (!defined($output_minconfig)) { 2466 if (!defined($output_minconfig)) {
2446 fail "OUTPUT_MIN_CONFIG not defined" and return; 2467 fail "OUTPUT_MIN_CONFIG not defined" and return;
2447 } 2468 }
2469
2470 # If output_minconfig exists, and the start_minconfig
2471 # came from min_config, than ask if we should use
2472 # that instead.
2473 if (-f $output_minconfig && !$start_minconfig_defined) {
2474 print "$output_minconfig exists\n";
2475 if (read_yn " Use it as minconfig?") {
2476 $start_minconfig = $output_minconfig;
2477 }
2478 }
2479
2448 if (!defined($start_minconfig)) { 2480 if (!defined($start_minconfig)) {
2449 fail "START_MIN_CONFIG or MIN_CONFIG not defined" and return; 2481 fail "START_MIN_CONFIG or MIN_CONFIG not defined" and return;
2450 } 2482 }
2451 2483
2484 my $temp_config = "$tmpdir/temp_config";
2485
2452 # First things first. We build an allnoconfig to find 2486 # First things first. We build an allnoconfig to find
2453 # out what the defaults are that we can't touch. 2487 # out what the defaults are that we can't touch.
2454 # Some are selections, but we really can't handle selections. 2488 # Some are selections, but we really can't handle selections.
@@ -2581,6 +2615,19 @@ sub make_min_config {
2581 # this config is needed, add it to the ignore list. 2615 # this config is needed, add it to the ignore list.
2582 $keep_configs{$config} = $min_configs{$config}; 2616 $keep_configs{$config} = $min_configs{$config};
2583 delete $min_configs{$config}; 2617 delete $min_configs{$config};
2618
2619 # update new ignore configs
2620 if (defined($ignore_config)) {
2621 open (OUT, ">$temp_config")
2622 or die "Can't write to $temp_config";
2623 foreach my $config (keys %keep_configs) {
2624 print OUT "$keep_configs{$config}\n";
2625 }
2626 close OUT;
2627 run_command "mv $temp_config $ignore_config" or
2628 dodie "failed to copy update to $ignore_config";
2629 }
2630
2584 } else { 2631 } else {
2585 # We booted without this config, remove it from the minconfigs. 2632 # We booted without this config, remove it from the minconfigs.
2586 doprint "$config is not needed, disabling\n"; 2633 doprint "$config is not needed, disabling\n";
@@ -2599,8 +2646,8 @@ sub make_min_config {
2599 } 2646 }
2600 2647
2601 # Save off all the current mandidory configs 2648 # Save off all the current mandidory configs
2602 open (OUT, ">$output_minconfig") 2649 open (OUT, ">$temp_config")
2603 or die "Can't write to $output_minconfig"; 2650 or die "Can't write to $temp_config";
2604 foreach my $config (keys %keep_configs) { 2651 foreach my $config (keys %keep_configs) {
2605 print OUT "$keep_configs{$config}\n"; 2652 print OUT "$keep_configs{$config}\n";
2606 } 2653 }
@@ -2608,6 +2655,9 @@ sub make_min_config {
2608 print OUT "$min_configs{$config}\n"; 2655 print OUT "$min_configs{$config}\n";
2609 } 2656 }
2610 close OUT; 2657 close OUT;
2658
2659 run_command "mv $temp_config $output_minconfig" or
2660 dodie "failed to copy update to $output_minconfig";
2611 } 2661 }
2612 2662
2613 doprint "Reboot and wait $sleep_time seconds\n"; 2663 doprint "Reboot and wait $sleep_time seconds\n";
@@ -2627,18 +2677,7 @@ if ($#ARGV == 0) {
2627 $ktest_config = $ARGV[0]; 2677 $ktest_config = $ARGV[0];
2628 if (! -f $ktest_config) { 2678 if (! -f $ktest_config) {
2629 print "$ktest_config does not exist.\n"; 2679 print "$ktest_config does not exist.\n";
2630 my $ans; 2680 if (!read_yn "Create it?") {
2631 for (;;) {
2632 print "Create it? [Y/n] ";
2633 $ans = <STDIN>;
2634 chomp $ans;
2635 if ($ans =~ /^\s*$/) {
2636 $ans = "y";
2637 }
2638 last if ($ans =~ /^y$/i || $ans =~ /^n$/i);
2639 print "Please answer either 'y' or 'n'.\n";
2640 }
2641 if ($ans !~ /^y$/i) {
2642 exit 0; 2681 exit 0;
2643 } 2682 }
2644 } 2683 }
@@ -2804,7 +2843,10 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
2804 $target_image = set_test_option("TARGET_IMAGE", $i); 2843 $target_image = set_test_option("TARGET_IMAGE", $i);
2805 $localversion = set_test_option("LOCALVERSION", $i); 2844 $localversion = set_test_option("LOCALVERSION", $i);
2806 2845
2846 $start_minconfig_defined = 1;
2847
2807 if (!defined($start_minconfig)) { 2848 if (!defined($start_minconfig)) {
2849 $start_minconfig_defined = 0;
2808 $start_minconfig = $minconfig; 2850 $start_minconfig = $minconfig;
2809 } 2851 }
2810 2852
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index d096a0c80401..b8bcd14b5a4d 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -854,6 +854,9 @@
854# this file as your new min config, and use it to continue the test. 854# this file as your new min config, and use it to continue the test.
855# This file does not need to exist on start of test. 855# This file does not need to exist on start of test.
856# This file is not created until a config is found that can be removed. 856# This file is not created until a config is found that can be removed.
857# If this file exists, you will be prompted if you want to use it
858# as the min_config (overriding MIN_CONFIG) if START_MIN_CONFIG
859# is not defined.
857# (required field) 860# (required field)
858# 861#
859# START_MIN_CONFIG is the config to use to start the test with. 862# START_MIN_CONFIG is the config to use to start the test with.