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

Side by Side Diff: testing/xvfb.py

Issue 2521353003: Remove build_dir arg from xvfb.py (Closed)
Patch Set: Rebase again Created 4 years 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
« no previous file with comments | « testing/scripts/run_telemetry_as_googletest.py ('k') | tools/mb/mb.py » ('j') | 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/env python 1 #!/usr/bin/env 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 """Runs tests with Xvfb and Openbox on Linux and normally on other platforms.""" 6 """Runs tests with Xvfb and Openbox on Linux and normally on other platforms."""
7 7
8 import os 8 import os
9 import platform 9 import platform
10 import signal 10 import signal
(...skipping 24 matching lines...) Expand all
35 thread.join(timeout_in_seconds) 35 thread.join(timeout_in_seconds)
36 if thread.is_alive(): 36 if thread.is_alive():
37 print >> sys.stderr, 'Xvfb running after SIGTERM, trying SIGKILL.' 37 print >> sys.stderr, 'Xvfb running after SIGTERM, trying SIGKILL.'
38 _kill(proc, signal.SIGKILL) 38 _kill(proc, signal.SIGKILL)
39 39
40 thread.join(timeout_in_seconds) 40 thread.join(timeout_in_seconds)
41 if thread.is_alive(): 41 if thread.is_alive():
42 print >> sys.stderr, 'Xvfb running after SIGTERM and SIGKILL; good luck!' 42 print >> sys.stderr, 'Xvfb running after SIGTERM and SIGKILL; good luck!'
43 43
44 44
45 def run_executable(cmd, build_dir, env): 45 def run_executable(cmd, env):
46 """Runs an executable within Xvfb on Linux or normally on other platforms. 46 """Runs an executable within Xvfb on Linux or normally on other platforms.
47 47
48 Returns the exit code of the specified commandline, or 1 on failure. 48 Returns the exit code of the specified commandline, or 1 on failure.
49 """ 49 """
50 if sys.platform == 'linux2': 50 if sys.platform == 'linux2':
51 if env.get('_CHROMIUM_INSIDE_XVFB') == '1': 51 if env.get('_CHROMIUM_INSIDE_XVFB') == '1':
52 openbox_proc = None 52 openbox_proc = None
53 xcompmgr_proc = None 53 xcompmgr_proc = None
54 try: 54 try:
55 # Some ChromeOS tests need a window manager. 55 # Some ChromeOS tests need a window manager.
56 openbox_proc = subprocess.Popen('openbox', stdout=subprocess.PIPE, 56 openbox_proc = subprocess.Popen('openbox', stdout=subprocess.PIPE,
57 stderr=subprocess.STDOUT, env=env) 57 stderr=subprocess.STDOUT, env=env)
58 58
59 # Some tests need a compositing wm to make use of transparent visuals. 59 # Some tests need a compositing wm to make use of transparent visuals.
60 xcompmgr_proc = subprocess.Popen('xcompmgr', stdout=subprocess.PIPE, 60 xcompmgr_proc = subprocess.Popen('xcompmgr', stdout=subprocess.PIPE,
61 stderr=subprocess.STDOUT, env=env) 61 stderr=subprocess.STDOUT, env=env)
62 62
63 return test_env.run_executable(cmd, env) 63 return test_env.run_executable(cmd, env)
64 except OSError as e: 64 except OSError as e:
65 print >> sys.stderr, 'Failed to start Xvfb or Openbox: %s' % str(e) 65 print >> sys.stderr, 'Failed to start Xvfb or Openbox: %s' % str(e)
66 return 1 66 return 1
67 finally: 67 finally:
68 kill(openbox_proc) 68 kill(openbox_proc)
69 kill(xcompmgr_proc) 69 kill(xcompmgr_proc)
70 else: 70 else:
71 env['_CHROMIUM_INSIDE_XVFB'] = '1' 71 env['_CHROMIUM_INSIDE_XVFB'] = '1'
72 return subprocess.call(['xvfb-run', '-a', "--server-args=-screen 0 " 72 return subprocess.call(['xvfb-run', '-a', "--server-args=-screen 0 "
73 "1280x800x24 -ac -nolisten tcp -dpi 96", 73 "1280x800x24 -ac -nolisten tcp -dpi 96",
74 __file__, build_dir] + cmd, env=env) 74 __file__] + cmd, env=env)
75 else: 75 else:
76 return test_env.run_executable(cmd, env) 76 return test_env.run_executable(cmd, env)
77 77
78 78
79 def main(): 79 def main():
80 if len(sys.argv) < 3: 80 if len(sys.argv) < 2:
81 print >> sys.stderr, ( 81 print >> sys.stderr, (
82 'Usage: xvfb.py [path to build_dir] [command args...]') 82 'Usage: xvfb.py [command args...]')
83 return 2 83 return 2
84 return run_executable(sys.argv[2:], sys.argv[1], os.environ.copy()) 84 return run_executable(sys.argv[1:], os.environ.copy())
85 85
86 86
87 if __name__ == "__main__": 87 if __name__ == "__main__":
88 sys.exit(main()) 88 sys.exit(main())
OLDNEW
« no previous file with comments | « testing/scripts/run_telemetry_as_googletest.py ('k') | tools/mb/mb.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698