Modify FAFTSetup to work with and without servo, in and out of chroot
Running FAFT in the test lab requires to decouple FAFT from chroot and
modify missing pieces to allow servo connected to either local host or
a Beaglebone board.
This change introduces modifications necessary to have the
firmware_FAFTSetup pass:
- verifying test image on the USB flash stick now relies on presence
of the 'test' string in the CHROMEOS_RELEASE_DESCRIPTION line of
/etc/lsb-release. The check is case insensitive, because developer
builds and buildbots produce different line formats.
The replaced check compared contents of the ssh key files, but the
file was obtained from the Chrome OS chroot checkout. This also
required implementing the actual check locally instead of relying on
lab_test.VerifyImageAndGetId(), which requires chroot presence.
- servo API to execute commands on the servo host has been modified to
match the utils provided API. In particular the system_output()
method is being added to runn commands and return their console
output.
- instead of using the utils library indiscriminantly, the servo
module executes commands on the servohost when servo is not local.
- changes to servo_test.py are mostly cosmetic, helping with debugging.
BUG=chrome-os-partner:15610
TEST=manual
. outside of chroot with local and remote servo:
$ ./server/autoserv -m 192.168.1.4 --ssh-port 22 -s server/site_tests/firmware_FAFTSetup/control -r /tmp/autot --args ''
$ ./server/autoserv -m 192.168.1.4 --ssh-port 22 -s server/site_tests/firmware_FAFTSetup/control -r /tmp/autot --args 'servo_host=192.168.1.103 servo_port=9999'
. inside chroot with local and remote servo:
$ run_remote_tests.sh --board=link --servo --remote=192.168.1.4 firmware_FAFTSetup.control
$ run_remote_tests.sh --board=link --remote=192.168.1.4 firmware_FAFTSetup.control --args 'servo_host=192.168.1.103 servo_port=9999'
Change-Id: I88ffac43526e2988ec9f88e2bbb8995ef55c5f7b
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39809
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
diff --git a/server/cros/faftsequence.py b/server/cros/faftsequence.py
index 2ebba93..fdfbe53 100644
--- a/server/cros/faftsequence.py
+++ b/server/cros/faftsequence.py
@@ -84,6 +84,8 @@
CHROMEOS_MAGIC = "CHROMEOS"
CORRUPTED_MAGIC = "CORRUPTD"
+ _ROOTFS_PARTITION_NUMBER = 3
+
_HTTP_PREFIX = 'http://'
_DEVSERVER_PORT = '8090'
@@ -366,29 +368,6 @@
raise error.TestFail('Timed out waiting for DUT reboot')
- def assert_test_image_in_path(self, image_path, install_shim=False):
- """Assert the image of image_path be a Chrome OS test image.
-
- Args:
- image_path: A path on the host to the test image.
- install_shim: True to verify an install shim instead of a test image.
-
- Raises:
- error.TestError: if the image is not a test (install shim) image.
- """
- try:
- build_ver, build_hash = lab_test.VerifyImageAndGetId(
- os.environ['CROS_WORKON_SRCROOT'],
- image_path,
- install_shim=install_shim)
- logging.info('Build of image: %s %s', build_ver, build_hash)
- except ChromeOSTestError:
- raise error.TestError(
- 'An USB disk containning a %s image should be plugged '
- 'in the servo board.' %
- ('install shim' if install_shim else 'test'))
-
-
def assert_test_image_in_usb_disk(self, usb_dev=None, install_shim=False):
"""Assert an USB disk plugged-in on servo and a test image inside.
@@ -403,15 +382,6 @@
"""
if self.check_setup_done('usb_check'):
return
-
- # TODO(waihong@chromium.org): We skip the check when servod runs in
- # a different host since no easy way to access the servo host so far.
- # Should find a way to work-around it.
- if not self.servo.is_localhost():
- logging.info('Skip checking Chrome OS test image in USB as servod '
- 'runs in a different host.')
- return
-
if usb_dev:
assert self.servo.get('usb_mux_sel1') == 'servo_sees_usbkey'
else:
@@ -420,7 +390,29 @@
if not usb_dev:
raise error.TestError(
'An USB disk should be plugged in the servo board.')
- self.assert_test_image_in_path(usb_dev, install_shim=install_shim)
+
+ rootfs = '%s%s' % (usb_dev, self._ROOTFS_PARTITION_NUMBER)
+ logging.info('usb dev is %s', usb_dev)
+ tmpd = self.servo.system_output('mktemp -d -t usbcheck.XXXX')
+ self.servo.system('mount -o ro %s %s' % (rootfs, tmpd))
+
+ if install_shim:
+ dir_list = self.servo.system_output('ls -a %s' %
+ os.path.join(tmpd, 'root'))
+ check_passed = '.factory_installer' in dir_list
+ else:
+ check_passed = self.servo.system_output(
+ 'grep -i "CHROMEOS_RELEASE_DESCRIPTION=.*test" %s' %
+ os.path.join(tmpd, 'etc/lsb-release'),
+ ignore_status=True)
+ for cmd in ('umount %s' % rootfs, 'sync', 'rm -rf %s' % tmpd):
+ self.servo.system(cmd)
+
+ if not check_passed:
+ raise error.TestError(
+ 'No Chrome OS %s found on the USB flash plugged into servo' %
+ 'install shim' if install_shim else 'test')
+
self.mark_setup_done('usb_check')
@@ -500,13 +492,11 @@
devserver = None
image_url = image_path
elif self.servo.is_localhost():
- self.assert_test_image_in_path(image_path)
# If servod is localhost, i.e. both servod and FAFT see the same
# file system, do nothing.
devserver = None
image_url = image_path
else:
- self.assert_test_image_in_path(image_path)
image_dir, image_base = os.path.split(image_path)
logging.info('Starting devserver to serve the image...')
# The following stdout and stderr arguments should not be None,
@@ -535,6 +525,8 @@
logging.info('Ask Servo to install the image from %s', image_url)
self.servo.image_to_servo_usb(image_url)
+ self.assert_test_image_in_usb_disk()
+
if devserver and devserver.poll() is None:
logging.info('Shutting down devserver...')
devserver.terminate()