#!/bin/bash
# Reproducer driver for the ANGLE linkValidateOutputVariables OOB.
# Prerequisite: chromium-changes.patch and swiftshader-env-workaround.patch
# applied; out/asan/chrome rebuilt.
set -e
HERE="$(cd "$(dirname "$0")" && pwd)"
cd "$HERE"

python3 server.py &
SRV=$!
trap 'kill $SRV 2>/dev/null' EXIT
sleep 1

rm -rf /tmp/chrome-poc-profile
ASAN_OPTIONS="handle_abort=1:symbolize=1" \
timeout 45 "${CHROME:-out/asan/chrome}" \
  --headless --no-sandbox \
  --no-first-run --no-default-browser-check \
  --use-gl=angle --use-angle=swiftshader \
  --enable-unsafe-swiftshader \
  --enable-logging=stderr --v=0 \
  --disable-in-process-stack-traces \
  --user-data-dir=/tmp/chrome-poc-profile \
  http://127.0.0.1:8090/poc.html 2>&1 \
  | grep -av 'dbus\|DBus\|dbind\|Fontconfig\|udev\|gcm\|Registration response'
