Skip to content

Commit 9e12a14

Browse files
authored
Add nondet and sanity check to vulkan worker (#100)
1 parent cc762c7 commit 9e12a14

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

python/src/main/python/drivers/vkrun.py

+34-2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ def run_android(vert, frag, json, skip_render):
126126
adb('shell touch ' + ANDROID_SDCARD + '/SKIP_RENDER')
127127

128128
adb('logcat -c')
129+
cmd = ANDROID_APP + '/android.app.NativeActivity'
130+
# Explicitely set all options, don't rely on defaults
131+
flags = '--num-render 3 --png-template image --sanity-before sanity_before.png --sanity-after sanity_after.png'
132+
# Pass command line args as Intent extra. Need to nest-quote, hence the "\'blabla\'"
133+
cmd += '-e gfz "\'' + flags + '\'"'
129134
adb('shell am start ' + ANDROID_APP + '/android.app.NativeActivity')
130135

131136
# Busy wait
@@ -141,7 +146,7 @@ def run_android(vert, frag, json, skip_render):
141146
# be able to detect the app pid.
142147
time.sleep(0.1)
143148

144-
retcode = adb('shell test -f /sdcard/graphicsfuzz/DONE').returncode
149+
retcode = adb('shell test -f ' + ANDROID_SDCARD + '/DONE').returncode
145150
if retcode == 0:
146151
done = True
147152
break
@@ -150,7 +155,7 @@ def run_android(vert, frag, json, skip_render):
150155
if retcode == 1:
151156

152157
# double check that no DONE file is present
153-
retcode = adb('shell test -f /sdcard/graphicsfuzz/DONE').returncode
158+
retcode = adb('shell test -f ' + ANDROID_SDCARD + '/DONE').returncode
154159
if retcode == 0:
155160
done = True
156161
break
@@ -168,6 +173,33 @@ def run_android(vert, frag, json, skip_render):
168173
elif not done:
169174
status = 'TIMEOUT'
170175

176+
# Check sanity
177+
if status == 'SUCCESS':
178+
sanity_png_before = ANDROID_SDCARD + '/sanity_before.png'
179+
sanity_png_after = ANDROID_SDCARD + '/sanity_after.png'
180+
sanity_before_exists = adb('shell test -f ' + sanity_png_before).returncode == 0
181+
sanity_after_exists = adb('shell test -f ' + sanity_png_after).returncode == 0
182+
if sanity_before_exists and sanity_after_exists:
183+
# diff the sanity images on device
184+
retcode = adb('shell diff ' + sanity_png_before + ' ' + sanity_png_after).returncode
185+
if retcode != 0:
186+
status = 'SANITY_ERROR'
187+
188+
# Check nondet.
189+
if status == 'SUCCESS':
190+
ref_image = ANDROID_SDCARD + '/image_0.png'
191+
ref_image_exists = adb('shell test -f ' + ref_image).returncode == 0
192+
if (ref_image_exists):
193+
# If reference image is here, report nondet if either other images a
194+
# different, or missing, using return code of 'diff' on device
195+
for i in range(1,3):
196+
next_image = ANDROID_SDCARD + '/image_' + str(i) + '.png'
197+
retcode = adb('shell diff ' + ref_image + ' ' + next_image).returncode
198+
if retcode != 0:
199+
status = 'NONDET'
200+
adb('pull ' + ref_image + ' nondet0.png')
201+
adb('pull ' + next_image + ' nondet1.png')
202+
171203
with open('STATUS', 'w') as f:
172204
f.write(status)
173205

python/src/main/python/drivers/worker_vk.py

+8
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ def doImageJob(args, imageJob):
179179
res.status = tt.JobStatus.CRASH
180180
elif status == 'TIMEOUT':
181181
res.status = tt.JobStatus.TIMEOUT
182+
elif status == 'SANITY_ERROR':
183+
res.status = tt.JobStatus.SANITY_ERROR
184+
elif status == 'NONDET':
185+
res.status = tt.JobStatus.NONDET
186+
with open('nondet0.png', 'rb') as f:
187+
res.PNG = f.read()
188+
with open('nondet1.png', 'rb') as f:
189+
res.PNG2 = f.read()
182190
else:
183191
res.log += '\nUnknown status value: ' + status + '\n'
184192
res.status = tt.JobStatus.UNEXPECTED_ERROR

0 commit comments

Comments
 (0)