#!/bin/sh

if [ ! -s tst_list ]; then
    echo PASS: no tests
    exit 0
fi

if [ -z "$LANG" ]; then
    export LANG=C.UTF-8
fi
if [ -z "$QT_QPA_PLATFORM" ]; then
    export QT_QPA_PLATFORM=offscreen
fi
if [ $UID -ne 0 ]; then
    if [ ! -w ${HOME} ]; then
        echo "Home directory should be writable, run as root:"
        echo "usermod -d /home/${USER} ${USER} && mkhomedir_helper ${USER}"
    fi
fi
if [ $UID -eq 0 ]; then
    export QTWEBENGINE_DISABLE_SANDBOX=1
fi

for test in $(cat tst_list); do
    (
    cd $(dirname ${test})
    t=$(basename ${test})
    ./${t} && echo PASS: ${t} || echo FAIL: ${t}
    )
done
