Exemple #1
0
    def test_strip_metrics(self):
        patterns = [
            ('RenderView at (0,0) size 800x600', 'RenderView '),
            ('text run at (0,0) width 100: "some text"', '"some text"'),
            ('RenderBlock {HTML} at (0,0) size 800x600',
             'RenderBlock {HTML} '),
            ('RenderBlock {INPUT} at (29,3) size 12x12 [color=#000000]',
             'RenderBlock {INPUT}'),
            ('RenderBlock (floating) {DT} at (5,5) size 79x310 [border: (5px solid #000000)]',
             'RenderBlock (floating) {DT} [border: px solid #000000)]'),
            ('\n    "truncate text    "\n', '\n    "truncate text"\n'),
            ('RenderText {#text} at (0,3) size 41x12\n    text run at (0,3) width 41: "whimper "\n',
             'RenderText {#text} \n    "whimper"\n'),
            ("""text run at (0,0) width 109: ".one {color: green;}"
          text run at (109,0) width 0: " "
          text run at (0,17) width 81: ".1 {color: red;}"
          text run at (81,17) width 0: " "
          text run at (0,34) width 102: ".a1 {color: green;}"
          text run at (102,34) width 0: " "
          text run at (0,51) width 120: "P.two {color: purple;}"
          text run at (120,51) width 0: " "\n""",
             '".one {color: green;}  .1 {color: red;}  .a1 {color: green;}  P.two {color: purple;}"\n'
             ),
            ('text-- other text', 'text--other text'),
            (' some output   "truncate trailing spaces at end of line after text"   \n',
             ' some output   "truncate trailing spaces at end of line after text"\n'
             ),
            (r'scrollWidth 120', r'scrollWidth'),
            (r'scrollHeight 120', r'scrollHeight'),
        ]

        for pattern in patterns:
            driver_output = DriverOutput(pattern[0], None, None, None)
            driver_output.strip_metrics()
            self.assertEqual(driver_output.text, pattern[1])
Exemple #2
0
    def run_test(self, driver_input):
        command = self._command_from_driver_input(driver_input)
        start_time = time.time()
        deadline = time.time() + int(driver_input.timeout) / 1000.0

        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.

        error_lines = self._server_process.error.splitlines()
        # FIXME: This is a hack.  It is unclear why sometimes
        # we do not get any error lines from the server_process
        # probably we are not flushing stderr.
        if error_lines and error_lines[-1] == "#EOF":
            error_lines.pop()  # Remove the expected "#EOF"
        error = "\n".join(error_lines)

        # FIXME: This seems like the wrong section of code to be resetting _server_process.error.
        self._server_process.error = ""
        return DriverOutput(text,
                            image,
                            actual_image_hash,
                            audio,
                            crash=self.detected_crash(),
                            test_time=time.time() - start_time,
                            timeout=self._server_process.timed_out,
                            error=error)
Exemple #3
0
    def run_test(self, test_input):
        start_time = time.time()
        test_name = test_input.test_name
        test = self._port._tests[test_name]
        if test.keyboard:
            raise KeyboardInterrupt
        if test.exception:
            raise ValueError('exception from ' + test_name)
        if test.hang:
            time.sleep((float(test_input.timeout) * 4) / 1000.0)

        audio = None
        if test.actual_audio:
            audio = base64.b64decode(test.actual_audio)
        crashed_process_name = None
        if test.crash:
            crashed_process_name = self._port.driver_name()
        elif test.web_process_crash:
            crashed_process_name = 'WebProcess'
        return DriverOutput(test.actual_text,
                            test.actual_image,
                            test.actual_checksum,
                            audio,
                            crash=test.crash or test.web_process_crash,
                            crashed_process_name=crashed_process_name,
                            test_time=time.time() - start_time,
                            timeout=test.timeout,
                            error=test.error)
Exemple #4
0
    def run_test(self, driver_input):
        if not self._server_process:
            self._start()
        self.error_from_test = str()
        self.err_seen_eof = False

        command = self._command_from_driver_input(driver_input)
        start_time = time.time()
        deadline = time.time() + int(driver_input.timeout) / 1000.0

        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.

        # We may not have read all of the output if an error (crash) occured.
        # Since some platforms output the stacktrace over error, we should
        # dump any buffered error into self.error_from_test.
        # FIXME: We may need to also read stderr until the process dies?
        self.error_from_test += self._server_process.pop_all_buffered_stderr()

        return DriverOutput(text,
                            image,
                            actual_image_hash,
                            audio,
                            crash=self._detected_crash(),
                            test_time=time.time() - start_time,
                            timeout=self._server_process.timed_out,
                            error=self.error_from_test,
                            crashed_process_name=self._crashed_process_name())
