A FAFT test case for user request recovery boot and check for recovery test.
This test requires a USB disk plugged-in, which contains a Chrome OS test
image (built by "build_image --test"). On runtime, this test first requests
a recovery mode on next boot by setting the crossystem recovery_request
flag. It then triggers recovery mode by unplugging and plugging in the USB
disk and checks success of it.
BUG=chromium-os:19710
TEST=run_remote_tests.sh --remote=$REMOTE_IP -a \
"servo_vid=0x18d1 servo_pid=0x5001" firmware_UserRequestRecovery
Change-Id: I0e75ba2d16bb98f9faa55ecc2cf7f5d05f8430a7
Reviewed-on: https://gerrit.chromium.org/gerrit/10633
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 468ad1b..692b05c 100644
--- a/server/cros/faftsequence.py
+++ b/server/cros/faftsequence.py
@@ -3,10 +3,13 @@
# found in the LICENSE file.
import logging
+import os
import re
+import tempfile
import time
import xmlrpclib
+from autotest_lib.client.bin import utils
from autotest_lib.client.common_lib import error
from autotest_lib.server.cros.servotest import ServoTest
@@ -84,6 +87,29 @@
super(FAFTSequence, self).cleanup()
+ def assert_test_image_in_usb_disk(self):
+ """Assert an USB disk plugged-in on servo and a test image inside.
+
+ Raises:
+ error.TestError: if USB disk not detected or not a test image.
+ """
+ self.servo.set('usb_mux_sel1', 'servo_sees_usbkey')
+ usb_dev = self.probe_host_usb_dev()
+ if not usb_dev:
+ raise error.TestError(
+ 'An USB disk should be plugged in the servo board.')
+
+ tmp_dir = tempfile.mkdtemp()
+ utils.system('sudo mount %s3 %s' % (usb_dev, tmp_dir))
+ code = utils.system('grep -q "Test Build" %s/etc/lsb-release' %
+ tmp_dir, ignore_status=True)
+ utils.system('sudo umount %s' % tmp_dir)
+ os.removedirs(tmp_dir)
+ if code != 0:
+ raise error.TestError(
+ 'The image in the USB disk should be a test image.')
+
+
def _parse_crossystem_output(self, lines):
"""Parse the crossystem output into a dict.