faft: Directly run usbkm232-xxx commands on devices without build-in keyboards
For the device without build-in keyboards, we use an additional USBKM232
device, which is connected between servo board and DUT, to emulate an
external USB keyboard. The key-sending commands are ready, like usbkm232-enter,
usbkm232-ctrld, etc. So far we pass this commands to FAFT via arguments
manually. However, an user may forget to pass these arguments to the test
and cause a test error.
This CL is to run the commands directly without configuring them. A simple
check is added to ensure the environment variable USBKM232_UART_DEVICE is
set correctly.
BUG=chromium-os:34823
TEST=run on the devices without build-in keyboards:
run_remote_tests.sh --board stumpy --remote dut FAFTSetup
Change-Id: Ibd2bf71a4324cb1d209afea8561eae1a261be199
Reviewed-on: https://gerrit.chromium.org/gerrit/36770
Commit-Ready: Tom Wai-Hong Tam <waihong@chromium.org>
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Tested-by: Tom Wai-Hong Tam <waihong@chromium.org>
diff --git a/server/cros/faftsequence.py b/server/cros/faftsequence.py
index 8350998..73dfd33 100644
--- a/server/cros/faftsequence.py
+++ b/server/cros/faftsequence.py
@@ -70,8 +70,6 @@
_faft_template: The default FAFT_STEP of each step. The actions would
be over-written if the registered FAFT_SEQUENCE is valid.
_faft_sequence: The registered FAFT_SEQUENCE.
- _customized_key_commands: The dict of the customized key commands,
- including Ctrl-D, Ctrl-U, and Enter.
_install_image_path: The URL or the path on the host to the Chrome OS
test image to be installed.
_firmware_update: Boolean. True if firmware update needed after
@@ -96,11 +94,6 @@
_faft_template = {}
_faft_sequence = ()
- _customized_key_commands = {
- 'ctrl_d': None,
- 'ctrl_u': None,
- 'enter': None,
- }
_install_image_path = None
_firmware_update = False
_trapped_in_recovery_reason = 0
@@ -152,14 +145,6 @@
match = re.search("^(\w+)=(.+)", arg)
if match:
args[match.group(1)] = match.group(2)
-
- # Keep the arguments which will be used later.
- for key in self._customized_key_commands:
- key_cmd = key + '_cmd'
- if key_cmd in args:
- self._customized_key_commands[key] = args[key_cmd]
- logging.info('Customized %s key command: %s' %
- (key, args[key_cmd]))
if 'image' in args:
self._install_image_path = args['image']
logging.info('Install Chrome OS test image path: %s' %
@@ -184,6 +169,14 @@
if self.client_attr.chrome_ec:
self.ec = ChromeEC(self.servo)
+ if not self.client_attr.has_keyboard:
+ # The environment variable USBKM232_UART_DEVICE should point
+ # to the USB-KM232 UART device.
+ if ('USBKM232_UART_DEVICE' not in os.environ or
+ not os.path.exists(os.environ['USBKM232_UART_DEVICE'])):
+ raise error.TestError('Must set a valid environment '
+ 'variable USBKM232_UART_DEVICE.')
+
# Setting up key matrix mapping
self.servo.set_key_matrix(self.client_attr.key_matrix_layout)
@@ -842,9 +835,9 @@
def press_ctrl_d(self):
"""Send Ctrl-D key to DUT."""
- if self._customized_key_commands['ctrl_d']:
- logging.info('running the customized Ctrl-D key command')
- os.system(self._customized_key_commands['ctrl_d'])
+ if not self.client_attr.has_keyboard:
+ logging.info('Running usbkm232-ctrld...')
+ os.system('usbkm232-ctrld')
else:
self.servo.ctrl_d()
@@ -856,9 +849,9 @@
error.TestError: if a non-Chrome EC device or no Ctrl-U command given
on a no-build-in-keyboard device.
"""
- if self._customized_key_commands['ctrl_u']:
- logging.info('running the customized Ctrl-U key command')
- os.system(self._customized_key_commands['ctrl_u'])
+ if not self.client_attr.has_keyboard:
+ logging.info('Running usbkm232-ctrlu...')
+ os.system('usbkm232-ctrlu')
elif self.check_ec_capability(['keyboard'], suppress_warning=True):
self.ec.key_down('<ctrl_l>')
self.ec.key_down('u')
@@ -874,9 +867,9 @@
def press_enter(self):
"""Send Enter key to DUT."""
- if self._customized_key_commands['enter']:
- logging.info('running the customized Enter key command')
- os.system(self._customized_key_commands['enter'])
+ if not self.client_attr.has_keyboard:
+ logging.info('Running usbkm232-enter...')
+ os.system('usbkm232-enter')
else:
self.servo.enter_key()
diff --git a/server/site_tests/firmware_DevBootUSB/firmware_DevBootUSB.py b/server/site_tests/firmware_DevBootUSB/firmware_DevBootUSB.py
index b97cc35..b299810 100644
--- a/server/site_tests/firmware_DevBootUSB/firmware_DevBootUSB.py
+++ b/server/site_tests/firmware_DevBootUSB/firmware_DevBootUSB.py
@@ -67,11 +67,6 @@
raise error.TestError("TEST IT MANUALLY! This test can't be "
"automated on non-Chrome-EC devices.")
- if (not self.client_attr.has_keyboard and
- not self._customized_key_commands['ctrl_u']):
- raise error.TestError("Should specify the ctrl_u_cmd argument "
- "on no-build-in-keyboard devices.")
-
self.register_faft_sequence((
{ # Step 1, expected developer mode, set dev_boot_usb to 0
'state_checker': (self.dev_boot_usb_checker, False),
diff --git a/server/site_tests/firmware_FAFTSetup/firmware_FAFTSetup.py b/server/site_tests/firmware_FAFTSetup/firmware_FAFTSetup.py
index 3130dcb..675b189 100644
--- a/server/site_tests/firmware_FAFTSetup/firmware_FAFTSetup.py
+++ b/server/site_tests/firmware_FAFTSetup/firmware_FAFTSetup.py
@@ -67,14 +67,6 @@
press_action: A callable that would press the keys when called.
expected_output: Expected output from "showkey".
"""
- if not self.client_attr.has_keyboard:
- # Check all customized key commands are provided
- if not all([self._customized_key_commands['ctrl_d'],
- self._customized_key_commands['ctrl_u'],
- self._customized_key_commands['enter']]):
- logging.error("No customized key command assigned.")
- return False
-
# Stop UI so that key presses don't go to X.
self.faft_client.run_shell_command("stop ui")
# Press the keys