Home | History | Annotate | Download | only in firmware_ECSharedMem
      1 # Copyright (c) 2012 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 import logging
      6 import time
      7 
      8 from autotest_lib.client.common_lib import error
      9 from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
     10 
     11 
     12 class firmware_ECSharedMem(FirmwareTest):
     13     """
     14     Servo based EC shared memory test.
     15     """
     16     version = 1
     17 
     18     def initialize(self, host, cmdline_args):
     19         super(firmware_ECSharedMem, self).initialize(host, cmdline_args)
     20         # Only run in normal mode
     21         self.switcher.setup_mode('normal')
     22         self.ec.send_command("chan 0")
     23 
     24     def cleanup(self):
     25         self.ec.send_command("chan 0xffffffff")
     26         super(firmware_ECSharedMem, self).cleanup()
     27 
     28     def shared_mem_checker(self):
     29         match = self.ec.send_command_get_output("shmem",
     30                                                 ["Size:\s+([0-9-]+)\r"])[0]
     31         shmem_size = int(match[1])
     32         logging.info("EC shared memory size if %d bytes", shmem_size)
     33         if shmem_size <= 0:
     34             return False
     35         elif shmem_size <= 256:
     36             logging.warning("EC shared memory is less than 256 bytes")
     37         return True
     38 
     39     def jump_checker(self):
     40         self.ec.send_command("sysjump RW")
     41         time.sleep(self.faft_config.ec_boot_to_console)
     42         return self.shared_mem_checker()
     43 
     44     def run_once(self):
     45         if not self.check_ec_capability():
     46             raise error.TestNAError("Nothing needs to be tested on this device")
     47 
     48         logging.info("Check shared memory in normal operation and crash EC.")
     49         self.check_state(self.shared_mem_checker)
     50         self.switcher.mode_aware_reboot(
     51                 'custom', lambda:self.ec.send_command('crash unaligned'))
     52 
     53         logging.info("Check shared memory after crash and system jump.")
     54         self.check_state([self.shared_mem_checker, self.jump_checker])
     55         self.switcher.mode_aware_reboot('custom', self.sync_and_ec_reboot)
     56