Chromium Code Reviews| Index: testing/xvfb.py |
| =================================================================== |
| --- testing/xvfb.py (revision 282630) |
| +++ testing/xvfb.py (working copy) |
| @@ -55,26 +55,27 @@ |
| cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| except OSError: |
| print >> sys.stderr, 'Failed to run %s' % ' '.join(cmd) |
| - return 0 |
| - return proc.pid |
| + return |
| + return proc |
| def wait_for_xvfb(xdisplaycheck, env): |
| """Waits for xvfb to be fully initialized by using xdisplaycheck.""" |
| try: |
| - subprocess.check_call( |
| + _logs = subprocess.check_output( |
| [xdisplaycheck], |
| - stdout=subprocess.PIPE, |
| stderr=subprocess.STDOUT, |
| env=env) |
| except OSError: |
| print >> sys.stderr, 'Failed to load %s with cwd=%s' % ( |
| xdisplaycheck, os.getcwd()) |
| return False |
| - except subprocess.CalledProcessError: |
| + except subprocess.CalledProcessError as e: |
| print >> sys.stderr, ( |
| - 'Xvfb failed to load properly while trying to run %s' % xdisplaycheck) |
| + 'Xvfb failed to load properly (code %d) according to %s' % |
| + (e.returncode, xdisplaycheck)) |
| return False |
| + |
| return True |
| @@ -98,11 +99,22 @@ |
| if sys.platform == 'linux2': |
| # Defaults to X display 9. |
| display = ':9' |
| - pid = start_xvfb(xvfb, display) |
| - if not pid: |
| + proc = start_xvfb(xvfb, display) |
|
M-A Ruel
2014/07/14 16:54:35
I'd prefer xvfb_proc just so it's easier to scan t
Peter Mayo
2014/07/14 16:58:08
I agree. Done.
|
| + if not proc or not proc.pid: |
| return 1 |
| env['DISPLAY'] = display |
| if not wait_for_xvfb(os.path.join(build_dir, 'xdisplaycheck'), env): |
| + rc = proc.poll() |
| + if rc is None: |
| + print 'Xvfb still running, stopping.' |
| + proc.terminate() |
| + else: |
| + print 'Xvfb exited, code %d' % rc |
| + |
| + print 'Xvfb output:' |
| + for l in proc.communicate()[0].splitlines(): |
| + print '> %s' % l |
| + |
| return 3 |
| # Inhibit recursion. |
| env['_CHROMIUM_INSIDE_XVFB'] = '1' |