@@ -69,12 +69,12 @@ def adb(adbargs, serial=None):
69
69
adbcmd += ' ' + adbargs
70
70
71
71
try :
72
- p = subprocess .run (adbcmd , shell = True , timeout = TIMEOUT_ADB_CMD )
72
+ p = subprocess .run (adbcmd , shell = True , timeout = TIMEOUT_ADB_CMD , stdout = subprocess . PIPE , universal_newlines = True )
73
73
except subprocess .TimeoutExpired as err :
74
74
print ('ERROR: adb command timed out: ' + err .cmd )
75
75
return 1
76
76
else :
77
- return p . returncode
77
+ return p
78
78
79
79
################################################################################
80
80
@@ -199,16 +199,16 @@ def getImageVulkanAndroid(args, frag, skipRender):
199
199
# although it is being started.
200
200
time .sleep (0.1 )
201
201
202
- retcode = adb ('shell test -f /sdcard/graphicsfuzz/DONE' )
202
+ retcode = adb ('shell test -f /sdcard/graphicsfuzz/DONE' ). returncode
203
203
if retcode == 0 :
204
204
done = True
205
205
break
206
206
207
- retcode = adb ('shell pidof ' + app + ' > /dev/null' )
207
+ retcode = adb ('shell pidof ' + app + ' > /dev/null' ). returncode
208
208
if retcode == 1 :
209
209
210
210
# double check that no DONE file is present
211
- retcode = adb ('shell test -f /sdcard/graphicsfuzz/DONE' )
211
+ retcode = adb ('shell test -f /sdcard/graphicsfuzz/DONE' ). returncode
212
212
if retcode == 0 :
213
213
done = True
214
214
break
@@ -355,6 +355,15 @@ def get_service(server, args):
355
355
except (TApplicationException , ConnectionRefusedError , ConnectionResetError ) as exception :
356
356
return None , None
357
357
358
+ ################################################################################
359
+
360
+ def isDeviceOffline (serial ):
361
+ devices = adb ('devices' ).stdout .splitlines ()
362
+ for d in devices :
363
+ if serial in d and 'offline' in d :
364
+ return True
365
+ return False
366
+
358
367
################################################################################
359
368
# Main
360
369
@@ -405,6 +414,10 @@ def get_service(server, args):
405
414
# Main loop
406
415
while True :
407
416
417
+ if isDeviceOffline (os .environ ['ANDROID_SERIAL' ]):
418
+ print ('#### ABORT: device is offline' )
419
+ exit (1 )
420
+
408
421
if not (service ):
409
422
service , token = get_service (server , args )
410
423
0 commit comments