This exercise came about as an option for running unittests on windows mobile. We ran into an issue where the http server was running but not returning web pages. Vlad had mentioned running the web server on a host machine to be respectful of the memory on the device. In the past other members of the QA team have tried this with no luck. With the help of :waldo, I was able to get tests running while accessing a remote webserver.
For a quick background, all unittests rely on httpd.js running via xpcshell to serve web pages. For example, xpcshell update tests (test_0030_general.js) utilize httpd.js to download a .mar file and mochitest uses httpd.js for every test it runs. It is a little tricky to get this to run on a remote server as there are a few things to edit:
- Have an identical test directory structure on the local (machine under test) and remote (web server) host so that references to tests can be found by the test harness on the local machine, and references identically on the remote web server. Note that all changes mentioned below need to live on both machines.
- For mochitests, edit server-locations.txt and change the reference in line 78 from http://localhost:8888 to http://’your_ip_addr’:8888. This is important to have on both local and remote machines as automation.py adds exceptions to the remote script permissions for mochitest to access chrome
- in httpd.js, change references from “localhost” to ‘your_ip_addr’. Note, do not change the “xlocalhost” reference on line 811.
- Edit the call to ServerSocket() in httpd.js to set the second parameter to false, as true is loopback only
- Edit runtests.py and change TEST_SERVER_HOST from localhost reference to ‘your_ip_addr’ instead.
- Edit any tests that specifically reference localhost. For example in the xpcshell test_update/test_0030_general.js, we try to download from localhost as references in head_update.js
Now you need to fire up xpcshell to run as a server:
#set any env variables such as
#LD_LIBRARY_PATH=$firefox_dir/xulrunner on linux
./xpcshell -f ../../mochitest/httpd.js -f ../../mochitest/server.js
On the remote machine launch your test and be happy!
To really utilize this for the Fennec unittests on Windows Mobile, we will have to make many changes to the tests in addition to the ones mentioned above. Making it fit into automation would be very difficult as ip addresses can change and we might need to set it dynamically. Alternatively, running 1 host to many clients does have some attraction.