aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/ktest
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-11-22 20:48:57 -0500
committerSteven Rostedt <rostedt@goodmis.org>2011-12-22 21:59:01 -0500
commitdad98754924735d4dfcbd49b68c00957e999c0ef (patch)
tree9d0a36d38ebe3c36dc2a56fdfa1e8c508d5469a6 /tools/testing/ktest
parent0e7a22de25212cfcaa0ba2c957e4e60eaa70fb9d (diff)
ktest: Allow bisect test to restart where it left off
If a bisect is killed for some reason, have ktest detect that a bisect is in progress and if so, allow the user to start the bisect where it left off. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing/ktest')
-rwxr-xr-xtools/testing/ktest/ktest.pl70
1 files changed, 64 insertions, 6 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 77b464980de1..2ffb67c3c49d 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -239,20 +239,36 @@ $config_help{"REBOOT_SCRIPT"} = << "EOF"
239EOF 239EOF
240 ; 240 ;
241 241
242sub read_yn { 242sub read_prompt {
243 my ($prompt) = @_; 243 my ($cancel, $prompt) = @_;
244 244
245 my $ans; 245 my $ans;
246 246
247 for (;;) { 247 for (;;) {
248 print "$prompt [Y/n] "; 248 if ($cancel) {
249 print "$prompt [y/n/C] ";
250 } else {
251 print "$prompt [Y/n] ";
252 }
249 $ans = <STDIN>; 253 $ans = <STDIN>;
250 chomp $ans; 254 chomp $ans;
251 if ($ans =~ /^\s*$/) { 255 if ($ans =~ /^\s*$/) {
252 $ans = "y"; 256 if ($cancel) {
257 $ans = "c";
258 } else {
259 $ans = "y";
260 }
253 } 261 }
254 last if ($ans =~ /^y$/i || $ans =~ /^n$/i); 262 last if ($ans =~ /^y$/i || $ans =~ /^n$/i);
255 print "Please answer either 'y' or 'n'.\n"; 263 if ($cancel) {
264 last if ($ans =~ /^c$/i);
265 print "Please answer either 'y', 'n' or 'c'.\n";
266 } else {
267 print "Please answer either 'y' or 'n'.\n";
268 }
269 }
270 if ($ans =~ /^c/i) {
271 exit;
256 } 272 }
257 if ($ans !~ /^y$/i) { 273 if ($ans !~ /^y$/i) {
258 return 0; 274 return 0;
@@ -260,6 +276,18 @@ sub read_yn {
260 return 1; 276 return 1;
261} 277}
262 278
279sub read_yn {
280 my ($prompt) = @_;
281
282 return read_prompt 0, $prompt;
283}
284
285sub read_ync {
286 my ($prompt) = @_;
287
288 return read_prompt 1, $prompt;
289}
290
263sub get_ktest_config { 291sub get_ktest_config {
264 my ($config) = @_; 292 my ($config) = @_;
265 my $ans; 293 my $ans;
@@ -1895,6 +1923,13 @@ sub run_bisect {
1895 } 1923 }
1896} 1924}
1897 1925
1926sub update_bisect_replay {
1927 my $tmp_log = "$tmpdir/ktest_bisect_log";
1928 run_command "git bisect log > $tmp_log" or
1929 die "can't create bisect log";
1930 return $tmp_log;
1931}
1932
1898sub bisect { 1933sub bisect {
1899 my ($i) = @_; 1934 my ($i) = @_;
1900 1935
@@ -1934,8 +1969,31 @@ sub bisect {
1934 $type = "boot"; 1969 $type = "boot";
1935 } 1970 }
1936 1971
1972 # Check if a bisect was running
1973 my $bisect_start_file = "$builddir/.git/BISECT_START";
1974
1937 my $check = $opt{"BISECT_CHECK[$i]"}; 1975 my $check = $opt{"BISECT_CHECK[$i]"};
1938 if (defined($check) && $check ne "0") { 1976 my $do_check = defined($check) && $check ne "0";
1977
1978 if ( -f $bisect_start_file ) {
1979 print "Bisect in progress found\n";
1980 if ($do_check) {
1981 print " If you say yes, then no checks of good or bad will be done\n";
1982 }
1983 if (defined($replay)) {
1984 print "** BISECT_REPLAY is defined in config file **";
1985 print " Ignore config option and perform new git bisect log?\n";
1986 if (read_ync " (yes, no, or cancel) ") {
1987 $replay = update_bisect_replay;
1988 $do_check = 0;
1989 }
1990 } elsif (read_yn "read git log and continue?") {
1991 $replay = update_bisect_replay;
1992 $do_check = 0;
1993 }
1994 }
1995
1996 if ($do_check) {
1939 1997
1940 # get current HEAD 1998 # get current HEAD
1941 my $head = get_sha1("HEAD"); 1999 my $head = get_sha1("HEAD");