Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abort vk worker when device becomes offline #90

Merged
merged 1 commit into from
Oct 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions python/src/main/python/drivers/worker_vk.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ def adb(adbargs, serial=None):
adbcmd += ' ' + adbargs

try:
p = subprocess.run(adbcmd, shell=True, timeout=TIMEOUT_ADB_CMD)
p = subprocess.run(adbcmd, shell=True, timeout=TIMEOUT_ADB_CMD, stdout=subprocess.PIPE, universal_newlines=True)
except subprocess.TimeoutExpired as err:
print('ERROR: adb command timed out: ' + err.cmd)
return 1
else:
return p.returncode
return p

################################################################################

Expand Down Expand Up @@ -199,16 +199,16 @@ def getImageVulkanAndroid(args, frag, skipRender):
# although it is being started.
time.sleep(0.1)

retcode = adb('shell test -f /sdcard/graphicsfuzz/DONE')
retcode = adb('shell test -f /sdcard/graphicsfuzz/DONE').returncode
if retcode == 0:
done = True
break

retcode = adb('shell pidof ' + app + ' > /dev/null')
retcode = adb('shell pidof ' + app + ' > /dev/null').returncode
if retcode == 1:

# double check that no DONE file is present
retcode = adb('shell test -f /sdcard/graphicsfuzz/DONE')
retcode = adb('shell test -f /sdcard/graphicsfuzz/DONE').returncode
if retcode == 0:
done = True
break
Expand Down Expand Up @@ -355,6 +355,15 @@ def get_service(server, args):
except (TApplicationException, ConnectionRefusedError, ConnectionResetError) as exception:
return None, None

################################################################################

def isDeviceOffline(serial):
devices = adb('devices').stdout.splitlines()
for d in devices:
if serial in d and 'offline' in d:
return True
return False

################################################################################
# Main

Expand Down Expand Up @@ -405,6 +414,10 @@ def get_service(server, args):
# Main loop
while True:

if isDeviceOffline(os.environ['ANDROID_SERIAL']):
print('#### ABORT: device is offline')
exit(1)

if not(service):
service, token = get_service(server, args)

Expand Down