Exemple #5
0
 def run_test(self, driver_input):
     start_time = time.time()
     fs = self._port._filesystem
     if (self._port.is_reftest(driver_input.test_name)
             or driver_input.test_name.endswith('-expected.html')):
         text = 'test-text'
         image = 'test-image'
         checksum = 'test-checksum'
         audio = None
     elif driver_input.test_name.endswith('-expected-mismatch.html'):
         text = 'test-text-mismatch'
         image = 'test-image-mismatch'
         checksum = 'test-checksum-mismatch'
         audio = None
     else:
         text = self._port.expected_text(driver_input.test_name)
         image = self._port.expected_image(driver_input.test_name)
         checksum = self._port.expected_checksum(driver_input.test_name)
         audio = self._port.expected_audio(driver_input.test_name)
     return DriverOutput(text,
                         image,
                         checksum,
                         audio,
                         crash=False,
                         test_time=time.time() - start_time,
                         timeout=False,
                         error='')
Exemple #6
0
    def run_test(self, test_input, stop_when_done):
        start_time = time.time()
        test_name = test_input.test_name
        test_args = test_input.args or []
        test = self._port._tests[test_name]
        if test.keyboard:
            raise KeyboardInterrupt
        if test.exception:
            raise ValueError('exception from ' + test_name)
        if test.hang:
            time.sleep(
                (float(test_input.timeout) * 4) / 1000.0 + 1.0
            )  # The 1.0 comes from thread_padding_sec in layout_test_runnery.

        audio = None
        actual_text = test.actual_text

        if 'flaky' in test_name and not test_name in self._port._flakes:
            self._port._flakes.add(test_name)
            actual_text = 'flaky text failure'

        if actual_text and test_args and test_name == 'passes/args.html':
            actual_text = actual_text + ' ' + ' '.join(test_args)

        if test.actual_audio:
            audio = base64.b64decode(test.actual_audio)
        crashed_process_name = None
        crashed_pid = None
        if test.crash:
            crashed_process_name = self._port.driver_name()
            crashed_pid = 1
        elif test.web_process_crash:
            crashed_process_name = 'WebProcess'
            crashed_pid = 2

        crash_log = ''
        if crashed_process_name:
            crash_logs = CrashLogs(self._port.host)
            crash_log = crash_logs.find_newest_log(crashed_process_name,
                                                   None) or ''

        if stop_when_done:
            self.stop()

        if test.actual_checksum == test_input.image_hash:
            image = None
        else:
            image = test.actual_image
        return DriverOutput(actual_text,
                            image,
                            test.actual_checksum,
                            audio,
                            crash=test.crash or test.web_process_crash,
                            crashed_process_name=crashed_process_name,
                            crashed_pid=crashed_pid,
                            crash_log=crash_log,
                            test_time=time.time() - start_time,
                            timeout=test.timeout,
                            error=test.error)
