ptests: Update test environment for non and root user

Export LANG only if it has not yet been defined for the current user.

Check that HOME directory exists and is writable before running tests.
For example "ptest" user is created without home directory by default.

Webengine tests expect --no-sandbox when running as root so export
environment variable to disable sandbox.

Task-number: QTBUG-118680
Change-Id: I7f40378f92e089bfb3279270ead0b92b309eeb47
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
This commit is contained in:
Ari Parkkila 2024-05-20 08:44:26 +03:00
parent dcd4f6f846
commit e13760ae97

View File

@ -5,8 +5,22 @@ if [ ! -s tst_list ]; then
exit 0
fi
export LANG=C.UTF-8
export QT_QPA_PLATFORM=offscreen
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})