| OLD | NEW |
| 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, sys | 5 import glob, hashlib, logging, os, pprint, re, sys |
| 6 from autotest_lib.client.bin import factory |
| 6 from autotest_lib.client.bin import test, utils | 7 from autotest_lib.client.bin import test, utils |
| 7 from autotest_lib.client.common_lib import error | 8 from autotest_lib.client.common_lib import error |
| 8 from autotest_lib.client.common_lib import flashrom_util | 9 from autotest_lib.client.common_lib import flashrom_util |
| 9 from autotest_lib.client.common_lib import site_vblock | 10 from autotest_lib.client.common_lib import site_vblock |
| 10 | 11 |
| 11 | 12 |
| 12 class hardware_Components(test.test): | 13 class hardware_Components(test.test): |
| 13 version = 1 | 14 version = 1 |
| 14 _cids = [ | 15 _cids = [ |
| 15 'hash_ro_firmware', | 16 'hash_ro_firmware', |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 291 |
| 291 | 292 |
| 292 def pformat(self, obj): | 293 def pformat(self, obj): |
| 293 return "\n" + self._pp.pformat(obj) + "\n" | 294 return "\n" + self._pp.pformat(obj) + "\n" |
| 294 | 295 |
| 295 | 296 |
| 296 def initialize(self): | 297 def initialize(self): |
| 297 self._pp = pprint.PrettyPrinter() | 298 self._pp = pprint.PrettyPrinter() |
| 298 | 299 |
| 299 | 300 |
| 300 def run_once(self, approved_dbs='approved_components', ignored_cids=[]): | 301 def run_once(self, approved_dbs='approved_components', ignored_cids=[], |
| 302 shared_dict={}): |
| 301 self._ignored = ignored_cids | 303 self._ignored = ignored_cids |
| 302 all_failures = '' | 304 all_failures = '' |
| 303 os.chdir(self.bindir) | 305 os.chdir(self.bindir) |
| 304 | 306 |
| 307 # If found the HwQual ID in shared_dict, use the list with the same ID. |
| 308 if 'part_id_hwqual' in shared_dict: |
| 309 id = shared_dict['part_id_hwqual'] |
| 310 id = id.rpartition(' ')[0].replace(' ', '_') |
| 311 approved_dbs = 'qualified_components*%s' % id |
| 312 |
| 305 # approved_dbs supports shell-like filename expansion. | 313 # approved_dbs supports shell-like filename expansion. |
| 306 for db in glob.iglob(approved_dbs): | 314 for db in glob.iglob(approved_dbs): |
| 307 self._system = {} | 315 self._system = {} |
| 308 self._failures = {} | 316 self._failures = {} |
| 309 | 317 |
| 310 if not os.path.exists(db): | 318 if not os.path.exists(db): |
| 311 raise error.TestError('Unable to find approved db: %s' % db) | 319 raise error.TestError('Unable to find approved db: %s' % db) |
| 312 | 320 |
| 313 self._approved = eval(utils.read_file(db)) | 321 self._approved = eval(utils.read_file(db)) |
| 314 logging.debug('Approved DB: %s', self.pformat(self._approved)) | 322 logging.debug('Approved DB: %s', self.pformat(self._approved)) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 327 | 335 |
| 328 logging.debug('System: %s', self.pformat(self._system)) | 336 logging.debug('System: %s', self.pformat(self._system)) |
| 329 | 337 |
| 330 outdb = os.path.join(self.resultsdir, 'system_components') | 338 outdb = os.path.join(self.resultsdir, 'system_components') |
| 331 utils.open_write_close(outdb, self.pformat(self._system)) | 339 utils.open_write_close(outdb, self.pformat(self._system)) |
| 332 | 340 |
| 333 if self._failures: | 341 if self._failures: |
| 334 all_failures += 'Approved DB: %s' % db | 342 all_failures += 'Approved DB: %s' % db |
| 335 all_failures += self.pformat(self._failures) | 343 all_failures += self.pformat(self._failures) |
| 336 else: | 344 else: |
| 337 # If one of DBs is matched, record the hwqual_id and exit. | 345 # If one of DBs is matched, record some data in shared_dict. |
| 338 self.write_test_keyval( | 346 cids_need_to_be_record = ['part_id_hwqual'] |
| 339 {'hwqual_id': self._approved['part_id_hwqual'][0]}) | 347 for cid in cids_need_to_be_record: |
| 348 factory.log_shared_data(cid, self._approved[cid][0]) |
| 340 return | 349 return |
| 341 | 350 |
| 342 raise error.TestFail(all_failures) | 351 raise error.TestFail(all_failures) |
| OLD | NEW |