blob: 7c630c5bfbc0933ccdcfae7a93f98e3c8c2812ed [file] [log] [blame]
# 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 glob
from itertools import groupby
import logging
from threading import Timer
from autotest_lib.client.common_lib import error
from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
from autotest_lib.client.bin.input.input_device import *
class firmware_FAFTSetup(FirmwareTest):
"""This test checks the following FAFT hardware requirement:
- Warm reset
- Cold reset
- Recovery boot with USB stick
- USB stick is plugged into Servo board, not DUT
- Keyboard simulation
- No terminal opened on EC console
version = 1
# Delay to ensure client is ready to read the key press.
def console_checker(self):
"""Verify EC console is available if using Chrome EC."""
if not self.check_ec_capability(suppress_warning=True):
# Not Chrome EC. Nothing to check.
return True
try:"chan 0")
expected_output = ["Chip:\s+[^\r\n]*\r\n",
expected_output)"chan 0xffffffff")
return True
except: # pylint: disable=W0702
logging.error("Cannot talk to EC console.")
"Please check there is no terminal opened on EC console.")
raise error.TestFail("Failed EC console check.")
def base_keyboard_checker(self, press_action):
"""Press key and check from DUT.
press_action: A callable that would press the keys when called.
result = True
# Stop UI so that key presses don't go to Chrome.
self.faft_client.system.run_shell_command("stop ui")
# Press the keys
Timer(self.KEY_PRESS_DELAY, press_action).start()
# Invoke client side script to monitor keystrokes
if not self.faft_client.system.check_keys([28, 29, 32]):
result = False
# Turn UI back on
self.faft_client.system.run_shell_command("start ui")
return result
def keyboard_checker(self):
"""Press 'd', Ctrl, ENTER by servo and check from DUT."""
def keypress():
keys = self.faft_config.key_checker
return self.base_keyboard_checker(keypress)
def run_once(self):"Check EC console is available and test warm reboot")
self.reboot_warm()"Check test image is on USB stick and run recovery boot")
{'mainfw_type': 'recovery'}))"Check cold boot")
self.reboot_cold()"Check keyboard simulation")