]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
Merge tag 'ktest-v4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 8 Mar 2017 19:06:05 +0000 (11:06 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 8 Mar 2017 19:06:05 +0000 (11:06 -0800)
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

1  2 
tools/testing/ktest/ktest.pl

index 6e4eb2fc2d1e78edc356692dcadfe3bfaebd65ec,49f7c8b9d9c4effe623e72663ba0a1b2fe33027b..0c8b61f8398edace8b4d7be42e50b8638679520d
@@@ -720,14 -720,14 +720,14 @@@ sub set_value 
  
      if ($buildonly && $lvalue =~ /^TEST_TYPE(\[.*\])?$/ && $prvalue ne "build") {
        # Note if a test is something other than build, then we
 -      # will need other manditory options.
 +      # will need other mandatory options.
        if ($prvalue ne "install") {
            # for bisect, we need to check BISECT_TYPE
            if ($prvalue ne "bisect") {
                $buildonly = 0;
            }
        } else {
 -          # install still limits some manditory options.
 +          # install still limits some mandatory options.
            $buildonly = 2;
        }
      }
        if ($prvalue ne "install") {
            $buildonly = 0;
        } else {
 -          # install still limits some manditory options.
 +          # install still limits some mandatory options.
            $buildonly = 2;
        }
      }
@@@ -1880,6 -1880,7 +1880,7 @@@ sub get_grub_index 
  sub wait_for_input
  {
      my ($fp, $time) = @_;
+     my $start_time;
      my $rin;
      my $rout;
      my $nr;
      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;
        }
  
            last if ($ch eq "\n");
        }
  
-       if (!length($line)) {
-           return undef;
-       }
+       last if (!length($line));
  
        return $line;
      }
+     return undef;
  }
  
  sub reboot_to {
@@@ -4030,7 -4035,7 +4035,7 @@@ sub make_min_config 
                }
            }
  
 -          # Save off all the current mandidory configs
 +          # Save off all the current mandatory configs
            open (OUT, ">$temp_config")
                or die "Can't write to $temp_config";
            foreach my $config (keys %keep_configs) {