OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os.path | 6 import os.path |
7 import re | 7 import re |
8 import shutil | 8 import shutil |
9 import sys | 9 import sys |
10 import tempfile | 10 import tempfile |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 if self.tool_log_dir is not None: | 135 if self.tool_log_dir is not None: |
136 RemoveDirectory(self.tool_log_dir) | 136 RemoveDirectory(self.tool_log_dir) |
137 | 137 |
138 def MakeProfileDirectory(self): | 138 def MakeProfileDirectory(self): |
139 self.profile = tempfile.mkdtemp(prefix='browserprofile_') | 139 self.profile = tempfile.mkdtemp(prefix='browserprofile_') |
140 return self.profile | 140 return self.profile |
141 | 141 |
142 def SetStandardStream(self, env, var_name, redirect_file, is_output): | 142 def SetStandardStream(self, env, var_name, redirect_file, is_output): |
143 if redirect_file is None: | 143 if redirect_file is None: |
144 return | 144 return |
145 redirect_file = os.path.abspath(redirect_file) | 145 # logic must match src/trusted/service_runtime/nacl_resource.* |
| 146 # resource specification notation |
| 147 is_file = (redirect_file.startswith('file:') or |
| 148 not (redirect_file.startswith('dev:') or |
| 149 redirect_file.startswith('DEBUG_ONLY:dev:'))) |
| 150 if is_file: |
| 151 if redirect_file.startswith('file:'): |
| 152 bare_file = redirect_file[5:] |
| 153 else: |
| 154 bare_file = redirect_file |
| 155 # why always abspath? does chrome chdir or might it in the |
| 156 # future? this means we do not test/use the relative path case. |
| 157 redirect_file = 'file:' + os.path.abspath(bare_file) |
| 158 else: |
| 159 bare_file = None # ensure error if used without checking is_file |
146 env[var_name] = redirect_file | 160 env[var_name] = redirect_file |
147 if is_output: | 161 if is_output: |
148 # sel_ldr appends program output to the file so we need to clear it | 162 # sel_ldr appends program output to the file so we need to clear it |
149 # in order to get the stable result. | 163 # in order to get the stable result. |
150 if os.path.exists(redirect_file): | 164 if is_file: |
151 os.remove(redirect_file) | 165 if os.path.exists(bare_file): |
152 parent_dir = os.path.dirname(redirect_file) | 166 os.remove(bare_file) |
153 # parent directory may not exist. | 167 parent_dir = os.path.dirname(bare_file) |
154 if not os.path.exists(parent_dir): | 168 # parent directory may not exist. |
155 os.makedirs(parent_dir) | 169 if not os.path.exists(parent_dir): |
| 170 os.makedirs(parent_dir) |
156 | 171 |
157 def Launch(self, cmd, env): | 172 def Launch(self, cmd, env): |
158 browser_path = cmd[0] | 173 browser_path = cmd[0] |
159 if not os.path.exists(browser_path): | 174 if not os.path.exists(browser_path): |
160 raise LaunchFailure('Browser does not exist %r'% browser_path) | 175 raise LaunchFailure('Browser does not exist %r'% browser_path) |
161 if not os.access(browser_path, os.X_OK): | 176 if not os.access(browser_path, os.X_OK): |
162 raise LaunchFailure('Browser cannot be executed %r (Is this binary on an ' | 177 raise LaunchFailure('Browser cannot be executed %r (Is this binary on an ' |
163 'NFS volume?)' % browser_path) | 178 'NFS volume?)' % browser_path) |
164 if self.options.sel_ldr: | 179 if self.options.sel_ldr: |
165 env['NACL_SEL_LDR'] = self.options.sel_ldr | 180 env['NACL_SEL_LDR'] = self.options.sel_ldr |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 '--trace-children=yes', | 316 '--trace-children=yes', |
302 '--nacl-file=%s' % (self.options.files[0],), | 317 '--nacl-file=%s' % (self.options.files[0],), |
303 '--ignore=../tools/valgrind/tsan/ignores.txt', | 318 '--ignore=../tools/valgrind/tsan/ignores.txt', |
304 '--suppressions=../tools/valgrind/tsan/suppressions.txt', | 319 '--suppressions=../tools/valgrind/tsan/suppressions.txt', |
305 '--log-file=%s/log.%%p' % (self.tool_log_dir,)] + cmd | 320 '--log-file=%s/log.%%p' % (self.tool_log_dir,)] + cmd |
306 elif self.options.tool != None: | 321 elif self.options.tool != None: |
307 raise LaunchFailure('Invalid tool name "%s"' % (self.options.tool,)) | 322 raise LaunchFailure('Invalid tool name "%s"' % (self.options.tool,)) |
308 cmd.extend(self.options.browser_flags) | 323 cmd.extend(self.options.browser_flags) |
309 cmd.append(url) | 324 cmd.append(url) |
310 return cmd | 325 return cmd |
OLD | NEW |