Bug 31603 - WebSocket server is confused if WebKit tests run from within /tmp on Mac OS X
Summary: WebSocket server is confused if WebKit tests run from within /tmp on Mac OS X
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 31501
  Show dependency treegraph
 
Reported: 2009-11-17 16:26 PST by Mark Rowe (bdash)
Modified: 2009-11-17 17:25 PST (History)
2 users (show)

See Also:


Attachments
Patch (2.15 KB, patch)
2009-11-17 16:33 PST, Mark Rowe (bdash)
ap: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Rowe (bdash) 2009-11-17 16:26:39 PST
On Mac OS X /tmp is a symlink to /private/tmp.  If the WebSocket server is started from below this directory it gets confused and logs errors rather than serving content:

mrowe@angara:/tmp/WebKit$ PYTHONPATH=WebKitTools/pywebsocket /usr/bin/python WebKitTools/pywebsocket/mod_pywebsocket/standalone.py -p 2048 -d $PWD/LayoutTests -s $PWD/LayoutTests/websocket/tests
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50785)
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 558, in process_request_thread
    self.finish_request(request, client_address)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 320, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "WebKitTools/pywebsocket/mod_pywebsocket/standalone.py", line 170, in __init__
    WebSocketRequestHandler.options.scan_dir)
  File "/private/tmp/WebKit/WebKitTools/pywebsocket/mod_pywebsocket/dispatch.py", line 141, in __init__
    'root_dir:%s.' % (scan_dir, root_dir))
DispatchError: scan_dir:/tmp/WebKit/LayoutTests/websocket/tests must be a directory under root_dir:..
----------------------------------------

This happens because dispatch.py uses the following code to determine if scan_dir is below root_dir: os.path.abspath(scan_dir).startswith(os.path.abspath(root_dir))

scan_dir is “/tmp/WebKit/LayoutTests/websocket/tests” and so abspath(scan_dir) evalutes to "/tmp/WebKit/LayoutTests/websocket/tests”.
root_dir is “.” and so abspath(root_dir) evaluates to “/private/tmp/WebKit/LayoutTests”.

I suspect this code wants to be using os.path.realpath rather than os.path.abspath.  This returns the canonical version of the path and therefore is not confused by the /tmp symlink.
Comment 1 Mark Rowe (bdash) 2009-11-17 16:33:12 PST
Created attachment 43388 [details]
Patch

I suspect that pywebsocket is from an external source but the README doesn’t include any information about that.  This patch appears to address the problem.
Comment 2 Alexey Proskuryakov 2009-11-17 16:55:42 PST
Comment on attachment 43388 [details]
Patch

r=me
Comment 3 Mark Rowe (bdash) 2009-11-17 17:13:04 PST
Landed in r51099.
Comment 4 Yuzo Fujishima 2009-11-17 17:25:36 PST
Sorry for the bug and thank you for fixing.

I'll fix this also upstream.
( http://code.google.com/p/pywebsocket/issues/detail?id=23 )

FYI:
os.path.abspath is used also in line 65.

Yuzo