1b8e80941Smrg#!/bin/sh
2b8e80941Smrg
3b8e80941Smrgset -x
4b8e80941Smrg
5b8e80941Smrg# To prevent memory leaks from slowing throughput, restart everything between batches
6b8e80941SmrgBATCH_SIZE=5000
7b8e80941Smrg
8b8e80941Smrgexport XDG_RUNTIME_DIR=/tmp
9b8e80941Smrgexport LIBGL_DRIVERS_PATH=/mesa/lib/aarch64-linux-gnu/dri/
10b8e80941Smrgexport LD_LIBRARY_PATH=/mesa/lib/aarch64-linux-gnu
11b8e80941Smrgexport XDG_CONFIG_HOME=$(pwd)
12b8e80941Smrg
13b8e80941Smrgecho "[core]\nidle-time=0\nrequire-input=false\n[shell]\nlocking=false" > weston.ini
14b8e80941Smrg
15b8e80941Smrgcd /deqp/modules/gles2
16b8e80941Smrg
17b8e80941Smrg# Generate test case list file
18b8e80941Smrgweston --tty=7 &
19b8e80941Smrgsleep 1  # Give some time for Weston to start up
20b8e80941Smrg./deqp-gles2 --deqp-runmode=stdout-caselist | grep dEQP-GLES2 | cut -d ' ' -f 2 > /tmp/case-list.txt
21b8e80941Smrg
22b8e80941Smrg# Disable for now tests that are very slow, either by just using lots of CPU or by crashing
23b8e80941Smrgsed -i '/dEQP-GLES2.performance/d' /tmp/case-list.txt
24b8e80941Smrgsed -i '/dEQP-GLES2.functional.texture.filtering.2d.linear_mipmap_linear_/d' /tmp/case-list.txt
25b8e80941Smrgsed -i '/dEQP-GLES2.functional.texture.filtering.cube.linear_mipmap_linear_/d' /tmp/case-list.txt
26b8e80941Smrgsed -i '/dEQP-GLES2.functional.texture.filtering.cube.linear_mipmap_nearest_/d' /tmp/case-list.txt
27b8e80941Smrg
28b8e80941Smrg# Cannot use tee because dash doesn't have pipefail
29b8e80941Smrgtouch /tmp/result.txt
30b8e80941Smrgtail -f /tmp/result.txt &
31b8e80941Smrg
32b8e80941Smrgwhile [ -s /tmp/case-list.txt ]; do
33b8e80941Smrg    head -$BATCH_SIZE /tmp/case-list.txt > /tmp/next-batch.txt
34b8e80941Smrg	./deqp-gles2 --deqp-log-filename=/dev/null --deqp-caselist-file=/tmp/next-batch.txt --deqp-watchdog=enable --deqp-crashhandler=enable >> /tmp/result.txt
35b8e80941Smrg	deqp_status=$?
36b8e80941Smrg
37b8e80941Smrg	kill $(pidof weston)
38b8e80941Smrg	sleep 1  # Give some time for Weston to release the VT
39b8e80941Smrg	weston --tty=7 &
40b8e80941Smrg	sleep 1  # Give some time for Weston to start up
41b8e80941Smrg
42b8e80941Smrg	if [ $deqp_status -ne 0 ]; then
43b8e80941Smrg		# Continue from the subtest after the failing one
44b8e80941Smrg		crashed_test=$(grep "Test case" /tmp/result.txt | tail -1 | sed "s/Test case '\(.*\)'\.\./\1/")
45b8e80941Smrg		sed -i "0,/^$crashed_test$/d" /tmp/case-list.txt
46b8e80941Smrg
47b8e80941Smrg		# So LAVA knows what happened
48b8e80941Smrg		echo "Test case '$crashed_test'.."
49b8e80941Smrg		echo "  Crash"
50b8e80941Smrg	else
51b8e80941Smrg		# Consume a whole batch
52b8e80941Smrg	    sed -i '1,'$BATCH_SIZE'd' /tmp/case-list.txt
53b8e80941Smrg	fi
54b8e80941Smrgdone
55