firmware_Cr50DeepSleepStress: check sleepmask and ccdstate

sleepmask and ccdstate contain the information to debug what is keeping
cr50 awake. Modify firmware_Cr50DeepSleepStress to log this information
so it's easier to debug sleep issues.

BUG=none
BRANCH=none
TEST=none

Change-Id: Id6401da8ae1c9cd0f282a0572cfd0c6e16ca6cf4
Reviewed-on: https://chromium-review.googlesource.com/1558294
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-by: Kevin Shelton <kmshelton@chromium.org>
diff --git a/server/site_tests/firmware_Cr50DeepSleepStress/firmware_Cr50DeepSleepStress.py b/server/site_tests/firmware_Cr50DeepSleepStress/firmware_Cr50DeepSleepStress.py
index 6400d98..6e8d1cf 100644
--- a/server/site_tests/firmware_Cr50DeepSleepStress/firmware_Cr50DeepSleepStress.py
+++ b/server/site_tests/firmware_Cr50DeepSleepStress/firmware_Cr50DeepSleepStress.py
@@ -85,6 +85,7 @@
             # Power on the device
             self.servo.power_short_press()
             time.sleep(self.MIN_RESUME)
+            self.log_basic_cr50_sleep_information()
 
             # Make sure it booted into normal mode
             self.check_state((self.checkers.crossystem_checker,
@@ -122,6 +123,21 @@
         return 0 if (reset_type != 'reboot' and is_arm) else suspend_count
 
 
+    def log_basic_cr50_sleep_information(self):
+        """Log ccdstate and sleepmask.
+
+        Run ccdstate and sleepmask to get some basic information about what
+        cr50 thinks the device is doing.
+        sleepmask will show what may be preventing cr50 from entering sleep.
+        ccdstate will show what cr50 thinks the AP state is. If the AP is 'on'
+        cr50 won't enter deep sleep.
+        """
+        logging.info(self.cr50.send_command_get_output('sleepmask',
+                ['sleepmask.*>'])[0])
+        logging.info(self.cr50.send_command_get_output('ccdstate',
+                ['ccdstate.*>'])[0])
+
+
     def run_once(self, host, suspend_count, reset_type):
         """Verify deep sleep after suspending for the given number of cycles
 
@@ -148,6 +164,7 @@
         # Clear the deep sleep count
         logging.info('Clear Cr50 deep sleep count')
         self.cr50.clear_deep_sleep_count()
+        self.log_basic_cr50_sleep_information()
 
         if reset_type == 'reboot':
             self.run_reboots(suspend_count)
@@ -156,6 +173,7 @@
         else:
             raise error.TestNAError('Invalid reset_type. Use "mem" or "reboot"')
 
+        self.log_basic_cr50_sleep_information()
         # Cr50 should enter deep sleep once per suspend cycle if deep sleep is
         # supported
         expected_ds_count = self.get_expected_ds_count(host, reset_type,