faft: Unify all USB disk setup code in a new method setup_usbkey()
This CL adds a new method setup_usbkey() in FAFTSequence class, which
helps all USB disk related setup and check. Its usage:
If the test requires USB key (Chrome OS test image inside) and muxes to host:
self.setup_usbkey(usbkey=True, host=True)
If the test requires USB key (Chrome OS test image inside) and muxes to DUT:
self.setup_usbkey(usbkey=True, host=False)
If the test does not requires USB key:
self.setup_usbkey(usbkey=False)
BUG=chromium-os:35902
TEST=run the FAFT suite:
$ run_remote_tests.sh --board link --remote dut suite:faft_bios
Change-Id: If6eb94ee52f612df568c4f2f07a7acbbdd0a0b66
Reviewed-on: https://gerrit.chromium.org/gerrit/37193
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: 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 cde9259..3cea48e 100644
--- a/server/cros/faftsequence.py
+++ b/server/cros/faftsequence.py
@@ -398,6 +398,30 @@
self.mark_setup_done('usb_check')
+ def setup_usbkey(self, usbkey, host=None):
+ """Setup the USB disk for the test.
+
+ It checks the setup of USB disk and a valid ChromeOS test image inside.
+ It also muxes the USB disk to either the host or DUT by request.
+
+ Args:
+ usbkey: True if the USB disk is required for the test, False if not
+ required.
+ host: Optional, True to mux the USB disk to host, False to mux it
+ to DUT, default to do nothing.
+ """
+ if usbkey:
+ self.assert_test_image_in_usb_disk()
+ elif host is None:
+ # USB disk is not required for the test. Better to mux it to host.
+ host = True
+
+ if host is True:
+ self.servo.set('usb_mux_sel1', 'servo_sees_usbkey')
+ elif host is False:
+ self.servo.set('usb_mux_sel1', 'dut_sees_usbkey')
+
+
def get_server_address(self):
"""Get the server address seen from the client.