parameters: (self, driver_input, stop_when_done)
return_statement: return DriverOutput(text, image, actual_image_hash, audio,
              crash=crashed, test_time=time.time() - test_begin_time, measurements=self._measurements,
              timeout=timed_out or driver_timed_out, error=self.error_from_test,
              crashed_process_name=self._crashed_process_name,
              crashed_pid=self._crashed_pid, crash_log=crash_log, pid=pid)
docstring: Run a single test and return the results.
  
          Note that it is okay if a test times out or crashes and leaves
          the driver in an indeterminate state. The upper layers of the program
          are responsible for cleaning up and ensuring things are okay.
  
          Returns a DriverOutput object.
docstring_summary: Run a single test and return the results.
docstring_tokens: Run a single test and return the results .
function: def run_test(self, driver_input, stop_when_done):
          """Run a single test and return the results.
  
          Note that it is okay if a test times out or crashes and leaves
          the driver in an indeterminate state. The upper layers of the program
          are responsible for cleaning up and ensuring things are okay.
  
          Returns a DriverOutput object.
          """
          start_time = time.time()
          self.start(driver_input.should_run_pixel_test, driver_input.args)
          test_begin_time = time.time()
          self._driver_timed_out = False
          self._crash_report_from_driver = None
          self.error_from_test = str()
          self.err_seen_eof = False
  
          command = self._command_from_driver_input(driver_input)
  
          # Certain timeouts are detected by the tool itself; tool detection is better,
          # because results contain partial output in this case. Make script timeout longer
          # by 5 seconds to avoid racing for which timeout is detected first.
          # FIXME: It's not the job of the driver to decide what the timeouts should be.
          # Move the additional timeout to driver_input.
          if self._no_timeout:
              deadline = test_begin_time + 60 * 60 * 24 * 7  # 7 days. Using sys.maxint causes a hang.
          else:
              deadline = test_begin_time + int(driver_input.timeout) / 1000.0 + 5
  
          self._server_process.write(command)
          text, audio = self._read_first_block(deadline)  # First block is either text or audio
          image, actual_image_hash = self._read_optional_image_block(deadline)  # The second (optional) block is image data.
  
          crashed = self.has_crashed()
          timed_out = self._server_process.timed_out
          driver_timed_out = self._driver_timed_out
          pid = self._server_process.pid()
  
          if stop_when_done or crashed or timed_out:
              # We call stop() even if we crashed or timed out in order to get any remaining stdout/stderr output.
              # In the timeout case, we kill the hung process as well.
              out, err = self._server_process.stop(self._port.driver_stop_timeout() if stop_when_done else 0.0)
              if out:
                  text += out
              if err:
                  self.error_from_test += err
              self._server_process = None
  
          crash_log = None
          if self._crash_report_from_driver:
              crash_log = self._crash_report_from_driver
          elif crashed:
              self.error_from_test, crash_log = self._get_crash_log(text, self.error_from_test, newer_than=start_time)
              # If we don't find a crash log use a placeholder error message instead.
              if not crash_log:
                  pid_str = str(self._crashed_pid) if self._crashed_pid else "unknown pid"
                  crash_log = 'No crash log found for %s:%s.\n' % (self._crashed_process_name, pid_str)
  
                  # Print stdout and stderr to the placeholder crash log; we want as much context as possible.
                  if self.error_from_test:
                      crash_log += '\nstdout:\n%s\nstderr:\n%s\n' % (text, self.error_from_test)
  
          return DriverOutput(text, image, actual_image_hash, audio,
              crash=crashed, test_time=time.time() - test_begin_time, measurements=self._measurements,
              timeout=timed_out or driver_timed_out, error=self.error_from_test,
              crashed_process_name=self._crashed_process_name,
              crashed_pid=self._crashed_pid, crash_log=crash_log, pid=pid)
function_tokens: def run_test ( self , driver_input , stop_when_done ) : start_time = time . time ( ) self . start ( driver_input . should_run_pixel_test , driver_input . args ) test_begin_time = time . time ( ) self . _driver_timed_out = False self . _crash_report_from_driver = None self . error_from_test = str ( ) self . err_seen_eof = False command = self . _command_from_driver_input ( driver_input ) # Certain timeouts are detected by the tool itself; tool detection is better, # because results contain partial output in this case. Make script timeout longer # by 5 seconds to avoid racing for which timeout is detected first. # FIXME: It's not the job of the driver to decide what the timeouts should be. # Move the additional timeout to driver_input. if self . _no_timeout : deadline = test_begin_time + 60 * 60 * 24 * 7 # 7 days. Using sys.maxint causes a hang. else : deadline = test_begin_time + int ( driver_input . timeout ) / 1000.0 + 5 self . _server_process . write ( command ) text , audio = self . _read_first_block ( deadline ) # First block is either text or audio image , actual_image_hash = self . _read_optional_image_block ( deadline ) # The second (optional) block is image data. crashed = self . has_crashed ( ) timed_out = self . _server_process . timed_out driver_timed_out = self . _driver_timed_out pid = self . _server_process . pid ( ) if stop_when_done or crashed or timed_out : # We call stop() even if we crashed or timed out in order to get any remaining stdout/stderr output. # In the timeout case, we kill the hung process as well. out , err = self . _server_process . stop ( self . _port . driver_stop_timeout ( ) if stop_when_done else 0.0 ) if out : text += out if err : self . error_from_test += err self . _server_process = None crash_log = None if self . _crash_report_from_driver : crash_log = self . _crash_report_from_driver elif crashed : self . error_from_test , crash_log = self . _get_crash_log ( text , self . error_from_test , newer_than = start_time ) # If we don't find a crash log use a placeholder error message instead. if not crash_log : pid_str = str ( self . _crashed_pid ) if self . _crashed_pid else "unknown pid" crash_log = 'No crash log found for %s:%s.\n' % ( self . _crashed_process_name , pid_str ) # Print stdout and stderr to the placeholder crash log; we want as much context as possible. if self . error_from_test : crash_log += '\nstdout:\n%s\nstderr:\n%s\n' % ( text , self . error_from_test ) return DriverOutput ( text , image , actual_image_hash , audio , crash = crashed , test_time = time . time ( ) - test_begin_time , measurements = self . _measurements , timeout = timed_out or driver_timed_out , error = self . error_from_test , crashed_process_name = self . _crashed_process_name , crashed_pid = self . _crashed_pid , crash_log = crash_log , pid = pid )