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

Side by Side Diff: trunk/src/testing/xvfb.py

Issue 60343005: Revert 233071 "Migrate to Openbox from IceWM (In chrome scripts)" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 1 month 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/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 the test with xvfb on linux. Runs the test normally on other platforms. 6 """Runs the test with xvfb on linux. Runs the test normally on other platforms.
7 7
8 For simplicity in gyp targets, this script just runs the test normal on 8 For simplicity in gyp targets, this script just runs the test normal on
9 non-linux platforms. 9 non-linux platforms.
10 """ 10 """
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 print >> sys.stderr, ( 75 print >> sys.stderr, (
76 'Xvfb failed to load properly while trying to run %s' % xdisplaycheck) 76 'Xvfb failed to load properly while trying to run %s' % xdisplaycheck)
77 return False 77 return False
78 return True 78 return True
79 79
80 80
81 def run_executable(cmd, build_dir, env): 81 def run_executable(cmd, build_dir, env):
82 """Runs an executable within a xvfb buffer on linux or normally on other 82 """Runs an executable within a xvfb buffer on linux or normally on other
83 platforms. 83 platforms.
84 84
85 Requires that both xvfb and openbox are installed on linux. 85 Requires that both xvfb and icewm are installed on linux.
86 86
87 Detects recursion with an environment variable and do not create a recursive X 87 Detects recursion with an environment variable and do not create a recursive X
88 buffer if present. 88 buffer if present.
89 """ 89 """
90 # First look if we are inside a display. 90 # First look if we are inside a display.
91 if env.get('_CHROMIUM_INSIDE_XVFB') == '1': 91 if env.get('_CHROMIUM_INSIDE_XVFB') == '1':
92 # No need to recurse. 92 # No need to recurse.
93 return test_env.run_executable(cmd, env) 93 return test_env.run_executable(cmd, env)
94 94
95 pid = None 95 pid = None
96 xvfb = 'Xvfb' 96 xvfb = 'Xvfb'
97 try: 97 try:
98 if sys.platform == 'linux2': 98 if sys.platform == 'linux2':
99 # Defaults to X display 9. 99 # Defaults to X display 9.
100 display = ':9' 100 display = ':9'
101 pid = start_xvfb(xvfb, display) 101 pid = start_xvfb(xvfb, display)
102 if not pid: 102 if not pid:
103 return 1 103 return 1
104 env['DISPLAY'] = display 104 env['DISPLAY'] = display
105 if not wait_for_xvfb(os.path.join(build_dir, 'xdisplaycheck'), env): 105 if not wait_for_xvfb(os.path.join(build_dir, 'xdisplaycheck'), env):
106 return 3 106 return 3
107 # Inhibit recursion. 107 # Inhibit recursion.
108 env['_CHROMIUM_INSIDE_XVFB'] = '1' 108 env['_CHROMIUM_INSIDE_XVFB'] = '1'
109 # Some ChromeOS tests need a window manager. Technically, it could be 109 # Some ChromeOS tests need a window manager. Technically, it could be
110 # another script but that would be overkill. 110 # another script but that would be overkill.
111 try: 111 try:
112 wm_cmd = ['openbox'] 112 ice_cmd = ['icewm']
113 subprocess.Popen( 113 subprocess.Popen(
114 wm_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env) 114 ice_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env)
115 except OSError: 115 except OSError:
116 print >> sys.stderr, 'Failed to run %s' % ' '.join(wm_cmd) 116 print >> sys.stderr, 'Failed to run %s' % ' '.join(ice_cmd)
117 return 1 117 return 1
118 return test_env.run_executable(cmd, env) 118 return test_env.run_executable(cmd, env)
119 finally: 119 finally:
120 if pid: 120 if pid:
121 kill(pid) 121 kill(pid)
122 122
123 123
124 def main(): 124 def main():
125 if len(sys.argv) < 3: 125 if len(sys.argv) < 3:
126 print >> sys.stderr, ( 126 print >> sys.stderr, (
127 'Usage: xvfb.py [path to build_dir] [command args...]') 127 'Usage: xvfb.py [path to build_dir] [command args...]')
128 return 2 128 return 2
129 return run_executable(sys.argv[2:], sys.argv[1], os.environ.copy()) 129 return run_executable(sys.argv[2:], sys.argv[1], os.environ.copy())
130 130
131 131
132 if __name__ == "__main__": 132 if __name__ == "__main__":
133 sys.exit(main()) 133 sys.exit(main())
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