diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-11-02 14:57:43 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-11-18 11:23:07 -0500 |
| commit | 5a391fbff8755592eb080784ef32ff818d2daa44 (patch) | |
| tree | 5efe64b62ad61a5b5a82326cd8342d39222baabc /tools | |
| parent | 5f9b6ced04a4e9c3ee6b4d4042ac5935ef5a8dbd (diff) | |
ktest: Added better console, add test build
Better reading of the console.
Added running a script to do testing after build succeeds.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/testing/ktest/ktest.pl | 207 |
1 files changed, 159 insertions, 48 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index a34f6f4193df..9eaf8d05c749 100644 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
| @@ -23,6 +23,7 @@ $opt{"REBOOT_ON_ERROR"} = 0; | |||
| 23 | $opt{"POWEROFF_ON_ERROR"} = 0; | 23 | $opt{"POWEROFF_ON_ERROR"} = 0; |
| 24 | $opt{"POWEROFF_ON_SUCCESS"} = 0; | 24 | $opt{"POWEROFF_ON_SUCCESS"} = 0; |
| 25 | $opt{"BUILD_OPTIONS"} = ""; | 25 | $opt{"BUILD_OPTIONS"} = ""; |
| 26 | $opt{"BISECT_SLEEP_TIME"} = 10; # sleep time between bisects | ||
| 26 | 27 | ||
| 27 | my $version; | 28 | my $version; |
| 28 | my $grub_number; | 29 | my $grub_number; |
| @@ -32,6 +33,7 @@ my $noclean; | |||
| 32 | my $minconfig; | 33 | my $minconfig; |
| 33 | my $in_bisect = 0; | 34 | my $in_bisect = 0; |
| 34 | my $bisect_bad = ""; | 35 | my $bisect_bad = ""; |
| 36 | my $run_test; | ||
| 35 | 37 | ||
| 36 | sub read_config { | 38 | sub read_config { |
| 37 | my ($config) = @_; | 39 | my ($config) = @_; |
| @@ -68,7 +70,7 @@ sub doprint { | |||
| 68 | } | 70 | } |
| 69 | 71 | ||
| 70 | sub dodie { | 72 | sub dodie { |
| 71 | doprint "CRITICAL FAILURE... ", @_; | 73 | doprint "CRITICAL FAILURE... ", @_, "\n"; |
| 72 | 74 | ||
| 73 | if ($opt{"REBOOT_ON_ERROR"}) { | 75 | if ($opt{"REBOOT_ON_ERROR"}) { |
| 74 | doprint "REBOOTING\n"; | 76 | doprint "REBOOTING\n"; |
| @@ -84,14 +86,14 @@ sub dodie { | |||
| 84 | 86 | ||
| 85 | sub run_command { | 87 | sub run_command { |
| 86 | my ($command) = @_; | 88 | my ($command) = @_; |
| 87 | my $redirect = ""; | 89 | my $redirect_log = ""; |
| 88 | 90 | ||
| 89 | if (defined($opt{"LOG_FILE"})) { | 91 | if (defined($opt{"LOG_FILE"})) { |
| 90 | $redirect = " >> $opt{LOG_FILE} 2>&1"; | 92 | $redirect_log = " >> $opt{LOG_FILE} 2>&1"; |
| 91 | } | 93 | } |
| 92 | 94 | ||
| 93 | doprint "$command ... "; | 95 | doprint "$command ... "; |
| 94 | `$command $redirect`; | 96 | `$command $redirect_log`; |
| 95 | 97 | ||
| 96 | my $failed = $?; | 98 | my $failed = $?; |
| 97 | 99 | ||
| @@ -106,7 +108,7 @@ sub run_command { | |||
| 106 | 108 | ||
| 107 | sub get_grub_index { | 109 | sub get_grub_index { |
| 108 | 110 | ||
| 109 | return if ($grub_number >= 0); | 111 | return if (defined($grub_number)); |
| 110 | 112 | ||
| 111 | doprint "Find grub menu ... "; | 113 | doprint "Find grub menu ... "; |
| 112 | $grub_number = -1; | 114 | $grub_number = -1; |
| @@ -164,28 +166,40 @@ sub reboot_to { | |||
| 164 | run_command "ssh $target '(echo \"savedefault --default=$grub_number --once\" | grub --batch; reboot)'"; | 166 | run_command "ssh $target '(echo \"savedefault --default=$grub_number --once\" | grub --batch; reboot)'"; |
| 165 | } | 167 | } |
| 166 | 168 | ||
| 167 | sub monitor { | 169 | sub open_console { |
| 170 | my ($fp) = @_; | ||
| 171 | |||
| 168 | my $flags; | 172 | my $flags; |
| 173 | |||
| 174 | my $pid = open($fp, "$opt{CONSOLE}|") or | ||
| 175 | dodie "Can't open console $opt{CONSOLE}"; | ||
| 176 | |||
| 177 | $flags = fcntl($fp, F_GETFL, 0) or | ||
| 178 | dodie "Can't get flags for the socket: $!\n"; | ||
| 179 | $flags = fcntl($fp, F_SETFL, $flags | O_NONBLOCK) or | ||
| 180 | dodie "Can't set flags for the socket: $!\n"; | ||
| 181 | |||
| 182 | return $pid; | ||
| 183 | } | ||
| 184 | |||
| 185 | sub close_console { | ||
| 186 | my ($fp, $pid) = @_; | ||
| 187 | |||
| 188 | doprint "kill child process $pid\n"; | ||
| 189 | kill 2, $pid; | ||
| 190 | |||
| 191 | print "closing!\n"; | ||
| 192 | close($fp); | ||
| 193 | } | ||
| 194 | |||
| 195 | sub monitor { | ||
| 169 | my $booted = 0; | 196 | my $booted = 0; |
| 170 | my $bug = 0; | 197 | my $bug = 0; |
| 171 | my $pid; | 198 | my $pid; |
| 172 | my $doopen2 = 0; | ||
| 173 | my $skip_call_trace = 0; | 199 | my $skip_call_trace = 0; |
| 200 | my $fp = \*IN; | ||
| 174 | 201 | ||
| 175 | if ($doopen2) { | 202 | $pid = open_console($fp); |
| 176 | $pid = open2(\*IN, \*OUT, $opt{"CONSOLE"}); | ||
| 177 | if ($pid < 0) { | ||
| 178 | dodie "Failed to connect to the console"; | ||
| 179 | } | ||
| 180 | } else { | ||
| 181 | $pid = open(IN, "$opt{CONSOLE} |"); | ||
| 182 | } | ||
| 183 | |||
| 184 | $flags = fcntl(IN, F_GETFL, 0) or | ||
| 185 | dodie "Can't get flags for the socket: $!\n"; | ||
| 186 | |||
| 187 | $flags = fcntl(IN, F_SETFL, $flags | O_NONBLOCK) or | ||
| 188 | dodie "Can't set flags for the socket: $!\n"; | ||
| 189 | 203 | ||
| 190 | my $line; | 204 | my $line; |
| 191 | my $full_line = ""; | 205 | my $full_line = ""; |
| @@ -193,14 +207,14 @@ sub monitor { | |||
| 193 | doprint "Wait for monitor to settle down.\n"; | 207 | doprint "Wait for monitor to settle down.\n"; |
| 194 | # read the monitor and wait for the system to calm down | 208 | # read the monitor and wait for the system to calm down |
| 195 | do { | 209 | do { |
| 196 | $line = wait_for_input(\*IN, 5); | 210 | $line = wait_for_input($fp, 5); |
| 197 | } while (defined($line)); | 211 | } while (defined($line)); |
| 198 | 212 | ||
| 199 | reboot_to; | 213 | reboot_to; |
| 200 | 214 | ||
| 201 | for (;;) { | 215 | for (;;) { |
| 202 | 216 | ||
| 203 | $line = wait_for_input(\*IN); | 217 | $line = wait_for_input($fp); |
| 204 | 218 | ||
| 205 | last if (!defined($line)); | 219 | last if (!defined($line)); |
| 206 | 220 | ||
| @@ -234,19 +248,15 @@ sub monitor { | |||
| 234 | } | 248 | } |
| 235 | } | 249 | } |
| 236 | 250 | ||
| 237 | doprint "kill child process $pid\n"; | 251 | close_console($fp, $pid); |
| 238 | kill 2, $pid; | ||
| 239 | |||
| 240 | print "closing!\n"; | ||
| 241 | close(IN); | ||
| 242 | 252 | ||
| 243 | if (!$booted) { | 253 | if (!$booted) { |
| 244 | return 1 if (!$in_bisect); | 254 | return 1 if ($in_bisect); |
| 245 | dodie "failed - never got a boot prompt.\n"; | 255 | dodie "failed - never got a boot prompt.\n"; |
| 246 | } | 256 | } |
| 247 | 257 | ||
| 248 | if ($bug) { | 258 | if ($bug) { |
| 249 | return 1 if (!$in_bisect); | 259 | return 1 if ($in_bisect); |
| 250 | dodie "failed - got a bug report\n"; | 260 | dodie "failed - got a bug report\n"; |
| 251 | } | 261 | } |
| 252 | 262 | ||
| @@ -395,6 +405,84 @@ sub get_version { | |||
| 395 | doprint "$version\n"; | 405 | doprint "$version\n"; |
| 396 | } | 406 | } |
| 397 | 407 | ||
| 408 | sub child_run_test { | ||
| 409 | my $failed; | ||
| 410 | |||
| 411 | $failed = !run_command $run_test; | ||
| 412 | exit $failed; | ||
| 413 | } | ||
| 414 | |||
| 415 | my $child_done; | ||
| 416 | |||
| 417 | sub child_finished { | ||
| 418 | $child_done = 1; | ||
| 419 | } | ||
| 420 | |||
| 421 | sub do_run_test { | ||
| 422 | my $child_pid; | ||
| 423 | my $child_exit; | ||
| 424 | my $pid; | ||
| 425 | my $line; | ||
| 426 | my $full_line; | ||
| 427 | my $bug = 0; | ||
| 428 | my $fp = \*IN; | ||
