Skip to content

Commit

Permalink
Make it possible to run performance tests on Chromium Android
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=103268

Reviewed by Ryosuke Niwa.

Based on a patch by Peter Beverloo.

This patch (almost) makes it possible to run WebKit performance tests
on the Chromium port for Android. There are a few things I had to do
in order to make this happen:

1) The worker number when creating a driver for a port is zero-based
   for layout tests and elsewhere. Android uses this to determine
   which device it has to run on, so make it zero based for performance
   tests as well.

2) Tests aren't available on the Android device, so we start an HTTP
   server that serves the tests to the device or emulator.

The one shortcoming of this patch is that chromium-android produces
some stderr output that confuses run-perf-tests. I'll address that
issue in a subsequent CL. This patch also depends on
https://codereview.chromium.org/11416182 in order to work.

* Scripts/webkitpy/layout_tests/port/chromium_android.py:
(ChromiumAndroidPort.start_http_server):
(ChromiumAndroidDriver._command_from_driver_input):
* Scripts/webkitpy/performance_tests/perftest.py:
(ReplayPerfTest.prepare):
* Scripts/webkitpy/performance_tests/perftestsrunner.py:
(PerfTestsRunner.__init__):
(PerfTestsRunner._parse_args):
(PerfTestsRunner._start_servers):
(PerfTestsRunner):
(PerfTestsRunner._stop_servers):
(PerfTestsRunner.run):
(PerfTestsRunner._run_tests_set):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@135930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
[email protected] committed Nov 27, 2012
1 parent 776956b commit 0441266
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 10 deletions.
40 changes: 40 additions & 0 deletions Tools/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
2012-11-27 Adam Barth <[email protected]>

Make it possible to run performance tests on Chromium Android
https://bugs.webkit.org/show_bug.cgi?id=103268

Reviewed by Ryosuke Niwa.

Based on a patch by Peter Beverloo.

This patch (almost) makes it possible to run WebKit performance tests
on the Chromium port for Android. There are a few things I had to do
in order to make this happen:

1) The worker number when creating a driver for a port is zero-based
for layout tests and elsewhere. Android uses this to determine
which device it has to run on, so make it zero based for performance
tests as well.

2) Tests aren't available on the Android device, so we start an HTTP
server that serves the tests to the device or emulator.

The one shortcoming of this patch is that chromium-android produces
some stderr output that confuses run-perf-tests. I'll address that
issue in a subsequent CL. This patch also depends on
https://codereview.chromium.org/11416182 in order to work.

* Scripts/webkitpy/layout_tests/port/chromium_android.py:
(ChromiumAndroidPort.start_http_server):
(ChromiumAndroidDriver._command_from_driver_input):
* Scripts/webkitpy/performance_tests/perftest.py:
(ReplayPerfTest.prepare):
* Scripts/webkitpy/performance_tests/perftestsrunner.py:
(PerfTestsRunner.__init__):
(PerfTestsRunner._parse_args):
(PerfTestsRunner._start_servers):
(PerfTestsRunner):
(PerfTestsRunner._stop_servers):
(PerfTestsRunner.run):
(PerfTestsRunner._run_tests_set):

2012-11-27 Zan Dobersek <[email protected]>

Remove use of deprecated logging from webkitpy.common and webkitpy.layout_tests
Expand Down
16 changes: 10 additions & 6 deletions Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
# All the test cases are still served to DumpRenderTree through file protocol,
# but we use a file-to-http feature to bridge the file request to host's http
# server to get the real test files and corresponding resources.
TEST_PATH_PREFIX = '/all-tests'
# See webkit/support/platform_support_android.cc for the other side of this bridge.
PERF_TEST_PATH_PREFIX = '/all-perf-tests'
LAYOUT_TEST_PATH_PREFIX = '/all-tests'

# All ports the Android forwarder to forward.
# 8000, 8080 and 8443 are for http/https tests.
Expand Down Expand Up @@ -129,7 +131,8 @@
# 1. as a virtual path in file urls that will be bridged to HTTP.
# 2. pointing to some files that are pushed to the device for tests that
# don't work on file-over-http (e.g. blob protocol tests).
DEVICE_LAYOUT_TESTS_DIR = DEVICE_SOURCE_ROOT_DIR + 'third_party/WebKit/LayoutTests/'
DEVICE_WEBKIT_BASE_DIR = DEVICE_SOURCE_ROOT_DIR + 'third_party/WebKit/'
DEVICE_LAYOUT_TESTS_DIR = DEVICE_WEBKIT_BASE_DIR + 'LayoutTests/'

