Bug 58708

Summary: new-run-webkit-tests: read stderr from chromium DRT separately
Product: WebKit Reporter: Dirk Pranke <dpranke>
Component: New BugsAssignee: Dirk Pranke <dpranke>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, aroben, eric, jamesr, ojan, tony
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Bug Depends on: 58771    
Bug Blocks: 37739    
Attachments:
Description Flags
Patch
none
use non-blocking sockets on unix instead none

Description Dirk Pranke 2011-04-15 16:26:27 PDT
new-run-webkit-tests: read stderr from chromium DRT separately
Comment 1 Dirk Pranke 2011-04-15 16:32:11 PDT
Created attachment 89875 [details]
Patch
Comment 2 Dirk Pranke 2011-04-15 16:33:36 PDT
easily the least portable python I've ever written, but it seems to work ...
Comment 3 Dirk Pranke 2011-04-15 16:34:33 PDT
on unix, it might be better to just mark the socket as non-blocking and do a select(), but the patch is posted for the record :).
Comment 4 Dirk Pranke 2011-04-15 16:59:06 PDT
Created attachment 89880 [details]
use non-blocking sockets on unix instead
Comment 5 Ojan Vafai 2011-04-15 17:06:58 PDT
Comment on attachment 89880 [details]
use non-blocking sockets on unix instead

View in context: https://bugs.webkit.org/attachment.cgi?id=89880&action=review

Looks fine to me. Can't say I really understand what _read_stderr is doing. Maybe tony or someone with my python experience can comment. I don't think we need to block getting this on on that though.

The only issue, I'm pretty sure some tests currently have stderr output in their expected results, so you'll probably need to rebaseline them with this patch.

> Tools/Scripts/webkitpy/layout_tests/port/chromium.py:578
> +    def _read_stderr(self):
> +        if sys.platform in ('win32', 'cygwin'):
> +            import msvcrt
> +            import win32pipe
> +
> +            fd = self._proc.stderr.fileno()
> +            osf = msvcrt.get_osfhandle(fd)
> +            _, avail, _ = win32pipe.PeekNamedPipe(osf, 0)
> +            if avail:
> +                return self._proc.stderr.read(avail)
> +            return ''
> +        else:
> +            if not self._stderr_is_nonblocking:
> +                import fcntl
> +                import os
> +                fd = self._proc.stderr.fileno()
> +                fl = fcntl.fcntl(fd, fcntl.F_GETFL)
> +                fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
> +                self._stderr_is_nonblocking = True
> +            return self._proc.stderr.read()

this doesn't seem chromium specific. don't other ports need this code as well?
Comment 6 Dirk Pranke 2011-04-15 17:10:33 PDT
(In reply to comment #5)
> (From update of attachment 89880 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=89880&action=review
> 
> Looks fine to me. Can't say I really understand what _read_stderr is doing. Maybe tony or someone with my python experience can comment. I don't think we need to block getting this on on that though.
> 
> The only issue, I'm pretty sure some tests currently have stderr output in their expected results, so you'll probably need to rebaseline them with this patch.
> 

Yeah, that wouldn't surprise me.

> > Tools/Scripts/webkitpy/layout_tests/port/chromium.py:578
> > +    def _read_stderr(self):
> > +        if sys.platform in ('win32', 'cygwin'):
> > +            import msvcrt
> > +            import win32pipe
> > +
> > +            fd = self._proc.stderr.fileno()
> > +            osf = msvcrt.get_osfhandle(fd)
> > +            _, avail, _ = win32pipe.PeekNamedPipe(osf, 0)
> > +            if avail:
> > +                return self._proc.stderr.read(avail)
> > +            return ''
> > +        else:
> > +            if not self._stderr_is_nonblocking:
> > +                import fcntl
> > +                import os
> > +                fd = self._proc.stderr.fileno()
> > +                fl = fcntl.fcntl(fd, fcntl.F_GETFL)
> > +                fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
> > +                self._stderr_is_nonblocking = True
> > +            return self._proc.stderr.read()
> 
> this doesn't seem chromium specific. don't other ports need this code as well?

All of the other ports use the server_process.py code (via port/webkit.py) which uses select and non-blocking reads. As a result we don't have any other ports that will actually work correctly on windows (see bug 38756). As a part of that, we'll likely need to re-use this code there as well in some form.
Comment 7 Dirk Pranke 2011-04-15 17:11:24 PDT
This will probably allow us to figure out whether or not to fix bug 37426, as well.
Comment 8 Dirk Pranke 2011-04-17 14:48:12 PDT
Committed r84111: <http://trac.webkit.org/changeset/84111>
Comment 9 Tony Chang 2011-04-17 15:42:55 PDT
Comment on attachment 89880 [details]
use non-blocking sockets on unix instead

View in context: https://bugs.webkit.org/attachment.cgi?id=89880&action=review

> Tools/Scripts/webkitpy/layout_tests/port/chromium.py:562
> +            import msvcrt
> +            import win32pipe

Do both of these exist in cygwin python?  I thought cygwin python could import fcntl so maybe it can go through the other code path?
Comment 10 James Robinson 2011-08-23 15:05:20 PDT
This got reverted in http://trac.webkit.org/changeset/84128 but the bug wasn't reopened.  I think this is (at least part of) the problem with https://bugs.webkit.org/show_bug.cgi?id=66806
Comment 11 James Robinson 2011-08-23 15:05:47 PDT
Reopening, patch was reverted
Comment 12 Dirk Pranke 2012-05-08 14:41:08 PDT
closing, this is fixed w/ r115490 and r115903.