1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
#!/bin/bash
#
# Copyright 2012 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Author: Juhapekka Piiroinen <juhapekka.piiroinen@canonical.com>
################################################################################
set -e
source `dirname $0`/../../export_qml_dir.sh
_CMD=""
_TARGETPATH=$1
_TESTFILEPATH=$2
_MINIMAL=$3
relpath() {
python -c 'import os, sys; print(os.path.relpath(*sys.argv[1:]))' $*
}
if [ -z $_TESTFILEPATH ]; then
_TESTFILEPATH=$_TARGETPATH
elif [[ 'minimal custom' == *$_TESTFILEPATH* ]]; then
_MINIMAL=$_TESTFILEPATH
_TESTFILEPATH=$_TARGETPATH
fi
test -z $_MINIMAL && _MINIMAL=default
if [ -z $_TARGETPATH ]; then
echo Usage:
echo " $0 TEST_EXECUTABLE [QML_FILE] [QT_QPA_PLATFORM]"
echo ''
echo 'Examples:'
echo " $0 $(relpath ${BUILD_DIR}/tests/unit/components/components) $(relpath ${SRC_DIR}/tests/unit/components/tst_label13.qml) minimal"
echo ''
echo " cd $(relpath ${BUILD_DIR}/tests/unit/mainview13)"
echo " ../$(basename $0) mainview13 minimal"
echo " cd ../../.."
echo ''
echo " cd $(relpath ${BUILD_DIR}/tests/unit/visual)"
echo " ../../xvfb.sh ../../unit/$(basename $0) visual ../../unit/visual/tst_listitem13.qml"
echo " cd ../../.."
echo ''
echo " $(relpath ${BUILD_DIR}/tests/xvfb.sh) $0 $(relpath ${BUILD_DIR}/tests/unit/bottomedge/bottomedge)"
exit 1
fi
_TARGET=$(basename $_TARGETPATH)
_TESTFILE=$(basename $_TESTFILEPATH)
_XML="${BUILD_DIR}/tests/$_TARGET_$_TESTFILE.xml"
_ARGS="-p -o -p $_XML,xunitxml -p -o -p -,txt"
function create_fallback_xml {
cat << EOF > $_XML
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite errors="$1" failures="1" tests="1" name="$_TESTFILE">
<testcase result="fail" name="${_TESTFILE}_Execution">
$2
</testcase>
</testsuite>
EOF
}
function abspath {
if [[ "$1" = /* ]]; then
ABSPATH=$1
else
ABSPATH=./$1
fi
# Note: '|| echo' so we get a sane error message if it doesn't exist
echo -n $(readlink -f $ABSPATH || echo $ABSPATH)
}
function create_test_cmd {
EXE=$(abspath $_TARGETPATH)
_CMD="-n $_TESTFILE -m 500"
DEB_HOST_ARCH=$(dpkg-architecture -qDEB_HOST_ARCH)
if [[ ${DEB_HOST_ARCH} =~ 'arm' ]]; then
_CMD="dbus-test-runner --task $EXE $_CMD"
else
_CMD="dbus-test-runner --task gdb -p --quiet $_CMD"
_CMD="$_CMD -p --batch -p -ex -p 'set print thread-events off' -p -ex -p run -p -ex -p bt -p --return-child-result -p --args -p $EXE"
fi
if [[ 'minimal custom' == *$_MINIMAL* ]]; then
_CMD="$_CMD -p -platform -p $_MINIMAL"
fi
if [[ $_TESTFILEPATH == *\.qml* ]]; then
_CMD="$_CMD -p -input -p $(abspath $_TESTFILEPATH)"
fi
_CMD="$_CMD -p -maxwarnings -p 100"
}
function execute_test_cmd {
echo "Executing $_CMD $_ARGS"
if [ ! -x $_TARGETPATH ]; then
echo "Error: $_TARGET wasn't built!"
RESULT=2
elif [ $DISPLAY ]; then
SRC_TARGETPATH=$(echo $EXE | sed "s@$BUILD_DIR@$SRC_DIR@")
cd $(dirname $SRC_TARGETPATH)
# https://bugs.launchpad.net/lomiri-ui-toolkit/+bug/1256999
# https://bugreports.qt-project.org/browse/QTBUG-36243
# QV4_MM_AGGRESSIVE_GC=1 \
# qt.qml.connections silence "onFoo()" deprecation warnings, and
# qt.qml.binding.restoreMode silence "Binding.restoreMode" warnings.
# They're deprecated/require new behavior in Qt 5.15 but new syntax/
# new behavior isn't available in Qt 5.12.
# https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=a2eef6b511988b2435c4e39b6b5551e857ce7775
# https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=316a120f37982db9f3062ac1e094d92da4e356d7
ALARM_BACKEND=memory SUPPRESS_DEPRECATED_NOTE=no \
QT_LOGGING_RULES="qt.qml.connections.warning=false;qt.qml.binding.restoreMode.warning=false;[PERFORMANCE].warning=false" \
$_CMD $_ARGS 2>&1 | sed "s@$_TESTFILE: @@" | grep -v 'QFontDatabase: Cannot find font directory'
if [ ! -s $_XML ]; then
# Write fallback in case it crashed and the file is empty
if [[ $_XML == *".SEGFAULT"* ]]; then
create_fallback_xml 0 '<!-- message="Test results corrupted (crashed)" type="qwarn" -->'
else
create_fallback_xml 1 '<failure message="Test results corrupted (crashed)" result="fail"/>'
fi
fi
if [ "x$UITK_TEST_KEEP_RUNNING" != "x1" ]; then
${SRC_DIR}/tests/checkresults.sh $_XML
RESULT=$?
fi
else
echo "Skipped because no DISPLAY available"
fi
if [ -z $RESULT ]; then
RESULT=0
# segfault
elif [ $RESULT -eq 139 ]; then
RESULT=2
# abort
elif [ $RESULT -eq 134 ]; then
RESULT=2
fi
echo "$_TARGET_$_TESTFILE exited with $RESULT"
return $RESULT
}
# Tests are written using this theme in mind.
export UITK_ICON_THEME="suru"
# Always create XML in case the test can't be run, eg. .so file missing
create_fallback_xml 1 '<failure message="Test couldnt be run" result="fail"/>'
create_test_cmd
execute_test_cmd
RESULT=$?
exit $RESULT
|