diff options
| author | Ingo Molnar <mingo@kernel.org> | 2017-03-16 09:50:50 +0100 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2017-03-16 09:50:50 +0100 |
| commit | 2b95bd7d58d368fe5dcbe6f4e494847ea082d89d (patch) | |
| tree | 48c38d792f31f2fe10b26b03bdf1b10a82ca03a4 /tools/testing/ktest | |
| parent | Merge tag 'perf-core-for-mingo-4.12-20170314' of git://git.kernel.org/pub/scm... (diff) | |
| parent | Merge branch 'for-linus' of git://git.kernel.dk/linux-block (diff) | |
| download | linux-2b95bd7d58d368fe5dcbe6f4e494847ea082d89d.tar.gz linux-2b95bd7d58d368fe5dcbe6f4e494847ea082d89d.zip | |
Merge branch 'linus' into perf/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/testing/ktest')
| -rwxr-xr-x | tools/testing/ktest/ktest.pl | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 6e4eb2fc2d1e..0c8b61f8398e 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -1880,6 +1880,7 @@ sub get_grub_index { sub wait_for_input { my ($fp, $time) = @_; + my $start_time; my $rin; my $rout; my $nr; @@ -1895,17 +1896,22 @@ sub wait_for_input vec($rin, fileno($fp), 1) = 1; vec($rin, fileno(\*STDIN), 1) = 1; + $start_time = time; + while (1) { $nr = select($rout=$rin, undef, undef, $time); - if ($nr <= 0) { - return undef; - } + last if ($nr <= 0); # copy data from stdin to the console if (vec($rout, fileno(\*STDIN), 1) == 1) { - sysread(\*STDIN, $buf, 1000); - syswrite($fp, $buf, 1000); + $nr = sysread(\*STDIN, $buf, 1000); + syswrite($fp, $buf, $nr) if ($nr > 0); + } + + # The timeout is based on time waiting for the fp data + if (vec($rout, fileno($fp), 1) != 1) { + last if (defined($time) && (time - $start_time > $time)); next; } @@ -1917,12 +1923,11 @@ sub wait_for_input last if ($ch eq "\n"); } - if (!length($line)) { - return undef; - } + last if (!length($line)); return $line; } + return undef; } sub reboot_to { |
