Improve the check for end of update at OOBE.

Today we check for a None return value from get_update_engine_status()
to tell us that the DUT has automatically rebooted. However when the
update-engine takes a while to return a result it also returns None.

If the command timed out, Im checking for update_engine_client --status
showing some progress. If it never started, the DUT must have rebooted.

BUG=chromium:1032786
TEST=autoupdate_ForcedOOBEUpdate locally

Change-Id: Ie2c3f965204ef12442bbff6a3cfd403b1744458c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/1960976
Commit-Queue: David Haddock <dhaddock@chromium.org>
Tested-by: David Haddock <dhaddock@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/client/cros/update_engine/update_engine_util.py b/client/cros/update_engine/update_engine_util.py
index 728e8a5..74e3a9f 100644
--- a/client/cros/update_engine/update_engine_util.py
+++ b/client/cros/update_engine/update_engine_util.py
@@ -169,13 +169,23 @@
             time.sleep(1)
 
 
-    def _get_update_engine_status(self, timeout=3600, ignore_status=True):
-        """Returns a dictionary version of update_engine_client --status"""
+    def _get_update_engine_status(self, timeout=3600, ignore_timeout=True):
+        """
+        Gets a dictionary version of update_engine_client --status.
+
+        @param timeout: How long to wait for the status to return.
+        @param ignore_timeout: True to throw an exception if timeout occurs.
+
+        @return Dictionary of values within update_engine_client --status.
+        @raise: error.AutoservError if command times out
+
+        """
         status = self._run('update_engine_client --status', timeout=timeout,
-                           ignore_timeout=True, ignore_status=ignore_status)
+                           ignore_status=True, ignore_timeout=ignore_timeout)
+
         if status is None:
             return None
-        logging.debug(status)
+        logging.info(status)
         if status.exit_status != 0:
             return None
         status_dict = {}
diff --git a/server/site_tests/autoupdate_ForcedOOBEUpdate/autoupdate_ForcedOOBEUpdate.py b/server/site_tests/autoupdate_ForcedOOBEUpdate/autoupdate_ForcedOOBEUpdate.py
index 48834a5..561a2d1 100644
--- a/server/site_tests/autoupdate_ForcedOOBEUpdate/autoupdate_ForcedOOBEUpdate.py
+++ b/server/site_tests/autoupdate_ForcedOOBEUpdate/autoupdate_ForcedOOBEUpdate.py
@@ -40,17 +40,18 @@
         boot_id = self._host.get_boot_id()
 
         while True:
-            status = self._get_update_engine_status(timeout=10)
+            try:
+                self._get_update_engine_status(timeout=10,
+                                               ignore_timeout=False)
+            except error.AutoservRunError as e:
+                # Check if command timed out because update-engine was taking
+                # a while or if the command didn't even start.
+                query = 'Querying Update Engine status...'
+                if query not in e.result_obj.stderr:
+                    # Command did not start. DUT rebooted at end of update.
+                    self._host.test_wait_for_boot(boot_id)
+                    break
 
-            # During reboot, status will be None
-            if status is None:
-                # Checking only for the status to change to IDLE can hide
-                # errors that occurred between status checks. When the forced
-                # update is complete, it will automatically reboot the device.
-                # So we wait for an explict reboot. We will verify that the
-                # update completed successfully later in verify_update_events()
-                self._host.test_wait_for_boot(boot_id)
-                break
             time.sleep(1)
             if time.time() > timeout:
                 raise error.TestFail('OOBE update did not finish in %d '