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 os.path |
9 import platform | 10 import platform |
10 import signal | 11 import signal |
11 import subprocess | 12 import subprocess |
12 import sys | 13 import sys |
13 import threading | 14 import threading |
14 | 15 |
15 import test_env | 16 import test_env |
16 | 17 |
17 | 18 |
18 def _kill(proc, send_signal): | 19 def _kill(proc, send_signal): |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 if xvfb_script.endswith('.pyc'): | 74 if xvfb_script.endswith('.pyc'): |
74 xvfb_script = xvfb_script[:-1] | 75 xvfb_script = xvfb_script[:-1] |
75 return subprocess.call(['xvfb-run', '-a', "--server-args=-screen 0 " | 76 return subprocess.call(['xvfb-run', '-a', "--server-args=-screen 0 " |
76 "1280x800x24 -ac -nolisten tcp -dpi 96", | 77 "1280x800x24 -ac -nolisten tcp -dpi 96", |
77 xvfb_script] + cmd, env=env) | 78 xvfb_script] + cmd, env=env) |
78 else: | 79 else: |
79 return test_env.run_executable(cmd, env) | 80 return test_env.run_executable(cmd, env) |
80 | 81 |
81 | 82 |
82 def main(): | 83 def main(): |
| 84 USAGE = 'Usage: xvfb.py [command args...]' |
83 if len(sys.argv) < 2: | 85 if len(sys.argv) < 2: |
| 86 print >> sys.stderr, USAGE |
| 87 return 2 |
| 88 |
| 89 # If the user still thinks the first argument is the execution directory then |
| 90 # print a friendly error message and quit. |
| 91 if os.path.isdir(sys.argv[1]): |
84 print >> sys.stderr, ( | 92 print >> sys.stderr, ( |
85 'Usage: xvfb.py [command args...]') | 93 'Invalid command: \"%s\" is a directory' % sys.argv[1]) |
86 return 2 | 94 print >> sys.stderr, USAGE |
| 95 return 3 |
| 96 |
87 return run_executable(sys.argv[1:], os.environ.copy()) | 97 return run_executable(sys.argv[1:], os.environ.copy()) |
88 | 98 |
89 | 99 |
90 if __name__ == "__main__": | 100 if __name__ == "__main__": |
91 sys.exit(main()) | 101 sys.exit(main()) |
OLD | NEW |