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

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

Issue 6658005: Add memory size check (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@0.11.241.B
Patch Set: . 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 | 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 firmware_hash 5 import firmware_hash
6 import glob 6 import glob
7 import logging 7 import logging
8 import os 8 import os
9 import pprint 9 import pprint
10 import re 10 import re
(...skipping 14 matching lines...) Expand all
25 # - USB: USB devices; 25 # - USB: USB devices;
26 # - probable: returns existed or not by given some pre-defined choices; 26 # - probable: returns existed or not by given some pre-defined choices;
27 # - not test: only data, don't test them. 27 # - not test: only data, don't test them.
28 _enumerable_cids = [ 28 _enumerable_cids = [
29 'data_display_geometry', 29 'data_display_geometry',
30 'hash_ec_firmware', 30 'hash_ec_firmware',
31 'hash_ro_firmware', 31 'hash_ro_firmware',
32 'part_id_audio_codec', 32 'part_id_audio_codec',
33 'part_id_cpu', 33 'part_id_cpu',
34 'part_id_display_panel', 34 'part_id_display_panel',
35 'part_id_dram',
35 'part_id_embedded_controller', 36 'part_id_embedded_controller',
36 'part_id_ethernet', 37 'part_id_ethernet',
37 'part_id_flash_chip', 38 'part_id_flash_chip',
38 'part_id_ec_flash_chip', 39 'part_id_ec_flash_chip',
39 'part_id_hwqual', 40 'part_id_hwqual',
40 'part_id_storage', 41 'part_id_storage',
41 'part_id_tpm', 42 'part_id_tpm',
42 'part_id_wireless', 43 'part_id_wireless',
43 'vendor_id_touchpad', 44 'vendor_id_touchpad',
44 'version_rw_firmware', 45 'version_rw_firmware',
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 vendor_file = '/sys/class/net/eth0/device/vendor' 208 vendor_file = '/sys/class/net/eth0/device/vendor'
208 part_file = '/sys/class/net/eth0/device/device' 209 part_file = '/sys/class/net/eth0/device/device'
209 if os.path.exists(part_file) and os.path.exists(vendor_file): 210 if os.path.exists(part_file) and os.path.exists(vendor_file):
210 vendor_id = utils.read_one_line(vendor_file).replace('0x', '') 211 vendor_id = utils.read_one_line(vendor_file).replace('0x', '')
211 part_id = utils.read_one_line(part_file).replace('0x', '') 212 part_id = utils.read_one_line(part_file).replace('0x', '')
212 return "%s:%s" % (vendor_id, part_id) 213 return "%s:%s" % (vendor_id, part_id)
213 else: 214 else:
214 return self._not_present 215 return self._not_present
215 216
216 217
218 def get_part_id_dram(self):
219 grep_cmd = 'grep i2c_dev /proc/modules'
220 i2c_loaded = (utils.system(grep_cmd, ignore_status=True) == 0)
221 if not i2c_loaded:
222 utils.system('modprobe -r i2c_dev')
223 cmd = ('mosys -l memory spd print geometry | '
224 'grep size_mb | cut -f2 -d"|"')
225 part_id = utils.system_output(cmd).strip()
226 if part_id != '':
227 return part_id
228 else:
229 return self._not_present
230
231
217 def get_part_id_flash_chip(self): 232 def get_part_id_flash_chip(self):
218 # example output: 233 # example output:
219 # Found chip "Winbond W25x16" (2048 KB, FWH) at physical address 0xfe 234 # Found chip "Winbond W25x16" (2048 KB, FWH) at physical address 0xfe
220 parts = [] 235 parts = []
221 lines = utils.system_output('flashrom -V -p internal:bus=spi', 236 lines = utils.system_output('flashrom -V -p internal:bus=spi',
222 ignore_status=True).split('\n') 237 ignore_status=True).split('\n')
223 for line in lines: 238 for line in lines:
224 match = re.search(r'Found chip "(.*)" .* at physical address ', 239 match = re.search(r'Found chip "(.*)" .* at physical address ',
225 line) 240 line)
226 if match: 241 if match:
227 parts.append(match.group(1)) 242 parts.append(match.group(1))
228 part_id = ", ".join(parts) 243 part_id = ", ".join(parts)
229 return part_id 244 return part_id
230 245
Tammo Spalink 2011/03/11 07:59:58 while you are fixing ws -- how about adding one he
Nick Sanders 2011/03/11 09:40:57 Done.
231 def get_part_id_ec_flash_chip(self): 246 def get_part_id_ec_flash_chip(self):
232 # example output: 247 # example output:
233 # Found chip "Winbond W25x10" (128 KB, SPI) at physical address ... 248 # Found chip "Winbond W25x10" (128 KB, SPI) at physical address ...
234 parts = [] 249 parts = []
235 # Undo BBS register after call. 250 # Undo BBS register after call.
236 lines = utils.system_output('flashrom -V -p internal:bus=lpc; ' 251 lines = utils.system_output('flashrom -V -p internal:bus=lpc; '
237 'flashrom -p internal:bus=spi', 252 'flashrom -p internal:bus=spi',
238 ignore_status=True).split('\n') 253 ignore_status=True).split('\n')
239 for line in lines: 254 for line in lines:
240 match = re.search(r'Found chip "(.*)" .* at physical address ', 255 match = re.search(r'Found chip "(.*)" .* at physical address ',
241 line) 256 line)
242 if match: 257 if match:
243 parts.append(match.group(1)) 258 parts.append(match.group(1))
244 part_id = ", ".join(parts) 259 part_id = ", ".join(parts)
245 return part_id 260 return part_id
246 261
Tammo Spalink 2011/03/11 07:59:58 and here
Nick Sanders 2011/03/11 09:40:57 Done.
247 def get_part_id_hwqual(self): 262 def get_part_id_hwqual(self):
248 hwid_file = '/sys/devices/platform/chromeos_acpi/HWID' 263 hwid_file = '/sys/devices/platform/chromeos_acpi/HWID'
249 if os.path.exists(hwid_file): 264 if os.path.exists(hwid_file):
250 part_id = utils.read_one_line(hwid_file) 265 part_id = utils.read_one_line(hwid_file)
251 return part_id 266 return part_id
252 else: 267 else:
253 return self._not_present 268 return self._not_present
254 269
Tammo Spalink 2011/03/11 07:59:58 and keeping this :)
Nick Sanders 2011/03/11 09:40:57 Done.
255
256 def get_part_id_storage(self): 270 def get_part_id_storage(self):
257 cmd = ('cd $(find /sys/devices -name sda)/../..; ' 271 cmd = ('cd $(find /sys/devices -name sda)/../..; '
258 'cat vendor model | tr "\n" " " | sed "s/ \+/ /g"') 272 'cat vendor model | tr "\n" " " | sed "s/ \+/ /g"')
259 part_id = utils.system_output(cmd).strip() 273 part_id = utils.system_output(cmd).strip()
260 return part_id 274 return part_id
261 275
262 276
263 def get_part_id_tpm(self): 277 def get_part_id_tpm(self):
264 """ 278 """
265 Returns Manufacturer_info : Chip_Version 279 Returns Manufacturer_info : Chip_Version
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 data = utils.system_output(detect_program, ignore_status=True) 316 data = utils.system_output(detect_program, ignore_status=True)
303 properties = dict(map(str.strip, line.split('=', 1)) 317 properties = dict(map(str.strip, line.split('=', 1))
304 for line in data.splitlines() if '=' in line) 318 for line in data.splitlines() if '=' in line)
305 model = properties.get(model_string_str, 'UnknownModel') 319 model = properties.get(model_string_str, 'UnknownModel')
306 firmware_id = properties.get(firmware_id_str, 'UnknownFWID') 320 firmware_id = properties.get(firmware_id_str, 'UnknownFWID')
307 # The pattern " on xxx Port" may vary by the detection approach, 321 # The pattern " on xxx Port" may vary by the detection approach,
308 # so we need to strip it. 322 # so we need to strip it.
309 model = re.sub(' on [^ ]* [Pp]ort$', '', model) 323 model = re.sub(' on [^ ]* [Pp]ort$', '', model)
310 # Format: Model #FirmwareId 324 # Format: Model #FirmwareId
311 part_id = '%s #%s' % (model, firmware_id) 325 part_id = '%s #%s' % (model, firmware_id)
326
Tammo Spalink 2011/03/11 07:59:58 did you mean to add this?
Nick Sanders 2011/03/11 09:40:57 Done.
312 return part_id 327 return part_id
313 328
314 329
315 def get_vendor_id_touchpad(self): 330 def get_vendor_id_touchpad(self):
316 # First, try to use closed-source method to probe touch pad 331 # First, try to use closed-source method to probe touch pad
317 part_id = self.get_closed_vendor_id_touchpad('Synaptics') 332 part_id = self.get_closed_vendor_id_touchpad('Synaptics')
318 if part_id != '': 333 if part_id != '':
319 return part_id 334 return part_id
320 # If the closed-source method above fails to find vendor infomation, 335 # If the closed-source method above fails to find vendor infomation,
321 # try an open-source method. 336 # try an open-source method.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 else: 447 else:
433 raise error.TestError('The ignored cid %s is not defined' % cid) 448 raise error.TestError('The ignored cid %s is not defined' % cid)
434 self._not_test_cids.append(cid) 449 self._not_test_cids.append(cid)
435 450
436 451
437 def read_approved_from_file(self, filename): 452 def read_approved_from_file(self, filename):
438 approved = eval(utils.read_file(filename)) 453 approved = eval(utils.read_file(filename))
439 for group in self._to_be_tested_cids_groups + [ self._not_test_cids ]: 454 for group in self._to_be_tested_cids_groups + [ self._not_test_cids ]:
440 for cid in group: 455 for cid in group:
441 if cid not in approved: 456 if cid not in approved:
442 raise error.TestFail('%s missing from database' % cid) 457 # If we don't have any listing for this type of part in HWID ,
Tammo Spalink 2011/03/11 07:59:58 exceeded 80 cols here
Nick Sanders 2011/03/11 09:40:57 Done.
458 # it's not required.
459 factory.log('Bypassing unlisted cid %s' % cid)
460 approved[cid] = '*'
443 return approved 461 return approved
444 462
445 463
446 def select_correct_dbs(self, approved_dbs): 464 def select_correct_dbs(self, approved_dbs):
447 os.chdir(self.bindir) 465 os.chdir(self.bindir)
448 id_hwqual = None 466 id_hwqual = None
449 try: 467 try:
450 id_hwqual = factory.get_shared_data('part_id_hwqual') 468 id_hwqual = factory.get_shared_data('part_id_hwqual')
451 except Exception, e: 469 except Exception, e:
452 # hardware_Components may run without factory environment 470 # hardware_Components may run without factory environment
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 # hardware_Components may run without factory environment 544 # hardware_Components may run without factory environment
527 factory.log('Failed setting shared data, ignored: %s' % 545 factory.log('Failed setting shared data, ignored: %s' %
528 repr(e)) 546 repr(e))
529 return 547 return
530 548
531 if only_cardreader_failed: 549 if only_cardreader_failed:
532 all_failures = ('You may forget to insert an SD card.\n' + 550 all_failures = ('You may forget to insert an SD card.\n' +
533 all_failures) 551 all_failures)
534 552
535 raise error.TestFail(all_failures) 553 raise error.TestFail(all_failures)
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