diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-11-02 14:58:27 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-11-18 11:23:08 -0500 |
| commit | a75fececff3cc1e86d74e98de634ea2ed1b47697 (patch) | |
| tree | 85f6857fc44f8b9c110ed2fd27b02b4cbda81669 /tools/testing | |
| parent | 7faafbd69639b53b6cc2d450c283d9cc12e62c70 (diff) | |
ktest: Added sample.conf, new %default option format
Added sample.conf as a nice document to show new users.
Use a %default hash to separate out the options that are default
and allow us to complain about options being set twice.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing')
| -rw-r--r-- | tools/testing/ktest/ktest.pl | 461 | ||||
| -rw-r--r-- | tools/testing/ktest/sample.conf | 330 |
2 files changed, 649 insertions, 142 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index ff6283a44847..1f28c45f15b8 100644 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
| @@ -16,28 +16,45 @@ $#ARGV >= 0 || die "usage: autotest.pl config-file\n"; | |||
| 16 | $| = 1; | 16 | $| = 1; |
| 17 | 17 | ||
| 18 | my %opt; | 18 | my %opt; |
| 19 | my %default; | ||
| 19 | 20 | ||
| 20 | #default opts | 21 | #default opts |
| 21 | $opt{"NUM_BUILDS"} = 5; | 22 | $default{"NUM_TESTS"} = 5; |
| 22 | $opt{"BUILD_TYPE"} = "randconfig"; | 23 | $default{"REBOOT_TYPE"} = "grub"; |
| 23 | $opt{"MAKE_CMD"} = "make"; | 24 | $default{"TEST_TYPE"} = "test"; |
| 24 | $opt{"TIMEOUT"} = 120; | 25 | $default{"BUILD_TYPE"} = "randconfig"; |
| 25 | $opt{"TMP_DIR"} = "/tmp/autotest"; | 26 | $default{"MAKE_CMD"} = "make"; |
| 26 | $opt{"SLEEP_TIME"} = 60; # sleep time between tests | 27 | $default{"TIMEOUT"} = 120; |
| 27 | $opt{"BUILD_NOCLEAN"} = 0; | 28 | $default{"TMP_DIR"} = "/tmp/autotest"; |
| 28 | $opt{"REBOOT_ON_ERROR"} = 0; | 29 | $default{"SLEEP_TIME"} = 60; # sleep time between tests |
| 29 | $opt{"POWEROFF_ON_ERROR"} = 0; | 30 | $default{"BUILD_NOCLEAN"} = 0; |
| 30 | $opt{"REBOOT_ON_SUCCESS"} = 1; | 31 | $default{"REBOOT_ON_ERROR"} = 0; |
| 31 | $opt{"POWEROFF_ON_SUCCESS"} = 0; | 32 | $default{"POWEROFF_ON_ERROR"} = 0; |
| 32 | $opt{"BUILD_OPTIONS"} = ""; | 33 | $default{"REBOOT_ON_SUCCESS"} = 1; |
| 33 | $opt{"BISECT_SLEEP_TIME"} = 10; # sleep time between bisects | 34 | $default{"POWEROFF_ON_SUCCESS"} = 0; |
| 34 | $opt{"CLEAR_LOG"} = 0; | 35 | $default{"BUILD_OPTIONS"} = ""; |
| 35 | $opt{"SUCCESS_LINE"} = "login:"; | 36 | $default{"BISECT_SLEEP_TIME"} = 60; # sleep time between bisects |
| 36 | $opt{"BOOTED_TIMEOUT"} = 1; | 37 | $default{"CLEAR_LOG"} = 0; |
| 37 | $opt{"DIE_ON_FAILURE"} = 1; | 38 | $default{"SUCCESS_LINE"} = "login:"; |
| 39 | $default{"BOOTED_TIMEOUT"} = 1; | ||
| 40 | $default{"DIE_ON_FAILURE"} = 1; | ||
| 38 | 41 | ||
| 39 | my $version; | 42 | my $version; |
| 43 | my $machine; | ||
| 44 | my $tmpdir; | ||
| 45 | my $builddir; | ||
| 46 | my $outputdir; | ||
| 47 | my $test_type; | ||
| 40 | my $build_type; | 48 | my $build_type; |
| 49 | my $build_options; | ||
| 50 | my $reboot_type; | ||
| 51 | my $reboot_script; | ||
| 52 | my $power_cycle; | ||
| 53 | my $reboot_on_error; | ||
| 54 | my $poweroff_on_error; | ||
| 55 | my $die_on_failure; | ||
| 56 | my $power_off; | ||
| 57 | my $grub_menu; | ||
| 41 | my $grub_number; | 58 | my $grub_number; |
| 42 | my $target; | 59 | my $target; |
| 43 | my $make; | 60 | my $make; |
| @@ -55,6 +72,16 @@ my $dmesg; | |||
| 55 | my $monitor_fp; | 72 | my $monitor_fp; |
| 56 | my $monitor_pid; | 73 | my $monitor_pid; |
| 57 | my $monitor_cnt = 0; | 74 | my $monitor_cnt = 0; |
| 75 | my $sleep_time; | ||
| 76 | my $bisect_sleep_time; | ||
| 77 | my $store_failures; | ||
| 78 | my $timeout; | ||
| 79 | my $booted_timeout; | ||
| 80 | my $console; | ||
| 81 | my $success_line; | ||
| 82 | my $build_target; | ||
| 83 | my $target_image; | ||
| 84 | my $localversion; | ||
| 58 | 85 | ||
| 59 | sub read_config { | 86 | sub read_config { |
| 60 | my ($config) = @_; | 87 | my ($config) = @_; |
| @@ -70,11 +97,22 @@ sub read_config { | |||
| 70 | my $lvalue = $1; | 97 | my $lvalue = $1; |
| 71 | my $rvalue = $2; | 98 | my $rvalue = $2; |
| 72 | 99 | ||
| 100 | if (defined($opt{$lvalue})) { | ||
| 101 | die "Error: Option $lvalue defined more than once!\n"; | ||
| 102 | } | ||
| 73 | $opt{$lvalue} = $rvalue; | 103 | $opt{$lvalue} = $rvalue; |
| 74 | } | 104 | } |
| 75 | } | 105 | } |
| 76 | 106 | ||
| 77 | close(IN); | 107 | close(IN); |
| 108 | |||
| 109 | # set any defaults | ||
| 110 | |||
| 111 | foreach my $default (keys %default) { | ||
| 112 | if (!defined($opt{$default})) { | ||
| 113 | $opt{$default} = $default{$default}; | ||
| 114 | } | ||
| 115 | } | ||
| 78 | } | 116 | } |
| 79 | 117 | ||
| 80 | sub logit { | 118 | sub logit { |
| @@ -96,20 +134,20 @@ sub reboot { | |||
| 96 | # try to reboot normally | 134 | # try to reboot normally |
| 97 | if (!run_command "ssh $target reboot") { | 135 | if (!run_command "ssh $target reboot") { |
| 98 | # nope? power cycle it. | 136 | # nope? power cycle it. |
| 99 | run_command "$opt{POWER_CYCLE}"; | 137 | run_command "$power_cycle"; |
| 100 | } | 138 | } |
| 101 | } | 139 | } |
| 102 | 140 | ||
| 103 | sub dodie { | 141 | sub dodie { |
| 104 | doprint "CRITICAL FAILURE... ", @_, "\n"; | 142 | doprint "CRITICAL FAILURE... ", @_, "\n"; |
| 105 | 143 | ||
| 106 | if ($opt{"REBOOT_ON_ERROR"}) { | 144 | if ($reboot_on_error && $test_type ne "build") { |
| 107 | doprint "REBOOTING\n"; | 145 | doprint "REBOOTING\n"; |
| 108 | reboot; | 146 | reboot; |
| 109 | 147 | ||
| 110 | } elsif ($opt{"POWEROFF_ON_ERROR"} && defined($opt{"POWER_OFF"})) { | 148 | } elsif ($poweroff_on_error && defined($power_off)) { |
| 111 | doprint "POWERING OFF\n"; | 149 | doprint "POWERING OFF\n"; |
| 112 | `$opt{"POWER_OFF"}`; | 150 | `$power_off`; |
| 113 | } | 151 | } |
| 114 | 152 | ||
| 115 | die @_; | 153 | die @_; |
| @@ -120,8 +158,8 @@ sub open_console { | |||
| 120 | 158 | ||
| 121 | my $flags; | 159 | my $flags; |
| 122 | 160 | ||
| 123 | my $pid = open($fp, "$opt{CONSOLE}|") or | 161 | my $pid = open($fp, "$console|") or |
| 124 | dodie "Can't open console $opt{CONSOLE}"; | 162 | dodie "Can't open console $console"; |
| 125 | 163 | ||
| 126 | $flags = fcntl($fp, F_GETFL, 0) or | 164 | $flags = fcntl($fp, F_GETFL, 0) or |
| 127 | dodie "Can't get flags for the socket: $!\n"; | 165 | dodie "Can't get flags for the socket: $!\n"; |
| @@ -147,6 +185,10 @@ sub start_monitor { | |||
| 147 | } | 185 | } |
| 148 | $monitor_fp = \*MONFD; | 186 | $monitor_fp = \*MONFD; |
| 149 | $monitor_pid = open_console $monitor_fp; | 187 | $monitor_pid = open_console $monitor_fp; |
| 188 | |||
| 189 | return; | ||
| 190 | |||
| 191 | open(MONFD, "Stop perl from warning about single use of MONFD"); | ||
| 150 | } | 192 | } |
| 151 | 193 | ||
| 152 | sub end_monitor { | 194 | sub end_monitor { |
| @@ -160,43 +202,50 @@ sub wait_for_monitor { | |||
| 160 | my ($time) = @_; | 202 | my ($time) = @_; |
| 161 | my $line; | 203 | my $line; |
| 162 | 204 | ||
| 163 | doprint "Wait for monitor to settle down.\n"; | 205 | doprint "** Wait for monitor to settle down **\n"; |
| 164 | 206 | ||
| 165 | # read the monitor and wait for the system to calm down | 207 | # read the monitor and wait for the system to calm down |
| 166 | do { | 208 | do { |
| 167 | $line = wait_for_input($monitor_fp, $time); | 209 | $line = wait_for_input($monitor_fp, $time); |
| 210 | print "$line" if (defined($line)); | ||
| 168 | } while (defined($line)); | 211 | } while (defined($line)); |
| 212 | print "** Monitor flushed **\n"; | ||
| 169 | } | 213 | } |
| 170 | 214 | ||
| 171 | sub fail { | 215 | sub fail { |
| 172 | 216 | ||
| 173 | if ($opt{"DIE_ON_FAILURE"}) { | 217 | if ($die_on_failure) { |
| 174 | dodie @_; | 218 | dodie @_; |
| 175 | } | 219 | } |
| 176 | |||
