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 factory |
7 from autotest_lib.client.bin import test, utils | 7 from autotest_lib.client.bin import test, utils |
8 from autotest_lib.client.common_lib import error | 8 from autotest_lib.client.common_lib import error |
9 from autotest_lib.client.common_lib import flashrom_util | 9 from autotest_lib.client.common_lib import flashrom_util |
10 from autotest_lib.client.common_lib import gbb_util | 10 from autotest_lib.client.common_lib import gbb_util |
| 11 from autotest_lib.client.common_lib import site_fmap |
11 from autotest_lib.client.common_lib import site_vblock | 12 from autotest_lib.client.common_lib import site_vblock |
12 | 13 |
13 | 14 |
14 class hardware_Components(test.test): | 15 class hardware_Components(test.test): |
15 version = 1 | 16 version = 1 |
16 _cids = [ | 17 _cids = [ |
17 'hash_ro_firmware', | 18 'hash_ro_firmware', |
18 'part_id_audio_codec', | 19 'part_id_audio_codec', |
19 'part_id_cpu', | 20 'part_id_cpu', |
20 'part_id_display_panel', | 21 'part_id_display_panel', |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 base_img = flashrom.read_whole() | 254 base_img = flashrom.read_whole() |
254 flashrom_size = len(base_img) | 255 flashrom_size = len(base_img) |
255 # XXX Allowing the FMAP to override our default layout may be an exploit | 256 # XXX Allowing the FMAP to override our default layout may be an exploit |
256 # here, because vendor can provide fake (non-used) GBB/BSTUB in unused | 257 # here, because vendor can provide fake (non-used) GBB/BSTUB in unused |
257 # area. However since the flash memory layout may change, we need to | 258 # area. However since the flash memory layout may change, we need to |
258 # trust FMAP here. | 259 # trust FMAP here. |
259 layout = flashrom.detect_chromeos_bios_layout(flashrom_size, base_img) | 260 layout = flashrom.detect_chromeos_bios_layout(flashrom_size, base_img) |
260 if not layout: | 261 if not layout: |
261 raise error.TestError('Cannot detect ChromeOS flashrom layout') | 262 raise error.TestError('Cannot detect ChromeOS flashrom layout') |
262 hash_src = '' | 263 hash_src = '' |
| 264 fmap_obj = site_fmap.fmap_decode(base_img) |
| 265 if not fmap_obj: |
| 266 raise error.TestError('No FMAP structure in flashrom.') |
| 267 hash_src = hash_src + site_fmap.fmap_encode(fmap_obj) |
263 for section in hash_ro_list: | 268 for section in hash_ro_list: |
264 src = flashrom.get_section(base_img, layout, section) | 269 src = flashrom.get_section(base_img, layout, section) |
265 if not src: | 270 if not src: |
266 raise error.TestError('Cannot get section [%s] from flashrom' % | 271 raise error.TestError('Cannot get section [%s] from flashrom' % |
267 section) | 272 section) |
268 hash_src = hash_src + src | 273 hash_src = hash_src + src |
269 if not hash_src: | 274 if not hash_src: |
270 raise error.TestError('Invalid hash source from flashrom.') | 275 raise error.TestError('Invalid hash source from flashrom.') |
271 return hashlib.sha256(hash_src).hexdigest() | 276 return hashlib.sha256(hash_src).hexdigest() |
272 | 277 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 cids_need_to_be_record = ['part_id_hwqual'] | 380 cids_need_to_be_record = ['part_id_hwqual'] |
376 for cid in cids_need_to_be_record: | 381 for cid in cids_need_to_be_record: |
377 factory.log_shared_data(cid, self._approved[cid][0]) | 382 factory.log_shared_data(cid, self._approved[cid][0]) |
378 return | 383 return |
379 | 384 |
380 if only_cardreader_failed: | 385 if only_cardreader_failed: |
381 all_failures = ('You may forget to insert an SD card.\n' + | 386 all_failures = ('You may forget to insert an SD card.\n' + |
382 all_failures) | 387 all_failures) |
383 | 388 |
384 raise error.TestFail(all_failures) | 389 raise error.TestFail(all_failures) |
OLD | NEW |