Two fixes for AUTest to work on builders.

Fix timeout logic. It's possible for the builders to be going under so much
work that the timeout will pass before we enter the while loop. Fix this.

I've also gone ahead and check for error code 127 to avoid ever having an issue
where we can't find gsutil in the future. I spent a long time debugging this
before realizing the devserver couldn't find gsutil.

BUG=chromium:196387
TEST=Ran this code on a builder where it used to fail. Also ran unittests and
modified unittests to test new behavior.

Change-Id: Ibaeeb04c00c29783fc83547c4828972b1f38fce5
Reviewed-on: https://gerrit.chromium.org/gerrit/45505
Commit-Queue: Chris Sosa <sosa@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
diff --git a/gsutil_util_unittest.py b/gsutil_util_unittest.py
index ca84970..8225a75 100755
--- a/gsutil_util_unittest.py
+++ b/gsutil_util_unittest.py
@@ -39,8 +39,9 @@
       else:
         mock_process = self._good_mock_process
 
-      subprocess.Popen(mox.StrContains(str_should_contain), shell=True,
-                       stdout=subprocess.PIPE).AndReturn(mock_process)
+      subprocess.Popen(mox.StrContains(str_should_contain),
+                       shell=True, stdout=subprocess.PIPE,
+                       stderr=subprocess.PIPE).AndReturn(mock_process)
       mock_process.communicate().AndReturn(('Does not matter', None))
 
   def testDownloadFromGS(self):
@@ -105,8 +106,9 @@
                                     pattern).AndReturn([name])
 
     self.mox.ReplayAll()
+    # Timeout explicitly set to 0 to test that we always run at least once.
     returned_names = gsutil_util.GetGSNamesWithWait(
-        pattern, archive_url, msg, delay=1)
+        pattern, archive_url, msg, delay=1, timeout=0)
     self.assertEqual([name], returned_names)
     self.mox.VerifyAll()
 
@@ -135,7 +137,7 @@
 
     self.mox.ReplayAll()
     returned_names = gsutil_util.GetGSNamesWithWait(
-        pattern, archive_url, msg, delay=1)
+        pattern, archive_url, msg, delay=1, timeout=3)
     self.assertEqual(name, returned_names[0])
     self.mox.VerifyAll()