Debian Codegraph @

tests/unit/runtest.sh

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