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.
This commit is contained in:
Geoff Brown 2019-02-01 12:56:25 -07:00
parent 599d3ecb6b
commit 7d230281f8

View File

@ -725,8 +725,20 @@ class ADBDevice(ADBCommand):
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: