fix cr50 tests so they can run devices with servo v4

Devices may be setup in the lab with servo v4. The ccd connection will
interfere with the cr50 ap usb connection. Make all tests verifying the
cr50 ap usb connection FirmwareTests. Disable ccd before running them.
Reenable ccd at the end.

BUG=none
BRANCh=none
TEST=connect servo v4 to a device and run these tests.

Change-Id: Id55ed71cfbb0473497eaad118c6954c192c36da7
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/469128
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Tyler Reid <twreid@google.com>
diff --git a/server/site_tests/firmware_Cr50USB/control b/server/site_tests/firmware_Cr50USB/control
index 93c184b..899420a 100644
--- a/server/site_tests/firmware_Cr50USB/control
+++ b/server/site_tests/firmware_Cr50USB/control
@@ -17,13 +17,15 @@
 """
 
 args_dict = utils.args_to_dict(args)
+servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
 
 def run(machine):
-    host = hosts.create_host(machine)
+    host = hosts.create_host(machine, servo_args=servo_args)
+
     num_iterations = int(args_dict.get("num_iterations", 100))
     exit_condition = args_dict.get("exit_condition", "")
 
-    job.run_test("firmware_Cr50USB", host=host, num_iterations=num_iterations,
-                 exit_condition=exit_condition)
+    job.run_test("firmware_Cr50USB", host=host, cmdline_args=args,
+                 num_iterations=num_iterations, exit_condition=exit_condition)
 
 parallel_simple(run, machines)
diff --git a/server/site_tests/firmware_Cr50USB/firmware_Cr50USB.py b/server/site_tests/firmware_Cr50USB/firmware_Cr50USB.py
index 5b2f725..4527b3e 100644
--- a/server/site_tests/firmware_Cr50USB/firmware_Cr50USB.py
+++ b/server/site_tests/firmware_Cr50USB/firmware_Cr50USB.py
@@ -7,9 +7,10 @@
 
 from autotest_lib.client.common_lib import error
 from autotest_lib.server import autotest, test
+from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
 
 
-class firmware_Cr50USB(test.test):
+class firmware_Cr50USB(FirmwareTest):
     """
     Stress the Cr50 usb connection to the DUT.
 
@@ -24,8 +25,19 @@
 
     SLEEP_DELAY = 20
 
-    def run_once(self, host, num_iterations=100, exit_condition=None):
+    def cleanup(self):
+        """Reenable CCD before cleanup"""
+        if hasattr(self, "cr50"):
+            self.cr50.ccd_enable()
+        super(firmware_Cr50USB, self).cleanup()
+
+
+    def run_once(self, host, cmdline_args, num_iterations=100,
+                 exit_condition=None):
         self.host = host
+        # Disable CCD so it doesn't interfere with the Cr50 AP usb connection.
+        if hasattr(self, "cr50"):
+            self.cr50.ccd_disable()
 
         # Make sure the device is logged in so TPM activity doesn't keep it
         # awake
diff --git a/server/site_tests/firmware_Cr50UpdateScriptStress/control b/server/site_tests/firmware_Cr50UpdateScriptStress/control
index ef76167..2462510 100644
--- a/server/site_tests/firmware_Cr50UpdateScriptStress/control
+++ b/server/site_tests/firmware_Cr50UpdateScriptStress/control
@@ -17,13 +17,14 @@
 """
 
 args_dict = utils.args_to_dict(args)
+servo_args = hosts.CrosHost.get_servo_arguments(args_dict)
 
 def run(machine):
-    host = hosts.create_host(machine)
+    host = hosts.create_host(machine, servo_args=servo_args)
 
     iterations = int(args_dict.get("iterations", 100))
 
     job.run_test("firmware_Cr50UpdateScriptStress", host=host,
-                 iterations=iterations)
+                 cmdline_args=args, iterations=iterations)
 
 parallel_simple(run, machines)
diff --git a/server/site_tests/firmware_Cr50UpdateScriptStress/firmware_Cr50UpdateScriptStress.py b/server/site_tests/firmware_Cr50UpdateScriptStress/firmware_Cr50UpdateScriptStress.py
index 4a11bd0..2540a0f 100644
--- a/server/site_tests/firmware_Cr50UpdateScriptStress/firmware_Cr50UpdateScriptStress.py
+++ b/server/site_tests/firmware_Cr50UpdateScriptStress/firmware_Cr50UpdateScriptStress.py
@@ -8,9 +8,10 @@
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.common_lib.cros import cr50_utils
 from autotest_lib.server import autotest, test
+from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
 
 
-class firmware_Cr50UpdateScriptStress(test.test):
+class firmware_Cr50UpdateScriptStress(FirmwareTest):
     """
     Stress the Cr50 Update Script.
 
@@ -24,7 +25,19 @@
     """
     version = 1
 
-    def run_once(self, host):
+    def cleanup(self):
+        """Reenable CCD before cleanup"""
+        if hasattr(self, "cr50"):
+            self.cr50.ccd_enable()
+
+        super(firmware_Cr50UpdateScriptStress, self).cleanup()
+
+
+    def run_once(self, host, cmdline_args):
+        # Disable CCD so it doesn't interfere with the Cr50 AP usb connection.
+        if hasattr(self, "cr50"):
+            self.cr50.ccd_disable()
+
         # Find the last cr50 update message already in /var/log/messages
         last_message = cr50_utils.CheckForFailures(host, '')