| 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 factory |
| 7 from autotest_lib.client.bin import test, utils | 8 from autotest_lib.client.bin import test, utils |
| 8 from autotest_lib.client.common_lib import error | 9 from autotest_lib.client.common_lib import error |
| 9 from autotest_lib.client.common_lib import flashrom_util | 10 from autotest_lib.client.common_lib import flashrom_util |
| 10 | 11 |
| 11 | 12 |
| 12 class factory_WriteGBB(test.test): | 13 class factory_WriteGBB(test.test): |
| 13 version = 1 | 14 version = 1 |
| 14 | 15 |
| 15 def run_once(self, gbb_file): | 16 def run_once(self, gbb_file='', shared_dict={}): |
| 16 os.chdir(self.bindir) | 17 os.chdir(self.bindir) |
| 18 |
| 19 # If found the HwQual ID in shared_dict, use the GBB with the same ID. |
| 20 if 'part_id_hwqual' in shared_dict: |
| 21 id = shared_dict['part_id_hwqual'] |
| 22 id = id.rpartition(' ')[0].replace(' ', '_') |
| 23 gbb_file = 'gbb*%s' % id |
| 24 |
| 17 gbb_files = glob.glob(gbb_file) | 25 gbb_files = glob.glob(gbb_file) |
| 18 if len(gbb_files) > 1: | 26 if len(gbb_files) > 1: |
| 19 raise error.TestError('More than one GBB file found') | 27 raise error.TestError('More than one GBB file found') |
| 20 elif len(gbb_files) == 1: | 28 elif len(gbb_files) == 1: |
| 21 gbb_file = gbb_files[0] | 29 gbb_file = gbb_files[0] |
| 22 else: | 30 else: |
| 23 raise error.TestError('Unable to find GBB file: %s' % gbb_file) | 31 raise error.TestError('Unable to find GBB file: %s' % gbb_file) |
| 24 gbb_data = utils.read_file(gbb_file) | 32 gbb_data = utils.read_file(gbb_file) |
| 25 | 33 |
| 26 flashrom = flashrom_util.FlashromUtility() | 34 flashrom = flashrom_util.FlashromUtility() |
| 27 flashrom.initialize(flashrom.TARGET_BIOS) | 35 flashrom.initialize(flashrom.TARGET_BIOS) |
| 28 | 36 |
| 29 gbb_section = 'FV_GBB' | 37 gbb_section = 'FV_GBB' |
| 30 original_data = flashrom.read_section(gbb_section) | 38 original_data = flashrom.read_section(gbb_section) |
| 31 # If no difference, no need to update. | 39 # If no difference, no need to update. |
| 32 if gbb_data == original_data: | 40 if gbb_data == original_data: |
| 33 return | 41 return |
| 34 | 42 |
| 35 original_file = os.path.join(self.resultsdir, 'original_gbb.bin') | 43 original_file = os.path.join(self.resultsdir, 'original_gbb.bin') |
| 36 utils.open_write_close(original_file, original_data) | 44 utils.open_write_close(original_file, original_data) |
| 37 | 45 |
| 38 flashrom.write_section(gbb_section, gbb_data) | 46 flashrom.write_section(gbb_section, gbb_data) |
| 39 flashrom.commit() | 47 flashrom.commit() |
| OLD | NEW |