# Test resources that need to be accessed as files directly.
# Each item can be the relative path of a directory or a file.
Expand Down Expand Up @@ -242,7 +245,8 @@ def requires_http_server(self):
def start_http_server(self, additional_dirs=None, number_of_servers=0):
if not additional_dirs:
additional_dirs = {}
additional_dirs[TEST_PATH_PREFIX] = self.layout_tests_dir()
additional_dirs[PERF_TEST_PATH_PREFIX] = self.perf_tests_dir()
additional_dirs[LAYOUT_TEST_PATH_PREFIX] = self.layout_tests_dir()
super(ChromiumAndroidPort, self).start_http_server(additional_dirs, number_of_servers)

def create_driver(self, worker_number, no_timeout=False):
Expand Down Expand Up @@ -665,10 +669,10 @@ def stop(self):
def _command_from_driver_input(self, driver_input):
command = super(ChromiumAndroidDriver, self)._command_from_driver_input(driver_input)
if command.startswith('/'):
# Convert the host file path to a device file path. See comment of
# DEVICE_LAYOUT_TESTS_DIR for details.
fs = self._port._filesystem
# FIXME: what happens if command lies outside of the layout_tests_dir on the host?
command = DEVICE_LAYOUT_TESTS_DIR + self._port.relative_test_filename(command)
relative_test_filename = fs.relpath(command, fs.dirname(self._port.layout_tests_dir()))
command = DEVICE_WEBKIT_BASE_DIR + relative_test_filename
return command

def _read_prompt(self, deadline):
Expand Down
2 changes: 1 addition & 1 deletion Tools/Scripts/webkitpy/performance_tests/perftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def prepare(self, time_out_ms):

_log.info("Preparing replay for %s" % self.test_name())

driver = self._port.create_driver(worker_number=1, no_timeout=True)
driver = self._port.create_driver(worker_number=0, no_timeout=True)
try:
output = self.run_single(driver, self._archive_path, time_out_ms, record=True)
finally:
Expand Down
29 changes: 26 additions & 3 deletions Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def __init__(self, args=None, port=None):
self._base_path = self._port.perf_tests_dir()
self._results = {}
self._timestamp = time.time()
self._needs_http = None
self._has_http_lock = False

@staticmethod
def _parse_args(args=None):
Expand All @@ -83,6 +85,8 @@ def _expand_path(option, opt_str, value, parser):
help="Specify port/platform being tested (i.e. chromium-mac)"),
optparse.make_option("--chromium",
action="store_const", const='chromium', dest='platform', help='Alias for --platform=chromium'),
optparse.make_option("--chromium-android",
action="store_const", const='chromium-android', dest='platform', help='Alias for --platform=chromium-android'),
optparse.make_option("--builder-name",
help=("The name of the builder shown on the waterfall running this script e.g. google-mac-2.")),
optparse.make_option("--build-number",
Expand Down Expand Up @@ -151,8 +155,21 @@ def _is_test_file(filesystem, dirname, filename):

return tests

def _start_servers(self):
if self._needs_http:
self._port.acquire_http_lock()
self._port.start_http_server(number_of_servers=2)
self._has_http_lock = True

def _stop_servers(self):
if self._has_http_lock:
self._port.stop_http_server()
self._port.release_http_lock()

def run(self):
if not self._port.check_build(needs_http=False):
self._needs_http = self._port.requires_http_server()

if not self._port.check_build(needs_http=self._needs_http):
_log.error("Build not up to date for %s" % self._port._path_to_driver())
return self.EXIT_CODE_BAD_BUILD

Expand All @@ -163,7 +180,13 @@ def run(self):
if not test.prepare(self._options.time_out_ms):
return self.EXIT_CODE_BAD_PREPARATION

unexpected = self._run_tests_set(sorted(list(tests), key=lambda test: test.test_name()), self._port)
try:
self._start_servers()
unexpected = self._run_tests_set(sorted(list(tests), key=lambda test: test.test_name()), self._port)

finally:
self._stop_servers()

if self._options.generate_results:
exit_code = self._generate_and_show_results()
if exit_code:
Expand Down Expand Up @@ -290,7 +313,7 @@ def _run_tests_set(self, tests, port):
driver = None

for test in tests:
driver = port.create_driver(worker_number=1, no_timeout=True)
driver = port.create_driver(worker_number=0, no_timeout=True)

if self._options.pause_before_testing:
driver.start()
Expand Down

0 comments on commit 0441266

Please sign in to comment.