Home | History | Annotate | Download | only in firmware_CgptStress
      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 
      7 from autotest_lib.client.common_lib import utils
      8 from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
      9 
     10 
     11 class firmware_CgptStress(FirmwareTest):
     12     """
     13     Servo based, iterative cgpt test. One iteration of test modifies CGPT to
     14     switch to boot kernel B and then switch back to kernel A again.
     15     """
     16     version = 1
     17 
     18     def initialize(self, host, cmdline_args, dev_mode):
     19         # Parse arguments from command line
     20         dict_args = utils.args_to_dict(cmdline_args)
     21         self.faft_iterations = int(dict_args.get('faft_iterations', 1))
     22         super(firmware_CgptStress, self).initialize(host, cmdline_args)
     23         self.backup_cgpt_attributes()
     24         self.switcher.setup_mode('dev' if dev_mode else 'normal')
     25         self.setup_usbkey(usbkey=False)
     26         self.setup_kernel('a')
     27 
     28     def cleanup(self):
     29         try:
     30             self.restore_cgpt_attributes()
     31         except Exception as e:
     32             logging.error("Caught exception: %s", str(e))
     33         super(firmware_CgptStress, self).cleanup()
     34 
     35     def run_once(self):
     36         for i in xrange(self.faft_iterations):
     37             logging.info('======== Running FAFT ITERATION %d/%s ========',
     38                          i + 1, self.faft_iterations)
     39             logging.info("Expected kernel A boot and prioritize kernel B.")
     40             self.check_state((self.checkers.root_part_checker, 'a'))
     41             self.reset_and_prioritize_kernel('b')
     42             self.switcher.mode_aware_reboot()
     43 
     44             logging.info("Expected kernel B boot and prioritize kernel A.")
     45             self.check_state((self.checkers.root_part_checker, 'b'))
     46             self.reset_and_prioritize_kernel('a')
     47             self.switcher.mode_aware_reboot()
     48 
     49             logging.info("Expected kernel A boot, done.")
     50             self.check_state((self.checkers.root_part_checker, 'a'))
     51