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

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

Issue 3053016: Not check versions of BIOS. Checking hash is enough. (Closed) Base URL: ssh://gitrw.chromium.org/autotest.git
Patch Set: grep and ignore_status=True Created 10 years, 5 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
« no previous file with comments | « client/site_tests/hardware_Components/approved_components ('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
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 glob, hashlib, logging, os, pprint, re 5 import glob, hashlib, logging, os, pprint, re
6 from autotest_lib.client.bin import test, utils 6 from autotest_lib.client.bin import test, utils
7 from autotest_lib.client.common_lib import error 7 from autotest_lib.client.common_lib import error
8 from autotest_lib.client.common_lib import flashrom_util 8 from autotest_lib.client.common_lib import flashrom_util
9 from autotest_lib.client.common_lib import site_vblock 9 from autotest_lib.client.common_lib import site_vblock
10 10
11 11
12 class hardware_Components(test.test): 12 class hardware_Components(test.test):
13 version = 1 13 version = 1
14 _cids = [ 14 _cids = [
15 'hash_ro_firmware', 15 'hash_ro_firmware',
16 'part_id_audio_codec', 16 'part_id_audio_codec',
17 'part_id_bios',
18 'part_id_cpu', 17 'part_id_cpu',
19 'part_id_display_panel', 18 'part_id_display_panel',
20 'part_id_embedded_controller', 19 'part_id_embedded_controller',
21 'part_id_ethernet', 20 'part_id_ethernet',
22 'part_id_flash_chip', 21 'part_id_flash_chip',
23 'part_id_hwqual', 22 'part_id_hwqual',
24 'part_id_storage', 23 'part_id_storage',
25 'part_id_wireless', 24 'part_id_wireless',
25 'vendor_id_bios',
26 'vendor_id_touchpad', 26 'vendor_id_touchpad',
27 'ver_rw_firmware', 27 'ver_rw_firmware',
28 ] 28 ]
29 _pci_cids = [ 29 _pci_cids = [
30 'part_id_chipset', 30 'part_id_chipset',
31 'part_id_usb_hosts', 31 'part_id_usb_hosts',
32 'part_id_vga', 32 'part_id_vga',
33 ] 33 ]
34 _usb_cids = [ 34 _usb_cids = [
35 'part_id_bluetooth', 35 'part_id_bluetooth',
(...skipping 19 matching lines...) Expand all
55 55
56 app_cids = self._approved[comp_key] 56 app_cids = self._approved[comp_key]
57 57
58 if '*' in app_cids: 58 if '*' in app_cids:
59 return 59 return
60 60
61 if not comp_id in app_cids: 61 if not comp_id in app_cids:
62 self._failures[comp_key] = [ comp_id ] 62 self._failures[comp_key] = [ comp_id ]
63 63
64 64
65 def check_approved_part_id_existence(self, cid, type):
66 """
67 Check if there are matching devices on the system.
68 Parameter type should be one of 'pci', 'usb', or 'others'.
69 """
70 if cid in self._ignored:
71 return
72
73 if not self._approved.has_key(cid):
74 raise error.TestFail('%s missing from database' % cid)
75
76 approved_devices = self._approved[cid]
77 if '*' in approved_devices:
78 self._system[cid] = [ '*' ]
79 return
80
81 for device in approved_devices:
82 present = False
83 if type in ['pci', 'usb']:
84 try:
85 cmd = '/usr/sbin/ls' + type + ' -d %s'
86 output = utils.system_output(cmd % device)
87 # If it shows something, means found.
88 if output:
89 present = True
90 except:
91 pass
92 elif type == 'others':
93 present = getattr(self, 'check_existence_' + cid)(device)
94
95 if present:
96 self._system[cid] = [ device ]
97 return
98
99 self._failures[cid] = [ 'No match' ]
100
101
102 def check_existence_part_id_chrontel(self, part_id):
103 if part_id == self._not_present:
104 return True
105
106 if part_id == 'ch7036':
107 grep_cmd = 'grep i2c_dev /proc/modules'
108 i2c_loaded = (utils.system(grep_cmd, ignore_status=True) == 0)
109 if not i2c_loaded:
110 utils.system('modprobe i2c_dev')
111
112 probe_cmd = 'ch7036_monitor -p'
113 present = (utils.system(probe_cmd, ignore_status=True) == 0)
114
115 if not i2c_loaded:
116 utils.system('modprobe -r i2c_dev')
117 return present
118
119 return False
120
121
65 def get_part_id_audio_codec(self): 122 def get_part_id_audio_codec(self):
66 cmd = 'grep -R Codec: /proc/asound/* | head -n 1 | sed s/.\*Codec://' 123 cmd = 'grep -R Codec: /proc/asound/* | head -n 1 | sed s/.\*Codec://'
67 part_id = utils.system_output(cmd).strip() 124 part_id = utils.system_output(cmd).strip()
68 return part_id 125 return part_id
69 126
70 127
71 def get_part_id_bios(self):
72 cmd = ('dmidecode | grep -A 2 "BIOS Information" | tail -2 '
73 '| sed "s/.*: //" | tr "\n" " "')
74 part_id = utils.system_output(cmd).strip()
75
76 cmd = ('dmidecode | grep "\(BIOS\|Firmware\) Revision" | sed "s/\t//" '
77 '| sed "s/Revision/Rev/"')
78 rev_num = ', '.join(utils.system_output(cmd).split('\n'))
79
80 if rev_num:
81 part_id = part_id + ' (' + rev_num + ')'
82
83 return part_id
84
85
86 def get_part_id_cpu(self): 128 def get_part_id_cpu(self):
87 cmd = 'grep -m 1 \'model name\' /proc/cpuinfo | sed s/.\*://' 129 cmd = 'grep -m 1 \'model name\' /proc/cpuinfo | sed s/.\*://'
88 part_id = utils.system_output(cmd).strip() 130 part_id = utils.system_output(cmd).strip()
89 return part_id 131 return part_id
90 132
91 133
92 def get_part_id_display_panel(self): 134 def get_part_id_display_panel(self):
93 cmd = ('get-edid | parse-edid | grep ModelName | ' 135 cmd = ('get-edid | parse-edid | grep ModelName | '
94 'sed \'s/^.*ModelName "\(.*\)"$/\\1/\'') 136 'sed \'s/^.*ModelName "\(.*\)"$/\\1/\'')
95 part_id = utils.system_output(cmd).strip() 137 part_id = utils.system_output(cmd).strip()
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 def get_part_id_wireless(self): 201 def get_part_id_wireless(self):
160 """ 202 """
161 Returns a colon delimited string where the first section 203 Returns a colon delimited string where the first section
162 is the vendor id and the second section is the device id. 204 is the vendor id and the second section is the device id.
163 """ 205 """
164 part_id = utils.read_one_line('/sys/class/net/wlan0/device/device') 206 part_id = utils.read_one_line('/sys/class/net/wlan0/device/device')
165 vendor_id = utils.read_one_line('/sys/class/net/wlan0/device/vendor') 207 vendor_id = utils.read_one_line('/sys/class/net/wlan0/device/vendor')
166 return "%s:%s" % (vendor_id.replace('0x',''), part_id.replace('0x','')) 208 return "%s:%s" % (vendor_id.replace('0x',''), part_id.replace('0x',''))
167 209
168 210
169 def check_approved_part_id_existence(self, cid, type): 211 def get_vendor_id_bios(self):
170 """ 212 cmd = ('dmidecode | grep -A 1 "BIOS Information" | grep Vendor: '
171 Check if there are matching devices on the system. 213 '| sed "s/.*Vendor: //"')
172 Parameter type should be one of 'pci', 'usb', or 'others'. 214 part_id = utils.system_output(cmd, ignore_status=True).strip()
173 """ 215 return part_id
174 if cid in self._ignored:
175 return
176
177 if not self._approved.has_key(cid):
178 raise error.TestFail('%s missing from database' % cid)
179
180 approved_devices = self._approved[cid]
181 if '*' in approved_devices:
182 self._system[cid] = [ '*' ]
183 return
184
185 for device in approved_devices:
186 present = False
187 if type in ['pci', 'usb']:
188 try:
189 cmd = '/usr/sbin/ls' + type + ' -d %s'
190 output = utils.system_output(cmd % device)
191 # If it shows something, means found.
192 if output:
193 present = True
194 except:
195 pass
196 elif type == 'others':
197 present = getattr(self, 'check_existence_' + cid)(device)
198
199 if present:
200 self._system[cid] = [ device ]
201 return
202
203 self._failures[cid] = [ 'No match' ]
204
205
206 def check_existence_part_id_chrontel(self, part_id):
207 if part_id == self._not_present:
208 return True
209
210 if part_id == 'ch7036':
211 grep_cmd = 'grep i2c_dev /proc/modules'
212 i2c_loaded = (utils.system(grep_cmd, ignore_status=True) == 0)
213 if not i2c_loaded:
214 utils.system('modprobe i2c_dev')
215
216 probe_cmd = 'ch7036_monitor -p'
217 present = (utils.system(probe_cmd, ignore_status=True) == 0)
218
219 if not i2c_loaded:
220 utils.system('modprobe -r i2c_dev')
221 return present
222
223 return False
224 216
225 217
226 def get_vendor_id_touchpad(self): 218 def get_vendor_id_touchpad(self):
227 cmd = 'grep -i Touchpad /proc/bus/input/devices | sed s/.\*=//' 219 cmd = 'grep -i Touchpad /proc/bus/input/devices | sed s/.\*=//'
228 part_id = utils.system_output(cmd).strip('"') 220 part_id = utils.system_output(cmd).strip('"')
229 return part_id 221 return part_id
230 222
231 223
232 def get_vendor_id_webcam(self): 224 def get_vendor_id_webcam(self):
233 cmd = 'cat /sys/class/video4linux/video0/name' 225 cmd = 'cat /sys/class/video4linux/video0/name'
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 if self._failures: 327 if self._failures:
336 all_failures += 'Approved DB: %s' % db 328 all_failures += 'Approved DB: %s' % db
337 all_failures += self.pformat(self._failures) 329 all_failures += self.pformat(self._failures)
338 else: 330 else:
339 # If one of DBs is matched, record the hwqual_id and exit. 331 # If one of DBs is matched, record the hwqual_id and exit.
340 self.write_test_keyval( 332 self.write_test_keyval(
341 {'hwqual_id': self._approved['part_id_hwqual'][0]}) 333 {'hwqual_id': self._approved['part_id_hwqual'][0]})
342 return 334 return
343 335
344 raise error.TestFail(all_failures) 336 raise error.TestFail(all_failures)
OLDNEW
« no previous file with comments | « client/site_tests/hardware_Components/approved_components ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698