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, os | 5 import glob, os |
6 | 6 |
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 gbb_util | 9 from autotest_lib.client.common_lib import gbb_util |
10 | 10 |
11 | 11 |
12 class factory_WriteGBB(test.test): | 12 class factory_WriteGBB(test.test): |
13 version = 2 | 13 version = 2 |
14 | 14 |
15 def run_once(self, shared_dict={}): | 15 def run_once(self, shared_dict={}): |
16 # More convenient to set the CWD to hardware_Components since a lot of | 16 # More convenient to set the CWD to hardware_Components since a lot of |
17 # values in the component list are based on that directory. | 17 # values in the component list are based on that directory. |
18 os.chdir(os.path.join(self.bindir, '../hardware_Components')) | 18 os.chdir(os.path.join(self.bindir, '../hardware_Components')) |
19 | 19 |
20 # If found the HwQual ID in shared_dict, identify the component files. | 20 # If found the HwQual ID in shared_dict, identify the component files. |
21 if 'part_id_hwqual' in shared_dict: | 21 if 'part_id_hwqual' in shared_dict: |
22 id = shared_dict['part_id_hwqual'].replace(' ', '_') | 22 id = shared_dict['part_id_hwqual'].replace(' ', '_') |
23 component_file = 'data_*/components_%s' % id | 23 component_file = 'data_*/components_%s' % id |
| 24 else: |
| 25 raise error.TestError( |
| 26 'You need to run this test from factory UI, and have ' + |
| 27 'successfully completed the HWQual-ID matching test ') |
24 | 28 |
25 component_files = glob.glob(component_file) | 29 component_files = glob.glob(component_file) |
26 if len(component_files) != 1: | 30 if len(component_files) != 1: |
27 raise error.TestError( | 31 raise error.TestError( |
28 'Unable to find the component file: %s' % component_file) | 32 'Unable to find the component file: %s' % component_file) |
29 component_file = component_files[0] | 33 component_file = component_files[0] |
30 components = eval(utils.read_file(component_file)) | 34 components = eval(utils.read_file(component_file)) |
31 | 35 |
32 gbb = gbb_util.GBBUtility(temp_dir=self.resultsdir, | 36 gbb = gbb_util.GBBUtility(temp_dir=self.resultsdir, |
33 keep_temp_files=True) | 37 keep_temp_files=True) |
34 gbb.set_bmpfv(utils.read_file(components['data_bitmap_fv'][0])) | 38 gbb.set_bmpfv(utils.read_file(components['data_bitmap_fv'][0])) |
35 gbb.set_hwid(components['part_id_hwqual'][0]) | 39 gbb.set_hwid(components['part_id_hwqual'][0]) |
36 gbb.set_recoverykey(utils.read_file(components['key_recovery'][0])) | 40 gbb.set_recoverykey(utils.read_file(components['key_recovery'][0])) |
37 gbb.set_rootkey(utils.read_file(components['key_root'][0])) | 41 gbb.set_rootkey(utils.read_file(components['key_root'][0])) |
38 gbb.commit() | 42 gbb.commit() |
OLD | NEW |