Exemple #7
0
    def run_test(self, driver_input):
        start_time = time.time()
        self.start(driver_input.should_run_pixel_test, driver_input.args)
        self.error_from_test = str()
        self.err_seen_eof = False

        command = self._command_from_driver_input(driver_input)
        deadline = start_time + int(driver_input.timeout) / 1000.0

        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.

        # We may not have read all of the output if an error (crash) occured.
        # Since some platforms output the stacktrace over error, we should
        # dump any buffered error into self.error_from_test.
        # FIXME: We may need to also read stderr until the process dies?
        self.error_from_test += self._server_process.pop_all_buffered_stderr()

        crash_log = None
        if self.has_crashed():
            crash_log = self._port._get_crash_log(self._crashed_process_name,
                                                  self._crashed_pid,
                                                  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:
                crash_log = 'no crash log found for %s:%d.' % (
                    self._crashed_process_name, self._crashed_pid)
                # If we were unresponsive append a message informing there may not have been a crash.
                if self._subprocess_was_unresponsive:
                    crash_log += '  Process failed to become responsive before timing out.'

        timeout = self._server_process.timed_out
        if timeout:
            # DRT doesn't have a built in timer to abort the test, so we might as well
            # kill the process directly and not wait for it to shut down cleanly (since it may not).
            self._server_process.kill()

        return DriverOutput(text,
                            image,
                            actual_image_hash,
                            audio,
                            crash=self.has_crashed(),
                            test_time=time.time() - start_time,
                            timeout=timeout,
                            error=self.error_from_test,
                            crashed_process_name=self._crashed_process_name,
                            crashed_pid=self._crashed_pid,
                            crash_log=crash_log)
Exemple #8
0
    def test_strip_metrics(self):
        patterns = [
            ("RenderView at (0,0) size 800x600", "RenderView "),
            ('text run at (0,0) width 100: "some text"', '"some text"'),
            ("RenderBlock {HTML} at (0,0) size 800x600", "RenderBlock {HTML} "),
            ("RenderBlock {INPUT} at (29,3) size 12x12 [color=#000000]", "RenderBlock {INPUT}"),
            (
                "RenderBlock (floating) {DT} at (5,5) size 79x310 [border: (5px solid #000000)]",
                "RenderBlock (floating) {DT} [border: px solid #000000)]",
            ),
            ('\n    "truncate text    "\n', '\n    "truncate text"\n'),
            (
                'RenderText {#text} at (0,3) size 41x12\n    text run at (0,3) width 41: "whimper "\n',
                'RenderText {#text} \n    "whimper"\n',
            ),
            (
                """text run at (0,0) width 109: ".one {color: green;}"
          text run at (109,0) width 0: " "
          text run at (0,17) width 81: ".1 {color: red;}"
          text run at (81,17) width 0: " "
          text run at (0,34) width 102: ".a1 {color: green;}"
          text run at (102,34) width 0: " "
          text run at (0,51) width 120: "P.two {color: purple;}"
          text run at (120,51) width 0: " "\n""",
                '".one {color: green;}  .1 {color: red;}  .a1 {color: green;}  P.two {color: purple;}"\n',
            ),
            ("text-- other text", "text--other text"),
            (
                ' some output   "truncate trailing spaces at end of line after text"   \n',
                ' some output   "truncate trailing spaces at end of line after text"\n',
            ),
            (r"scrollWidth 120", r"scrollWidth"),
            (r"scrollHeight 120", r"scrollHeight"),
        ]

        for pattern in patterns:
            driver_output = DriverOutput(pattern[0], None, None, None)
            driver_output.strip_metrics()
            self.assertEqual(driver_output.text, pattern[1])
Exemple #9
0
    def run_test(self, test_input):
        start_time = time.time()
        test_name = test_input.test_name
        test_args = test_input.args or []
        test = self._port._tests[test_name]
        if test.keyboard:
            raise KeyboardInterrupt
        if test.exception:
            raise ValueError('exception from ' + test_name)
        if test.hang:
            time.sleep((float(test_input.timeout) * 4) / 1000.0)

        audio = None
        actual_text = test.actual_text
        if actual_text and test_args and test_name == 'passes/args.html':
            actual_text = actual_text + ' ' + ' '.join(test_args)

        if test.actual_audio:
            audio = base64.b64decode(test.actual_audio)
        crashed_process_name = None
        crashed_pid = None
        if test.crash:
            crashed_process_name = self._port.driver_name()
            crashed_pid = 1
        elif test.web_process_crash:
            crashed_process_name = 'WebProcess'
            crashed_pid = 2

        crash_log = ''
        if crashed_process_name:
            crash_logs = CrashLogs(self._port.host)
            crash_log = crash_logs.find_newest_log(crashed_process_name,
                                                   None) or ''

        return DriverOutput(actual_text,
                            test.actual_image,
                            test.actual_checksum,
                            audio,
                            crash=test.crash or test.web_process_crash,
                            crashed_process_name=crashed_process_name,
                            crashed_pid=crashed_pid,
                            crash_log=crash_log,
                            test_time=time.time() - start_time,
                            timeout=test.timeout,
                            error=test.error)
Exemple #10
0
    def run_test(self, driver_input, stop_when_done):
        if not self.started:
            self.started = True
            self.pid = TestDriver.next_pid
            TestDriver.next_pid += 1

        start_time = time.time()
        test_name = driver_input.test_name
        test_args = driver_input.args or []
        test = self._port._tests[test_name]
        if test.keyboard:
            raise KeyboardInterrupt
        if test.exception:
            raise ValueError('exception from ' + test_name)
        if test.device_failure:
            raise DeviceFailure('device failure in ' + test_name)

        audio = None
        actual_text = test.actual_text
        crash = test.crash
        web_process_crash = test.web_process_crash

        if 'flaky/text.html' in test_name and not test_name in self._port._flakes:
            self._port._flakes.add(test_name)
            actual_text = 'flaky text failure'

        if 'crash_then_text.html' in test_name:
            if test_name in self._port._flakes:
                actual_text = 'text failure'
            else:
                self._port._flakes.add(test_name)
                crashed_process_name = self._port.driver_name()
                crashed_pid = 1
                crash = True

        if 'text_then_crash.html' in test_name:
            if test_name in self._port._flakes:
                crashed_process_name = self._port.driver_name()
                crashed_pid = 1
                crash = True
            else:
                self._port._flakes.add(test_name)
                actual_text = 'text failure'

        if actual_text and test_args and test_name == 'passes/args.html':
            actual_text = actual_text + ' ' + ' '.join(test_args)

        if test.actual_audio:
            audio = base64.b64decode(test.actual_audio)
        crashed_process_name = None
        crashed_pid = None
        if crash:
            crashed_process_name = self._port.driver_name()
            crashed_pid = 1
        elif web_process_crash:
            crashed_process_name = 'WebProcess'
            crashed_pid = 2

        crash_log = ''
        if crashed_process_name:
            crash_logs = CrashLogs(self._port.host)
            crash_log = crash_logs.find_newest_log(crashed_process_name,
                                                   None) or ''

        if stop_when_done:
            self.stop()

        if test.actual_checksum == driver_input.image_hash:
            image = None
        else:
            image = test.actual_image
        return DriverOutput(actual_text,
                            image,
                            test.actual_checksum,
                            audio,
                            crash=(crash or web_process_crash),
                            crashed_process_name=crashed_process_name,
                            crashed_pid=crashed_pid,
                            crash_log=crash_log,
                            test_time=time.time() - start_time,
                            timeout=test.timeout,
                            error=test.error,
                            pid=self.pid,
                            leak=test.leak)