Debian Codegraph @

src/tests/runtest

raw ◀ ▶
1 Debian patch touch this file
1 #!/bin/sh
2
3 # -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*-
4 # vim:set et sts=4:
5
6 # Run a test case given by the first argument in a separate directory.
7 # This script may also launch $top_builddir/bus/ibus-daemon for testing.
8
9 # Executing a test that uses this file
10 # ====================================
11 #
12 # Running a single test:
13 #
14 # $ make check TESTS=ibus-foo
15 #
16 # or
17 #
18 # $ top_builddir=<...> top_srcdir=<...> builddir=<...> ./runtest ibus-foo
19
20 : ${top_builddir:=../..}
21 : ${top_srcdir:=../..}
22 : ${builddir:=.}
23 : ${srcdir:=.}
24 : ${DISABLE_GUI_TESTS:=''}
25 : ${DISABLE_DAEMONIZE_IN_TESTS:=''}
26 : ${TEST_GTK_VERSION:=0}
27 : ${TEST_GTK:=0}
28
29 BUS_REQUIRED_TESTS="
30 ibus-bus
31 ibus-config
32 ibus-configservice
33 ibus-factory
34 ibus-inputcontext
35 ibus-inputcontext-create
36 ibus-engine-switch
37 ibus-compose
38 ibus-keypress
39 test-stress
40 xkb-latin-layouts
•41 "
42 IBUS_SCHEMA_FILE='org.freedesktop.ibus.gschema.xml'
43 #GTK_QUERY_MODULE=gtk-query-immodules-3.0-32
44 # On Debian with multiarch support, gtk-query-immodules-3.0 is under
45 # /usr/lib/x86_64-linux-gnu/libgtk-3-0/
46 GTK_QUERY_MODULE=/usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`/libgtk-3-0/gtk-query-immodules-3.0
•47 MACHINE=`uname -m`
48
49 ###if test x"$MACHINE" = xx86_64 ; then
50 ### GTK_QUERY_MODULE=gtk-query-immodules-3.0-64
51 ###fi
52 if ! command -v $GTK_QUERY_MODULE > /dev/null 2>&1 ; then
53 GTK_QUERY_MODULE=gtk-query-immodules-3.0
54 fi
55
56 retval=0
57
58 # Portable replacement of basename.
59 func_basename () {
60 case "$1" in
61 */*)
62 expr "$1" : '.*/\(.*\)'
63 ;;
64 *)
65 echo "$1"
66 esac
67 }
68
69 # Portable replacement of dirname.
70 func_dirname () {
71 case "$1" in
72 */*)
73 expr "$1" : '\(.*\)/.*'
74 ;;
75 *)
76 echo .
77 esac
78 }
79
80 # Kill ibus-daemon process and remove temporary files.
81 func_cleanup () {
82 tstdir=$1
83 if test -f $tstdir/ibus-daemon.pid; then
84 . $tstdir/ibus-daemon.pid
85 kill $IBUS_DAEMON_PID > /dev/null 2>&1
86 fi
87 rm -fr $tstdir
88 }
89
90 # Prepare component files necessary for testing, under components/.
91 func_copy_component () {
92 file=$1
93 base=`func_basename $file`
94 libexecdir=`func_dirname $file`
95 # top_srcdir != top_builddir in make dist
96 libexecdir=`echo "$libexecdir" | sed -e "s|$top_srcdir|$top_builddir|"`
97 if test -f $file.in; then
98 mkdir -p components
99 sed "s|@libexecdir@|$libexecdir|g" < $file.in > components/$base
100 fi
101 }
102
103 trap 'func_cleanup $tstdir' 1 2 3 15
104
105 tst=$1; shift
106 tstdir=tmp-`func_basename $tst`
107
108 for t in $DISABLE_GUI_TESTS; do
109 if test $t = `func_basename $tst`; then
110 exit 77
111 fi
112 done
113
114 # IBusEngine has GSettings
115 if test ! -f "$top_srcdir/data/dconf/$IBUS_SCHEMA_FILE" ; then
116 echo "NOT FOUND $top_srcdir/data/dconf/$IBUS_SCHEMA_FILE"
117 exit 1
118 fi
119
120 run_test_case()
121 {
122 test -d $tstdir || mkdir $tstdir
123 backup_dir=$PWD
124 cd $tstdir
125
126 need_bus=no
127 for t in $BUS_REQUIRED_TESTS; do
128 if test $t = `func_basename $tst`; then
129 need_bus=yes
130 fi
131 done
132
133 if test $need_bus = yes; then
134 if test ! -f "../$top_builddir/conf/memconf/ibus-memconf" ; then
135 echo "NOT FOUNND ibus-memconf. Need configure --enable-memconf"
136 exit 1
137 fi
138 # func_copy_component replaces s/$top_srcdir/%top_builddir/
139 func_copy_component "../$top_srcdir/engine/simple.xml"
140 func_copy_component "../$top_srcdir/conf/memconf/memconf.xml"
141
142 IBUS_COMPONENT_PATH=$PWD/components
143 export IBUS_COMPONENT_PATH
144
145 IBUS_ADDRESS_FILE=$PWD/ibus-daemon.pid
146 export IBUS_ADDRESS_FILE
147
148 test $TEST_GTK -eq 1 && case $TEST_GTK_VERSION in
149 4)
150 if test -f "../$top_builddir/client/gtk4/.libs/libim-ibus.so" ; then
151 IM_IBUS_SO="../$top_builddir/client/gtk4/.libs/libim-ibus.so"
152 elif test -f "../$top_builddir/client/gtk4/libim-ibus.so" ; then
153 IM_IBUS_SO="../$top_builddir/client/gtk4/libim-ibus.so"
154 else
155 echo "NOT FOUND $top_builddir/client/gtk4/libim-ibus.so"
156 exit 1
157 fi
158 mkdir -p "$PWD/lib/gtk-4.0/immodules"
159 cp "$IM_IBUS_SO" "$PWD/lib/gtk-4.0/immodules/."
160 export GTK_EXE_PREFIX="$PWD"
161 ;;
162 3)
163 if test -f "../$top_builddir/client/gtk3/.libs/im-ibus.so" ; then
164 IM_IBUS_SO="../$top_builddir/client/gtk3/.libs/im-ibus.so"
165 elif test -f "../$top_builddir/client/gtk3/im-ibus.so" ; then
166 IM_IBUS_SO="../$top_builddir/client/gtk3/im-ibus.so"
167 else
168 echo "NOT FOUND $top_builddir/client/gtk3/im-ibus.so"
169 exit 1
170 fi
171 GTK_IM_MODULE_FILE=$PWD/imcache
172 export GTK_IM_MODULE_FILE
173 $GTK_QUERY_MODULE "$IM_IBUS_SO" > $GTK_IM_MODULE_FILE
174 ;;
175 *)
176 echo "NOT SUPPORT GTK_VERSION $TEST_GTK_VERSION"
177 exit 1
178 ;;
179 esac || :
180
181 cp "../$top_srcdir/data/dconf/$IBUS_SCHEMA_FILE" $PWD
182 glib-compile-schemas $PWD
183 if test $? -ne 0 ; then
184 echo "FAILED glib-compile-schemas"
185 retval=1
186 return
187 fi
188 if test ! -f $PWD/gschemas.compiled ; then
189 echo "NOT FOUND $PWD/gschemas.compiled"
190 retval=1
191 return
192 fi
193 export GSETTINGS_SCHEMA_DIR=$PWD
194
195 # Start ibus-daemon.
196 DAEMON_ARGS='
197 --cache=none
198 --panel=disable
199 --emoji-extension=disable
200 --config=default
201 --verbose
202 '
203 if test x"$DISABLE_DAEMONIZE_IN_TESTS" = x ; then
204 ../$top_builddir/bus/ibus-daemon \
205 $DAEMON_ARGS --daemonize;
206 else
207 ../$top_builddir/bus/ibus-daemon \
208 $DAEMON_ARGS &
209 fi
210
211 # Wait until all necessary components are up.
212 sleep 3
213
214 export GTK_IM_MODULE=ibus
215 # Gtk-WARNING **: Unable to acquire the address of the accessibility
216 # bus: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ExecFailed:
217 # Failed to execute program org.a11y.Bus: Permission denied. If you are
218 # attempting to run GTK without a11y support, GTK_A11Y should be set to
219 # 'none'.
220 export GTK_A11Y=none
221 fi
222
223 export IBUS_COMPOSE_CACHE_DIR=$PWD
224
225 "../$tst" ../$top_srcdir/src/tests ${1+"$@"}
226
227 retval=`expr $retval \| $?`
228
229 cd $backup_dir
230
231 func_cleanup $tstdir
232 }
233
234 envfile=$srcdir/`func_basename $tst`.env
235 if test -f $envfile ; then
236 ENVS="`cat $envfile`"
237 fi;
238 if test x"$ENVS" = x ; then
239 run_test_case $@
240 else
241 LANG_backup=$LANG
242 i=1
243 # "for e in $ENVS" separates the variable by space but not line feed.
244 # "echo $ENVS | while read e" does not forward `retval`
245 # to the parent process.
246 while read e; do
247 first=`echo "$e" | cut -c1-1`
248 if test x"$first" = x"#" ; then
249 continue
250 fi
251 unset NO_LOAD_COMPOSE_FILE
252 unset COMPOSE_FILE
253 export $e
254 echo "Run `func_basename $tst` on $e"
255 echo "======================="
256 run_test_case $@
257 echo ""
258 i=`expr $i + 1`
259 done << EOF_ENVS
260 `echo "$ENVS"`
261 EOF_ENVS
262 export LANG=$LANG_backup
263 fi
264
265 exit $retval