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

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

Issue 6576056: Create power_ARMSettings test (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git
Patch Set: Fixed comments Created 9 years, 10 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 | « client/site_tests/power_ARMSettings/control ('k') | 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
(Empty)
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
3 # found in the LICENSE file.
4
5 import glob, logging, os, re
6 from autotest_lib.client.bin import test
7 from autotest_lib.client.common_lib import error, site_power_status, utils
8
9 class power_ARMSettings(test.test):
10 version = 1
11
12 def run_once(self):
13 if not self._check_cpu_type():
14 raise error.TestNAError('Unsupported CPU')
15
16 power_status = site_power_status.get_status()
17 if power_status.linepower[0].online:
18 logging.info('AC Power is online')
19 self._on_ac = True
20 else:
21 logging.info('AC Power is offline')
22 self._on_ac = False
23
24 failures = ''
25
26 fail_count = self._verify_wifi_power_settings()
27 if fail_count:
28 failures += 'wifi_failures(%d) ' % fail_count
29
30 fail_count = self._verify_usb_power_settings()
31 if fail_count:
32 failures += 'usb_failures(%d) ' % fail_count
33
34 if failures:
35 raise error.TestFail(failures)
36
37
38 def _check_cpu_type(self):
39 cpuinfo = utils.read_file('/proc/cpuinfo')
40
41 # Look for ARM
42 match = re.search(r'ARMv[4-7]', cpuinfo)
43 if match:
44 return True
45
46 logging.info(cpuinfo)
47 return False
48
49
50 def _verify_wifi_power_settings(self):
51 if self._on_ac:
52 expected_state = 'off'
53 else:
54 expected_state = 'on'
55
56 iwconfig_out = utils.system_output('iwconfig', retain_output=True)
57 match = re.search(r'Power Management:(.*)', iwconfig_out)
58 if match and match.group(1) == expected_state:
59 return 0
60
61 logging.info(iwconfig_out)
62 return 1
63
64
65 def _verify_usb_power_settings(self):
66 if self._on_ac:
67 expected_state = 'on'
68 else:
69 expected_state = 'auto'
70
71 dirs_path = '/sys/bus/usb/devices/*/power'
72 dirs = glob.glob(dirs_path)
73 if not dirs:
74 logging.info('USB power path not found')
75 return 1
76
77 errors = 0
78 for dir in dirs:
79 level_file = os.path.join(dir, 'level')
80 if not os.path.exists(level_file):
81 logging.info('USB: power level file not found for %s', dir)
82 continue
83
84 out = utils.read_one_line(level_file)
85 logging.debug('USB: path set to %s for %s',
86 out, level_file)
87 if out != expected_state:
88 logging.info(level_file)
89 errors += 1
90
91 return errors
OLDNEW
« no previous file with comments | « client/site_tests/power_ARMSettings/control ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698