[autotest] Update servo_host verify to check for multiple servod configs.
The updated servod upstart job creates the servod config file using the
nomenclature "config_$PORT" and we need to update the verify to
accommodate for that change (and also check for the old style config
file).
BUG=chromium:632093
TEST=Locally on moblab that files are detected (either one) and if both
are not there, will fail as expected.
Change-Id: Iddee4d0c0eb4cde3e9d5402a321e8eb383d848d8
Reviewed-on: https://chromium-review.googlesource.com/363910
Commit-Ready: Kevin Cheng <kevcheng@chromium.org>
Tested-by: Kevin Cheng <kevcheng@chromium.org>
Reviewed-by: Richard Barnette <jrbarnette@google.com>
diff --git a/server/hosts/servo_host.py b/server/hosts/servo_host.py
index 0aacce9..8bfbc75 100644
--- a/server/hosts/servo_host.py
+++ b/server/hosts/servo_host.py
@@ -110,6 +110,7 @@
else:
self._is_in_lab = is_in_lab
self._is_localhost = (self.hostname == 'localhost')
+ self._servo_port = servo_port
# Commands on the servo host must be run by the superuser. Our account
# on Beaglebone is root, but locally we might be running as a
@@ -334,19 +335,34 @@
@raises ServoHostVerifyFailure if /var/lib/servod/config does not exist.
"""
- if self._is_localhost:
+ if self._is_localhost or not self._is_cros_host():
+ logging.info('We will skip servo config check, either %s '
+ 'is not running chromeos or we cannot find enough '
+ 'information about the host.', self.hostname)
return
- try:
- self.run('test -f /var/lib/servod/config')
- except (error.AutoservRunError, error.AutoservSSHTimeout) as e:
- if not self._is_cros_host():
- logging.info('Ignoring servo config check failure, either %s '
- 'is not running chromeos or we cannot find enough '
- 'information about the host.', self.hostname)
+
+ failure_data = []
+ servod_config_file = '/var/lib/servod/config'
+ config_files = ['%s_%s' % (servod_config_file, self._servo_port),
+ servod_config_file]
+
+ # We'll need to check for two types of config files since we're
+ # transistioning to support a new servo setup and we need to keep both
+ # to enable successful reverts.
+ # TODO(kevcheng): We can get rid of checking for servod_config_file once
+ # the fleet of beaglebones all have new style config file.
+ for config_file in config_files:
+ try:
+ self.run('test -f %s' % config_file)
return
- raise ServoHostVerifyFailure(
- 'Servo config file check failed for %s: %s' %
- (self.hostname, e))
+ except (error.AutoservRunError, error.AutoservSSHTimeout) as e:
+ failure_data.append((config_file, e))
+
+ failure_message = ('Servo config file check failed for %s: ' %
+ self.hostname)
+ for data in failure_data:
+ failure_message += '%s (%s) ' % (data[0], data[1])
+ raise ServoHostVerifyFailure(failure_message)
def _check_servod_status(self):