| 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 | 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 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 def pformat(self, obj): | 286 def pformat(self, obj): |
| 287 return "\n" + self._pp.pformat(obj) + "\n" | 287 return "\n" + self._pp.pformat(obj) + "\n" |
| 288 | 288 |
| 289 | 289 |
| 290 def initialize(self): | 290 def initialize(self): |
| 291 self._pp = pprint.PrettyPrinter() | 291 self._pp = pprint.PrettyPrinter() |
| 292 | 292 |
| 293 | 293 |
| 294 def run_once(self, approved_dbs='approved_components', ignored_cids=[]): | 294 def run_once(self, approved_dbs='approved_components', ignored_cids=[]): |
| 295 self._ignored = ignored_cids | 295 self._ignored = ignored_cids |
| 296 all_failures = '' | 296 only_cardreader_failed = False |
| 297 all_failures = 'The following components are not matched.\n' |
| 297 os.chdir(self.bindir) | 298 os.chdir(self.bindir) |
| 298 | 299 |
| 299 # approved_dbs supports shell-like filename expansion. | 300 # approved_dbs supports shell-like filename expansion. |
| 300 for db in glob.iglob(approved_dbs): | 301 for db in glob.iglob(approved_dbs): |
| 301 self._system = {} | 302 self._system = {} |
| 302 self._failures = {} | 303 self._failures = {} |
| 303 | 304 |
| 304 if not os.path.exists(db): | 305 if not os.path.exists(db): |
| 305 raise error.TestError('Unable to find approved db: %s' % db) | 306 raise error.TestError('Unable to find approved db: %s' % db) |
| 306 | 307 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 318 | 319 |
| 319 for cid in self._check_existence_cids: | 320 for cid in self._check_existence_cids: |
| 320 self.check_approved_part_id_existence(cid, type='others') | 321 self.check_approved_part_id_existence(cid, type='others') |
| 321 | 322 |
| 322 logging.debug('System: %s', self.pformat(self._system)) | 323 logging.debug('System: %s', self.pformat(self._system)) |
| 323 | 324 |
| 324 outdb = os.path.join(self.resultsdir, 'system_components') | 325 outdb = os.path.join(self.resultsdir, 'system_components') |
| 325 utils.open_write_close(outdb, self.pformat(self._system)) | 326 utils.open_write_close(outdb, self.pformat(self._system)) |
| 326 | 327 |
| 327 if self._failures: | 328 if self._failures: |
| 328 all_failures += 'Approved DB: %s' % db | 329 if self._failures.keys() == ['part_id_cardreader']: |
| 330 only_cardreader_failed = True |
| 331 all_failures += 'For DB %s:' % db |
| 329 all_failures += self.pformat(self._failures) | 332 all_failures += self.pformat(self._failures) |
| 330 else: | 333 else: |
| 331 # If one of DBs is matched, record the hwqual_id and exit. | 334 # If one of DBs is matched, record the hwqual_id and exit. |
| 332 self.write_test_keyval( | 335 self.write_test_keyval( |
| 333 {'hwqual_id': self._approved['part_id_hwqual'][0]}) | 336 {'hwqual_id': self._approved['part_id_hwqual'][0]}) |
| 334 return | 337 return |
| 335 | 338 |
| 339 if only_cardreader_failed: |
| 340 all_failures = ('You may forget to insert an SD card.\n' + |
| 341 all_failures) |
| 342 |
| 336 raise error.TestFail(all_failures) | 343 raise error.TestFail(all_failures) |
| OLD | NEW |