Bug 64468 - WIN: DumpRenderTree hangs under NRWT
Summary: WIN: DumpRenderTree hangs under NRWT
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows 7
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 38756
  Show dependency treegraph
 
Reported: 2011-07-13 11:18 PDT by Adam Roben (:aroben)
Modified: 2012-01-09 13:16 PST (History)
7 users (show)

See Also:


Attachments
Convert Cygwin paths to Windows paths before passing them to DRT (2.03 KB, patch)
2012-01-09 10:36 PST, Adam Roben (:aroben)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Roben (:aroben) 2011-07-13 11:18:05 PDT
To reproduce:

1. new-run-webkit-tests

DRT launches and hangs.

The problem is that we're passing Cygwin-style paths to DRT. We need to pass Windows-style paths instead.
Comment 1 Eric Seidel (no email) 2011-07-13 15:41:12 PDT
It appears that Chromium's DumpRenderTree implementation expects file:/// uris:
http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py#L439

but all the WebKit ones seem to expect absolute file paths?
http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py#L465

is that correct?

It should be easy to convert the paths, but we don't have very standard cygwin support in the codebase yet.
Comment 2 Dirk Pranke 2011-07-13 15:47:09 PDT
(In reply to comment #1)
> It appears that Chromium's DumpRenderTree implementation expects file:/// uris:
> http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py#L439
> 
> but all the WebKit ones seem to expect absolute file paths?
> http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py#L465
> 
> is that correct?
> 

As far as I know, yes.

> It should be easy to convert the paths, but we don't have very standard cygwin support in the codebase yet.

Do you need more than what we have in common.system.path ? There is also the port.uri_to_test_name() and port.abspath_for_test() routines that should allow you to get from any variant of URL to path to test.
Comment 3 Eric Seidel (no email) 2011-07-13 15:52:54 PDT
It looks like abspath_for_test should already do the right thing on windows:

    def abspath_for_test(self, test_name):
        """Returns the full path to the file for a given test name. This is the
        inverse of relative_test_filename()."""
        return self._filesystem.normpath(self._filesystem.join(self.layout_tests_dir(), test_name))

I think the bug is that we're calling test_to_uri in WebKItDriver when we really want to just call abspath_for_test.

I'll upload a patch which might fix this, but again, someone with Windows will have to test.
Comment 4 Eric Seidel (no email) 2011-07-13 15:55:04 PDT
Hmm... I'll have to check to see what ORWT does for http tests on windows.
Comment 5 Adam Roben (:aroben) 2011-07-14 07:41:31 PDT
Note that abspath_for_test isn't sufficient on Windows because it will produce a Cygwin-style path.

The bare-minimum required change is here:

http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py?rev=90826#L465

Changing this:

command = uri[7:] if uri.startswith("file:///") else uri

to this:

command = cygpath(urllib.unquote(uri[7:])) if uri.startswith("file:///") else uri

This is a bit icky, of course, since we're converting to a URL then back to a path (but the code already does this). I think the urllib.unquote call is actually the right thing to do on all platforms if we keep this test name -> URL -> file path approach. Only the cygpath() call is Windows-specific.
Comment 6 Adam Roben (:aroben) 2011-07-14 07:43:10 PDT
And of course my above change completely ignores using abstraction. :-) A new method like Port.prepare_path_for_driver could do the cygpath conversion.
Comment 7 Dirk Pranke 2011-07-14 12:51:02 PDT
(In reply to comment #5)
> Note that abspath_for_test isn't sufficient on Windows because it will produce a Cygwin-style path.
> 
> The bare-minimum required change is here:
> 
> http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py?rev=90826#L465
> 
> Changing this:
> 
> command = uri[7:] if uri.startswith("file:///") else uri
> 
> to this:
> 
> command = cygpath(urllib.unquote(uri[7:])) if uri.startswith("file:///") else uri
> 
> This is a bit icky, of course, since we're converting to a URL then back to a path (but the code already does this). I think the urllib.unquote call is actually the right thing to do on all platforms if we keep this test name -> URL -> file path approach. Only the cygpath() call is Windows-specific.

There's no reason to go through the URL if you don't need to. You could just as easily change command_From_driver_input() to something like:

if driver_input.test_name.startswith('http/'):
  command = self.test_to_uri(driver_input.test_name)
else:
  command = cygpath(self.abspath_for_test(driver_input.test_name)
Comment 8 Adam Roben (:aroben) 2011-07-14 12:53:58 PDT
Agreed.
Comment 9 Adam Roben (:aroben) 2012-01-05 08:25:09 PST
(In reply to comment #7)
> There's no reason to go through the URL if you don't need to. You could just as easily change command_From_driver_input() to something like:
> 
> if driver_input.test_name.startswith('http/'):
>   command = self.test_to_uri(driver_input.test_name)
> else:
>   command = cygpath(self.abspath_for_test(driver_input.test_name)

Unfortunately, test_to_uri contains some tricky logic about whether to use an http:/https: URL or a file: URL. I don't think we want to duplicate that logic in command_from_driver_input. Maybe we can share the logic, or maybe we can make the roundtrip through test_to_uri work.
Comment 10 Adam Roben (:aroben) 2012-01-05 08:39:43 PST
(In reply to comment #5)
> Note that abspath_for_test isn't sufficient on Windows because it will produce a Cygwin-style path.
> 
> The bare-minimum required change is here:
> 
> http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py?rev=90826#L465
> 
> Changing this:
> 
> command = uri[7:] if uri.startswith("file:///") else uri
> 
> to this:
> 
> command = cygpath(urllib.unquote(uri[7:])) if uri.startswith("file:///") else uri
> 
> This is a bit icky, of course, since we're converting to a URL then back to a path (but the code already does this). I think the urllib.unquote call is actually the right thing to do on all platforms if we keep this test name -> URL -> file path approach. Only the cygpath() call is Windows-specific.

It seems that uri now contains a Windows-style file: URL, not a Cygwin-style file: URL. Not sure when that changed. Anyway, now the minimum change is:

command = urllib.unquote(uri[8:]).replace('/', '\\') if uri.startswith("file:///") else uri

Gotta come up with some better solution that doesn't break Mac etc. of course :-)
Comment 11 Dirk Pranke 2012-01-05 11:58:09 PST
Test names as passed to run_test() are expected to be relative-path filenames. We could centralize and standardize testing whether the test is an http test in a separate method on Port() if we wanted, but the change I suggested in comment #7 is correct for the cygwin platform. It would probably be good to change cygpath to be a no-op on non-cygpath platform just to be portable, or you could change the implementation to get an abspath and then only call cygpath if needed.

I would not go through the uri transformation; it's unnecessary and confusing.
Comment 12 Dirk Pranke 2012-01-05 11:59:13 PST
that is, assuming webkit-based DRTs expects filenames and not URIs :).
Comment 13 Adam Roben (:aroben) 2012-01-05 12:05:19 PST
(In reply to comment #11)
> Test names as passed to run_test() are expected to be relative-path filenames. We could centralize and standardize testing whether the test is an http test in a separate method on Port() if we wanted, but the change I suggested in comment #7 is correct for the cygwin platform. It would probably be good to change cygpath to be a no-op on non-cygpath platform just to be portable, or you could change the implementation to get an abspath and then only call cygpath if needed.
> 
> I would not go through the uri transformation; it's unnecessary and confusing.

Your proposed change in comment 7 isn't quite right: tests in http/tests/local are supposed to be loaded as local files, not as http: URLs. At least according to Port.test_to_uri.

It seems best to me to keep cygpath as-is. Having it be a no-op for most developers will most likely mean that it won't be used correctly.

I'm trying to come up with a good name for the concept of "path to test that the driver will understand" as opposed to "path to test that Python will understand". If we had such a name, we could have a Port.test_to_<name> function that would generate the right type of path.
Comment 14 Dirk Pranke 2012-01-05 12:13:00 PST
(In reply to comment #13)
> Your proposed change in comment 7 isn't quite right: tests in http/tests/local are supposed to be loaded as local files, not as http: URLs. At least according to Port.test_to_uri.
>

Oh. Hm. You're right. That's bad, as it means the logic in controllers/manager.py is broken, and we should probably create an is_http_test() to actually codify/fix this.
 
> It seems best to me to keep cygpath as-is. Having it be a no-op for most developers will most likely mean that it won't be used correctly.
>

Sounds good.
 
> I'm trying to come up with a good name for the concept of "path to test that the driver will understand" as opposed to "path to test that Python will understand". If we had such a name, we could have a Port.test_to_<name> function that would generate the right type of path.

"path to test that the driver will understand" is probably only actually used under Driver.run_test(), so I'm not sure if there's value in creating a separate routine for it (at least, not on the Port object, we could put on on the driver object if necessary).

By that same logic, test_to_uri() is only used by the chromium Driver (and various pieces of test code), and should probably be moved out of the Port object and down into the chromium Driver.
Comment 15 Dirk Pranke 2012-01-05 12:13:26 PST
As an aside, it seems goofy that we have tests that aren't http tests under the http directory, but that long predates me so I have no idea why ...
Comment 16 Adam Roben (:aroben) 2012-01-05 12:20:05 PST
(In reply to comment #15)
> As an aside, it seems goofy that we have tests that aren't http tests under the http directory, but that long predates me so I have no idea why ...

http://trac.webkit.org/changeset/19553
Comment 17 Dirk Pranke 2012-01-05 12:22:21 PST
(In reply to comment #16)
> (In reply to comment #15)
> > As an aside, it seems goofy that we have tests that aren't http tests under the http directory, but that long predates me so I have no idea why ...
> 
> http://trac.webkit.org/changeset/19553

Ah. What an annoying special case to have to cover :).
Comment 18 Adam Roben (:aroben) 2012-01-05 12:24:02 PST
(In reply to comment #14)
> (In reply to comment #13)
> > Your proposed change in comment 7 isn't quite right: tests in http/tests/local are supposed to be loaded as local files, not as http: URLs. At least according to Port.test_to_uri.
> >
> 
> Oh. Hm. You're right. That's bad, as it means the logic in controllers/manager.py is broken, and we should probably create an is_http_test() to actually codify/fix this.

Sounds good to me! I think http/tests/websocket/tests/local is supposed to be run locally too.

> > I'm trying to come up with a good name for the concept of "path to test that the driver will understand" as opposed to "path to test that Python will understand". If we had such a name, we could have a Port.test_to_<name> function that would generate the right type of path.
> 
> "path to test that the driver will understand" is probably only actually used under Driver.run_test(), so I'm not sure if there's value in creating a separate routine for it (at least, not on the Port object, we could put on on the driver object if necessary).

Does Driver know whether it's running under Cygwin or not? I didn't think it did.

> By that same logic, test_to_uri() is only used by the chromium Driver (and various pieces of test code), and should probably be moved out of the Port object and down into the chromium Driver.

It's also used by WebKitPort._command_from_driver_input, of course!
Comment 19 Adam Roben (:aroben) 2012-01-05 12:24:29 PST
(In reply to comment #17)
> (In reply to comment #16)
> > (In reply to comment #15)
> > > As an aside, it seems goofy that we have tests that aren't http tests under the http directory, but that long predates me so I have no idea why ...
> > 
> > http://trac.webkit.org/changeset/19553
> 
> Ah. What an annoying special case to have to cover :).

We could probably change things such that Apache is always running whenever any test is run. Then these tests could be moved out of the http/ directory entirely.
Comment 20 Eric Seidel (no email) 2012-01-05 12:29:35 PST
(In reply to comment #19)
> (In reply to comment #17)
> > (In reply to comment #16)
> > > (In reply to comment #15)
> > > > As an aside, it seems goofy that we have tests that aren't http tests under the http directory, but that long predates me so I have no idea why ...
> > > 
> > > http://trac.webkit.org/changeset/19553
> > 
> > Ah. What an annoying special case to have to cover :).
> 
> We could probably change things such that Apache is always running whenever any test is run. Then these tests could be moved out of the http/ directory entirely.

The Qt folks run more than one instance of RWT/NRWT per server.  So they are excited about having httpd run for as short a period of time as possible.  I'm not sure we really want to support that usecase (at least not in that way).  A better alternative would be to fix all DRT instances to remap port 8080 requests to whatever port the DRT was told to remap to on startup, but that's more involved.
Comment 21 Dirk Pranke 2012-01-05 12:34:01 PST
(In reply to comment #18)
> (In reply to comment #14)
> > (In reply to comment #13)
> > > Your proposed change in comment 7 isn't quite right: tests in http/tests/local are supposed to be loaded as local files, not as http: URLs. At least according to Port.test_to_uri.
> > >
> > 
> > Oh. Hm. You're right. That's bad, as it means the logic in controllers/manager.py is broken, and we should probably create an is_http_test() to actually codify/fix this.
> 
> Sounds good to me! I think http/tests/websocket/tests/local is supposed to be run locally too.
>

Actually, now that I think about it further, the manager logic is correct; it needs to know whether a server is needed, not whether the test itself is local or http.

> Does Driver know whether it's running under Cygwin or not? I didn't think it did.
>

It certainly could know if it needed it ...
 
> > By that same logic, test_to_uri() is only used by the chromium Driver (and various pieces of test code), and should probably be moved out of the Port object and down into the chromium Driver.
> 
> It's also used by WebKitPort._command_from_driver_input, of course!

right :) Even so, this should probably be on the Driver class and not the port class if nothing outside of Drivers need it.

(In reply to comment #19)
> We could probably change things such that Apache is always running whenever any test is run. Then these tests could be moved out of the http/ directory entirely.

In addition to Eric's comment, it also makes NRWT's startup significantly slower in the common case of just running a subset of non-http tests.
Comment 22 Adam Roben (:aroben) 2012-01-05 12:58:11 PST
(In reply to comment #21)
> (In reply to comment #18)
> > (In reply to comment #14)
> > Does Driver know whether it's running under Cygwin or not? I didn't think it did.
> >
> 
> It certainly could know if it needed it ...
> 
> > > By that same logic, test_to_uri() is only used by the chromium Driver (and various pieces of test code), and should probably be moved out of the Port object and down into the chromium Driver.
> > 
> > It's also used by WebKitPort._command_from_driver_input, of course!
> 
> right :) Even so, this should probably be on the Driver class and not the port class if nothing outside of Drivers need it.

I don't think I understand your proposal well enough to implement it myself. Any chance you'd be willing to take a stab at it?
Comment 23 Dirk Pranke 2012-01-05 13:24:49 PST
(In reply to comment #22)
> (In reply to comment #21)
> > (In reply to comment #18)
> > > (In reply to comment #14)
> > > Does Driver know whether it's running under Cygwin or not? I didn't think it did.
> > >
> > 
> > It certainly could know if it needed it ...
> > 
> > > > By that same logic, test_to_uri() is only used by the chromium Driver (and various pieces of test code), and should probably be moved out of the Port object and down into the chromium Driver.
> > > 
> > > It's also used by WebKitPort._command_from_driver_input, of course!
> > 
> > right :) Even so, this should probably be on the Driver class and not the port class if nothing outside of Drivers need it.
> 
> I don't think I understand your proposal well enough to implement it myself. Any chance you'd be willing to take a stab at it?

Sure, I can probably post something in a bit.
Comment 24 Dirk Pranke 2012-01-05 14:17:20 PST
check out https://bugs.webkit.org/show_bug.cgi?id=75648 .
Comment 25 Adam Roben (:aroben) 2012-01-06 06:35:36 PST
(In reply to comment #24)
> check out https://bugs.webkit.org/show_bug.cgi?id=75648 .

Thanks!

(In reply to comment #21)
> (In reply to comment #18)
> > Does Driver know whether it's running under Cygwin or not? I didn't think it did.
> >
> 
> It certainly could know if it needed it ...

Any preference for how this should be done?
Comment 26 Dirk Pranke 2012-01-06 10:13:49 PST
(In reply to comment #25)
> (In reply to comment #24)
> > check out https://bugs.webkit.org/show_bug.cgi?id=75648 .
> 
> Thanks!
> 
> (In reply to comment #21)
> > (In reply to comment #18)
> > > Does Driver know whether it's running under Cygwin or not? I didn't think it did.
> > >
> > 
> > It certainly could know if it needed it ...
> 
> Any preference for how this should be done?

I typically just check for sys.platform == 'cygwin' where I need to. There's no need for this code to be particularly platform independent.
Comment 27 Radar WebKit Bug Importer 2012-01-09 10:33:44 PST
<rdar://problem/10663409>
Comment 28 Adam Roben (:aroben) 2012-01-09 10:36:05 PST
Created attachment 121683 [details]
Convert Cygwin paths to Windows paths before passing them to DRT
Comment 29 Dirk Pranke 2012-01-09 12:20:22 PST
Comment on attachment 121683 [details]
Convert Cygwin paths to Windows paths before passing them to DRT

I think you probably could have imported webkitpy.common.system.path in webkit_unittest and then overridden cygpath to point to a mocked-out function, but I think this is okay, too.
Comment 30 Dirk Pranke 2012-01-09 12:20:51 PST
(since it'll be tested heavily by nrwt.
Comment 31 Adam Roben (:aroben) 2012-01-09 12:24:59 PST
(In reply to comment #29)
> (From update of attachment 121683 [details])
> I think you probably could have imported webkitpy.common.system.path in webkit_unittest and then overridden cygpath to point to a mocked-out function, but I think this is okay, too.

I tried that but it didn't seem to work. The real cygpath was being called, not my mocked-out version.
Comment 32 Dirk Pranke 2012-01-09 12:27:20 PST
(In reply to comment #31)
> (In reply to comment #29)
> > (From update of attachment 121683 [details] [details])
> > I think you probably could have imported webkitpy.common.system.path in webkit_unittest and then overridden cygpath to point to a mocked-out function, but I think this is okay, too.
> 
> I tried that but it didn't seem to work. The real cygpath was being called, not my mocked-out version.

Hm. I'll have to dig into that at some point to figure out what was going on.
Comment 33 WebKit Review Bot 2012-01-09 13:16:33 PST
Comment on attachment 121683 [details]
Convert Cygwin paths to Windows paths before passing them to DRT

Clearing flags on attachment: 121683

Committed r104483: <http://trac.webkit.org/changeset/104483>
Comment 34 WebKit Review Bot 2012-01-09 13:16:39 PST
All reviewed patches have been landed.  Closing bug.