OLD | NEW |
| (Empty) |
1 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 """This is the Linux implementation of the layout_package.platform_utils | |
6 package. This file should only be imported by that package.""" | |
7 | |
8 import os | |
9 import path_utils | |
10 import subprocess | |
11 import sys | |
12 | |
13 | |
14 def PlatformName(): | |
15 """Returns the name of the platform we're currently running on.""" | |
16 # We're not ready for version-specific results yet. When we uncomment | |
17 # this, we also need to add it to the BaselineSearchPath() | |
18 return 'chromium-win' + PlatformVersion() | |
19 | |
20 | |
21 def PlatformVersion(): | |
22 """Returns the version string for the platform, e.g. '-vista' or | |
23 '-snowleopard'. If the platform does not distinguish between | |
24 minor versions, it returns ''.""" | |
25 winver = sys.getwindowsversion() | |
26 if winver[0] == 6 and (winver[1] == 1): | |
27 return '-7' | |
28 if winver[0] == 6 and (winver[1] == 0): | |
29 return '-vista' | |
30 if winver[0] == 5 and (winver[1] == 1 or winver[1] == 2): | |
31 return '-xp' | |
32 return '' | |
33 | |
34 | |
35 def GetNumCores(): | |
36 """Returns the number of cores on the machine. For hyperthreaded machines, | |
37 this will be double the number of actual processors.""" | |
38 return int(os.environ.get('NUMBER_OF_PROCESSORS', 1)) | |
39 | |
40 | |
41 def BaselinePath(platform=None): | |
42 """Returns the path relative to the top of the source tree for the | |
43 baselines for the specified platform version. If |platform| is None, | |
44 then the version currently in use is used.""" | |
45 if platform is None: | |
46 platform = PlatformName() | |
47 return path_utils.PathFromBase('webkit', 'data', 'layout_tests', | |
48 'platform', platform, 'LayoutTests') | |
49 | |
50 | |
51 def BaselineSearchPath(platform=None): | |
52 """Returns the list of directories to search for baselines/results, in | |
53 order of preference. Paths are relative to the top of the source tree.""" | |
54 dirs = [] | |
55 if platform is None: | |
56 platform = PlatformName() | |
57 | |
58 if platform == 'chromium-win-xp': | |
59 dirs.append(BaselinePath(platform)) | |
60 if platform in ('chromium-win-xp', 'chromium-win-vista'): | |
61 dirs.append(BaselinePath('chromium-win-vista')) | |
62 dirs.append(BaselinePath('chromium-win')) | |
63 dirs.append(path_utils.WebKitBaselinePath('win')) | |
64 dirs.append(path_utils.WebKitBaselinePath('mac')) | |
65 return dirs | |
66 | |
67 | |
68 def WDiffPath(): | |
69 """Path to the WDiff executable, whose binary is checked in on Win""" | |
70 return path_utils.PathFromBase('third_party', 'cygwin', 'bin', 'wdiff.exe') | |
71 | |
72 | |
73 def ImageDiffPath(target): | |
74 """Return the platform-specific binary path for the image compare util. | |
75 We use this if we can't find the binary in the default location | |
76 in path_utils. | |
77 | |
78 Args: | |
79 target: Build target mode (debug or release) | |
80 """ | |
81 return _FindBinary(target, 'image_diff.exe') | |
82 | |
83 | |
84 def LayoutTestHelperPath(target): | |
85 """Return the platform-specific binary path for the layout test helper. | |
86 We use this if we can't find the binary in the default location | |
87 in path_utils. | |
88 | |
89 Args: | |
90 target: Build target mode (debug or release) | |
91 """ | |
92 return _FindBinary(target, 'layout_test_helper.exe') | |
93 | |
94 | |
95 def TestShellPath(target): | |
96 """Return the platform-specific binary path for our TestShell. | |
97 We use this if we can't find the binary in the default location | |
98 in path_utils. | |
99 | |
100 Args: | |
101 target: Build target mode (debug or release) | |
102 """ | |
103 return _FindBinary(target, 'test_shell.exe') | |
104 | |
105 | |
106 def ApacheExecutablePath(): | |
107 """Returns the executable path to start Apache""" | |
108 path = path_utils.PathFromBase('third_party', 'cygwin', "usr", "sbin") | |
109 # Don't return httpd.exe since we want to use this from cygwin. | |
110 return os.path.join(path, "httpd") | |
111 | |
112 | |
113 def ApacheConfigFilePath(): | |
114 """Returns the path to Apache config file""" | |
115 return path_utils.PathFromBase("third_party", "WebKit", "LayoutTests", | |
116 "http", "conf", "cygwin-httpd.conf") | |
117 | |
118 | |
119 def LigHTTPdExecutablePath(): | |
120 """Returns the executable path to start LigHTTPd""" | |
121 return path_utils.PathFromBase('third_party', 'lighttpd', 'win', | |
122 'LightTPD.exe') | |
123 | |
124 | |
125 def LigHTTPdModulePath(): | |
126 """Returns the library module path for LigHTTPd""" | |
127 return path_utils.PathFromBase('third_party', 'lighttpd', 'win', 'lib') | |
128 | |
129 | |
130 def LigHTTPdPHPPath(): | |
131 """Returns the PHP executable path for LigHTTPd""" | |
132 return path_utils.PathFromBase('third_party', 'lighttpd', 'win', 'php5', | |
133 'php-cgi.exe') | |
134 | |
135 | |
136 def ShutDownHTTPServer(server_pid): | |
137 """Shut down the lighttpd web server. Blocks until it's fully shut down. | |
138 | |
139 Args: | |
140 server_pid: The process ID of the running server. | |
141 Unused in this implementation of the method. | |
142 """ | |
143 subprocess.Popen(('taskkill.exe', '/f', '/im', 'LightTPD.exe'), | |
144 stdout=subprocess.PIPE, | |
145 stderr=subprocess.PIPE).wait() | |
146 subprocess.Popen(('taskkill.exe', '/f', '/im', 'httpd.exe'), | |
147 stdout=subprocess.PIPE, | |
148 stderr=subprocess.PIPE).wait() | |
149 | |
150 | |
151 def KillProcess(pid): | |
152 """Forcefully kill the process. | |
153 | |
154 Args: | |
155 pid: The id of the process to be killed. | |
156 """ | |
157 subprocess.call(('taskkill.exe', '/f', '/pid', str(pid)), | |
158 stdout=subprocess.PIPE, | |
159 stderr=subprocess.PIPE) | |
160 | |
161 | |
162 def KillAllTestShells(self): | |
163 """Kills all instances of the test_shell binary currently running.""" | |
164 subprocess.Popen(('taskkill.exe', '/f', '/im', 'test_shell.exe'), | |
165 stdout=subprocess.PIPE, | |
166 stderr=subprocess.PIPE).wait() | |
167 | |
168 # | |
169 # Private helper functions. | |
170 # | |
171 | |
172 | |
173 def _FindBinary(target, binary): | |
174 """On Windows, we look for binaries that we compile in potentially | |
175 two places: src/webkit/$target (preferably, which we get if we | |
176 built using webkit_glue.gyp), or src/chrome/$target (if compiled some | |
177 other way).""" | |
178 try: | |
179 return path_utils.PathFromBase('webkit', target, binary) | |
180 except path_utils.PathNotFound: | |
181 try: | |
182 return path_utils.PathFromBase('chrome', target, binary) | |
183 except path_utils.PathNotFound: | |
184 return path_utils.PathFromBase('build', target, binary) | |
OLD | NEW |