1# Copyright (c) 2020 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 5import logging 6 7from autotest_lib.client.common_lib import common 8from autotest_lib.server.cros.faft.firmware_test import FirmwareTest 9 10 11class firmware_FAFTModeTransitions(FirmwareTest): 12 """This test checks FAFT mode transitions work.""" 13 version = 1 14 NEEDS_SERVO_USB = True 15 16 def _checked_reboot(self, to_mode): 17 """Reboots DUT to mode and sanity checks that it has done so. 18 19 @param to_mode: mode_switcher mode to reboot into 20 @type to_mode: string 21 22 @see: autotest_lib.server.cros.faft.utils.mode_switcher 23 """ 24 self.switcher.reboot_to_mode(to_mode) 25 self.check_state((self.checkers.mode_checker, to_mode)) 26 27 def run_once(self, mode_seq=[]): 28 """Main test logic. 29 30 @param mode_seq: A list of mode_switcher modes to transition through 31 @type mode_seq: list of strings 32 33 @see: autotest_lib.server.cros.faft.utils.mode_switcher 34 """ 35 36 if len(mode_seq) < 2: 37 raise ValueError("Not enough transitions to test: %s" % mode_seq) 38 39 logging.info("Testing transition sequence: %s", " -> ".join(mode_seq)) 40 41 if 'rec' in mode_seq: 42 logging.info("Mode sequence contains 'rec', setup USB stick with" 43 " image.") 44 self.setup_usbkey(usbkey=True) 45 46 m1 = mode_seq[0] 47 48 logging.info("Start in %s mode.", m1) 49 self.switcher.setup_mode(m1) 50 51 for m2 in mode_seq[1:]: 52 logging.info("Checking mode transition: %s -> %s.", m1, m2) 53 self._checked_reboot(m2) 54 m1 = m2 55