OLD | NEW |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 build_dir: The path of the build directory, used for xdisplaycheck. | 74 build_dir: The path of the build directory, used for xdisplaycheck. |
75 xvfb_path: The path to Xvfb. | 75 xvfb_path: The path to Xvfb. |
76 display: The X display number to use. | 76 display: The X display number to use. |
77 """ | 77 """ |
78 assert should_start_xvfb(env) | 78 assert should_start_xvfb(env) |
79 assert env.get('_CHROMIUM_INSIDE_XVFB') != '1' | 79 assert env.get('_CHROMIUM_INSIDE_XVFB') != '1' |
80 env['_CHROMIUM_INSIDE_XVFB'] = '1' | 80 env['_CHROMIUM_INSIDE_XVFB'] = '1' |
81 env['DISPLAY'] = display | 81 env['DISPLAY'] = display |
82 xvfb_proc = None | 82 xvfb_proc = None |
83 openbox_proc = None | 83 openbox_proc = None |
| 84 xcompmgr_proc = None |
84 | 85 |
85 try: | 86 try: |
86 xvfb_cmd = [xvfb_path, display, '-screen', '0', '1280x800x24', '-ac', | 87 xvfb_cmd = [xvfb_path, display, '-screen', '0', '1280x800x24', '-ac', |
87 '-nolisten', 'tcp', '-dpi', '96'] | 88 '-nolisten', 'tcp', '-dpi', '96'] |
88 xvfb_proc = subprocess.Popen(xvfb_cmd, stdout=subprocess.PIPE, | 89 xvfb_proc = subprocess.Popen(xvfb_cmd, stdout=subprocess.PIPE, |
89 stderr=subprocess.STDOUT) | 90 stderr=subprocess.STDOUT) |
90 | 91 |
91 if not wait_for_xvfb(os.path.join(build_dir, 'xdisplaycheck'), env): | 92 if not wait_for_xvfb(os.path.join(build_dir, 'xdisplaycheck'), env): |
92 rc = xvfb_proc.poll() | 93 rc = xvfb_proc.poll() |
93 if rc is None: | 94 if rc is None: |
94 print 'Xvfb still running after xdisplaycheck failure, stopping.' | 95 print 'Xvfb still running after xdisplaycheck failure, stopping.' |
95 kill(xvfb_proc) | 96 kill(xvfb_proc) |
96 else: | 97 else: |
97 print 'Xvfb exited (code %d) after xdisplaycheck failure.' % rc | 98 print 'Xvfb exited (code %d) after xdisplaycheck failure.' % rc |
98 print 'Xvfb output:' | 99 print 'Xvfb output:' |
99 for l in xvfb_proc.communicate()[0].splitlines(): | 100 for l in xvfb_proc.communicate()[0].splitlines(): |
100 print '> %s' % l | 101 print '> %s' % l |
101 return (None, None) | 102 return (None, None, None) |
102 | 103 |
103 # Some ChromeOS tests need a window manager. | 104 # Some ChromeOS tests need a window manager. |
104 openbox_proc = subprocess.Popen('openbox', stdout=subprocess.PIPE, | 105 openbox_proc = subprocess.Popen('openbox', stdout=subprocess.PIPE, |
105 stderr=subprocess.STDOUT, env=env) | 106 stderr=subprocess.STDOUT, env=env) |
| 107 |
| 108 # Some tests need a compositing manager to make use of transparent visuals. |
| 109 xcompmgr_proc = subprocess.Popen('xcompmgr', stdout=subprocess.PIPE, |
| 110 stderr=subprocess.STDOUT, env=env) |
106 except OSError as e: | 111 except OSError as e: |
107 print >> sys.stderr, 'Failed to start Xvfb or Openbox: %s' % str(e) | 112 print >> sys.stderr, 'Failed to start Xvfb or Openbox or xcompmgr: %s' % \ |
| 113 str(e) |
108 kill(xvfb_proc) | 114 kill(xvfb_proc) |
109 kill(openbox_proc) | 115 kill(openbox_proc) |
110 return (None, None) | 116 kill(xcompmgr_proc) |
| 117 return (None, None, None) |
111 | 118 |
112 return (xvfb_proc, openbox_proc) | 119 return (xvfb_proc, openbox_proc, xcompmgr_proc) |
113 | 120 |
114 | 121 |
115 def run_executable(cmd, build_dir, env): | 122 def run_executable(cmd, build_dir, env): |
116 """Runs an executable within Xvfb on Linux or normally on other platforms. | 123 """Runs an executable within Xvfb on Linux or normally on other platforms. |
117 | 124 |
118 Returns the exit code of the specified commandline, or 1 on failure. | 125 Returns the exit code of the specified commandline, or 1 on failure. |
119 """ | 126 """ |
120 xvfb = None | 127 xvfb = None |
121 openbox = None | 128 openbox = None |
| 129 xcompmgr = None |
122 if should_start_xvfb(env): | 130 if should_start_xvfb(env): |
123 (xvfb, openbox) = start_xvfb(env, build_dir) | 131 (xvfb, openbox, xcompmgr) = start_xvfb(env, build_dir) |
124 if not xvfb or not xvfb.pid or not openbox or not openbox.pid: | 132 if not xvfb or not xvfb.pid or not openbox or not openbox.pid or \ |
| 133 not xcompmgr or not xcompmgr.pid: |
125 return 1 | 134 return 1 |
126 try: | 135 try: |
127 return test_env.run_executable(cmd, env) | 136 return test_env.run_executable(cmd, env) |
128 finally: | 137 finally: |
129 kill(xvfb) | 138 kill(xvfb) |
130 kill(openbox) | 139 kill(openbox) |
| 140 kill(xcompmgr) |
131 | 141 |
132 | 142 |
133 def main(): | 143 def main(): |
134 if len(sys.argv) < 3: | 144 if len(sys.argv) < 3: |
135 print >> sys.stderr, ( | 145 print >> sys.stderr, ( |
136 'Usage: xvfb.py [path to build_dir] [command args...]') | 146 'Usage: xvfb.py [path to build_dir] [command args...]') |
137 return 2 | 147 return 2 |
138 return run_executable(sys.argv[2:], sys.argv[1], os.environ.copy()) | 148 return run_executable(sys.argv[2:], sys.argv[1], os.environ.copy()) |
139 | 149 |
140 | 150 |
141 if __name__ == "__main__": | 151 if __name__ == "__main__": |
142 sys.exit(main()) | 152 sys.exit(main()) |
OLD | NEW |