Changeset 58503 in webkit


Ignore:
Timestamp:
Apr 29, 2010 4:29:07 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-29 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

new-run-webkit-tests can deadlock with Chromium's TestShell
https://bugs.webkit.org/show_bug.cgi?id=38298

Fix _write_command_and_read_line to never send unicode() to
test_shell, instead to always encode as utf-8. This was causing
random hangs because if test_shell ever encounters a \0 in the
stream it can deadlock with NRWT.

There is still a deadlock bug to fix in NRWT/test_shell design, however
this fix should make the deadlock occur less often.

  • Scripts/webkitpy/layout_tests/port/chromium.py:
  • Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r58495 r58503  
     12010-04-29  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        new-run-webkit-tests can deadlock with Chromium's TestShell
     6        https://bugs.webkit.org/show_bug.cgi?id=38298
     7
     8        Fix _write_command_and_read_line to never send unicode() to
     9        test_shell, instead to always encode as utf-8.  This was causing
     10        random hangs because if test_shell ever encounters a \0 in the
     11        stream it can deadlock with NRWT.
     12
     13        There is still a deadlock bug to fix in NRWT/test_shell design, however
     14        this fix should make the deadlock occur less often.
     15
     16        * Scripts/webkitpy/layout_tests/port/chromium.py:
     17        * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
     18
    1192010-04-29  Chris Jerdonek  <cjerdonek@webkit.org>
    220
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py

    r58473 r58503  
    320320        try:
    321321            if input:
     322                if isinstance(input, unicode):
     323                    # TestShell expects utf-8
     324                    input = input.encode("utf-8")
    322325                self._proc.stdin.write(input)
    323326            # DumpRenderTree text output is always UTF-8.  However some tests
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py

    r58279 r58503  
    2929import chromium
    3030import unittest
     31import StringIO
    3132
    3233from webkitpy.thirdparty.mock import Mock
     
    4546        expected_command = "test.html 2 checksum\n"
    4647        self.assertEqual(self.driver._test_shell_command("test.html", 2, "checksum"), expected_command)
     48
     49    def _assert_write_command_and_read_line(self, input=None, expected_line=None, expected_stdin=None, expected_crash=False):
     50        if not expected_stdin:
     51            if input:
     52                expected_stdin = input
     53            else:
     54                # We reset stdin, so we should expect stdin.getValue = ""
     55                expected_stdin = ""
     56        self.driver._proc.stdin = StringIO.StringIO()
     57        line, did_crash = self.driver._write_command_and_read_line(input)
     58        self.assertEqual(self.driver._proc.stdin.getvalue(), expected_stdin)
     59        self.assertEqual(line, expected_line)
     60        self.assertEqual(did_crash, expected_crash)
     61
     62    def test_write_command_and_read_line(self):
     63        self.driver._proc = Mock()
     64        # Set up to read 3 lines before we get an IOError
     65        self.driver._proc.stdout = StringIO.StringIO("first\nsecond\nthird\n")
     66
     67        unicode_input = u"I \u2661 Unicode"
     68        utf8_input = unicode_input.encode("utf-8")
     69        # Test unicode input conversion to utf-8
     70        self._assert_write_command_and_read_line(input=unicode_input, expected_stdin=utf8_input, expected_line="first\n")
     71        # Test str() input.
     72        self._assert_write_command_and_read_line(input="foo", expected_line="second\n")
     73        # Test input=None
     74        self._assert_write_command_and_read_line(expected_line="third\n")
     75        # Test reading from a closed/empty stream.
     76        # reading from a StringIO does not raise IOError like a real file would, so raise IOError manually.
     77        def mock_readline():
     78            raise IOError
     79        self.driver._proc.stdout.readline = mock_readline
     80        self._assert_write_command_and_read_line(expected_crash=True)
Note: See TracChangeset for help on using the changeset viewer.