summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordpranke@google.com <dpranke@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 00:43:03 +0000
committerdpranke@google.com <dpranke@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 00:43:03 +0000
commit2112999ec51a6a514cc66f5609a79eb735e14cb3 (patch)
treef0b94513b228d0a65dec3609b5e303c99791229d /webkit
parent6641bf667244ed108b2d300766896f6fa84a6f4e (diff)
downloadchromium_src-2112999ec51a6a514cc66f5609a79eb735e14cb3.zip
chromium_src-2112999ec51a6a514cc66f5609a79eb735e14cb3.tar.gz
chromium_src-2112999ec51a6a514cc66f5609a79eb735e14cb3.tar.bz2
Reverting 23924 - several builds broke
BUG=none R=tony@chromium.org TEST=none Review URL: http://codereview.chromium.org/174207 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23928 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/tools/layout_tests/layout_package/failure_finder.py4
-rw-r--r--webkit/tools/layout_tests/layout_package/http_server.py58
-rw-r--r--webkit/tools/layout_tests/layout_package/path_utils.py393
-rw-r--r--webkit/tools/layout_tests/layout_package/platform_utils.py4
-rw-r--r--webkit/tools/layout_tests/layout_package/platform_utils_linux.py345
-rw-r--r--webkit/tools/layout_tests/layout_package/platform_utils_mac.py247
-rw-r--r--webkit/tools/layout_tests/layout_package/platform_utils_win.py335
-rw-r--r--webkit/tools/layout_tests/layout_package/test_expectations.py17
-rw-r--r--webkit/tools/layout_tests/layout_package/test_failures.py4
-rw-r--r--webkit/tools/layout_tests/layout_package/test_shell_thread.py7
-rw-r--r--webkit/tools/layout_tests/rebaseline.py38
-rwxr-xr-xwebkit/tools/layout_tests/run_webkit_tests.py70
-rw-r--r--webkit/tools/layout_tests/test_types/fuzzy_image_diff.py8
-rw-r--r--webkit/tools/layout_tests/test_types/image_diff.py13
-rw-r--r--webkit/tools/layout_tests/test_types/test_type_base.py19
-rw-r--r--webkit/tools/layout_tests/test_types/text_diff.py18
16 files changed, 1040 insertions, 540 deletions
diff --git a/webkit/tools/layout_tests/layout_package/failure_finder.py b/webkit/tools/layout_tests/layout_package/failure_finder.py
index 63fe573..392d2f9 100644
--- a/webkit/tools/layout_tests/layout_package/failure_finder.py
+++ b/webkit/tools/layout_tests/layout_package/failure_finder.py
@@ -8,8 +8,10 @@
import difflib
import errno
+import google.path_utils
import os
import path_utils
+import platform_utils
import re
import subprocess
import sys
@@ -138,7 +140,7 @@ def ScrapeURL(url):
def GeneratePNGDiff(file1, file2, output_file):
_compare_available = False;
try:
- executable = path_utils.ImageDiffPath("Debug")
+ executable = path_utils.ImageDiffBinaryPath("Debug")
cmd = [executable, '--diff', file1, file2, output_file]
_compare_available = True;
except Exception, e:
diff --git a/webkit/tools/layout_tests/layout_package/http_server.py b/webkit/tools/layout_tests/layout_package/http_server.py
index d30d695..1d32e58 100644
--- a/webkit/tools/layout_tests/layout_package/http_server.py
+++ b/webkit/tools/layout_tests/layout_package/http_server.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,13 +9,21 @@
import logging
import optparse
import os
+import platform_utils
import subprocess
import sys
import tempfile
import time
import urllib
-import path_utils
+import google.path_utils
+
+# This will be a native path to the directory this file resides in.
+# It can either be relative or absolute depending how it's executed.
+THISDIR = os.path.dirname(os.path.abspath(__file__))
+
+def PathFromBase(*pathies):
+ return google.path_utils.FindUpward(THISDIR, *pathies)
def RemoveLogFiles(folder, starts_with):
files = os.listdir(folder)
@@ -30,30 +38,30 @@ class HttpdNotStarted(Exception):
class Lighttpd:
# Webkit tests
try:
- _webkit_tests = path_utils.PathFromBase('third_party', 'WebKit',
- 'LayoutTests', 'http', 'tests')
- except path_utils.PathNotFound:
+ _webkit_tests = PathFromBase('third_party', 'WebKit',
+ 'LayoutTests', 'http', 'tests')
+ except google.path_utils.PathNotFound:
# If third_party/WebKit/LayoutTests/http/tests does not exist, assume wekit
# tests are located in webkit/data/layout_tests/LayoutTests/http/tests.
try:
- _webkit_tests = path_utils.PathFromBase('webkit', 'data', 'layout_tests',
- 'LayoutTests', 'http', 'tests')
- except path_utils.PathNotFound:
+ _webkit_tests = PathFromBase('webkit', 'data', 'layout_tests',
+ 'LayoutTests', 'http', 'tests')
+ except google.path_utils.PathNotFound:
_webkit_tests = None
# New tests for Chrome
try:
- _pending_tests = path_utils.PathFromBase('webkit', 'data', 'layout_tests',
- 'pending', 'http', 'tests')
- except path_utils.PathNotFound:
+ _pending_tests = PathFromBase('webkit', 'data', 'layout_tests',
+ 'pending', 'http', 'tests')
+ except google.path_utils.PathNotFound:
_pending_tests = None
# Path where we can access all of the tests
- _all_tests = path_utils.PathFromBase('webkit', 'data', 'layout_tests')
+ _all_tests = PathFromBase('webkit', 'data', 'layout_tests')
# Self generated certificate for SSL server (for client cert get
# <base-path>\chrome\test\data\ssl\certs\root_ca_cert.crt)
- _pem_file = path_utils.PathFromBase('tools', 'python', 'google',
- 'httpd_config', 'httpd2.pem')
+ _pem_file = PathFromBase('tools', 'python', 'google', 'httpd_config',
+ 'httpd2.pem')
VIRTUALCONFIG = [
# One mapping where we can get to everything
{'port': 8081, 'docroot': _all_tests}
@@ -95,8 +103,7 @@ class Lighttpd:
if self.IsRunning():
raise 'Lighttpd already running'
- base_conf_file = path_utils.PathFromBase('webkit',
- 'tools','layout_tests','layout_package', 'lighttpd.conf')
+ base_conf_file = os.path.join(THISDIR, 'lighttpd.conf')
out_conf_file = os.path.join(self._output_dir, 'lighttpd.conf')
time_str = time.strftime("%d%b%Y-%H%M%S")
access_file_name = "access.log-" + time_str + ".txt"
@@ -119,11 +126,12 @@ class Lighttpd:
# Write out our cgi handlers. Run perl through env so that it processes
# the #! line and runs perl with the proper command line arguments.
# Emulate apache's mod_asis with a cat cgi handler.
+ platform_util = platform_utils.PlatformUtility('')
f.write(('cgi.assign = ( ".cgi" => "/usr/bin/env",\n'
' ".pl" => "/usr/bin/env",\n'
' ".asis" => "/bin/cat",\n'
' ".php" => "%s" )\n\n') %
- path_utils.LigHTTPdPHPPath())
+ platform_util.LigHTTPdPHPPath())
# Setup log files
f.write(('server.errorlog = "%s"\n'
@@ -162,12 +170,11 @@ class Lighttpd:
'}\n\n') % (mapping['port'], mapping['docroot']))
f.close()
- executable = path_utils.LigHTTPdExecutablePath()
- module_path = path_utils.LigHTTPdModulePath()
+ executable = platform_util.LigHTTPdExecutablePath()
+ module_path = platform_util.LigHTTPdModulePath()
start_cmd = [ executable,
# Newly written config file
- '-f', path_utils.PathFromBase(self._output_dir,
- 'lighttpd.conf'),
+ '-f', PathFromBase(self._output_dir, 'lighttpd.conf'),
# Where it can find its module dynamic libraries
'-m', module_path,
# Don't background
@@ -177,12 +184,10 @@ class Lighttpd:
env = os.environ
if sys.platform in ('cygwin', 'win32'):
env['PATH'] = '%s;%s' % (
- path_utils.PathFromBase('third_party', 'cygwin', 'bin'),
- env['PATH'])
+ PathFromBase('third_party', 'cygwin', 'bin'), env['PATH'])
if sys.platform == 'win32' and self._register_cygwin:
- setup_mount = path_utils.PathFromBase('third_party', 'cygwin',
- 'setup_mount.bat')
+ setup_mount = PathFromBase('third_party', 'cygwin', 'setup_mount.bat')
subprocess.Popen(setup_mount).wait()
logging.info('Starting http server')
@@ -235,7 +240,8 @@ class Lighttpd:
return
logging.info('Shutting down http server')
- path_utils.ShutDownHTTPServer(self._process)
+ platform_util = platform_utils.PlatformUtility('')
+ platform_util.ShutDownHTTPServer(self._process)
if self._process:
self._process.wait()
diff --git a/webkit/tools/layout_tests/layout_package/path_utils.py b/webkit/tools/layout_tests/layout_package/path_utils.py
index 43db161..9d05d18 100644
--- a/webkit/tools/layout_tests/layout_package/path_utils.py
+++ b/webkit/tools/layout_tests/layout_package/path_utils.py
@@ -1,53 +1,176 @@
-# Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""This package contains utility methods for manipulating paths and
-filenames for test results and baselines. It also contains wrappers
-of a few routines in platform_utils.py so that platform_utils.py can
-be considered a 'protected' package - i.e., this file should be
-the only file that ever includes platform_utils. This leads to
-us including a few things that don't really have anything to do
- with paths, unfortunately."""
+"""Some utility methods for getting paths used by run_webkit_tests.py.
+"""
import errno
import os
import platform_utils
+import subprocess
+import sys
+
+import google.path_utils
-# Cache some values so we don't have to recalculate them. _basedir is
-# used by PathFromBase() and caches the full (native) path to the top
-# of the source tree (/src). _baseline_search_path is used by
-# ExpectedBaseline() and caches the list of native paths to search
-# for baseline results.
-_basedir = None
-_baseline_search_path = None
class PathNotFound(Exception): pass
-def LayoutTestsDir(path=None):
- """Returns the fully-qualified path to the directory containing the input
- data for the specified layout test.
+# Save some paths here so we don't keep re-evaling.
+_webkit_root = None
+_layout_data_dir = None
+_layout_tests_dir = None
+# A map from platform description to directory list.
+_platform_results_dirs = {}
- We have not fully upstreamed all of our layout tests, so we need to
- potentially return two different places."""
- if path and path.find('LayoutTests') == -1:
- return PathFromBase('webkit', 'data', 'layout_tests')
- else:
- return PathFromBase('third_party', 'WebKit');
+# An instance of the PlatformUtility for use by methods mapped from there.
+_platform_util = None
-def ChromiumBaselinePath(platform):
- """Returns the full path to the directory containing expected
- baseline results from chromium ports."""
- return PathFromBase('webkit', 'data', 'layout_tests', 'platform', platform)
+# TODO this should probably be moved into path_utils as ToUnixPath().
+def WinPathToUnix(path):
+ """Convert a windows path to use unix-style path separators (a/b/c)."""
+ return path.replace('\\', '/')
-def WebKitBaselinePath(platform):
- """Returns the full path to the directory containing expected
- baseline results from WebKit ports."""
- return PathFromBase('third_party', 'WebKit', 'LayoutTests',
- 'platform', platform)
+def WebKitRoot():
+ """Returns the full path to the directory containing webkit.gyp. Raises
+ PathNotFound if we're unable to find webkit.gyp."""
+ global _webkit_root
+ if _webkit_root:
+ return _webkit_root
+ webkit_gyp_path = google.path_utils.FindUpward(google.path_utils.ScriptDir(),
+ 'webkit.gyp')
+ _webkit_root = os.path.dirname(webkit_gyp_path)
+ return _webkit_root
+
+def LayoutDataDir():
+ """Gets the full path to the tests directory. Raises PathNotFound if
+ we're unable to find it."""
+ global _layout_data_dir
+ if _layout_data_dir:
+ return _layout_data_dir
+ _layout_data_dir = google.path_utils.FindUpward(WebKitRoot(), 'webkit',
+ 'data', 'layout_tests')
+ return _layout_data_dir
+
+def LayoutTestsDir(path = None):
+ """Returns the full path to the directory containing layout tests, based on
+ the supplied relative or absolute path to a layout tests. If the path contains
+ "LayoutTests" directory, locates this directory, assuming it's either in
+ in webkit/data/layout_tests or in third_party/WebKit."""
+
+ if path != None and path.find('LayoutTests') == -1:
+ return LayoutDataDir()
+
+ global _layout_tests_dir
+ if _layout_tests_dir:
+ return _layout_tests_dir
+
+ webkit_dir = google.path_utils.FindUpward(
+ google.path_utils.ScriptDir(), 'third_party', 'WebKit')
+
+ if os.path.exists(os.path.join(webkit_dir, 'LayoutTests')):
+ _layout_tests_dir = webkit_dir
+ else:
+ _layout_tests_dir = LayoutDataDir()
+ return _layout_tests_dir
-def ExpectedBaseline(filename, suffix):
+def ChromiumPlatformResultsEnclosingDir():
+ """Returns the full path to the directory containing Chromium platform
+ result directories.
+ """
+ # TODO(pamg): Once we move platform/chromium-* into LayoutTests/platform/,
+ # remove this and use PlatformResultsEnclosingDir() for everything.
+ return os.path.join(LayoutDataDir(), 'platform')
+
+def WebKitPlatformResultsEnclosingDir():
+ """Gets the full path to just above the platform results directory."""
+ return os.path.join(LayoutTestsDir(), 'LayoutTests', 'platform')
+
+def PlatformResultsEnclosingDir(platform):
+ """Gets the path to just above the results directory for this platform."""
+ if platform.startswith('chromium'):
+ return ChromiumPlatformResultsEnclosingDir()
+ return WebKitPlatformResultsEnclosingDir()
+
+def GetPlatformDirs(platform):
+ """Returns a list of directories to look in for test results.
+
+ The result will be sought in the chromium-specific platform directories,
+ in the corresponding WebKit platform directories, in the WebKit platform/mac/
+ directory, and finally next to the test file.
+
+ Suppose that the |platform| is 'chromium-win-xp'. In that case, the
+ following directories are searched in order, if they exist, and the first
+ match is returned:
+ LayoutTests/platform/chromium-win-xp/
+ LayoutTests/platform/chromium-win/
+ LayoutTests/platform/chromium/
+ LayoutTests/platform/win-xp/
+ LayoutTests/platform/win/
+ LayoutTests/platform/mac/
+ the directory in which the test itself is located
+
+ If the |platform| is 'chromium-mac-leopard', the sequence will be as follows:
+ LayoutTests/platform/chromium-mac-leopard/
+ LayoutTests/platform/chromium-mac/
+ LayoutTests/platform/chromium/
+ LayoutTests/platform/mac-leopard/
+ LayoutTests/platform/mac/
+ the directory in which the test itself is located
+
+ A platform may optionally fall back to the Windows results if its own
+ results are not found, by returning True from its platform-specific
+ platform_utils.IsNonWindowsPlatformTargettingWindowsResults(). Supposing
+ that Linux does so, the search sequence for the |platform| 'chromium-linux'
+ will be
+ LayoutTests/platform/chromium-linux/
+ LayoutTests/platform/chromium/
+ LayoutTests/platform/linux/
+ LayoutTests/platform/chromium-win/
+ LayoutTests/platform/win/
+ LayoutTests/platform/mac/
+ the directory in which the test itself is located
+
+ Args:
+ platform: a hyphen-separated list of platform descriptors from least to
+ most specific, matching the WebKit format, that will be used to find
+ the platform/ directories to look in. For example, 'chromium-win' or
+ 'chromium-mac-leopard'.
+ Returns:
+ a list of directories to search
+ """
+ # Use the cached directory list if we have one.
+ global _platform_results_dirs
+ platform_dirs = _platform_results_dirs.get(platform, [])
+ if len(platform_dirs) == 0:
+ # Build the list of platform directories: chromium-foo-bar, chromium-foo,
+ # chromium.
+ segments = platform.split('-')
+ for length in range(len(segments), 0, -1):
+ platform_dirs.append('-'.join(segments[:length]))
+
+ # Append corresponding WebKit platform directories too.
+ if platform.startswith('chromium-'):
+ for length in range(len(segments), 1, -1):
+ platform_dirs.append('-'.join(segments[1:length]))
+
+ if platform_utils.IsNonWindowsPlatformTargettingWindowsResults():
+ if platform.startswith('chromium'):
+ platform_dirs.append('chromium-win')
+ platform_dirs.append('win')
+
+ # Finally, append platform/mac/ to all searches.
+ if 'mac' not in platform_dirs:
+ platform_dirs.append('mac')
+
+ platform_dirs = [os.path.join(PlatformResultsEnclosingDir(x), x)
+ for x in platform_dirs]
+ _platform_results_dirs[platform] = platform_dirs
+
+ return platform_dirs
+
+def ExpectedBaseline(filename, suffix, platform):
"""Given a test name, finds where the baseline result is located. The
result is returned as a pair of values, the absolute path to top of the test
results directory, and the relative path from there to the results file.
@@ -62,13 +185,16 @@ def ExpectedBaseline(filename, suffix):
filename: absolute filename to test file
suffix: file suffix of the expected results, including dot; e.g. '.txt'
or '.png'. This should not be None, but may be an empty string.
+ platform: the most-specific directory name to use to build the
+ search list of directories, e.g., 'chromium-win', or
+ 'chromium-mac-leopard' (we follow the WebKit format)
Returns
- platform_dir - abs path to the top of the results tree (or test tree)
+ platform_dir - abs path to the top of the results tree (or test tree),
+ or None if the file doesn't exist.
results_filename - relative path from top of tree to the results file
(os.path.join of the two gives you the full path to the file, unless
None was returned.)
"""
- global _baseline_search_path
testname = os.path.splitext(RelativeTestFilename(filename))[0]
# While we still have tests in LayoutTests/, chrome/, and pending/, we need
@@ -77,9 +203,8 @@ def ExpectedBaseline(filename, suffix):
platform_filename = testname + '-expected' + suffix
testdir, base_filename = platform_filename.split('/', 1)
- if _baseline_search_path is None:
- _baseline_search_path = platform_utils.BaselineSearchPath()
- for platform_dir in _baseline_search_path:
+ platform_dirs = GetPlatformDirs(platform)
+ for platform_dir in platform_dirs:
# TODO(pamg): Clean this up once we upstream everything in chrome/ and
# pending/.
if os.path.basename(platform_dir).startswith('chromium'):
@@ -96,7 +221,7 @@ def ExpectedBaseline(filename, suffix):
return platform_dir, platform_filename
return None, platform_filename
-def ExpectedFilename(filename, suffix):
+def ExpectedFilename(filename, suffix, platform):
"""Given a test name, returns an absolute path to its expected results.
If no expected results are found in any of the searched directories, the
@@ -112,128 +237,86 @@ def ExpectedFilename(filename, suffix):
search list of directories, e.g., 'chromium-win', or
'chromium-mac-leopard' (we follow the WebKit format)
"""
- platform_dir, platform_filename = ExpectedBaseline(filename, suffix)
+ (platform_dir, platform_filename) = ExpectedBaseline(filename, suffix,
+ platform)
if platform_dir:
return os.path.join(platform_dir, platform_filename)
return os.path.join(LayoutTestsDir(filename), platform_filename)
+def ImageDiffBinaryPath(target):
+ """Gets the full path to the image_diff binary for the target build
+ configuration. Raises PathNotFound if the file doesn't exist"""
+ platform_util = platform_utils.PlatformUtility('')
+ full_path = os.path.join(WebKitRoot(), target,
+ platform_util.ImageDiffBinary())
+ if not os.path.exists(full_path):
+ # try output directory from either Xcode or chrome.sln
+ full_path = platform_util.ImageDiffBinaryPath(target)
+ if not os.path.exists(full_path):
+ raise PathNotFound('unable to find image_diff at %s' % full_path)
+ return full_path
+
+def TestShellBinaryPath(target):
+ """Gets the full path to the test_shell binary for the target build
+ configuration. Raises PathNotFound if the file doesn't exist"""
+ platform_util = platform_utils.PlatformUtility('')
+ full_path = os.path.join(WebKitRoot(), target,
+ platform_util.TestShellBinary())
+ if not os.path.exists(full_path):
+ # try output directory from either Xcode or chrome.sln
+ full_path = platform_util.TestShellBinaryPath(target)
+ if not os.path.exists(full_path):
+ raise PathNotFound('unable to find test_shell at %s' % full_path)
+ return full_path
+
+def LayoutTestHelperBinaryPath(target):
+ """Gets the full path to the layout test helper binary for the target build
+ configuration, if it is needed, or an empty string if it isn't.
+
+ Raises PathNotFound if it is needed and the file doesn't exist"""
+ platform_util = platform_utils.PlatformUtility('')
+ if len(platform_util.LayoutTestHelperBinary()):
+ full_path = os.path.join(WebKitRoot(), target,
+ platform_util.LayoutTestHelperBinary())
+ if not os.path.exists(full_path):
+ # try output directory from either Xcode or chrome.sln
+ full_path = platform_util.LayoutTestHelperBinaryPath(target)
+ if len(full_path) and not os.path.exists(full_path):
+ raise PathNotFound('unable to find layout_test_helper at %s' %
+ full_path)
+ return full_path
+ else:
+ return ''
+
def RelativeTestFilename(filename):
"""Provide the filename of the test relative to the layout data
directory as a unix style path (a/b/c)."""
- return _WinPathToUnix(filename[len(LayoutTestsDir(filename)) + 1:])
+ return WinPathToUnix(filename[len(LayoutTestsDir(filename)) + 1:])
+
+def GetPlatformUtil():
+ """Returns a singleton instance of the PlatformUtility."""
+ global _platform_util
+ if not _platform_util:
+ # Avoid circular import by delaying it.
+ import layout_package.platform_utils
+ _platform_util = (
+ layout_package.platform_utils.PlatformUtility(WebKitRoot()))
+ return _platform_util
+
+# Map platform specific path utility functions. We do this as a convenience
+# so importing path_utils will get all path related functions even if they are
+# platform specific.
+def GetAbsolutePath(path):
+ return GetPlatformUtil().GetAbsolutePath(path)
-def _WinPathToUnix(path):
- """Convert a windows path to use unix-style path separators (a/b/c)."""
- return path.replace('\\', '/')
+def FilenameToUri(path):
+ return GetPlatformUtil().FilenameToUri(path)
-#
-# Routines that are arguably platform-specific but have been made
-# generic for now (they used to be in platform_utils_*)
-#
-def FilenameToUri(full_path):
- """Convert a test file to a URI."""
- LAYOUTTEST_HTTP_DIR = "LayoutTests/http/tests/"
- PENDING_HTTP_DIR = "pending/http/tests/"
-
- relative_path = _WinPathToUnix(RelativeTestFilename(full_path))
- port = None
- use_ssl = False
-
- # LayoutTests/http/tests/ run off port 8000 and ssl/ off 8443
- if relative_path.startswith(LAYOUTTEST_HTTP_DIR):
- relative_path = relative_path[len(LAYOUTTEST_HTTP_DIR):]
- port = 8000
- # pending/http/tests/ run off port 9000 and ssl/ off 9443
- elif relative_path.startswith(PENDING_HTTP_DIR):
- relative_path = relative_path[len(PENDING_HTTP_DIR):]
- port = 9000
- # chrome/http/tests run off of port 8081 with the full path
- elif relative_path.find("/http/") >= 0:
- port = 8081
-
- if port:
- if relative_path.startswith("ssl/"):
- port += 443
- protocol = "https"
- else:
- protocol = "http"
- return "%s://127.0.0.1:%u/%s" % (protocol, port, relative_path)
- else:
- return "file:///" + GetAbsolutePath(full_path)
+def TestListPlatformDir():
+ return GetPlatformUtil().TestListPlatformDir()
-def GetAbsolutePath(path):
- """Returns an absolute UNIX path."""
- return _WinPathToUnix(os.path.abspath(path))
-
-def MaybeMakeDirectory(*path):
- """Creates the specified directory if it doesn't already exist."""
- # This is a reimplementation of google.path_utils.MaybeMakeDirectory().
- try:
- os.makedirs(os.path.join(*path))
- except OSError, e:
- if e.errno != errno.EEXIST:
- raise
-
-def PathFromBase(*comps):
- """Returns an absolute filename from a set of components specified
- relative to the top of the source tree. If the path does not exist,
- the exception PathNotFound is raised."""
- # This is a reimplementation of google.path_utils.PathFromBase().
- global _basedir
- if _basedir == None:
- # We compute the top of the source tree by finding the absolute
- # path of this source file, and then climbing up three directories
- # as given in subpath. If we move this file, subpath needs to be updated.
- path = os.path.abspath(__file__)
- subpath = os.path.join('webkit','tools','layout_tests')
- _basedir = path[:path.index(subpath)]
- path = os.path.join(_basedir, *comps)
- if not os.path.exists(path):
- raise PathNotFound('could not find %s' % (path))
- return path
-
-
-#
-# Wrappers around platform_utils
-#
-
-def PlatformName(platform=None):
- """Returns the appropriate chromium platform name for |platform|. If
- |platform| is None, returns the name of the chromium platform on the
- currently running system. If |platform| is of the form 'chromium-*',
- it is returned unchanged, otherwise 'chromium-' is prepended."""
- if platform == None:
- return platform_utils.PlatformName()
- if not platform.startswith('chromium-'):
- platform = "chromium-" + platform
- return platform
-
-def PlatformVersion():
- return platform_utils.PlatformVersion()
-
-def LigHTTPdExecutablePath():
- return platform_utils.LigHTTPdExecutablePath()
-
-def LigHTTPdModulePath():
- return platform_utils.LigHTTPdModulePath()
-
-def LigHTTPdPHPPath():
- return platform_utils.LigHTTPdPHPPath()
-
-def WDiffPath():
- return platform_utils.WDiffPath()
-
-def TestShellPath(target):
- return platform_utils.TestShellPath(target)
-
-def ImageDiffPath(target):
- return platform_utils.ImageDiffPath(target)
-
-def LayoutTestHelperPath(target):
- return platform_utils.LayoutTestHelperPath(target)
-
-def FuzzyMatchPath():
- return platform_utils.FuzzyMatchPath()
-
-def ShutDownHTTPServer(server_process):
- return platform_utils.ShutDownHTTPServer(server_process)
+def PlatformDir():
+ return GetPlatformUtil().PlatformDir()
+
+def PlatformNewResultsDir():
+ return GetPlatformUtil().PlatformNewResultsDir()
diff --git a/webkit/tools/layout_tests/layout_package/platform_utils.py b/webkit/tools/layout_tests/layout_package/platform_utils.py
index 2b6755b..bd12455 100644
--- a/webkit/tools/layout_tests/layout_package/platform_utils.py
+++ b/webkit/tools/layout_tests/layout_package/platform_utils.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,8 +8,6 @@ Any functions whose implementations or values differ from one platform to
another should be defined in their respective platform_utils_<platform>.py
modules. The appropriate one of those will be imported into this module to
provide callers with a common, platform-independent interface.
-
-This file should only ever be imported by layout_package.path_utils.
"""
import sys
diff --git a/webkit/tools/layout_tests/layout_package/platform_utils_linux.py b/webkit/tools/layout_tests/layout_package/platform_utils_linux.py
index 61267f8..c68b87d 100644
--- a/webkit/tools/layout_tests/layout_package/platform_utils_linux.py
+++ b/webkit/tools/layout_tests/layout_package/platform_utils_linux.py
@@ -1,138 +1,239 @@
-# Copyright (c) 2008-2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""This is the Linux implementation of the layout_package.platform_utils
- package. This file should only be imported by that package."""
+"""Platform-specific utility methods shared by several scripts."""
import os
+import re
import signal
import subprocess
import sys
import logging
-import path_utils
-
-def PlatformName():
- """Returns the name of the platform we're currently running on."""
- return 'chromium-linux' + PlatformVersion()
-
-def PlatformVersion():
- """Returns the version string for the platform, e.g. '-vista' or
- '-snowleopard'. If the platform does not distinguish between
- minor versions, it returns ''."""
- return ''
-
-def BaselineSearchPath():
- """Returns the list of directories to search for baselines/results, in
- order of preference. Paths are relative to the top of the source tree."""
- return [path_utils.ChromiumBaselinePath(PlatformName()),
- path_utils.ChromiumBaselinePath('chromium-win'),
- path_utils.WebKitBaselinePath('win'),
- path_utils.WebKitBaselinePath('mac')]
-
-def LigHTTPdExecutablePath():
- """Returns the executable path to start LigHTTPd"""
- binpath = "/usr/sbin/lighttpd"
- if os.path.exists(binpath):
- return binpath
- print "Unable to find LigHTTPd executable %s" % binpath
- _MissingLigHTTPd()
-
-def LigHTTPdModulePath():
- """Returns the library module path for LigHTTPd"""
- modpath = "/usr/lib/lighttpd"
- if os.path.exists(modpath):
- return modpath
- print "Unable to find LigHTTPd modules %s" % modpath
- _MissingLigHTTPd()
-
-def LigHTTPdPHPPath():
- """Returns the PHP executable path for LigHTTPd"""
- binpath = "/usr/bin/php-cgi"
- if os.path.exists(binpath):
- return binpath
- print "Unable to find PHP CGI executable %s" % binpath
- _MissingLigHTTPd()
-
-def WDiffPath():
- """Path to the WDiff executable, which we assume is already installed and
- in the user's $PATH.
- """
- return 'wdiff'
-
-def ImageDiffPath(target):
- """Path to the image_diff binary.
-
- Args:
- target: Build target mode (debug or release)"""
- return _PathFromBuildResults(target, 'image_diff')
-
-def LayoutTestHelperPath(target):
- """Path to the layout_test helper binary, if needed, empty otherwise"""
- return ''
-
-def TestShellPath(target):
- """Return the platform-specific binary path for our TestShell.
-
- Args:
- target: Build target mode (debug or release) """
- if target in ('Debug', 'Release'):
- try:
- debug_path = _PathFromBuildResults('Debug', 'test_shell')
- release_path = _PathFromBuildResults('Release', 'test_shell')
-
- debug_mtime = os.stat(debug_path).st_mtime
- release_mtime = os.stat(release_path).st_mtime
-
- if debug_mtime > release_mtime and target == 'Release' or \
- release_mtime > debug_mtime and target == 'Debug':
- logging.info('\x1b[31mWarning: you are not running the most ' + \
- 'recent test_shell binary. You need to pass ' + \
- '--debug or not to select between Debug and ' + \
- 'Release.\x1b[0m')
- # This will fail if we don't have both a debug and release binary.
- # That's fine because, in this case, we must already be running the
- # most up-to-date one.
- except path_utils.PathNotFound:
- pass
+import google.path_utils
+
+# Distinguish the path_utils.py in this dir from google.path_utils.
+import path_utils as layout_package_path_utils
+
+# This will be a native path to the directory this file resides in.
+# It can either be relative or absolute depending how it's executed.
+THISDIR = os.path.dirname(os.path.abspath(__file__))
+def PathFromBase(*pathies):
+ return google.path_utils.FindUpward(THISDIR, *pathies)
- return _PathFromBuildResults(target, 'test_shell')
-
-def FuzzyMatchPath():
- """Return the path to the fuzzy matcher binary."""
- return path_utils.PathFromBase('third_party', 'fuzzymatch', 'fuzzymatch')
-
-def ShutDownHTTPServer(server_process):
- """Shut down the lighttpd web server. Blocks until it's fully shut down.
-
- Args:
- server_process: The subprocess object representing the running server
- """
- # server_process is not set when "http_server.py stop" is run manually.
- if server_process is None:
- # TODO(mmoss) This isn't ideal, since it could conflict with lighttpd
- # processes not started by http_server.py, but good enough for now.
- subprocess.call(['killall', '-u', os.getenv('USER'), '-TERM', 'lighttpd'])
- else:
- os.kill(server_process.pid, signal.SIGTERM)
-
-#
-# Private helper functions
-#
-
-def _MissingLigHTTPd():
- print 'Please install using: "sudo apt-get install lighttpd php5-cgi"'
- print 'For complete Linux build requirements, please see:'
- print 'http://code.google.com/p/chromium/wiki/LinuxBuildInstructions'
- sys.exit(1)
-
-def _PathFromBuildResults(*pathies):
+def PathFromBuildResults(*pathies):
# FIXME(dkegel): use latest or warn if more than one found?
for dir in ["sconsbuild", "out", "xcodebuild"]:
try:
- return path_utils.PathFromBase(dir, *pathies)
+ return google.path_utils.FindUpward(THISDIR, dir, *pathies)
except:
pass
- raise path_utils.PathNotFound("Unable to find %s in build tree" %
- (os.path.join(*pathies)))
+ raise google.path_utils.PathNotFound("Unable to find %s under any ancestor of %s" % (os.path.join(*pathies), THISDIR))
+
+def IsNonWindowsPlatformTargettingWindowsResults():
+ """Returns true iff this platform is targetting Windows baseline, but isn't
+ Windows. By default, in path_utils.py:ExpectedFilename, we expect platforms to
+ be targetting Mac."""
+ return True
+
+def GetTestListPlatformName():
+ """Returns the name we use to identify the platform in the layout test
+ test list files."""
+ return "LINUX"
+
+class PlatformUtility(object):
+ def __init__(self, base_dir):
+ """Args:
+ base_dir: a directory above which third_party/cygwin can be found,
+ used to locate the cygpath executable for path conversions.
+ """
+ LAYOUTTEST_HTTP_DIR = "LayoutTests/http/tests/"
+ PENDING_HTTP_DIR = "pending/http/tests/"
+
+ def GetAbsolutePath(self, path, force=False):
+ """Returns an absolute UNIX path."""
+ return os.path.abspath(path)
+
+ # TODO(mmoss): would be great to get rid of the duplication with
+ # platform_utils_win/mac.py for the next two functions, but inheritance
+ # from tools/python/google on the Windows side makes that a bit difficult.
+
+ def _FilenameToUri(self, path, use_http=False, use_ssl=False, port=8000):
+ """Convert a Windows style path to a URI.
+
+ Args:
+ path: For an http URI, the path relative to the httpd server's
+ DocumentRoot; for a file URI, the full path to the file.
+ use_http: if True, returns a URI of the form http://127.0.0.1:8000/.
+ If False, returns a file:/// URI.
+ use_ssl: if True, returns HTTPS URL (https://127.0.0.1:8000/).
+ This parameter is ignored if use_http=False.
+ port: The port number to append when returning an HTTP URI
+ """
+ if use_http:
+ protocol = 'http'
+ if use_ssl:
+ protocol = 'https'
+ path = path.replace("\\", "/")
+ return "%s://127.0.0.1:%s/%s" % (protocol, str(port), path)
+ return "file:///" + self.GetAbsolutePath(path)
+
+ def FilenameToUri(self, full_path):
+ relative_path = layout_package_path_utils.RelativeTestFilename(full_path)
+ port = None
+ use_ssl = False
+
+ # LayoutTests/http/tests/ run off port 8000 and ssl/ off 8443
+ if relative_path.startswith(self.LAYOUTTEST_HTTP_DIR):
+ relative_path = relative_path[len(self.LAYOUTTEST_HTTP_DIR):]
+ port = 8000
+ # pending/http/tests/ run off port 9000 and ssl/ off 9443
+ elif relative_path.startswith(self.PENDING_HTTP_DIR):
+ relative_path = relative_path[len(self.PENDING_HTTP_DIR):]
+ port = 9000
+ # chrome/http/tests run off of port 8081 with the full path
+ elif relative_path.find("/http/") >= 0:
+ print relative_path
+ port = 8081
+
+ # We want to run off of the http server
+ if port:
+ if relative_path.startswith("ssl/"):
+ port += 443
+ use_ssl = True
+ return PlatformUtility._FilenameToUri(self,
+ relative_path,
+ use_http=True,
+ use_ssl=use_ssl,
+ port=port)
+
+ # Run off file://
+ return PlatformUtility._FilenameToUri(self, full_path, use_http=False,
+ use_ssl=False, port=0)
+
+ def KillAllTestShells(self):
+ """Kills all instances of the test_shell binary currently running."""
+ subprocess.Popen(('killall', '-TERM', self.TestShellBinary()),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE).wait()
+
+ def MissingLigHTTPd(self):
+ print 'Please install using: "sudo apt-get install lighttpd php5-cgi"'
+ print 'For complete Linux build requirements, please see:'
+ print 'http://code.google.com/p/chromium/wiki/LinuxBuildInstructions'
+ sys.exit(1)
+
+ def LigHTTPdExecutablePath(self):
+ """Returns the executable path to start LigHTTPd"""
+ binpath = "/usr/sbin/lighttpd"
+ if os.path.exists(binpath):
+ return binpath
+ print "Unable to find LigHTTPd executable %s" % binpath
+ self.MissingLigHTTPd()
+
+ def LigHTTPdModulePath(self):
+ """Returns the library module path for LigHTTPd"""
+ modpath = "/usr/lib/lighttpd"
+ if os.path.exists(modpath):
+ return modpath
+ print "Unable to find LigHTTPd modules %s" % modpath
+ self.MissingLigHTTPd()
+
+ def LigHTTPdPHPPath(self):
+ """Returns the PHP executable path for LigHTTPd"""
+ binpath = "/usr/bin/php-cgi"
+ if os.path.exists(binpath):
+ return binpath
+ print "Unable to find PHP CGI executable %s" % binpath
+ self.MissingLigHTTPd()
+
+ def ShutDownHTTPServer(self, server_process):
+ """Shut down the lighttpd web server. Blocks until it's fully shut down.
+
+ Args:
+ server_process: The subprocess object representing the running server
+ """
+ # server_process is not set when "http_server.py stop" is run manually.
+ if server_process is None:
+ # TODO(mmoss) This isn't ideal, since it could conflict with lighttpd
+ # processes not started by http_server.py, but good enough for now.
+ subprocess.call(['killall', '-u', os.getenv('USER'), '-TERM', 'lighttpd'])
+ else:
+ os.kill(server_process.pid, signal.SIGTERM)
+
+ def WDiffExecutablePath(self):
+ """Path to the WDiff executable, which we assume is already installed and
+ in the user's $PATH.
+ """
+ return 'wdiff'
+
+ def ImageDiffBinary(self):
+ return 'image_diff'
+
+ def ImageDiffBinaryPath(self, target):
+ """Path to the image_diff binary."""
+ return PathFromBuildResults(target, self.ImageDiffBinary())
+
+ def LayoutTestHelperBinary(self):
+ """Path to the layout_test helper binary, if needed, empty otherwise"""
+ return ''
+
+ def LayoutTestHelperBinaryPath(self, target):
+ """Path to the layout_test helper binary, if needed, empty otherwise"""
+ return ''
+
+ def TestShellBinary(self):
+ """The name of the binary for TestShell."""
+ return 'test_shell'
+
+ def TestShellBinaryPath(self, target):
+ """Return the platform-specific binary path for our TestShell.
+
+ Args:
+ target: Build target mode (debug or release)
+ """
+
+ if target in ('Debug', 'Release'):
+ try:
+ debug_path = PathFromBuildResults('Debug', self.TestShellBinary())
+ release_path = PathFromBuildResults('Release', \
+ self.TestShellBinary())
+
+ debug_mtime = os.stat(debug_path).st_mtime
+ release_mtime = os.stat(release_path).st_mtime
+
+ if debug_mtime > release_mtime and target == 'Release' or \
+ release_mtime > debug_mtime and target == 'Debug':
+ logging.info('\x1b[31mWarning: you are not running the most ' + \
+ 'recent test_shell binary. You need to pass ' + \
+ '--debug or not to select between Debug and ' + \
+ 'Release.\x1b[0m')
+ # This will fail if we don't have both a debug and release binary.
+ # That's fine because, in this case, we must already be running the
+ # most up-to-date one.
+ except OSError:
+ pass
+ except google.path_utils.PathNotFound:
+ pass
+
+ return PathFromBuildResults(target, self.TestShellBinary())
+
+ def FuzzyMatchBinaryPath(self):
+ """Return the path to the fuzzy matcher binary."""
+ return PathFromBase('third_party', 'fuzzymatch', 'fuzzymatch')
+
+ def TestListPlatformDir(self):
+ """Return the platform-specific directory for where the test lists live"""
+ return 'linux'
+
+ def PlatformDir(self):
+ """Returns the most specific directory name where platform-specific
+ results live.
+ """
+ return 'chromium-linux'
+
+ def PlatformNewResultsDir(self):
+ """Returns the directory name in which to output newly baselined tests.
+ """
+ return self.PlatformDir()
diff --git a/webkit/tools/layout_tests/layout_package/platform_utils_mac.py b/webkit/tools/layout_tests/layout_package/platform_utils_mac.py
index 5c3eb3d..4b6c832 100644
--- a/webkit/tools/layout_tests/layout_package/platform_utils_mac.py
+++ b/webkit/tools/layout_tests/layout_package/platform_utils_mac.py
@@ -1,97 +1,208 @@
-# Copyright (c) 2008-2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""This is the Mac implementation of the layout_package.platform_utils
- package. This file should only be imported by that package."""
+"""Platform-specific utility methods shared by several scripts."""
import os
import platform
+import re
import signal
import subprocess
+import sys
-import path_utils
+import google.path_utils
-def PlatformName():
- """Returns the name of the platform we're currently running on."""
- # At the moment all chromium mac results are version-independent. At some
- # point we may need to return 'chromium-mac' + PlatformVersion()
- return 'chromium-mac'
+# Distinguish the path_utils.py in this dir from google.path_utils.
+import path_utils as layout_package_path_utils
-def PlatformVersion():
- """Returns the version string for the platform, e.g. '-vista' or
- '-snowleopard'. If the platform does not distinguish between
- minor versions, it returns ''."""
+# This will be a native path to the directory this file resides in.
+# It can either be relative or absolute depending how it's executed.
+THISDIR = os.path.dirname(os.path.abspath(__file__))
+def PathFromBase(*pathies):
+ return google.path_utils.FindUpward(THISDIR, *pathies)
+
+def IsNonWindowsPlatformTargettingWindowsResults():
+ """Returns true iff this platform is targetting Windows baseline, but isn't
+ Windows. By default, in path_utils.py:ExpectedFilename, we expect platforms to
+ be targetting Mac."""
+ return False
+
+def GetTestListPlatformName():
+ """Returns the name we use to identify the platform in the layout test
+ test list files."""
+ return "MAC"
+
+def _HumanReadableSystemVersionName():
+ """ Returns the name of this OS X system version, or an empty string if this
+ is an unknown OS version.
+
+ Note: Chrome doesn't support Tiger, so the minimum version returned is
+ Leopard (10.5).
+ """
os_version_string = platform.mac_ver()[0] # e.g. "10.5.6"
release_version = int(os_version_string.split('.')[1])
-
- # we don't support 'tiger' or earlier releases
if release_version == 5:
- return '-leopard'
+ return 'leopard'
elif release_version == 6:
- return '-snowleopard'
- return ''
+ return 'snowleopard'
+ else:
+ return ''
-def BaselineSearchPath():
- """Returns the list of directories to search for baselines/results, in
- order of preference. Paths are relative to the top of the source tree."""
- return [path_utils.ChromiumBaselinePath(PlatformName()),
- path_utils.WebKitBaselinePath('mac' + PlatformVersion()),
- path_utils.WebKitBaselinePath('mac')]
+class PlatformUtility(object):
+ def __init__(self, base_dir):
+ """Args:
+ base_dir: a directory above which third_party/cygwin can be found,
+ used to locate the cygpath executable for path conversions.
+ """
+ self._cygwin_root = None
+ self._base_dir = base_dir
-def WDiffPath():
- """Path to the WDiff executable, which we assume is already installed and
- in the user's $PATH."""
- return 'wdiff'
+ LAYOUTTEST_HTTP_DIR = "LayoutTests/http/tests/"
+ PENDING_HTTP_DIR = "pending/http/tests/"
-def ImageDiffPath(target):
- """Path to the image_diff executable
+ def GetAbsolutePath(self, path, force=False):
+ """Returns an absolute UNIX path."""
+ return os.path.abspath(path)
- Args:
- target: build type - 'Debug','Release',etc."""
- return path_utils.PathFromBase('xcodebuild', target, 'image_diff')
+ # TODO(pinkerton): would be great to get rid of the duplication with
+ # platform_utils_win.py for the next two functions, but the inheritance
+ # from tools/python/google on the windows side makes that a bit difficult.
-def LayoutTestHelperPath(target):
- """Path to the layout_test_helper executable, if needed, empty otherwise
+ def _FilenameToUri(self, path, use_http=False, use_ssl=False, port=8000):
+ """Convert a Windows style path to a URI.
- Args:
- target: build type - 'Debug','Release',etc."""
- return path_utils.PathFromBase('xcodebuild', target, 'layout_test_helper')
+ Args:
+ path: For an http URI, the path relative to the httpd server's
+ DocumentRoot; for a file URI, the full path to the file.
+ use_http: if True, returns a URI of the form http://127.0.0.1:8000/.
+ If False, returns a file:/// URI.
+ use_ssl: if True, returns HTTPS URL (https://127.0.0.1:8000/).
+ This parameter is ignored if use_http=False.
+ port: The port number to append when returning an HTTP URI
+ """
+ if use_http:
+ protocol = 'http'
+ if use_ssl:
+ protocol = 'https'
+ path = path.replace("\\", "/")
+ return "%s://127.0.0.1:%s/%s" % (protocol, str(port), path)
+ return "file:///" + self.GetAbsolutePath(path)
+
+ def FilenameToUri(self, full_path):
+ relative_path = layout_package_path_utils.RelativeTestFilename(full_path)
+ port = None
+ use_ssl = False
+
+ # LayoutTests/http/tests/ run off port 8000 and ssl/ off 8443
+ if relative_path.startswith(self.LAYOUTTEST_HTTP_DIR):
+ relative_path = relative_path[len(self.LAYOUTTEST_HTTP_DIR):]
+ port = 8000
+ # pending/http/tests/ run off port 9000 and ssl/ off 9443
+ elif relative_path.startswith(self.PENDING_HTTP_DIR):
+ relative_path = relative_path[len(self.PENDING_HTTP_DIR):]
+ port = 9000
+ # chrome/http/tests run off of port 8081 with the full path
+ elif relative_path.find("/http/") >= 0:
+ print relative_path
+ port = 8081
+
+ # We want to run off of the http server
+ if port:
+ if relative_path.startswith("ssl/"):
+ port += 443
+ use_ssl = True
+ return PlatformUtility._FilenameToUri(self,
+ relative_path,
+ use_http=True,
+ use_ssl=use_ssl,
+ port=port)
+
+ # Run off file://
+ return PlatformUtility._FilenameToUri(self, full_path, use_http=False,
+ use_ssl=False, port=0)
+
+ def LigHTTPdExecutablePath(self):
+ """Returns the executable path to start LigHTTPd"""
+ return PathFromBase('third_party', 'lighttpd', 'mac', 'bin', 'lighttpd')
+
+ def LigHTTPdModulePath(self):
+ """Returns the library module path for LigHTTPd"""
+ return PathFromBase('third_party', 'lighttpd', 'mac', 'lib')
+
+ def LigHTTPdPHPPath(self):
+ """Returns the PHP executable path for LigHTTPd"""
+ return PathFromBase('third_party', 'lighttpd', 'mac', 'bin', 'php-cgi')
+
+ def ShutDownHTTPServer(self, server_process):
+ """Shut down the lighttpd web server. Blocks until it's fully shut down.
-def TestShellPath(target):
- """Path to the test_shell executable.
+ Args:
+ server_process: The subprocess object representing the running server
+ """
+ # server_process is not set when "http_server.py stop" is run manually.
+ if server_process is None:
+ # TODO(mmoss) This isn't ideal, since it could conflict with lighttpd
+ # processes not started by http_server.py, but good enough for now.
+ subprocess.call(['killall', '-u', os.getenv('USER'), '-TERM', 'lighttpd'])
+ else:
+ os.kill(server_process.pid, signal.SIGTERM)
+
+ def WDiffExecutablePath(self):
+ """Path to the WDiff executable, which we assume is already installed and
+ in the user's $PATH.
+ """
+ return 'wdiff'
+
+ def ImageDiffBinary(self):
+ """The name of the binary for image_diff."""
+ return 'image_diff'
+
+ def ImageDiffBinaryPath(self, target):
+ """Return the platform-specific binary path for our image compare util.
- Args:
- target: build type - 'Debug','Release',etc."""
- # TODO(pinkerton): make |target| happy with case-sensitive file systems.
- return path_utils.PathFromBase('xcodebuild', target, 'TestShell.app',
- 'Contents', 'MacOS','TestShell')
+ Args:
+ target: Build target mode (debug or release)
+ """
+ return PathFromBase('xcodebuild', target, self.ImageDiffBinary())
-def LigHTTPdExecutablePath():
- """Returns the executable path to start LigHTTPd"""
- return path_utils.PathFromBase('third_party', 'lighttpd', 'mac',
- 'bin', 'lighttpd')
+ def LayoutTestHelperBinary(self):
+ """name of the layout_test helper binary, if needed, empty otherwise"""
+ return 'layout_test_helper'
-def LigHTTPdModulePath():
- """Returns the library module path for LigHTTPd"""
- return path_utils.PathFromBase('third_party', 'lighttpd', 'mac', 'lib')
+ def LayoutTestHelperBinaryPath(self, target):
+ """Path to the layout_test helper binary, if needed, empty otherwise"""
+ return PathFromBase('xcodebuild', target, self.LayoutTestHelperBinary())
-def LigHTTPdPHPPath():
- """Returns the PHP executable path for LigHTTPd"""
- return path_utils.PathFromBase('third_party', 'lighttpd', 'mac', 'bin',
- 'php-cgi')
+ def TestShellBinary(self):
+ """The name of the binary for TestShell."""
+ return 'TestShell'
-def ShutDownHTTPServer(server_process):
- """Shut down the lighttpd web server. Blocks until it's fully shut down.
+ def TestShellBinaryPath(self, target):
+ """Return the platform-specific binary path for our TestShell.
Args:
- server_process: The subprocess object representing the running server
- """
- # server_process is not set when "http_server.py stop" is run manually.
- if server_process is None:
- # TODO(mmoss) This isn't ideal, since it could conflict with lighttpd
- # processes not started by http_server.py, but good enough for now.
- subprocess.call(['killall', '-u', os.getenv('USER'), '-TERM', 'lighttpd'])
- else:
- os.kill(server_process.pid, signal.SIGTERM)
-
+ target: Build target mode (debug or release)
+ """
+ # TODO(pinkerton): make |target| happy with case-sensitive file systems.
+ return PathFromBase('xcodebuild', target, 'TestShell.app',
+ 'Contents', 'MacOS', self.TestShellBinary())
+
+ def TestListPlatformDir(self):
+ """Return the platform-specific directory for where the test lists live."""
+ return 'mac'
+
+ def PlatformDir(self):
+ """Returns the most specific directory name where platform-specific
+ results live.
+ """
+ platform_dir = 'chromium-mac'
+ os_name = _HumanReadableSystemVersionName()
+ if len(os_name) > 0:
+ platform_dir += "-" + os_name
+ return platform_dir
+
+ def PlatformNewResultsDir(self):
+ """Returns the directory name in which to output newly baselined tests.
+ """
+ return 'chromium-mac'
diff --git a/webkit/tools/layout_tests/layout_package/platform_utils_win.py b/webkit/tools/layout_tests/layout_package/platform_utils_win.py
index 3c8a1ae..9075854 100644
--- a/webkit/tools/layout_tests/layout_package/platform_utils_win.py
+++ b/webkit/tools/layout_tests/layout_package/platform_utils_win.py
@@ -1,106 +1,249 @@
-# Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""This is the Linux implementation of the layout_package.platform_utils
- package. This file should only be imported by that package."""
+"""Platform specific utility methods. This file contains methods that are
+specific to running the layout tests on windows.
-import path_utils
+This file constitutes a complete wrapper for google.platform_utils_win,
+implementing or mapping all needed functions from there. Layout-test scripts
+should be able to import only this file (via platform_utils.py), with no need
+to fall back to the base functions.
+"""
+
+import os
+import re
import subprocess
import sys
-def PlatformName():
- """Returns the name of the platform we're currently running on."""
- return 'chromium-win' + PlatformVersion()
-
-def PlatformVersion():
- """Returns the version string for the platform, e.g. '-vista' or
- '-snowleopard'. If the platform does not distinguish between
- minor versions, it returns ''."""
- winver = sys.getwindowsversion()
- if winver[0] == 6 and winver[1] == 0:
- return '-vista'
- elif winver[0] == 5 and (winver[1] == 1 or winver[1] == 2):
- return '-xp'
- return ''
-
-def BaselineSearchPath():
- """Returns the list of directories to search for baselines/results, in
- order of preference. Paths are relative to the top of the source tree."""
- return [path_utils.ChromiumBaselinePath(PlatformName()),
- path_utils.ChromiumBaselinePath('chromium-win'),
- path_utils.WebKitBaselinePath('win'),
- path_utils.WebKitBaselinePath('mac')]
-
-def WDiffPath():
- """Path to the WDiff executable, whose binary is checked in on Win"""
- return path_utils.PathFromBase('third_party', 'cygwin', 'bin', 'wdiff.exe')
-
-def ImageDiffPath(target):
- """Return the platform-specific binary path for the image compare util.
+import google.httpd_utils
+import google.path_utils
+import google.platform_utils_win
+
+# Distinguish the path_utils.py in this dir from google.path_utils.
+import path_utils as layout_package_path_utils
+
+# This will be a native path to the directory this file resides in.
+# It can either be relative or absolute depending how it's executed.
+THISDIR = os.path.dirname(os.path.abspath(__file__))
+def PathFromBase(*pathies):
+ return google.path_utils.FindUpward(THISDIR, *pathies)
+
+def IsNonWindowsPlatformTargettingWindowsResults():
+ """Returns true iff this platform is targetting Windows baseline, but isn't
+ Windows. By default, in path_utils.py:ExpectedFilename, we expect platforms to
+ be targetting Mac."""
+ return False
+
+def GetTestListPlatformName():
+ """Returns the name we use to identify the platform in the layout test
+ test list files."""
+ #winver = sys.getwindowsversion()
+ #if winver[0] == 6 and winver[1] == 0:
+ # return "WIN-VISTA"
+ #elif winver[0] == 5 and (winver[1] == 1 or winver[1] == 2):
+ # return "WIN-XP"
+ #default to returning 'WIN' if it's an unsupported version
+ return "WIN"
+
+class PlatformUtility(google.platform_utils_win.PlatformUtility):
+ """Overrides base PlatformUtility methods as needed for layout tests."""
+
+ LAYOUTTEST_HTTP_DIR = "LayoutTests/http/tests/"
+ PENDING_HTTP_DIR = "pending/http/tests/"
+
+ def FilenameToUri(self, full_path):
+ relative_path = layout_package_path_utils.RelativeTestFilename(full_path)
+ port = None
+ use_ssl = False
+
+ # LayoutTests/http/tests/ run off port 8000 and ssl/ off 8443
+ if relative_path.startswith(self.LAYOUTTEST_HTTP_DIR):
+ relative_path = relative_path[len(self.LAYOUTTEST_HTTP_DIR):]
+ port = 8000
+ # pending/http/tests/ run off port 9000 and ssl/ off 9443
+ elif relative_path.startswith(self.PENDING_HTTP_DIR):
+ relative_path = relative_path[len(self.PENDING_HTTP_DIR):]
+ port = 9000
+ # chrome/http/tests run off of port 8081 with the full path
+ elif relative_path.find("/http/") >= 0:
+ print relative_path
+ port = 8081
+
+ # We want to run off of the http server
+ if port:
+ if relative_path.startswith("ssl/"):
+ port += 443
+ use_ssl = True
+ return google.platform_utils_win.PlatformUtility.FilenameToUri(self,
+ relative_path,
+ use_http=True,
+ use_ssl=use_ssl,
+ port=port)
+
+ # Run off file://
+ return google.platform_utils_win.PlatformUtility.FilenameToUri(
+ self, full_path)
+
+ def KillAllTestShells(self):
+ """Kills all instances of the test_shell binary currently running."""
+ subprocess.Popen(['taskkill.exe', '/f', '/im', self.TestShellBinary()],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE).wait()
+
+ def _GetVirtualHostConfig(self, document_root, port, ssl=False):
+ """Returns a <VirtualHost> directive block for an httpd.conf file. It will
+ listen to 127.0.0.1 on each of the given port.
+ """
+ cygwin_document_root = google.platform_utils_win.GetCygwinPath(
+ document_root)
+
+ return '\n'.join(('<VirtualHost 127.0.0.1:%s>' % port,
+ 'DocumentRoot %s' % cygwin_document_root,
+ ssl and 'SSLEngine On' or '',
+ '</VirtualHost>', ''))
+
+ def GetStartHttpdCommand(self, output_dir, apache2=False):
+ """Prepares the config file and output directory to start an httpd server.
+ Returns a list of strings containing the server's command line+args.
+
+ Creates the test output directory and generates an httpd.conf (or
+ httpd2.conf for Apache 2 if apache2 is True) file in it that contains
+ the necessary <VirtualHost> directives for running all the http tests.
+
+ WebKit http tests expect the DocumentRoot to be in LayoutTests/http/tests/,
+ but that prevents us from running http tests in chrome/ or pending/. So we
+ run two virtual hosts, one on ports 8000 and 8080 for WebKit, and one on
+ port 8081 with a much broader DocumentRoot for everything else. (Note that
+ WebKit http tests that have been modified and are temporarily in pending/
+ will still fail, if they expect the DocumentRoot to be located as described
+ above.)
+
+ Args:
+ output_dir: the path to the test output directory. It will be created.
+ apache2: boolean if true will cause this function to return start
+ command for Apache 2.x instead of Apache 1.3.x
+ """
+ layout_dir = google.platform_utils_win.GetCygwinPath(
+ layout_package_path_utils.LayoutTestsDir())
+ main_document_root = os.path.join(layout_dir, "LayoutTests",
+ "http", "tests")
+ pending_document_root = os.path.join(layout_dir, "pending",
+ "http", "tests")
+ chrome_document_root = layout_dir
+ apache_config_dir = google.httpd_utils.ApacheConfigDir(self._base_dir)
+ mime_types_path = os.path.join(apache_config_dir, "mime.types")
+
+ conf_file_name = "httpd.conf"
+ if apache2:
+ conf_file_name = "httpd2.conf"
+ # Make the test output directory and place the generated httpd.conf in it.
+ orig_httpd_conf_path = os.path.join(apache_config_dir, conf_file_name)
+
+ httpd_conf_path = os.path.join(output_dir, conf_file_name)
+ google.path_utils.MaybeMakeDirectory(output_dir)
+ httpd_conf = open(orig_httpd_conf_path).read()
+ httpd_conf = (httpd_conf +
+ self._GetVirtualHostConfig(main_document_root, 8000) +
+ self._GetVirtualHostConfig(main_document_root, 8080) +
+ self._GetVirtualHostConfig(pending_document_root, 9000) +
+ self._GetVirtualHostConfig(pending_document_root, 9080) +
+ self._GetVirtualHostConfig(chrome_document_root, 8081))
+ if apache2:
+ httpd_conf += self._GetVirtualHostConfig(main_document_root, 8443,
+ ssl=True)
+ httpd_conf += self._GetVirtualHostConfig(pending_document_root, 9443,
+ ssl=True)
+ f = open(httpd_conf_path, 'wb')
+ f.write(httpd_conf)
+ f.close()
+
+ return google.platform_utils_win.PlatformUtility.GetStartHttpdCommand(
+ self,
+ output_dir,
+ httpd_conf_path,
+ mime_types_path,
+ apache2=apache2)
+
+ def LigHTTPdExecutablePath(self):
+ """Returns the executable path to start LigHTTPd"""
+ return PathFromBase('third_party', 'lighttpd', 'win', 'LightTPD.exe')
+
+ def LigHTTPdModulePath(self):
+ """Returns the library module path for LigHTTPd"""
+ return PathFromBase('third_party', 'lighttpd', 'win', 'lib')
+
+ def LigHTTPdPHPPath(self):
+ """Returns the PHP executable path for LigHTTPd"""
+ return PathFromBase('third_party', 'lighttpd', 'win', 'php5', 'php-cgi.exe')
+
+ def ShutDownHTTPServer(self, server_process):
+ """Shut down the lighttpd web server. Blocks until it's fully shut down.
+
+ Args:
+ server_process: The subprocess object representing the running server.
+ Unused in this implementation of the method.
+ """
+ subprocess.Popen(('taskkill.exe', '/f', '/im', 'LightTPD.exe'),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE).wait()
+
+ def WDiffExecutablePath(self):
+ """Path to the WDiff executable, whose binary is checked in on Win"""
+ return PathFromBase('third_party', 'cygwin', 'bin', 'wdiff.exe')
+
+ def ImageDiffBinary(self):
+ return 'image_diff.exe'
+
+ def ImageDiffBinaryPath(self, target):
+ """Return the platform-specific binary path for the image compare util.
+ We use this if we can't find the binary in the default location
+ in path_utils.
+
+ Args:
+ target: Build target mode (debug or release)
+ """
+ return PathFromBase('chrome', target, self.ImageDiffBinary())
+
+ def LayoutTestHelperBinary(self):
+ """name of the layout test helper binary, if needed, empty otherwise"""
+ return 'layout_test_helper.exe'
+
+ def LayoutTestHelperBinaryPath(self, target):
+ """Return the platform-specific binary path for the layout test helper.
+ We use this if we can't find the binary in the default location
+ in path_utils.
+
+ Args:
+ target: Build target mode (debug or release)
+ """
+ return PathFromBase('chrome', target, self.LayoutTestHelperBinary())
+
+ def TestShellBinary(self):
+ """The name of the binary for TestShell."""
+ return 'test_shell.exe'
+
+ def TestShellBinaryPath(self, target):
+ """Return the platform-specific binary path for our TestShell.
We use this if we can't find the binary in the default location
in path_utils.
- Args:
- target: Build target mode (debug or release)
- """
- return _FindBinary(target, 'image_diff.exe')
-
-def LayoutTestHelperPath(target):
- """Return the platform-specific binary path for the layout test helper.
- We use this if we can't find the binary in the default location
- in path_utils.
-
- Args:
- target: Build target mode (debug or release)
- """
- return _FindBinary(target, 'layout_test_helper.exe')
-
-def TestShellPath(target):
- """Return the platform-specific binary path for our TestShell.
- We use this if we can't find the binary in the default location
- in path_utils.
-
- Args:
- target: Build target mode (debug or release)
- """
- return _FindBinary(target, 'test_shell.exe')
-
-def LigHTTPdExecutablePath():
- """Returns the executable path to start LigHTTPd"""
- return path_utils.PathFromBase('third_party', 'lighttpd', 'win',
- 'LightTPD.exe')
-
-def LigHTTPdModulePath():
- """Returns the library module path for LigHTTPd"""
- return path_utils.PathFromBase('third_party', 'lighttpd', 'win', 'lib')
-
-def LigHTTPdPHPPath():
- """Returns the PHP executable path for LigHTTPd"""
- return path_utils.PathFromBase('third_party', 'lighttpd', 'win', 'php5',
- 'php-cgi.exe')
-
-def ShutDownHTTPServer(server_process):
- """Shut down the lighttpd web server. Blocks until it's fully shut down.
-
- Args:
- server_process: The subprocess object representing the running server.
- Unused in this implementation of the method.
- """
- subprocess.Popen(('taskkill.exe', '/f', '/im', 'LightTPD.exe'),
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE).wait()
-
-#
-# Private helper functions.
-#
-
-def _FindBinary(target, binary):
- """On Windows, we look for binaries that we compile in potentially
- two places: src/webkit/$target (preferably, which we get if we
- built using webkit.gyp), or src/chrome/$target (if compiled some other
- way)."""
- try:
- return path_utils.PathFromBase('webkit', target, binary)
- except path_utils.PathNotFound:
- return path_utils.PathFromBase('chrome', target, binary)
+ Args:
+ target: Build target mode (debug or release)
+ """
+ return PathFromBase('chrome', target, self.TestShellBinary())
+
+ def TestListPlatformDir(self):
+ """Return the platform-specific directory for where the test lists live."""
+ return GetTestListPlatformName().lower()
+
+ def PlatformDir(self):
+ """Returns the most specific directory name where platform-specific
+ results live.
+ """
+ return 'chromium-' + GetTestListPlatformName().lower()
+
+ def PlatformNewResultsDir(self):
+ """Returns the directory name in which to output newly baselined tests.
+ """
+ return self.PlatformDir()
diff --git a/webkit/tools/layout_tests/layout_package/test_expectations.py b/webkit/tools/layout_tests/layout_package/test_expectations.py
index f6831fb..fa12894 100644
--- a/webkit/tools/layout_tests/layout_package/test_expectations.py
+++ b/webkit/tools/layout_tests/layout_package/test_expectations.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -223,9 +223,7 @@ class TestExpectationsFile:
self._full_test_list = full_test_list
self._errors = []
self._non_fatal_errors = []
- self._platform = self.ToTestPlatformName(platform)
- if self._platform is None:
- raise Exception("Unknown platform '%s'" % (platform))
+ self._platform = platform
self._is_debug_mode = is_debug_mode
# Maps relative test paths as listed in the expectations file to a list of
@@ -251,17 +249,6 @@ class TestExpectationsFile:
self._Read(path)
- def ToTestPlatformName(self, name):
- """Returns the test expectation platform that will be used for a
- given platform name, or None if there is no match."""
- chromium_prefix = 'chromium-'
- name = name.lower()
- if name.startswith(chromium_prefix):
- name = name[len(chromium_prefix):]
- if name in self.PLATFORMS:
- return name
- return None
-
def GetTestSet(self, modifier, expectation=None, include_skips=True):
if expectation is None:
tests = self._modifier_to_tests[modifier]
diff --git a/webkit/tools/layout_tests/layout_package/test_failures.py b/webkit/tools/layout_tests/layout_package/test_failures.py
index 831aa3d..3433fc2 100644
--- a/webkit/tools/layout_tests/layout_package/test_failures.py
+++ b/webkit/tools/layout_tests/layout_package/test_failures.py
@@ -1,9 +1,11 @@
-# Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Classes for failures that occur during tests."""
+import path_utils
+
class FailureSort(object):
"""A repository for failure sort orders and tool to facilitate sorting."""
diff --git a/webkit/tools/layout_tests/layout_package/test_shell_thread.py b/webkit/tools/layout_tests/layout_package/test_shell_thread.py
index 13e5d1a..a368137 100644
--- a/webkit/tools/layout_tests/layout_package/test_shell_thread.py
+++ b/webkit/tools/layout_tests/layout_package/test_shell_thread.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -22,6 +22,7 @@ import threading
import time
import path_utils
+import platform_utils
import test_failures
def ProcessOutput(proc, test_info, test_types, test_args, target):
@@ -332,7 +333,9 @@ class TestShellThread(threading.Thread):
# introducing spurious crashes. We accept that tradeoff in order to
# avoid losing the rest of this thread's results.
logging.error('Test thread hung: killing all test_shells')
- path_utils.KillAllTestShells()
+ # PlatformUtility() wants a base_dir, but it doesn't matter here.
+ platform_util = platform_utils.PlatformUtility('')
+ platform_util.KillAllTestShells()
try:
stats = worker.GetTestStats()
diff --git a/webkit/tools/layout_tests/rebaseline.py b/webkit/tools/layout_tests/rebaseline.py
index f49c072..2261933 100644
--- a/webkit/tools/layout_tests/rebaseline.py
+++ b/webkit/tools/layout_tests/rebaseline.py
@@ -30,7 +30,12 @@ import urllib
import webbrowser
import zipfile
+import google.path_utils
+
from layout_package import path_utils
+from layout_package import platform_utils_linux
+from layout_package import platform_utils_mac
+from layout_package import platform_utils_win
from layout_package import test_expectations
BASELINE_SUFFIXES = ['.txt', '.png', '.checksum']
@@ -289,6 +294,18 @@ class Rebaseliner(object):
logging.info('Archive downloaded and saved to file: "%s"', fn)
return fn
+ def _GetPlatformNewResultsDir(self):
+ """Get the dir name to extract new baselines for the given platform."""
+
+ if self._platform == 'win':
+ return platform_utils_win.PlatformUtility(None).PlatformNewResultsDir()
+ elif self._platform == 'mac':
+ return platform_utils_mac.PlatformUtility(None).PlatformNewResultsDir()
+ elif self._platform == 'linux':
+ return platform_utils_linux.PlatformUtility(None).PlatformNewResultsDir()
+
+ return None
+
def _ExtractAndAddNewBaselines(self, archive_file):
"""Extract new baselines from archive and add them to SVN repository.
@@ -307,8 +324,13 @@ class Rebaseliner(object):
for name in zip_namelist:
logging.debug(' ' + name)
- platform = path_utils.PlatformName(self._platform)
- logging.debug('Platform dir: "%s"', platform)
+ platform_dir = self._GetPlatformNewResultsDir()
+ if not platform_dir:
+ logging.error('Invalid platform new results dir, platform: "%s"',
+ self._platform)
+ return None
+
+ logging.debug('Platform new results dir: "%s"', platform_dir)
test_no = 1
self._rebaselined_tests = []
@@ -332,14 +354,16 @@ class Rebaseliner(object):
expected_filename = '%s-expected%s' % (test_basename, suffix)
expected_fullpath = os.path.join(
- path_utils.ChromiumBaselinePath(platform), expected_filename)
+ path_utils.ChromiumPlatformResultsEnclosingDir(),
+ platform_dir,
+ expected_filename)
expected_fullpath = os.path.normpath(expected_fullpath)
logging.debug(' Expected file full path: "%s"', expected_fullpath)
data = zip_file.read(archive_test_name)
# Create the new baseline directory if it doesn't already exist.
- path_utils.MaybeMakeDirectory(os.path.dirname(expected_fullpath))
+ google.path_utils.MaybeMakeDirectory(os.path.dirname(expected_fullpath))
f = open(expected_fullpath, 'wb')
f.write(data)
@@ -764,11 +788,6 @@ def main():
logging.error('Invalid "platforms" option. --platforms must be specified '
'in order to rebaseline.')
sys.exit(1)
- platforms = [p.strip().lower() for p in options.platforms.split(',')]
- for platform in platforms:
- if not TestExpectationsFile.ToTestPlatformName(platform):
- logging.error('Invalid platform platform: "%s"' % (platform))
- sys.exit(1)
if not options.no_html_results:
options.html_directory = SetupHtmlDirectory(options.html_directory,
@@ -776,6 +795,7 @@ def main():
rebaselining_tests = set()
backup = options.backup
+ platforms = [p.strip().lower() for p in options.platforms.split(',')]
for platform in platforms:
rebaseliner = Rebaseliner(platform, options)
diff --git a/webkit/tools/layout_tests/run_webkit_tests.py b/webkit/tools/layout_tests/run_webkit_tests.py
index 06a9089..807467e 100755
--- a/webkit/tools/layout_tests/run_webkit_tests.py
+++ b/webkit/tools/layout_tests/run_webkit_tests.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -35,11 +35,14 @@ import sys
import time
import traceback
+import google.path_utils
+
from layout_package import compare_failures
from layout_package import test_expectations
from layout_package import http_server
from layout_package import json_results_generator
from layout_package import path_utils
+from layout_package import platform_utils
from layout_package import test_failures
from layout_package import test_shell_thread
from test_types import fuzzy_image_diff
@@ -50,16 +53,19 @@ from test_types import simplified_text_diff
class TestInfo:
"""Groups information about a test for easy passing of data."""
- def __init__(self, filename, timeout):
+ def __init__(self, filename, timeout, platform):
"""Generates the URI and stores the filename and timeout for this test.
Args:
filename: Full path to the test.
timeout: Timeout for running the test in TestShell.
+ platform: The platform whose test expected results to grab.
"""
self.filename = filename
self.uri = path_utils.FilenameToUri(filename)
self.timeout = timeout
- expected_hash_file = path_utils.ExpectedFilename(filename, '.checksum')
+ expected_hash_file = path_utils.ExpectedFilename(filename,
+ '.checksum',
+ platform)
try:
self.image_hash = open(expected_hash_file, "r").read()
except IOError, e:
@@ -88,14 +94,17 @@ class TestRunner:
# test_shell.exe.
DEFAULT_TEST_TIMEOUT_MS = 10 * 1000
- def __init__(self, options, paths):
+ def __init__(self, options, paths, platform_new_results_dir):
"""Collect a list of files to test.
Args:
options: a dictionary of command line options
paths: a list of paths to crawl looking for test files
+ platform_new_results_dir: name of leaf directory to put rebaselined files
+ in.
"""
self._options = options
+ self._platform_new_results_dir = platform_new_results_dir
self._http_server = http_server.Lighttpd(options.results_directory)
# a list of TestType objects
@@ -108,13 +117,14 @@ class TestRunner:
if options.lint_test_files:
# Creating the expecations for each platform/target pair does all the
- # test list parsing and ensures it's correct syntax (e.g. no dupes).
+ # test list parsing and ensures it's correct syntax(e.g. no dupes).
for platform in test_expectations.TestExpectationsFile.PLATFORMS:
self._ParseExpectations(platform, is_debug_mode=True)
self._ParseExpectations(platform, is_debug_mode=False)
else:
self._GatherTestFiles(paths)
- self._expectations = self._ParseExpectations(options.platform,
+ self._expectations = self._ParseExpectations(
+ platform_utils.GetTestListPlatformName().lower(),
options.target == 'Debug')
self._PrepareListsAndPrintOutput()
@@ -276,7 +286,8 @@ class TestRunner:
# update expectations so that the stats are calculated correctly
self._expectations = self._ParseExpectations(
- path_utils.PlatformName(), options.target == 'Debug')
+ platform_utils.GetTestListPlatformName().lower(),
+ options.target == 'Debug')
else:
logging.info('Run: %d tests' % len(self._test_files))
@@ -366,7 +377,8 @@ class TestRunner:
else:
timeout = self._options.time_out_ms
- tests_by_dir[directory].append(TestInfo(test_file, timeout))
+ tests_by_dir[directory].append(TestInfo(test_file, timeout,
+ self._options.platform))
# Sort by the number of tests in the dir so that the ones with the most
# tests get run first in order to maximize parallelization. Number of tests
@@ -448,7 +460,8 @@ class TestRunner:
test_types = []
for t in self._test_types:
test_types.append(t(self._options.platform,
- self._options.results_directory))
+ self._options.results_directory,
+ self._platform_new_results_dir))
test_args, shell_args = self._GetTestShellArgs(i)
thread = test_shell_thread.TestShellThread(filename_queue,
@@ -482,12 +495,12 @@ class TestRunner:
if not self._test_files:
return 0
start_time = time.time()
- test_shell_binary = path_utils.TestShellPath(self._options.target)
+ test_shell_binary = path_utils.TestShellBinaryPath(self._options.target)
# Start up any helper needed
layout_test_helper_proc = None
if not options.no_pixel_tests:
- helper_path = path_utils.LayoutTestHelperPath(self._options.target)
+ helper_path = path_utils.LayoutTestHelperBinaryPath(self._options.target)
if len(helper_path):
logging.info("Starting layout helper %s" % helper_path)
layout_test_helper_proc = subprocess.Popen([helper_path],
@@ -510,7 +523,7 @@ class TestRunner:
logging.info("Starting tests")
# Create the output directory if it doesn't already exist.
- path_utils.MaybeMakeDirectory(self._options.results_directory)
+ google.path_utils.MaybeMakeDirectory(self._options.results_directory)
threads = self._InstantiateTestShellThreads(test_shell_binary)
@@ -928,7 +941,7 @@ class TestRunner:
"""Launches the test shell open to the results.html page."""
results_filename = os.path.join(self._options.results_directory,
"results.html")
- subprocess.Popen([path_utils.TestShellPath(self._options.target),
+ subprocess.Popen([path_utils.TestShellBinaryPath(self._options.target),
path_utils.FilenameToUri(results_filename)])
@@ -967,17 +980,25 @@ def main(options, args):
options.target = "Release"
if options.results_directory.startswith("/"):
- # Assume it's an absolute path and normalize.
+ # Assume it's an absolute path and normalize
options.results_directory = path_utils.GetAbsolutePath(
options.results_directory)
else:
# If it's a relative path, make the output directory relative to Debug or
# Release.
- options.results_directory = path_utils.PathFromBase('webkit',
- options.target)
+ basedir = path_utils.WebKitRoot()
+ basedir = os.path.join(basedir, options.target)
- # Ensure platform is valid and force it to the form 'chromium-<platform>'.
- options.platform = path_utils.PlatformName(options.platform)
+ options.results_directory = path_utils.GetAbsolutePath(
+ os.path.join(basedir, options.results_directory))
+
+ if options.platform is None:
+ options.platform = path_utils.PlatformDir()
+ platform_new_results_dir = path_utils.PlatformNewResultsDir()
+ else:
+ # If the user specified a platform on the command line then use
+ # that as the name of the output directory for rebaselined files.
+ platform_new_results_dir = options.platform
if not options.num_test_shells:
cpus = 1
@@ -1015,7 +1036,7 @@ def main(options, args):
if options.test_list:
paths += ReadTestFiles(options.test_list)
- test_runner = TestRunner(options, paths)
+ test_runner = TestRunner(options, paths, platform_new_results_dir)
if options.lint_test_files:
# Just creating the TestRunner checks the syntax of the test lists.
@@ -1028,18 +1049,18 @@ def main(options, args):
print("html,txt,checksum,png");
for t in test_runner._test_files:
(expected_txt_dir, expected_txt_file) = path_utils.ExpectedBaseline(
- t, '.txt')
+ t, '.txt', options.platform)
(expected_png_dir, expected_png_file) = path_utils.ExpectedBaseline(
- t, '.png')
+ t, '.png', options.platform)
(expected_checksum_dir,
expected_checksum_file) = path_utils.ExpectedBaseline(
- t, '.checksum')
+ t, '.checksum', options.platform)
print("%s,%s,%s,%s" % (path_utils.RelativeTestFilename(t),
expected_txt_dir, expected_checksum_dir, expected_png_dir))
return
try:
- test_shell_binary_path = path_utils.TestShellPath(options.target)
+ test_shell_binary_path = path_utils.TestShellBinaryPath(options.target)
except path_utils.PathNotFound:
print "\nERROR: test_shell is not found. Be sure that you have built it"
print "and that you are using the correct build. This script will run the"
@@ -1050,7 +1071,8 @@ def main(options, args):
logging.info("Placing test results in %s" % options.results_directory)
if options.new_baseline:
logging.info("Placing new baselines in %s" %
- path_utils.ChromiumBaselinePath())
+ os.path.join(path_utils.PlatformResultsEnclosingDir(options.platform),
+ platform_new_results_dir))
logging.info("Using %s build at %s" %
(options.target, test_shell_binary_path))
if not options.no_pixel_tests:
diff --git a/webkit/tools/layout_tests/test_types/fuzzy_image_diff.py b/webkit/tools/layout_tests/test_types/fuzzy_image_diff.py
index 03633b3e..6a87e22 100644
--- a/webkit/tools/layout_tests/test_types/fuzzy_image_diff.py
+++ b/webkit/tools/layout_tests/test_types/fuzzy_image_diff.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -27,7 +27,9 @@ class FuzzyImageDiff(test_type_base.TestTypeBase):
if test_args.hash is None:
return failures
- expected_png_file = path_utils.ExpectedFilename(filename, '.png')
+ expected_png_file = path_utils.ExpectedFilename(filename,
+ '.png',
+ self._platform)
if test_args.show_sources:
logging.debug('Using %s' % expected_png_file)
@@ -37,7 +39,7 @@ class FuzzyImageDiff(test_type_base.TestTypeBase):
failures.append(test_failures.FailureMissingImage(self))
# Run the fuzzymatcher
- r = subprocess.call([path_utils.FuzzyMatchPath(),
+ r = subprocess.call([path_utils.GetPlatformUtil().FuzzyMatchBinaryPath(),
test_args.png_path, expected_png_file])
if r != 0:
failures.append(test_failures.FailureFuzzyFailure(self))
diff --git a/webkit/tools/layout_tests/test_types/image_diff.py b/webkit/tools/layout_tests/test_types/image_diff.py
index d8f0a16..3f7fa74 100644
--- a/webkit/tools/layout_tests/test_types/image_diff.py
+++ b/webkit/tools/layout_tests/test_types/image_diff.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -16,6 +16,7 @@ import shutil
import subprocess
from layout_package import path_utils
+from layout_package import platform_utils
from layout_package import test_failures
from test_types import test_type_base
@@ -76,7 +77,7 @@ class ImageDiff(test_type_base.TestTypeBase):
cmd = ''
try:
- executable = path_utils.ImageDiffPath(target)
+ executable = path_utils.ImageDiffBinaryPath(target)
cmd = [executable, '--diff', actual_filename, expected_filename,
diff_filename]
except Exception, e:
@@ -121,9 +122,13 @@ class ImageDiff(test_type_base.TestTypeBase):
return failures
# Compare hashes.
- expected_hash_file = path_utils.ExpectedFilename(filename, '.checksum')
+ expected_hash_file = path_utils.ExpectedFilename(filename,
+ '.checksum',
+ self._platform)
- expected_png_file = path_utils.ExpectedFilename(filename, '.png')
+ expected_png_file = path_utils.ExpectedFilename(filename,
+ '.png',
+ self._platform)
if test_args.show_sources:
logging.debug('Using %s' % expected_png_file)
diff --git a/webkit/tools/layout_tests/test_types/test_type_base.py b/webkit/tools/layout_tests/test_types/test_type_base.py
index c6355d5..b51677e 100644
--- a/webkit/tools/layout_tests/test_types/test_type_base.py
+++ b/webkit/tools/layout_tests/test_types/test_type_base.py
@@ -13,7 +13,11 @@ import errno
import os.path
import subprocess
+
+import google.path_utils
+
from layout_package import path_utils
+from layout_package import platform_utils
class TestArguments(object):
"""Struct-like wrapper for additional arguments needed by specific tests."""
@@ -44,22 +48,25 @@ class TestTypeBase(object):
FILENAME_SUFFIX_WDIFF = "-wdiff.html"
FILENAME_SUFFIX_COMPARE = "-diff.png"
- def __init__(self, platform, root_output_dir):
+ def __init__(self, platform, root_output_dir, platform_new_results_dir):
"""Initialize a TestTypeBase object.
Args:
platform: the platform (e.g., 'chromium-mac-leopard') identifying the
platform-specific results to be used.
root_output_dir: The unix style path to the output dir.
+ platform_new_results_dir: Name of the directory to put newly baselined
+ results in.
"""
self._root_output_dir = root_output_dir
self._platform = platform
+ self._platform_new_results_dir = platform_new_results_dir
def _MakeOutputDirectory(self, filename):
"""Creates the output directory (if needed) for a given test filename."""
output_filename = os.path.join(self._root_output_dir,
path_utils.RelativeTestFilename(filename))
- path_utils.MaybeMakeDirectory(os.path.split(output_filename)[0])
+ google.path_utils.MaybeMakeDirectory(os.path.split(output_filename)[0])
def _SaveBaselineData(self, filename, data, modifier):
"""Saves a new baseline file into the platform directory.
@@ -73,12 +80,13 @@ class TestTypeBase(object):
modifier: type of the result file, e.g. ".txt" or ".png"
"""
relative_dir = os.path.dirname(path_utils.RelativeTestFilename(filename))
- output_dir = os.path.join(path_utils.ChromiumBaselinePath(self._platform),
+ output_dir = os.path.join(path_utils.PlatformResultsEnclosingDir(self._platform),
+ self._platform_new_results_dir,
relative_dir)
output_file = os.path.basename(os.path.splitext(filename)[0] +
self.FILENAME_SUFFIX_EXPECTED + modifier)
- path_utils.MaybeMakeDirectory(output_dir)
+ google.path_utils.MaybeMakeDirectory(output_dir)
open(os.path.join(output_dir, output_file), "wb").write(data)
def OutputFilename(self, filename, modifier):
@@ -172,7 +180,8 @@ class TestTypeBase(object):
if wdiff:
# Shell out to wdiff to get colored inline diffs.
- executable = path_utils.WDiffPath()
+ platform_util = platform_utils.PlatformUtility('')
+ executable = platform_util.WDiffExecutablePath()
cmd = [executable,
'--start-delete=##WDIFF_DEL##', '--end-delete=##WDIFF_END##',
'--start-insert=##WDIFF_ADD##', '--end-insert=##WDIFF_END##',
diff --git a/webkit/tools/layout_tests/test_types/text_diff.py b/webkit/tools/layout_tests/test_types/text_diff.py
index 576d03d..c1d1b70 100644
--- a/webkit/tools/layout_tests/test_types/text_diff.py
+++ b/webkit/tools/layout_tests/test_types/text_diff.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -12,7 +12,10 @@ import errno
import logging
import os.path
+import google.path_utils
+
from layout_package import path_utils
+from layout_package import platform_utils
from layout_package import test_failures
from test_types import test_type_base
@@ -33,7 +36,8 @@ class TestTextDiff(test_type_base.TestTypeBase):
and normalize the text. Returns a string with the expected text, or ''
if the expected output file was not found."""
# Read the platform-specific expected text.
- expected_filename = path_utils.ExpectedFilename(filename, '.txt')
+ expected_filename = path_utils.ExpectedFilename(filename, '.txt',
+ self._platform)
if show_sources:
logging.debug('Using %s' % expected_filename)
@@ -63,19 +67,21 @@ class TestTextDiff(test_type_base.TestTypeBase):
self.FILENAME_SUFFIX_EXPECTED + modifier)
if isRenderTreeDump(data):
relative_dir = os.path.dirname(path_utils.RelativeTestFilename(filename))
- output_dir = os.path.join(path_utils.ChromiumBaselinePath(),
+ output_dir = os.path.join(path_utils.PlatformResultsEnclosingDir(self._platform),
+ self._platform_new_results_dir,
relative_dir)
- path_utils.MaybeMakeDirectory(output_dir)
+ google.path_utils.MaybeMakeDirectory(output_dir)
open(os.path.join(output_dir, output_file), "wb").write(data)
else:
# If it's not a render tree, then the results can be shared between all
# platforms. Copy the file into the chromium-win and chromium-mac dirs.
relative_dir = os.path.dirname(path_utils.RelativeTestFilename(filename))
for platform in ('chromium-win', 'chromium-mac'):
- output_dir = os.path.join(path_utils.ChromiumBaselinePath(),
+ output_dir = os.path.join(path_utils.PlatformResultsEnclosingDir(self._platform),
+ platform,
relative_dir)
- path_utils.MaybeMakeDirectory(output_dir)
+ google.path_utils.MaybeMakeDirectory(output_dir)
open(os.path.join(output_dir, output_file), "wb").write(data)
def CompareOutput(self, filename, proc, output, test_args, target):