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

Side by Side Diff: ppapi/native_client/tools/browser_tester/browser_tester.py

Issue 17063018: NaCl: have browser_tester set-up the sandbox environment (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium 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 glob 6 import glob
7 import optparse 7 import optparse
8 import os.path 8 import os.path
9 import socket 9 import socket
10 import sys 10 import sys
11 import thread 11 import thread
12 import time 12 import time
13 import urllib 13 import urllib
14 14
15 # Allow the import of third party modules 15 # Allow the import of third party modules
16 script_dir = os.path.dirname(os.path.abspath(__file__)) 16 script_dir = os.path.dirname(os.path.abspath(__file__))
17 sys.path.append(os.path.join(script_dir, '../../../../third_party/')) 17 sys.path.append(os.path.join(script_dir, '../../../../third_party/'))
18 sys.path.append(os.path.join(script_dir, '../../../../tools/valgrind/')) 18 sys.path.append(os.path.join(script_dir, '../../../../tools/valgrind/'))
19 sys.path.append(os.path.join(script_dir, '../../../../testing/'))
19 20
20 import browsertester.browserlauncher 21 import browsertester.browserlauncher
21 import browsertester.rpclistener 22 import browsertester.rpclistener
22 import browsertester.server 23 import browsertester.server
23 24
24 import memcheck_analyze 25 import memcheck_analyze
25 import tsan_analyze 26 import tsan_analyze
26 27
28 import test_env
29
27 def BuildArgParser(): 30 def BuildArgParser():
28 usage = 'usage: %prog [options]' 31 usage = 'usage: %prog [options]'
29 parser = optparse.OptionParser(usage) 32 parser = optparse.OptionParser(usage)
30 33
31 parser.add_option('-p', '--port', dest='port', action='store', type='int', 34 parser.add_option('-p', '--port', dest='port', action='store', type='int',
32 default='0', help='The TCP port the server will bind to. ' 35 default='0', help='The TCP port the server will bind to. '
33 'The default is to pick an unused port number.') 36 'The default is to pick an unused port number.')
34 parser.add_option('--browser_path', dest='browser_path', action='store', 37 parser.add_option('--browser_path', dest='browser_path', action='store',
35 type='string', default=None, 38 type='string', default=None,
36 help='Use the browser located here.') 39 help='Use the browser located here.')
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 # Set the default here so we're assured hard_timeout will be defined. 193 # Set the default here so we're assured hard_timeout will be defined.
191 # Tests, such as run_inbrowser_trusted_crash_in_startup_test, may not use the 194 # Tests, such as run_inbrowser_trusted_crash_in_startup_test, may not use the
192 # RunFromCommand line entry point - and otherwise get stuck in an infinite 195 # RunFromCommand line entry point - and otherwise get stuck in an infinite
193 # loop when something goes wrong and the hard timeout is not set. 196 # loop when something goes wrong and the hard timeout is not set.
194 # http://code.google.com/p/chromium/issues/detail?id=105406 197 # http://code.google.com/p/chromium/issues/detail?id=105406
195 if options.hard_timeout is None: 198 if options.hard_timeout is None:
196 options.hard_timeout = options.timeout * 4 199 options.hard_timeout = options.timeout * 4
197 200
198 options.files.append(os.path.join(script_dir, 'browserdata', 'nacltest.js')) 201 options.files.append(os.path.join(script_dir, 'browserdata', 'nacltest.js'))
199 202
203 # Set-up the environment with the setuid sandbox path.
Mark Seaborn 2013/06/21 22:38:57 Grammar nit: no hyphen needed :-)
jln (very slow on Chromium) 2013/06/21 22:49:56 Done.
204 test_env.enable_sandbox_if_required(os.environ)
205
200 # Create server 206 # Create server
201 host = GetHostName() 207 host = GetHostName()
202 try: 208 try:
203 server = browsertester.server.Create(host, options.port) 209 server = browsertester.server.Create(host, options.port)
204 except Exception: 210 except Exception:
205 sys.stdout.write('Could not bind %r, falling back to localhost.\n' % host) 211 sys.stdout.write('Could not bind %r, falling back to localhost.\n' % host)
206 server = browsertester.server.Create('localhost', options.port) 212 server = browsertester.server.Create('localhost', options.port)
207 213
208 # If port 0 has been requested, an arbitrary port will be bound so we need to 214 # If port 0 has been requested, an arbitrary port will be bound so we need to
209 # query it. Older version of Python do not set server_address correctly when 215 # query it. Older version of Python do not set server_address correctly when
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 # Validate the URL 364 # Validate the URL
359 url = options.url 365 url = options.url
360 if url is None: 366 if url is None:
361 parser.error('Must specify a URL') 367 parser.error('Must specify a URL')
362 368
363 return Run(url, options) 369 return Run(url, options)
364 370
365 371
366 if __name__ == '__main__': 372 if __name__ == '__main__':
367 sys.exit(RunFromCommandLine()) 373 sys.exit(RunFromCommandLine())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698