Bug 1509207 - In android tests, wait for valid ro.build.version.sdk; r=bc
authorGeoff Brown <gbrown@mozilla.com>
Fri, 01 Feb 2019 12:56:25 -0700
changeset 456526 0f6e106e3efde0812c69233ec8ae9a2d824a5135
parent 456525 e454c9f140445c9655907f54a5c7f760d4e0d430
child 456527 8641112b948793530189b1b1fff705d145301f57
push id35488
push userdvarga@mozilla.com
push dateSat, 02 Feb 2019 09:44:51 +0000
treeherdermozilla-central@d8cebb3b46cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbc
bugs1509207
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1509207 - In android tests, wait for valid ro.build.version.sdk; r=bc 'getprop ro.build.version.sdk' intermittently returns '' on startup. This change tries to wait and retry until a valid response is received.
testing/mozbase/mozdevice/mozdevice/adb.py
--- a/testing/mozbase/mozdevice/mozdevice/adb.py
+++ b/testing/mozbase/mozdevice/mozdevice/adb.py
@@ -720,18 +720,30 @@ class ADBDevice(ADBCommand):
             cleared = self.shell_bool('logcat -P ""', timeout=timeout)
         except ADBError:
             cleared = False
         if not cleared:
             self._logger.info("Unable to turn off logcat chatty")
 
         self._selinux = None
         self.enforcing = 'Permissive'
-        self.version = int(self.shell_output("getprop ro.build.version.sdk",
-                                             timeout=timeout))
+
+        self.version = 0
+        while self.version < 1 and (time.time() - start_time) <= float(timeout):
+            try:
+                version = self.shell_output("getprop ro.build.version.sdk",
+                                            timeout=timeout)
+                self.version = int(version)
+            except ValueError:
+                self._logger.info("unexpected ro.build.version.sdk: '%s'" % version)
+                time.sleep(2)
+        if self.version < 1:
+            # note slightly different meaning to the ADBTimeoutError here (and above):
+            # failed to get valid (numeric) version string in all attempts in allowed time
+            raise ADBTimeoutError("ADBDevice: unable to determine ro.build.version.sdk.")
 
         # Do we have pidof?
         if self.version >= version_codes.N:
             self._have_pidof = self.shell_bool("type pidof", timeout=timeout)
         else:
             # unexpected pidof behavior observed on Android 6 in bug 1514363
             self._have_pidof = False
         self._logger.info("Native pidof support: {}".format(self._have_pidof))