[autotest] Check if servo config file exists before trying to verify servod

This is added to help the performance of servo verification. For boards like
butterfly and parrot, servo is not ready and servod config file is not created
intentionally. If this config file is not there, there is no need to verify
servod.

BUG=chromium:380773
TEST=local servo test.

Change-Id: I616389e1ca42872b817273cd115b09f241e3af64
Reviewed-on: https://chromium-review.googlesource.com/203281
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Prashanth B <beeps@chromium.org>
Reviewed-by: Richard Barnette <jrbarnette@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
diff --git a/server/hosts/servo_host.py b/server/hosts/servo_host.py
index 5ecc6d4..003a381 100644
--- a/server/hosts/servo_host.py
+++ b/server/hosts/servo_host.py
@@ -295,6 +295,7 @@
             return super(ServoHost, self).run(**run_args)
 
 
+    @_timer.decorate
     def _check_servod(self):
         """A sanity check of the servod state."""
         msg_prefix = 'Servod error: %s'
@@ -332,6 +333,24 @@
                     'USB sanity check on %s failed: %s' % (self.hostname, e))
 
 
+    def _check_servo_config(self):
+        """Check if config file exists for servod.
+
+        If servod config file does not exist, there is no need to verify if
+        servo is working. The servo could be attached to a board not supported
+        yet.
+
+        @raises ServoHostVerifyFailure if /var/lib/servod/config does not exist.
+
+        """
+        try:
+            self.run('test -f /var/lib/servod/config')
+        except (error.AutoservRunError, error.AutoservSSHTimeout) as e:
+            raise ServoHostVerifyFailure(
+                    'Servo config file check failed for %s: %s' %
+                    (self.hostname, e))
+
+
     @_timer.decorate
     def _update_image(self):
         """Update the image on the servo host, if needed.
@@ -447,9 +466,13 @@
         logging.info('Applying an update to the servo host, if necessary.')
         self._update_image()
 
+        logging.info('Verifying if servo config file exists.')
+        self._check_servo_config()
+
         logging.info('Verifying servo host %s with sanity checks.',
                      self.hostname)
         self._check_servo_host_usb()
+
         # If servo is already initialized, we don't need to do it again, call
         # _check_servod should be enough.
         if self._servo: