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

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

Issue 3108050: Make hardware_Components test work on legacy BIOS (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git
Patch Set: modify according to reviewer's suggestion 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 # 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, sys
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',
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 block = site_vblock.unpack_verification_block(data) 276 block = site_vblock.unpack_verification_block(data)
277 ver = block['VbFirmwarePreambleHeader']['firmware_version'] 277 ver = block['VbFirmwarePreambleHeader']['firmware_version']
278 versions[index] = ver 278 versions[index] = ver
279 # we embed error reports in return value. 279 # we embed error reports in return value.
280 assert len(versions) == 2 280 assert len(versions) == 2
281 if versions[0] != versions[1]: 281 if versions[0] != versions[1]:
282 return 'A=%d, B=%d' % (versions[0], versions[1]) 282 return 'A=%d, B=%d' % (versions[0], versions[1])
283 return '%d' % (versions[0]) 283 return '%d' % (versions[0])
284 284
285 285
286 def force_get_property(self, property_name):
287 """ Returns property value or empty string on error. """
288 try:
289 return getattr(self, property_name)()
290 except error.TestError as e:
291 logging.error("Test error in getting property %s", property_name,
292 exc_info=1)
293 return ''
294 except:
295 logging.error("Exception getting property %s", property_name,
296 exc_info=1)
297 return ''
298
299
286 def pformat(self, obj): 300 def pformat(self, obj):
287 return "\n" + self._pp.pformat(obj) + "\n" 301 return "\n" + self._pp.pformat(obj) + "\n"
288 302
289 303
290 def initialize(self): 304 def initialize(self):
291 self._pp = pprint.PrettyPrinter() 305 self._pp = pprint.PrettyPrinter()
292 306
293 307
294 def run_once(self, approved_dbs='approved_components', ignored_cids=[]): 308 def run_once(self, approved_dbs='approved_components', ignored_cids=[]):
295 self._ignored = ignored_cids 309 self._ignored = ignored_cids
296 all_failures = '' 310 all_failures = ''
297 os.chdir(self.bindir) 311 os.chdir(self.bindir)
298 312
299 # approved_dbs supports shell-like filename expansion. 313 # approved_dbs supports shell-like filename expansion.
300 for db in glob.iglob(approved_dbs): 314 for db in glob.iglob(approved_dbs):
301 self._system = {} 315 self._system = {}
302 self._failures = {} 316 self._failures = {}
303 317
304 if not os.path.exists(db): 318 if not os.path.exists(db):
305 raise error.TestError('Unable to find approved db: %s' % db) 319 raise error.TestError('Unable to find approved db: %s' % db)
306 320
307 self._approved = eval(utils.read_file(db)) 321 self._approved = eval(utils.read_file(db))
308 logging.debug('Approved DB: %s', self.pformat(self._approved)) 322 logging.debug('Approved DB: %s', self.pformat(self._approved))
309 323
310 for cid in self._cids: 324 for cid in self._cids:
311 self.check_component(cid, getattr(self, 'get_' + cid)()) 325 self.check_component(cid, self.force_get_property('get_' + cid))
312 326
313 for cid in self._pci_cids: 327 for cid in self._pci_cids:
314 self.check_approved_part_id_existence(cid, type='pci') 328 self.check_approved_part_id_existence(cid, type='pci')
315 329
316 for cid in self._usb_cids: 330 for cid in self._usb_cids:
317 self.check_approved_part_id_existence(cid, type='usb') 331 self.check_approved_part_id_existence(cid, type='usb')
318 332
319 for cid in self._check_existence_cids: 333 for cid in self._check_existence_cids:
320 self.check_approved_part_id_existence(cid, type='others') 334 self.check_approved_part_id_existence(cid, type='others')
321 335
322 logging.debug('System: %s', self.pformat(self._system)) 336 logging.debug('System: %s', self.pformat(self._system))
323 337
324 outdb = os.path.join(self.resultsdir, 'system_components') 338 outdb = os.path.join(self.resultsdir, 'system_components')
325 utils.open_write_close(outdb, self.pformat(self._system)) 339 utils.open_write_close(outdb, self.pformat(self._system))
326 340
327 if self._failures: 341 if self._failures:
328 all_failures += 'Approved DB: %s' % db 342 all_failures += 'Approved DB: %s' % db
329 all_failures += self.pformat(self._failures) 343 all_failures += self.pformat(self._failures)
330 else: 344 else:
331 # If one of DBs is matched, record the hwqual_id and exit. 345 # If one of DBs is matched, record the hwqual_id and exit.
332 self.write_test_keyval( 346 self.write_test_keyval(
333 {'hwqual_id': self._approved['part_id_hwqual'][0]}) 347 {'hwqual_id': self._approved['part_id_hwqual'][0]})
334 return 348 return
335 349
336 raise error.TestFail(all_failures) 350 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