aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtools/testing/ktest/ktest.pl21
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 {
1880sub wait_for_input 1880sub wait_for_input
1881{ 1881{
1882 my ($fp, $time) = @_; 1882 my ($fp, $time) = @_;
1883 my $start_time;
1883 my $rin; 1884 my $rin;
1884 my $rout; 1885 my $rout;
1885 my $nr; 1886 my $nr;
@@ -1895,17 +1896,22 @@ sub wait_for_input
1895 vec($rin, fileno($fp), 1) = 1; 1896 vec($rin, fileno($fp), 1) = 1;
1896 vec($rin, fileno(\*STDIN), 1) = 1; 1897 vec($rin, fileno(\*STDIN), 1) = 1;
1897 1898
1899 $start_time = time;
1900
1898 while (1) { 1901 while (1) {
1899 $nr = select($rout=$rin, undef, undef, $time); 1902 $nr = select($rout=$rin, undef, undef, $time);
1900 1903
1901 if ($nr <= 0) { 1904 last if ($nr <= 0);
1902 return undef;
1903 }
1904 1905
1905 # copy data from stdin to the console 1906 # copy data from stdin to the console
1906 if (vec($rout, fileno(\*STDIN), 1) == 1) { 1907 if (vec($rout, fileno(\*STDIN), 1) == 1) {
1907 sysread(\*STDIN, $buf, 1000); 1908 $nr = sysread(\*STDIN, $buf, 1000);
1908 syswrite($fp, $buf, 1000); 1909 syswrite($fp, $buf, $nr) if ($nr > 0);
1910 }
1911
1912 # The timeout is based on time waiting for the fp data
1913 if (vec($rout, fileno($fp), 1) != 1) {
1914 last if (defined($time) && (time - $start_time > $time));
1909 next; 1915 next;
1910 } 1916 }
1911 1917
@@ -1917,12 +1923,11 @@ sub wait_for_input
1917 last if ($ch eq "\n"); 1923 last if ($ch eq "\n");
1918 } 1924 }
1919 1925
1920 if (!length($line)) { 1926 last if (!length($line));
1921 return undef;
1922 }
1923 1927
1924 return $line; 1928 return $line;
1925 } 1929 }
1930 return undef;
1926} 1931}
1927 1932
1928sub reboot_to { 1933sub reboot_to {