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

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

Issue 3331008: Add check if EC is supported for factory_Leds test (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git
Patch Set: Created 10 years, 3 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 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 # 2 #
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 7
8 # DESCRIPTION : 8 # DESCRIPTION :
9 # 9 #
10 # This is a factory test to test the LEDs (wifi, battery, etc). 10 # This is a factory test to test the LEDs (wifi, battery, etc).
11 11
12 12
13 import cairo 13 import cairo
14 import gtk 14 import gtk
15 import pango 15 import pango
16 import os 16 import os
17 import subprocess 17 import subprocess
18 import sys 18 import sys
19 import re
19 20
20 from cmath import pi 21 from cmath import pi
21 from gtk import gdk 22 from gtk import gdk
22 23
23 from autotest_lib.client.bin import factory 24 from autotest_lib.client.bin import factory
24 from autotest_lib.client.bin import factory_ui_lib as ful 25 from autotest_lib.client.bin import factory_ui_lib as ful
25 from autotest_lib.client.bin import test 26 from autotest_lib.client.bin import test
27 from autotest_lib.client.bin import utils
26 from autotest_lib.client.common_lib import error 28 from autotest_lib.client.common_lib import error
27 29
28 30
29 _LABEL_STATUS_SIZE = (140, 30) 31 _LABEL_STATUS_SIZE = (140, 30)
30 _LABEL_FONT = pango.FontDescription('courier new condensed 16') 32 _LABEL_FONT = pango.FontDescription('courier new condensed 16')
31 _LABEL_FG = gtk.gdk.color_parse('light green') 33 _LABEL_FG = gtk.gdk.color_parse('light green')
32 _LABEL_UNTESTED_FG = gtk.gdk.color_parse('grey40') 34 _LABEL_UNTESTED_FG = gtk.gdk.color_parse('grey40')
33 35
34 _PATTERN_LABEL_STR = 'pattern / 圖樣: ' 36 _PATTERN_LABEL_STR = 'pattern / 圖樣: '
35 37
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 elif self._current_pattern.startswith("shift") and \ 167 elif self._current_pattern.startswith("shift") and \
166 event.keyval == gtk.keysyms.Shift_L: 168 event.keyval == gtk.keysyms.Shift_L:
167 self._shift_cnt += 1 169 self._shift_cnt += 1
168 self._pattern_da.queue_draw() 170 self._pattern_da.queue_draw()
169 return True 171 return True
170 172
171 def register_callbacks(self, window): 173 def register_callbacks(self, window):
172 window.connect('key-release-event', self.key_release_callback) 174 window.connect('key-release-event', self.key_release_callback)
173 window.add_events(gdk.KEY_RELEASE_MASK) 175 window.add_events(gdk.KEY_RELEASE_MASK)
174 176
177 def _get_embedded_controller_vendor(self):
178 # example output of superiotool:
179 # Found Nuvoton WPCE775x (id=0x05, rev=0x02) at 0x2e
180 re_vendor = re.compile(r'Found (\w*)')
181 vendor = []
182 res = utils.system_output('superiotool', ignore_status=True).split('\n')
183 for line in res:
184 match = re_vendor.search(line)
185 if match:
186 vendor.append(match.group(1))
187 return vendor
188
175 def run_once(self, led_ctl_path=None): 189 def run_once(self, led_ctl_path=None):
176 190
177 factory.log('%s run_once' % self.__class__) 191 factory.log('%s run_once' % self.__class__)
178 192
193 ec_vendor = self._get_embedded_controller_vendor()
194 if len(ec_vendor) == 0:
195 raise error.TestNAError('No embedded controller vendor found')
196 if 'Nuvoton' not in ec_vendor:
197 raise error.TestNAError('Currently not supported embedded controller s: %s' %
198 ', '.join(ec_vendor))
199
179 self._led_ctl_path = led_ctl_path 200 self._led_ctl_path = led_ctl_path
180 if not os.path.exists(self._led_ctl_path): 201 if not os.path.exists(self._led_ctl_path):
181 raise error.TestNAError('Command %s does not exist' % 202 raise error.TestNAError('Command %s does not exist' %
182 self._led_ctl_path) 203 self._led_ctl_path)
183 204
184 self._shift_color = ful.BLACK 205 self._shift_color = ful.BLACK
185 self._shift_cnt = 0 206 self._shift_cnt = 0
186 207
187 os.chdir(self.srcdir) 208 os.chdir(self.srcdir)
188 try: 209 try:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 cleanup_callback=self.quit) 256 cleanup_callback=self.quit)
236 257
237 failed_set = set(name for name, status in self._status_map.items() 258 failed_set = set(name for name, status in self._status_map.items()
238 if status is not ful.PASSED) 259 if status is not ful.PASSED)
239 if failed_set: 260 if failed_set:
240 raise error.TestFail('Some patterns failed\n' \ 261 raise error.TestFail('Some patterns failed\n' \
241 '以下圖樣測試未通過: %s' % 262 '以下圖樣測試未通過: %s' %
242 ', '.join(failed_set)) 263 ', '.join(failed_set))
243 264
244 factory.log('%s run_once finished' % self.__class__) 265 factory.log('%s run_once finished' % self.__class__)
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