Commit 0d1934a4 authored by dpranke@chromium.org's avatar dpranke@chromium.org

2010-02-03 Dirk Pranke <dpranke@chromium.org>

        Reviewed by Eric Seidel.

        Add a simple test implementation and the WebKit Mac implementation
        for the layout_tests/port package. Also add a simple test driver of
        that interface.

        https://bugs.webkit.org/show_bug.cgi?id=34511

        * Scripts/webkitpy/layout_tests/driver_test.py: Added.
        * Scripts/webkitpy/layout_tests/port/__init__.py:
        * Scripts/webkitpy/layout_tests/port/mac.py: Added.
        * Scripts/webkitpy/layout_tests/port/test.py: Added.


git-svn-id: svn://svn.chromium.org/blink/trunk@54452 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 273a0a62
2010-02-03 Dirk Pranke <dpranke@chromium.org>
Reviewed by Eric Seidel.
Add a simple test implementation and the WebKit Mac implementation
for the layout_tests/port package. Also add a simple test driver of
that interface.
https://bugs.webkit.org/show_bug.cgi?id=34511
* Scripts/webkitpy/layout_tests/driver_test.py: Added.
* Scripts/webkitpy/layout_tests/port/__init__.py:
* Scripts/webkitpy/layout_tests/port/mac.py: Added.
* Scripts/webkitpy/layout_tests/port/test.py: Added.
2010-02-03 Dirk Pranke <dpranke@chromium.org> 2010-02-03 Dirk Pranke <dpranke@chromium.org>
Reviewed by Eric Siedel. Reviewed by Eric Siedel.
......
#!/usr/bin/env python
# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# FIXME: this is a poor attempt at a unit tests driver. We should replace
# this with something that actually uses a unit testing framework or
# at least produces output that could be useful.
"""Simple test client for the port/Driver interface."""
import os
import optparse
import port
def run_tests(port, options, tests):
# |image_path| is a path to the image capture from the driver.
image_path = 'image_result.png'
driver = port.start_driver(image_path, None)
for t in tests:
uri = port.filename_to_uri(os.path.join(port.layout_tests_dir(), t))
print "uri: " + uri
crash, timeout, checksum, output, err = \
driver.run_test(uri, int(options.timeout), None)
print "crash: " + str(crash)
print "timeout: " + str(timeout)
print "checksum: " + str(checksum)
print 'stdout: """'
print ''.join(output)
print '"""'
print 'stderr: """'
print ''.join(err)
print '"""'
print
if __name__ == '__main__':
optparser = optparse.OptionParser()
optparser.add_option('-p', '--port', action='store', default='mac',
'Platform to test (e.g., "mac", "chromium-mac", etc.')
optparser.add_option('-t', '--target', action='store', default='Release',
'build type ("Debug" or "Release")')
optparser.add_option('', '--timeout', action='store', default='2000',
'test timeout in milliseconds (2000 by default)')
optparser.add_option('', '--wrapper', action='store')
optparser.add_option('', '--no-pixel-tests', action='store_true',
default=False,
help='disable pixel-to-pixel PNG comparisons')
options, args = optparser.parse_args()
p = port.get(options.port, options)
run_tests(p, options, args)
...@@ -38,7 +38,13 @@ def get(port_name=None, options=None): ...@@ -38,7 +38,13 @@ def get(port_name=None, options=None):
if port_to_use is None: if port_to_use is None:
port_to_use = 'chromium-mac' port_to_use = 'chromium-mac'
if port_to_use.startswith('chromium-mac'): if port_to_use == 'test':
import test
return test.TestPort(port_name, options)
elif port_to_use.startswith('mac'):
import mac
return mac.MacPort(port_name, options)
elif port_to_use.startswith('chromium-mac'):
import chromium_mac import chromium_mac
return chromium_mac.ChromiumMacPort(port_name, options) return chromium_mac.ChromiumMacPort(port_name, options)
elif port_to_use.startswith('chromium-linux'): elif port_to_use.startswith('chromium-linux'):
......
#!/usr/bin/env python
# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the Google name nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Dummy Port implementation used for testing."""
import os
import time
import base
class TestPort(base.Port):
"""Test implementation of the Port interface."""
def __init__(self, port_name=None, options=None):
base.Port.__init__(self, port_name, options)
def base_platforms(self):
return ('test',)
def baseline_path(self):
curdir = os.path.abspath(__file__)
self.topdir = curdir[0:curdir.index("WebKitTools")]
return os.path.join(self.topdir, 'LayoutTests', 'platform', 'test')
def baseline_search_path(self):
return [self.baseline_path()]
def check_sys_deps(self):
return True
def diff_image(self, actual_filename, expected_filename, diff_filename):
return False
def compare_text(self, actual_text, expected_text):
return False
def diff_text(self, actual_text, expected_text,
actual_filename, expected_filename):
return ''
def name(self):
return self._name
def num_cores(self):
return int(os.popen2("sysctl -n hw.ncpu")[1].read())
def options(self):
return self._options
def results_directory(self):
return '/tmp' + self._options.results_directory
def setup_test_run(self):
pass
def show_results_html_file(self, filename):
pass
def start_driver(self, image_path, options):
return TestDriver(image_path, options, self)
def start_http_server(self):
pass
def start_websocket_server(self):
pass
def start_helper(self):
pass
def stop_http_server(self):
pass
def stop_websocket_server(self):
pass
def stop_helper(self):
pass
def test_expectations(self):
return ''
def test_base_platform_names(self):
return ('test',)
def test_platform_name(self):
return 'test'
def test_platform_names(self):
return self.test_base_platform_names()
def version():
return ''
def wdiff_text(self, actual_filename, expected_filename):
return ''
class TestDriver(base.Driver):
"""Test/Dummy implementation of the DumpRenderTree interface."""
def __init__(self, image_path, test_driver_options, port):
self._driver_options = test_driver_options
self._image_path = image_path
self._port = port
def poll(self):
return True
def returncode(self):
return 0
def run_test(self, uri, timeoutms, image_hash):
return (False, False, image_hash, '', None)
def stop(self):
pass
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment