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 3 # found in the LICENSE file. 4 5 from autotest_lib.client.bin import test, utils 6 from autotest_lib.client.common_lib import error 7 8 class firmware_RomSize(test.test): 9 version = 3 10 11 TARGET_BIOS = '-p host' 12 TARGET_EC = '-p ec' 13 14 def get_size(self, target): 15 data = utils.system_output("flashrom --get-size %s" % target) 16 return int(data.splitlines()[-1]) 17 18 def has_flash_chip(self, target): 19 return utils.system("flashrom --flash-name %s" % target, 20 ignore_status=True) == 0 21 22 def run_once(self): 23 ec_size = 0 24 if self.has_flash_chip(self.TARGET_EC): 25 ec_size = self.get_size(self.TARGET_EC) / 1024 26 bios_size = self.get_size(self.TARGET_BIOS) / 1024 27 28 self.write_perf_keyval({"kb_system_rom_size": bios_size, 29 "kb_ec_rom_size": ec_size}) 30