Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: webkit/tools/layout_tests/layout_package/platform_utils_linux.py

Issue 10413: Add platform_utils and stub test lists for Linux. (Closed)
Patch Set: Add method to support test rearranging. Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright (c) 2008 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Platform-specific utility methods shared by several scripts."""
7
8 import os
9 import re
10 import subprocess
11 import sys
12
13 import google.path_utils
14
15 # Distinguish the path_utils.py in this dir from google.path_utils.
16 import path_utils as layout_package_path_utils
17
18 # This will be a native path to the directory this file resides in.
19 # It can either be relative or absolute depending how it's executed.
20 THISDIR = os.path.dirname(os.path.abspath(__file__))
21 def PathFromBase(*pathies):
22 return google.path_utils.FindUpward(THISDIR, *pathies)
23
24 class PlatformUtility(object):
25 def __init__(self, base_dir):
26 """Args:
27 base_dir: a directory above which third_party/cygwin can be found,
28 used to locate the cygpath executable for path conversions.
29 """
30 LAYOUTTEST_HTTP_DIR = "LayoutTests/http/tests/"
31 PENDING_HTTP_DIR = "pending/http/tests/"
32
33 def GetAbsolutePath(self, path, force=False):
34 """Returns an absolute UNIX path."""
35 return os.path.abspath(path)
36
37 # TODO(mmoss): would be great to get rid of the duplication with
38 # platform_utils_win/mac.py for the next two functions, but inheritance
39 # from tools/python/google on the Windows side makes that a bit difficult.
40
41 def _FilenameToUri(self, path, use_http=False, use_ssl=False, port=8000):
42 """Convert a Windows style path to a URI.
43
44 Args:
45 path: For an http URI, the path relative to the httpd server's
46 DocumentRoot; for a file URI, the full path to the file.
47 use_http: if True, returns a URI of the form http://127.0.0.1:8000/.
48 If False, returns a file:/// URI.
49 use_ssl: if True, returns HTTPS URL (https://127.0.0.1:8000/).
50 This parameter is ignored if use_http=False.
51 port: The port number to append when returning an HTTP URI
52 """
53 if use_http:
54 protocol = 'http'
55 if use_ssl:
56 protocol = 'https'
57 path = path.replace("\\", "/")
58 return "%s://127.0.0.1:%s/%s" % (protocol, str(port), path)
59 return "file:///" + self.GetAbsolutePath(path)
60
61 def FilenameToUri(self, full_path):
62 relative_path = layout_package_path_utils.RelativeTestFilename(full_path)
63 port = None
64 use_ssl = False
65
66 # LayoutTests/http/tests/ run off port 8000 and ssl/ off 8443
67 if relative_path.startswith(self.LAYOUTTEST_HTTP_DIR):
68 relative_path = relative_path[len(self.LAYOUTTEST_HTTP_DIR):]
69 port = 8000
70 # pending/http/tests/ run off port 9000 and ssl/ off 9443
71 elif relative_path.startswith(self.PENDING_HTTP_DIR):
72 relative_path = relative_path[len(self.PENDING_HTTP_DIR):]
73 port = 9000
74 # chrome/http/tests run off of port 8081 with the full path
75 elif relative_path.find("/http/") >= 0:
76 print relative_path
77 port = 8081
78
79 # We want to run off of the http server
80 if port:
81 if relative_path.startswith("ssl/"):
82 port += 443
83 use_ssl = True
84 return PlatformUtility._FilenameToUri(self,
85 relative_path,
86 use_http=True,
87 use_ssl=use_ssl,
88 port=port)
89
90 # Run off file://
91 return PlatformUtility._FilenameToUri(self, full_path, use_http=False,
92 use_ssl=False, port=0)
93
94 def LigHTTPdExecutablePath(self):
95 """Returns the executable path to start LigHTTPd"""
96 return PathFromBase('third_party', 'lighttpd', 'linux', 'bin', 'lighttpd')
97
98 def LigHTTPdModulePath(self):
99 """Returns the library module path for LigHTTPd"""
100 return PathFromBase('third_party', 'lighttpd', 'linux', 'lib')
101
102 def LigHTTPdPHPPath(self):
103 """Returns the PHP executable path for LigHTTPd"""
104 return PathFromBase('third_party', 'lighttpd', 'linux', 'bin', 'php-cgi')
105
106 def ShutDownHTTPServer(self, server_process):
107 """Shut down the lighttpd web server. Blocks until it's fully shut down.
108
109 Args:
110 server_process: The subprocess object representing the running server
111 """
112 subprocess.Popen(('kill', '-TERM', '%d' % server_process.pid),
113 stdout=subprocess.PIPE,
114 stderr=subprocess.PIPE).wait()
115
116 def WDiffExecutablePath(self):
117 """Path to the WDiff executable, which we assume is already installed and
118 in the user's $PATH.
119 """
120 return 'wdiff'
121
122 def TestShellBinary(self):
123 """The name of the binary for TestShell."""
124 return 'test_shell'
125
126 def TestShellBinaryPath(self, target):
127 """Return the platform-specific binary path for our TestShell.
128
129 Args:
130 target: Build target mode (debug or release)
131 """
132 # TODO(mmoss) - hard-coded to "Hammer" for now until I look into the scons
133 # output directory logic (and how/if it will change once Linux supports
134 # multiple debug/release targets).
135 return PathFromBase('chrome', 'Hammer', self.TestShellBinary())
136
137 def TestListPlatformDir(self):
138 """Return the platform-specific directory for where the test lists live"""
139 return 'linux'
140
141 def PlatformDir(self):
142 """Returns the most specific directory name where platform-specific
143 results live.
144 """
145 return 'chromium-linux'
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698