aboutsummaryrefslogtreecommitdiff
path: root/server/site_tests/firmware_CgptStress/firmware_CgptStress.py
blob: 652e60a38cc7232f0ca9bb388a00cac249d675c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import logging

from autotest_lib.client.common_lib import utils
from autotest_lib.server.cros.faft.firmware_test import FirmwareTest


class firmware_CgptStress(FirmwareTest):
    """
    Servo based, iterative cgpt test. One iteration of test modifies CGPT to
    switch to boot kernel B and then switch back to kernel A again.
    """
    version = 1

    def initialize(self, host, cmdline_args, dev_mode):
        # Parse arguments from command line
        dict_args = utils.args_to_dict(cmdline_args)
        self.faft_iterations = int(dict_args.get('faft_iterations', 1))
        super(firmware_CgptStress, self).initialize(host, cmdline_args)
        self.backup_cgpt_attributes()
        self.switcher.setup_mode('dev' if dev_mode else 'normal')
        self.setup_usbkey(usbkey=False)
        self.setup_kernel('a')

    def cleanup(self):
        try:
            self.restore_cgpt_attributes()
        except Exception as e:
            logging.error("Caught exception: %s", str(e))
        super(firmware_CgptStress, self).cleanup()

    def run_once(self):
        """Runs a single iteration of the test."""
        for i in xrange(self.faft_iterations):
            logging.info('======== Running FAFT ITERATION %d/%s ========',
                         i + 1, self.faft_iterations)
            logging.info("Expected kernel A boot and prioritize kernel B.")
            self.check_state((self.checkers.root_part_checker, 'a'))
            self.reset_and_prioritize_kernel('b')
            self.switcher.mode_aware_reboot()

            logging.info("Expected kernel B boot and prioritize kernel A.")
            self.check_state((self.checkers.root_part_checker, 'b'))
            self.reset_and_prioritize_kernel('a')
            self.switcher.mode_aware_reboot()

            logging.info("Expected kernel A boot, done.")
            self.check_state((self.checkers.root_part_checker, 'a'))