FAFT: Issue warning when running incompatible EC tests

Some EC tests require certain functinoality of EC which might not exists
on all devices. In this case, we should issue warning and let the test
pass so as not to raise false alarm.

BUG=chrome-os-partner:11629
TEST=Check tests are gated by EC attributes.

Change-Id: Ie518271e2a21094b1f8876c9520d95678a7474e5
Reviewed-on: https://gerrit.chromium.org/gerrit/28355
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
diff --git a/server/cros/faftsequence.py b/server/cros/faftsequence.py
index adabd08..8a0bd905 100644
--- a/server/cros/faftsequence.py
+++ b/server/cros/faftsequence.py
@@ -402,6 +402,29 @@
         return result_list
 
 
+    def check_ec_capability(self, required_cap=[]):
+        """Check if current platform has required EC capabilities.
+
+        Args:
+          required_cap: A list containing required EC capabilities. Pass in
+            None to only check for presence of Chrome EC.
+
+        Returns:
+          True if requirements are met. Otherwise, False.
+        """
+        if not self.client_attr.chrome_ec:
+            logging.warn('Requires Chrome EC to run this test.')
+            return False
+
+        for cap in required_cap:
+            if cap not in self.client_attr.ec_capability:
+                logging.warn('Requires EC capability "%s" to run this test.' %
+                             cap)
+                return False
+
+        return True
+
+
     def _parse_crossystem_output(self, lines):
         """Parse the crossystem output into a dict.