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

Side by Side Diff: client/site_tests/power_LoadTest/power_LoadTest.py

Issue 3569001: Forcibly turn display on and reset X settings at the start of each iteration. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git
Patch Set: logging backlight level per loop Created 10 years, 2 months 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 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging, os, shutil, sys, time 5 import logging, os, shutil, sys, time
6 from autotest_lib.client.bin import site_backchannel, site_ui_test, site_login 6 from autotest_lib.client.bin import site_backchannel, site_ui_test, site_login
7 from autotest_lib.client.common_lib import error, site_httpd, \ 7 from autotest_lib.client.common_lib import error, site_httpd, \
8 site_power_status, site_ui, utils 8 site_power_status, site_ui, utils
9 9
10 # Workaround so flimflam.py doesn't need to be installed in the chroot. 10 # Workaround so flimflam.py doesn't need to be installed in the chroot.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 ssid=wifi_ap, 95 ssid=wifi_ap,
96 security=wifi_sec, 96 security=wifi_sec,
97 passphrase=wifi_pw, 97 passphrase=wifi_pw,
98 mode='managed')[0]: 98 mode='managed')[0]:
99 raise error.TestError('Could not connect to WiFi network.') 99 raise error.TestError('Could not connect to WiFi network.')
100 100
101 if check_network and site_backchannel.is_network_iface_running('eth0'): 101 if check_network and site_backchannel.is_network_iface_running('eth0'):
102 raise error.TestError( 102 raise error.TestError(
103 'Ethernet interface is active. Please remove Ethernet cable') 103 'Ethernet interface is active. Please remove Ethernet cable')
104 104
105 # TODO (snanda): 105 # record the max backlight level
106 # - set brightness level
107 # - turn off suspend on idle (not implemented yet in Chrome OS)
108
109 # record the current and max backlight levels
110 cmd = 'backlight-tool --get_max_brightness' 106 cmd = 'backlight-tool --get_max_brightness'
111 self._tmp_keyvals['level_backlight_max'] = int( 107 self._max_backlight = int(utils.system_output(cmd).rstrip())
112 utils.system_output(cmd).rstrip()) 108 self._tmp_keyvals['level_backlight_max'] = self._max_backlight
113
114 cmd = 'backlight-tool --get_brightness'
115 self._tmp_keyvals['level_backlight_current'] = int(
116 utils.system_output(cmd).rstrip())
117
118 # disable screen locker and powerd
119 os.system('stop screen-locker')
120 os.system('stop powerd')
121 109
122 # fix up file perms for the power test extension so that chrome 110 # fix up file perms for the power test extension so that chrome
123 # can access it 111 # can access it
124 os.system('chmod -R 755 %s' % self.bindir) 112 os.system('chmod -R 755 %s' % self.bindir)
125 113
126
127 # TODO (bleung) : 114 # TODO (bleung) :
128 # The new external extension packed crx means we can't pass params by 115 # The new external extension packed crx means we can't pass params by
129 # modifying params.js 116 # modifying params.js
130 # Possible solution : 117 # Possible solution :
131 # - modify extension to not start until we poke it from the browser. 118 # - modify extension to not start until we poke it from the browser.
132 # then pass through URL. 119 # then pass through URL.
133 120
134 # write test parameters to the power extension's params.js file 121 # write test parameters to the power extension's params.js file
135 # self._ext_path = os.path.join(self.bindir, 'extension') 122 # self._ext_path = os.path.join(self.bindir, 'extension')
136 # self._write_ext_params() 123 # self._write_ext_params()
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 155
169 for i in range(self._loop_count): 156 for i in range(self._loop_count):
170 # the power test extension will report its status here 157 # the power test extension will report its status here
171 latch = self._testServer.add_wait_url('/status') 158 latch = self._testServer.add_wait_url('/status')
172 159
173 if site_login.logged_in(): 160 if site_login.logged_in():
174 site_login.attempt_logout() 161 site_login.attempt_logout()
175 # the act of logging in will launch chrome with external extension. 162 # the act of logging in will launch chrome with external extension.
176 self.login(self.username, self.password) 163 self.login(self.username, self.password)
177 164
165 # stop powerd
166 os.system('stop powerd')
167
168 # reset X settings since X gets restarted upon login
169 self._do_xset()
170
171 # reset backlight level since powerd might've modified it
172 # based on ambient light
173 self._set_backlight_level()
174
178 low_battery = self._do_wait(self._verbose, self._loop_time, 175 low_battery = self._do_wait(self._verbose, self._loop_time,
179 latch) 176 latch)
180 177
181 if self._verbose: 178 if self._verbose:
182 logging.debug('loop %d completed' % i) 179 logging.debug('loop %d completed' % i)
183 180
184 if low_battery: 181 if low_battery:
185 logging.info('Exiting due to low battery') 182 logging.info('Exiting due to low battery')
186 break 183 break
187 184
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 231
235 self.write_perf_keyval(keyvals) 232 self.write_perf_keyval(keyvals)
236 233
237 234
238 def cleanup(self): 235 def cleanup(self):
239 # remove json file after test to stop external extension launch. 236 # remove json file after test to stop external extension launch.
240 if self._json_path: 237 if self._json_path:
241 jsonfile = os.path.join(self._json_path, 'external_extensions.json') 238 jsonfile = os.path.join(self._json_path, 'external_extensions.json')
242 if os.path.exists(jsonfile): 239 if os.path.exists(jsonfile):
243 os.system('rm -f %s' % jsonfile) 240 os.system('rm -f %s' % jsonfile)
244 # re-enable screen locker and powerd. This also re-enables dpms. 241 # re-enable powerd
245 os.system('start powerd') 242 os.system('start powerd')
246 os.system('start screen-locker')
247 if site_login.logged_in(): 243 if site_login.logged_in():
248 site_login.attempt_logout() 244 site_login.attempt_logout()
249 245
250 246
251 def _percent_current_charge(self): 247 def _percent_current_charge(self):
252 return self._power_status.battery[0].charge_now * 100 / \ 248 return self._power_status.battery[0].charge_now * 100 / \
253 self._power_status.battery[0].charge_full_design 249 self._power_status.battery[0].charge_full_design
254 250
255 251
256 def _write_ext_params(self): 252 def _write_ext_params(self):
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 for e in form_data: 295 for e in form_data:
300 key = 'ext_' + e 296 key = 'ext_' + e
301 if key in self._tmp_keyvals: 297 if key in self._tmp_keyvals:
302 self._tmp_keyvals[key] += form_data[e] 298 self._tmp_keyvals[key] += form_data[e]
303 else: 299 else:
304 self._tmp_keyvals[key] = form_data[e] 300 self._tmp_keyvals[key] = form_data[e]
305 else: 301 else:
306 logging.debug("Didn't get status back from power extension") 302 logging.debug("Didn't get status back from power extension")
307 303
308 return low_battery 304 return low_battery
305
306
307 def _do_xset(self):
308 XSET = 'LD_LIBRARY_PATH=/usr/local/lib xset'
309 # Disable X screen saver
310 site_ui.xsystem('%s s 0 0' % XSET)
311 # Disable DPMS Standby/Suspend/Off
312 site_ui.xsystem('%s dpms 0 0 0' % XSET)
313 # Force monitor on
314 site_ui.xsystem('%s dpms force on' % XSET)
315 # Save off X settings
316 site_ui.xsystem('%s q' % XSET)
317
318
319 def _set_backlight_level(self):
320 # set backlight level to 40% of max
321 cmd = 'backlight-tool --set_brightness %d ' % (
322 int(self._max_backlight * 0.4))
323 os.system(cmd)
324
325 # record brightness level
326 cmd = 'backlight-tool --get_brightness'
327 level = int(utils.system_output(cmd).rstrip())
328 logging.info('backlight level is %d' % level)
329 self._tmp_keyvals['level_backlight_current'] = level
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