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

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

Issue 2844047: Modify power_LoadTest Extension to pull in test parameters. (Closed) Base URL: ssh://gitrw.chromium.org/autotest.git
Patch Set: Increase # loops to 11 (yay!) Created 9 years, 9 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
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2011 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, time 5 import logging, os, shutil, time
6 from autotest_lib.client.bin import utils 6 from autotest_lib.client.bin import utils
7 from autotest_lib.client.common_lib import error, site_power_status 7 from autotest_lib.client.common_lib import error, site_power_status
8 from autotest_lib.client.cros import backchannel, cros_ui, cros_ui_test 8 from autotest_lib.client.cros import backchannel, cros_ui, cros_ui_test
9 from autotest_lib.client.cros import httpd, login 9 from autotest_lib.client.cros import httpd, login
10 10
11 from autotest_lib.client.cros import flimflam_test_path 11 from autotest_lib.client.cros import flimflam_test_path
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 # record the max backlight level 105 # record the max backlight level
106 cmd = 'backlight-tool --get_max_brightness' 106 cmd = 'backlight-tool --get_max_brightness'
107 self._max_backlight = int(utils.system_output(cmd).rstrip()) 107 self._max_backlight = int(utils.system_output(cmd).rstrip())
108 self._tmp_keyvals['level_backlight_max'] = self._max_backlight 108 self._tmp_keyvals['level_backlight_max'] = self._max_backlight
109 109
110 # 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
111 # can access it 111 # can access it
112 os.system('chmod -R 755 %s' % self.bindir) 112 os.system('chmod -R 755 %s' % self.bindir)
113 113
114 # TODO (bleung) : 114 # write test parameters to the params.js file to be read by the test
115 # The new external extension packed crx means we can't pass params by 115 # extension.
116 # modifying params.js 116 self._write_ext_params()
117 # Possible solution :
118 # - modify extension to not start until we poke it from the browser.
119 # then pass through URL.
120
121 # write test parameters to the power extension's params.js file
122 # self._ext_path = os.path.join(self.bindir, 'extension')
123 # self._write_ext_params()
124 117
125 # copy external_extensions.json to known location 118 # copy external_extensions.json to known location
126 self._json_path = os.path.join(self.bindir, '..') 119 self._json_path = os.path.join(self.bindir, '..')
127 shutil.copy(os.path.join(self.bindir, 'external_extensions.json'), 120 shutil.copy(os.path.join(self.bindir, 'external_extensions.json'),
128 self._json_path) 121 self._json_path)
129 122
130 # setup a HTTP Server to listen for status updates from the power 123 # setup a HTTP Server to listen for status updates from the power
131 # test extension 124 # test extension
132 self._testServer = httpd.HTTPListener(8001, docroot=self.bindir) 125 self._testServer = httpd.HTTPListener(8001, docroot=self.bindir)
133 self._testServer.run() 126 self._testServer.run()
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 jsonfile = os.path.join(self._json_path, 'external_extensions.json') 231 jsonfile = os.path.join(self._json_path, 'external_extensions.json')
239 if os.path.exists(jsonfile): 232 if os.path.exists(jsonfile):
240 os.system('rm -f %s' % jsonfile) 233 os.system('rm -f %s' % jsonfile)
241 # re-enable powerd 234 # re-enable powerd
242 os.system('start powerd') 235 os.system('start powerd')
243 if login.logged_in(): 236 if login.logged_in():
244 login.attempt_logout() 237 login.attempt_logout()
245 # cleanup backchannel interface 238 # cleanup backchannel interface
246 if self._force_wifi: 239 if self._force_wifi:
247 backchannel.teardown() 240 backchannel.teardown()
248 241 self._testServer.stop()
249 242
250 def _percent_current_charge(self): 243 def _percent_current_charge(self):
251 return self._power_status.battery[0].charge_now * 100 / \ 244 return self._power_status.battery[0].charge_now * 100 / \
252 self._power_status.battery[0].charge_full_design 245 self._power_status.battery[0].charge_full_design
253 246
254 247
255 def _write_ext_params(self): 248 def _write_ext_params(self):
256 data = '' 249 data = ''
257 template= 'var %s = %s;\n' 250 template= 'var %s = %s;\n'
258 for k in params_dict: 251 for k in params_dict:
259 data += template % (k, getattr(self, params_dict[k])) 252 data += template % (k, getattr(self, params_dict[k]))
260 253
261 filename = os.path.join(self._ext_path, 'params.js') 254 filename = os.path.join(self.bindir, 'params.js')
262 utils.open_write_close(filename, data) 255 utils.open_write_close(filename, data)
263 256
264 logging.debug('filename ' + filename) 257 logging.debug('filename ' + filename)
265 logging.debug(data) 258 logging.debug(data)
266 259
267 260
268 def _do_wait(self, verbose, seconds, latch): 261 def _do_wait(self, verbose, seconds, latch):
269 latched = False 262 latched = False
270 low_battery = False 263 low_battery = False
271 total_time = seconds + 60 264 total_time = seconds + 60
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 # set backlight level to 40% of max 316 # set backlight level to 40% of max
324 cmd = 'backlight-tool --set_brightness %d ' % ( 317 cmd = 'backlight-tool --set_brightness %d ' % (
325 int(self._max_backlight * 0.4)) 318 int(self._max_backlight * 0.4))
326 os.system(cmd) 319 os.system(cmd)
327 320
328 # record brightness level 321 # record brightness level
329 cmd = 'backlight-tool --get_brightness' 322 cmd = 'backlight-tool --get_brightness'
330 level = int(utils.system_output(cmd).rstrip()) 323 level = int(utils.system_output(cmd).rstrip())
331 logging.info('backlight level is %d' % level) 324 logging.info('backlight level is %d' % level)
332 self._tmp_keyvals['level_backlight_current'] = level 325 self._tmp_keyvals['level_backlight_current'] = level
OLDNEW
« no previous file with comments | « client/site_tests/power_LoadTest/params.js ('k') | client/site_tests/power_LoadTest/testparams.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698