Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'ktest-v4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest

Pull ktest fixes from Steven Rostedt:
"Greg Kroah-Hartman reported to me that the ktest of v4.11-rc1 locked
up in an infinite loop while doing the make mrproper.

Looking into the cause I noticed that a recent update to the function
run_command (used for running all shell commands, including "make
mrproper") changed the internal loop to use the function
wait_for_input.

The wait_for_input function uses select to look at two file
descriptors. One is the file descriptor of the command it is running,
the other is STDIN. The STDIN check was not checking the return status
of the sysread call, and was also just writing a lot of data into
syswrite without regard to the size of the data read.

Changing the code to check the return status of sysread, and also to
still process the passed in descriptor data without looping back to
the select fixed Greg's problem.

While looking at this code I also realized that the loop did not honor
the timeout if STDIN always had input (or for some reason return
error). this could prevent wait_for_input to timeout on the file
descriptor it is suppose to be waiting for. That is fixed too"

* tag 'ktest-v4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest:
ktest: Make sure wait_for_input does honor the timeout
ktest: Fix while loop in wait_for_input

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