blob: 4794f6b7c19de89494f29021a13482443ffec91d [file] [log] [blame]
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +01001#!/bin/bash
2#
3# Runner for an individual run-test.
4
5msg() {
6 if [ "$QUIET" = "n" ]; then
7 echo "$@"
8 fi
9}
10
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +000011ANDROID_ROOT="/system"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010012ARCHITECTURES_32="(arm|x86|mips|none)"
Andreas Gampe1a5c4062015-01-15 12:10:47 -080013ARCHITECTURES_64="(arm64|x86_64|mips64|none)"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010014ARCHITECTURES_PATTERN="${ARCHITECTURES_32}"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +000015BOOT_IMAGE=""
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010016COMPILE_FLAGS=""
17DALVIKVM="dalvikvm32"
18DEBUGGER="n"
19DEV_MODE="n"
20DEX2OAT=""
Alex Light8a0e0332015-10-26 10:11:58 -070021EXPERIMENTAL=""
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010022FALSE_BIN="/system/bin/false"
23FLAGS=""
Alex Light7233c7e2016-07-28 10:07:45 -070024ANDROID_FLAGS=""
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010025GDB=""
Nicolas Geoffraybaf91022014-10-08 09:56:45 +010026GDB_ARGS=""
27GDB_SERVER="gdbserver"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010028HAVE_IMAGE="y"
29HOST="n"
30INTERPRETER="n"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080031JIT="n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010032INVOKE_WITH=""
Alex Lighte06b6342017-01-05 14:37:21 -080033IS_JVMTI_TEST="n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010034ISA=x86
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +000035LIBRARY_DIRECTORY="lib"
Colin Crossafd3c9e2016-09-16 13:47:21 -070036TEST_DIRECTORY="nativetest"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +000037MAIN=""
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010038OPTIMIZE="y"
39PATCHOAT=""
40PREBUILD="y"
41QUIET="n"
42RELOCATE="y"
Richard Uhler76f5cb62016-04-04 13:30:16 -070043STRIP_DEX="n"
Jeff Hao207a37d2014-10-29 17:24:25 -070044SECONDARY_DEX=""
Hiroshi Yamauchi6ffb9cc2015-08-31 15:14:17 -070045TIME_OUT="gdb" # "n" (disabled), "timeout" (use timeout), "gdb" (use gdb)
46# Value in seconds
Hiroshi Yamauchidcf0d4b2015-09-09 18:59:42 -070047if [ "$ART_USE_READ_BARRIER" = "true" ]; then
Hiroshi Yamauchia9b296c2016-10-07 17:07:03 -070048 TIME_OUT_VALUE=2400 # 40 minutes.
Hiroshi Yamauchidcf0d4b2015-09-09 18:59:42 -070049else
Mathieu Chartier2576be22016-05-24 10:24:53 -070050 TIME_OUT_VALUE=1200 # 20 minutes.
Hiroshi Yamauchidcf0d4b2015-09-09 18:59:42 -070051fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010052USE_GDB="n"
Nicolas Geoffray288a4a22014-10-07 11:02:40 +010053USE_JVM="n"
Igor Murashkin7617abd2015-07-10 18:27:47 -070054VERIFY="y" # y=yes,n=no,s=softfail
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010055ZYGOTE=""
Andreas Gampe2b0fa5b2014-10-31 18:12:30 -070056DEX_VERIFY=""
Andreas Gampe65357032015-02-19 15:10:24 -080057USE_DEX2OAT_AND_PATCHOAT="y"
Andreas Gampe4d2ef332015-08-05 09:24:45 -070058INSTRUCTION_SET_FEATURES=""
Mathieu Chartier031768a2015-08-27 10:25:02 -070059ARGS=""
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -070060EXTERNAL_LOG_TAGS="n" # if y respect externally set ANDROID_LOG_TAGS.
61DRY_RUN="n" # if y prepare to run the test but don't run it.
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +000062TEST_VDEX="n"
Alex Lighte06b6342017-01-05 14:37:21 -080063TEST_IS_NDEBUG="n"
Calin Juravle857f0582016-12-20 14:36:59 +000064APP_IMAGE="y"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010065
66while true; do
67 if [ "x$1" = "x--quiet" ]; then
68 QUIET="y"
69 shift
Alex Lighte06b6342017-01-05 14:37:21 -080070 elif [ "x$1" = "x--jvmti" ]; then
71 IS_JVMTI_TEST="y"
72 shift
Alex Lightfaf90b62016-08-12 14:43:48 -070073 elif [ "x$1" = "x-O" ]; then
Alex Lighte06b6342017-01-05 14:37:21 -080074 TEST_IS_NDEBUG="y"
Alex Lightfaf90b62016-08-12 14:43:48 -070075 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010076 elif [ "x$1" = "x--lib" ]; then
77 shift
78 if [ "x$1" = "x" ]; then
79 echo "$0 missing argument to --lib" 1>&2
80 exit 1
81 fi
82 LIB="$1"
83 shift
Alex Light97acf192016-03-17 09:59:38 -070084 elif [ "x$1" = "x--gc-stress" ]; then
85 # Give an extra 5 mins if we are gc-stress.
86 TIME_OUT_VALUE=$((${TIME_OUT_VALUE} + 300))
87 shift
Mathieu Chartier031768a2015-08-27 10:25:02 -070088 elif [ "x$1" = "x--testlib" ]; then
89 shift
90 if [ "x$1" = "x" ]; then
91 echo "$0 missing argument to --testlib" 1>&2
92 exit 1
93 fi
Mathieu Chartierde286fd2015-09-03 18:10:29 -070094 ARGS="${ARGS} $1"
Mathieu Chartier031768a2015-08-27 10:25:02 -070095 shift
David Srbecky52886112016-01-22 13:56:47 +000096 elif [ "x$1" = "x--args" ]; then
97 shift
98 if [ "x$1" = "x" ]; then
99 echo "$0 missing argument to --args" 1>&2
100 exit 1
101 fi
102 ARGS="${ARGS} $1"
103 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100104 elif [ "x$1" = "x-Xcompiler-option" ]; then
105 shift
106 option="$1"
107 FLAGS="${FLAGS} -Xcompiler-option $option"
108 COMPILE_FLAGS="${COMPILE_FLAGS} $option"
109 shift
Alex Light7233c7e2016-07-28 10:07:45 -0700110 elif [ "x$1" = "x--android-runtime-option" ]; then
111 shift
112 option="$1"
113 ANDROID_FLAGS="${ANDROID_FLAGS} $option"
114 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100115 elif [ "x$1" = "x--runtime-option" ]; then
116 shift
117 option="$1"
118 FLAGS="${FLAGS} $option"
119 shift
120 elif [ "x$1" = "x--boot" ]; then
121 shift
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000122 BOOT_IMAGE="$1"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100123 shift
124 elif [ "x$1" = "x--no-dex2oat" ]; then
125 DEX2OAT="-Xcompiler:${FALSE_BIN}"
Andreas Gampe65357032015-02-19 15:10:24 -0800126 USE_DEX2OAT_AND_PATCHOAT="n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100127 shift
128 elif [ "x$1" = "x--no-patchoat" ]; then
129 PATCHOAT="-Xpatchoat:${FALSE_BIN}"
Andreas Gampe65357032015-02-19 15:10:24 -0800130 USE_DEX2OAT_AND_PATCHOAT="n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100131 shift
132 elif [ "x$1" = "x--relocate" ]; then
133 RELOCATE="y"
134 shift
135 elif [ "x$1" = "x--no-relocate" ]; then
136 RELOCATE="n"
137 shift
138 elif [ "x$1" = "x--prebuild" ]; then
139 PREBUILD="y"
140 shift
Calin Juravle857f0582016-12-20 14:36:59 +0000141 elif [ "x$1" = "x--no-app-image" ]; then
142 APP_IMAGE="n"
143 shift
Richard Uhler76f5cb62016-04-04 13:30:16 -0700144 elif [ "x$1" = "x--strip-dex" ]; then
145 STRIP_DEX="y"
146 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100147 elif [ "x$1" = "x--host" ]; then
148 HOST="y"
Nicolas Geoffray8eedb472014-10-29 14:05:59 +0000149 ANDROID_ROOT="$ANDROID_HOST_OUT"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100150 shift
151 elif [ "x$1" = "x--no-prebuild" ]; then
152 PREBUILD="n"
153 shift
154 elif [ "x$1" = "x--no-image" ]; then
155 HAVE_IMAGE="n"
156 shift
Jeff Hao207a37d2014-10-29 17:24:25 -0700157 elif [ "x$1" = "x--secondary" ]; then
158 SECONDARY_DEX=":$DEX_LOCATION/$TEST_NAME-ex.jar"
Calin Juravle175dc732015-08-25 15:42:32 +0100159 # Enable cfg-append to make sure we get the dump for both dex files.
160 # (otherwise the runtime compilation of the secondary dex will overwrite
Roland Levillainb0103ca2016-11-01 14:48:47 +0000161 # the dump of the first one).
Calin Juravle175dc732015-08-25 15:42:32 +0100162 FLAGS="${FLAGS} -Xcompiler-option --dump-cfg-append"
163 COMPILE_FLAGS="${COMPILE_FLAGS} --dump-cfg-append"
Jeff Hao207a37d2014-10-29 17:24:25 -0700164 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100165 elif [ "x$1" = "x--debug" ]; then
166 DEBUGGER="y"
Brian Carlstrom93d6ce52014-11-04 22:31:35 -0800167 TIME_OUT="n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100168 shift
169 elif [ "x$1" = "x--gdb" ]; then
170 USE_GDB="y"
171 DEV_MODE="y"
Brian Carlstrom93d6ce52014-11-04 22:31:35 -0800172 TIME_OUT="n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100173 shift
Mathieu Chartierc0a8a802014-10-17 15:58:01 -0700174 elif [ "x$1" = "x--gdb-arg" ]; then
175 shift
176 gdb_arg="$1"
177 GDB_ARGS="${GDB_ARGS} $gdb_arg"
178 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100179 elif [ "x$1" = "x--zygote" ]; then
180 ZYGOTE="-Xzygote"
181 msg "Spawning from zygote"
182 shift
183 elif [ "x$1" = "x--dev" ]; then
184 DEV_MODE="y"
185 shift
186 elif [ "x$1" = "x--interpreter" ]; then
187 INTERPRETER="y"
188 shift
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800189 elif [ "x$1" = "x--jit" ]; then
190 JIT="y"
191 shift
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100192 elif [ "x$1" = "x--jvm" ]; then
193 USE_JVM="y"
194 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100195 elif [ "x$1" = "x--invoke-with" ]; then
196 shift
197 if [ "x$1" = "x" ]; then
198 echo "$0 missing argument to --invoke-with" 1>&2
199 exit 1
200 fi
201 if [ "x$INVOKE_WITH" = "x" ]; then
202 INVOKE_WITH="$1"
203 else
204 INVOKE_WITH="$INVOKE_WITH $1"
205 fi
206 shift
207 elif [ "x$1" = "x--no-verify" ]; then
208 VERIFY="n"
209 shift
Igor Murashkin7617abd2015-07-10 18:27:47 -0700210 elif [ "x$1" = "x--verify-soft-fail" ]; then
211 VERIFY="s"
212 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100213 elif [ "x$1" = "x--no-optimize" ]; then
214 OPTIMIZE="n"
215 shift
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000216 elif [ "x$1" = "x--android-root" ]; then
217 shift
218 ANDROID_ROOT="$1"
219 shift
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700220 elif [ "x$1" = "x--instruction-set-features" ]; then
221 shift
222 INSTRUCTION_SET_FEATURES="$1"
223 shift
Mathieu Chartier2576be22016-05-24 10:24:53 -0700224 elif [ "x$1" = "x--timeout" ]; then
225 shift
226 TIME_OUT_VALUE="$1"
227 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100228 elif [ "x$1" = "x--" ]; then
229 shift
230 break
231 elif [ "x$1" = "x--64" ]; then
232 ISA="x86_64"
233 GDB_SERVER="gdbserver64"
234 DALVIKVM="dalvikvm64"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000235 LIBRARY_DIRECTORY="lib64"
Colin Crossafd3c9e2016-09-16 13:47:21 -0700236 TEST_DIRECTORY="nativetest64"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100237 ARCHITECTURES_PATTERN="${ARCHITECTURES_64}"
238 shift
Andreas Gampec23c9c92014-10-28 14:47:25 -0700239 elif [ "x$1" = "x--pic-test" ]; then
240 FLAGS="${FLAGS} -Xcompiler-option --compile-pic"
241 COMPILE_FLAGS="${COMPILE_FLAGS} --compile-pic"
242 shift
Alex Light8a0e0332015-10-26 10:11:58 -0700243 elif [ "x$1" = "x--experimental" ]; then
244 if [ "$#" -lt 2 ]; then
245 echo "missing --experimental option" 1>&2
246 exit 1
247 fi
248 EXPERIMENTAL="$EXPERIMENTAL $2"
249 shift 2
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700250 elif [ "x$1" = "x--external-log-tags" ]; then
251 EXTERNAL_LOG_TAGS="y"
252 shift
253 elif [ "x$1" = "x--dry-run" ]; then
254 DRY_RUN="y"
255 shift
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000256 elif [ "x$1" = "x--vdex" ]; then
257 TEST_VDEX="y"
258 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100259 elif expr "x$1" : "x--" >/dev/null 2>&1; then
260 echo "unknown $0 option: $1" 1>&2
261 exit 1
262 else
263 break
264 fi
265done
266
Alex Light8a0e0332015-10-26 10:11:58 -0700267if [ "$USE_JVM" = "n" ]; then
Alex Light7233c7e2016-07-28 10:07:45 -0700268 FLAGS="${FLAGS} ${ANDROID_FLAGS}"
Alex Light8a0e0332015-10-26 10:11:58 -0700269 for feature in ${EXPERIMENTAL}; do
Alex Lightfa022852015-10-28 09:13:20 -0700270 FLAGS="${FLAGS} -Xexperimental:${feature} -Xcompiler-option --runtime-arg -Xcompiler-option -Xexperimental:${feature}"
Alex Light8a0e0332015-10-26 10:11:58 -0700271 COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xexperimental:${feature}"
272 done
273fi
274
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100275if [ "x$1" = "x" ] ; then
276 MAIN="Main"
277else
278 MAIN="$1"
Andreas Gampef2fdc732014-06-11 08:20:47 -0700279 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100280fi
281
282if [ "$ZYGOTE" = "" ]; then
283 if [ "$OPTIMIZE" = "y" ]; then
284 if [ "$VERIFY" = "y" ]; then
285 DEX_OPTIMIZE="-Xdexopt:verified"
286 else
287 DEX_OPTIMIZE="-Xdexopt:all"
288 fi
289 msg "Performing optimizations"
290 else
291 DEX_OPTIMIZE="-Xdexopt:none"
292 msg "Skipping optimizations"
293 fi
294
295 if [ "$VERIFY" = "y" ]; then
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100296 JVM_VERIFY_ARG="-Xverify:all"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100297 msg "Performing verification"
Igor Murashkin7617abd2015-07-10 18:27:47 -0700298 elif [ "$VERIFY" = "s" ]; then
299 JVM_VERIFY_ARG="Xverify:all"
300 DEX_VERIFY="-Xverify:softfail"
301 msg "Forcing verification to be soft fail"
302 else # VERIFY = "n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100303 DEX_VERIFY="-Xverify:none"
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100304 JVM_VERIFY_ARG="-Xverify:none"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100305 msg "Skipping verification"
306 fi
307fi
308
309msg "------------------------------"
310
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100311if [ "$DEBUGGER" = "y" ]; then
312 # Use this instead for ddms and connect by running 'ddms':
313 # DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y"
314 # TODO: add a separate --ddms option?
315
316 PORT=12345
317 msg "Waiting for jdb to connect:"
318 if [ "$HOST" = "n" ]; then
319 msg " adb forward tcp:$PORT tcp:$PORT"
320 fi
321 msg " jdb -attach localhost:$PORT"
322 DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
323fi
324
Alex Lightfba89fe2017-01-12 16:11:02 -0800325if [ "$IS_JVMTI_TEST" = "y" ]; then
326 plugin=libopenjdkjvmtid.so
327 agent=libtiagentd.so
328 lib=tiagentd
329 if [[ "$TEST_IS_NDEBUG" = "y" ]]; then
330 agent=libtiagent.so
331 plugin=libopenjdkjvmti.so
332 lib=tiagent
333 fi
334
335 ARGS="${ARGS} ${lib}"
336 if [[ "$USE_JVM" = "y" ]]; then
337 FLAGS="${FLAGS} -agentpath:${ANDROID_HOST_OUT}/nativetest64/${agent}=${TEST_NAME},jvm"
338 else
339 FLAGS="${FLAGS} -agentpath:${agent}=${TEST_NAME},art"
340 FLAGS="${FLAGS} -Xplugin:${plugin}"
341 FLAGS="${FLAGS} -Xfully-deoptable"
342 # Always make the compilation be debuggable.
343 COMPILE_FLAGS="${COMPILE_FLAGS} --debuggable"
344 fi
345fi
346
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100347if [ "$USE_JVM" = "y" ]; then
Alex Light9c20a142016-08-23 15:05:12 -0700348 export LD_LIBRARY_PATH=${ANDROID_HOST_OUT}/lib64
Mathieu Chartiera61894d2015-04-23 16:32:54 -0700349 # Xmx is necessary since we don't pass down the ART flags to JVM.
Vladimir Markoc5798bf2016-12-09 10:20:54 +0000350 # We pass the classes2 path whether it's used (src-multidex) or not.
351 cmdline="${JAVA} ${DEBUGGER_OPTS} ${JVM_VERIFY_ARG} -Xmx256m -classpath classes:classes2 ${FLAGS} $MAIN $@ ${ARGS}"
Andreas Gampe3f1dc562015-05-18 15:52:22 -0700352 if [ "$DEV_MODE" = "y" ]; then
353 echo $cmdline
354 fi
355 $cmdline
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100356 exit
357fi
358
359
360if [ "$HAVE_IMAGE" = "n" ]; then
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000361 DALVIKVM_BOOT_OPT="-Ximage:/system/non-existant/core.art"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000362else
363 DALVIKVM_BOOT_OPT="-Ximage:${BOOT_IMAGE}"
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100364fi
365
366
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100367if [ "$USE_GDB" = "y" ]; then
368 if [ "$HOST" = "n" ]; then
369 GDB="$GDB_SERVER :5039"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100370 else
371 if [ `uname` = "Darwin" ]; then
372 GDB=lldb
Mathieu Chartierc0a8a802014-10-17 15:58:01 -0700373 GDB_ARGS="$GDB_ARGS -- $DALVIKVM"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100374 DALVIKVM=
375 else
376 GDB=gdb
Mathieu Chartierc0a8a802014-10-17 15:58:01 -0700377 GDB_ARGS="$GDB_ARGS --args $DALVIKVM"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100378 # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line.
379 # gdbargs="--annotate=3 $gdbargs"
380 fi
381 fi
382fi
383
384if [ "$INTERPRETER" = "y" ]; then
Nicolas Geoffraye722d292015-12-15 11:51:37 +0000385 INT_OPTS="-Xint"
Andreas Gampe2b0fa5b2014-10-31 18:12:30 -0700386 if [ "$VERIFY" = "y" ] ; then
Richard Uhlerf4b34872016-04-13 11:03:46 -0700387 INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=interpret-only"
Andreas Gampe2b0fa5b2014-10-31 18:12:30 -0700388 COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=interpret-only"
Igor Murashkin7617abd2015-07-10 18:27:47 -0700389 elif [ "$VERIFY" = "s" ]; then
Richard Uhlerf4b34872016-04-13 11:03:46 -0700390 INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=verify-at-runtime"
Igor Murashkin7617abd2015-07-10 18:27:47 -0700391 COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=verify-at-runtime"
392 DEX_VERIFY="${DEX_VERIFY} -Xverify:softfail"
393 else # VERIFY = "n"
Richard Uhlerf4b34872016-04-13 11:03:46 -0700394 INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=verify-none"
Andreas Gampe2b0fa5b2014-10-31 18:12:30 -0700395 COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=verify-none"
396 DEX_VERIFY="${DEX_VERIFY} -Xverify:none"
397 fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100398fi
399
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800400if [ "$JIT" = "y" ]; then
Nicolas Geoffraye722d292015-12-15 11:51:37 +0000401 INT_OPTS="-Xusejit:true"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800402 if [ "$VERIFY" = "y" ] ; then
Calin Juravle09665582016-12-20 14:00:48 +0000403 INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=interpret-only"
404 COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=interpret-only"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800405 else
Richard Uhlerf4b34872016-04-13 11:03:46 -0700406 INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=verify-none"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800407 COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=verify-none"
408 DEX_VERIFY="${DEX_VERIFY} -Xverify:none"
409 fi
410fi
411
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100412JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni"
413
414if [ "$RELOCATE" = "y" ]; then
415 COMPILE_FLAGS="${COMPILE_FLAGS} --include-patch-information --runtime-arg -Xnorelocate"
416 FLAGS="${FLAGS} -Xrelocate -Xcompiler-option --include-patch-information"
417 if [ "$HOST" = "y" ]; then
418 # Run test sets a fairly draconian ulimit that we will likely blow right over
419 # since we are relocating. Get the total size of the /system/framework directory
420 # in 512 byte blocks and set it as the ulimit. This should be more than enough
421 # room.
422 if [ ! `uname` = "Darwin" ]; then # TODO: Darwin doesn't support "du -B..."
Alex Lightd26b7e42016-04-08 09:44:54 -0700423 ulimit -S $(du -c -B512 ${ANDROID_HOST_OUT}/framework 2>/dev/null | tail -1 | cut -f1) || exit 1
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100424 fi
425 fi
426else
427 FLAGS="$FLAGS -Xnorelocate"
428 COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xnorelocate"
Mathieu Chartiercae2ed92015-06-09 13:02:50 -0700429 if [ "$HOST" = "y" ]; then
430 # Increase ulimit to 64MB in case we are running hprof test.
431 ulimit -S 64000 || exit 1
432 fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100433fi
434
435if [ "$HOST" = "n" ]; then
Nicolas Geoffrayd295bc82016-11-04 13:03:05 +0000436 # Need to be root to query /data/dalvik-cache
437 adb root > /dev/null
438 adb wait-for-device
439 ISA=
440 ISA_adb_invocation=
441 ISA_outcome=
442 # We iterate a few times to workaround an adb issue. b/32655576
443 for i in {1..10}; do
444 ISA_adb_invocation=$(adb shell ls -F /data/dalvik-cache)
445 ISA_outcome=$?
446 ISA=$(echo $ISA_adb_invocation | grep -Ewo "${ARCHITECTURES_PATTERN}")
447 if [ x"$ISA" != "x" ]; then
448 break;
449 fi
450 done
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100451 if [ x"$ISA" = "x" ]; then
452 echo "Unable to determine architecture"
Nicolas Geoffray8f500fa2016-11-03 11:18:48 +0000453 # Print a few things for helping diagnosing the problem.
Nicolas Geoffrayd295bc82016-11-04 13:03:05 +0000454 echo "adb invocation output: $ISA_adb_invocation"
455 echo "adb invocation outcome: $ISA_outcome"
Nicolas Geoffray8f500fa2016-11-03 11:18:48 +0000456 echo $(adb shell ls -F /data/dalvik-cache)
457 echo $(adb shell ls /data/dalvik-cache)
458 echo ${ARCHITECTURES_PATTERN}
459 echo $(adb shell ls -F /data/dalvik-cache | grep -Ewo "${ARCHITECTURES_PATTERN}")
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100460 exit 1
461 fi
462fi
463
Wojciech Staszkiewicze6636532016-09-23 10:59:55 -0700464# Prevent test from silently falling back to interpreter in no-prebuild mode. This happens
465# when DEX_LOCATION path is too long, because vdex/odex filename is constructed by taking
466# full path to dex, stripping leading '/', appending '@classes.vdex' and changing every
467# remaining '/' into '@'.
468if [ "$HOST" = "y" ]; then
469 max_filename_size=$(getconf NAME_MAX $DEX_LOCATION)
470else
471 # There is no getconf on device, fallback to standard value. See NAME_MAX in kernel <linux/limits.h>
472 max_filename_size=255
473fi
474# Compute VDEX_NAME.
475DEX_LOCATION_STRIPPED="${DEX_LOCATION#/}"
476VDEX_NAME="${DEX_LOCATION_STRIPPED//\//@}@$TEST_NAME.jar@classes.vdex"
477if [ ${#VDEX_NAME} -gt $max_filename_size ]; then
478 echo "Dex location path too long."
479 exit 1
480fi
481
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100482dex2oat_cmdline="true"
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000483vdex_cmdline="true"
Alex Lightafb5d192016-05-24 15:57:45 -0700484mkdir_locations="${DEX_LOCATION}/dalvik-cache/$ISA"
Richard Uhler76f5cb62016-04-04 13:30:16 -0700485strip_cmdline="true"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100486
Jeff Haodcdc85b2015-12-04 14:06:18 -0800487
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100488if [ "$PREBUILD" = "y" ]; then
Alex Lightafb5d192016-05-24 15:57:45 -0700489 mkdir_locations="${mkdir_locations} ${DEX_LOCATION}/oat/$ISA"
Calin Juravle857f0582016-12-20 14:36:59 +0000490 if [ "$APP_IMAGE" = "y" ]; then
491 # Pick a base that will force the app image to get relocated.
492 app_image="--base=0x4000 --app-image-file=$DEX_LOCATION/oat/$ISA/$TEST_NAME.art"
493 fi
494
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000495 dex2oat_cmdline="$INVOKE_WITH $ANDROID_ROOT/bin/dex2oatd \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100496 $COMPILE_FLAGS \
Nicolas Geoffray68e25eb2014-10-29 23:02:11 +0000497 --boot-image=${BOOT_IMAGE} \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100498 --dex-file=$DEX_LOCATION/$TEST_NAME.jar \
Andreas Gampe14759242016-03-23 10:54:21 -0700499 --oat-file=$DEX_LOCATION/oat/$ISA/$TEST_NAME.odex \
Jeff Haodcdc85b2015-12-04 14:06:18 -0800500 ${app_image} \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100501 --instruction-set=$ISA"
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700502 if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then
503 dex2oat_cmdline="${dex2oat_cmdline} --instruction-set-features=${INSTRUCTION_SET_FEATURES}"
504 fi
Andreas Gampe2ea7b702015-08-07 08:07:16 -0700505
506 # Add in a timeout. This is important for testing the compilation/verification time of
507 # pathological cases.
508 # Note: as we don't know how decent targets are (e.g., emulator), only do this on the host for
509 # now. We should try to improve this.
510 # The current value is rather arbitrary. run-tests should compile quickly.
511 if [ "$HOST" != "n" ]; then
512 # Use SIGRTMIN+2 to try to dump threads.
513 # Use -k 1m to SIGKILL it a minute later if it hasn't ended.
514 dex2oat_cmdline="timeout -k 1m -s SIGRTMIN+2 1m ${dex2oat_cmdline}"
515 fi
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000516 if [ "$TEST_VDEX" = "y" ]; then
517 vdex_cmdline="${dex2oat_cmdline} --input-vdex=$DEX_LOCATION/oat/$ISA/$TEST_NAME.vdex"
518 fi
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700519fi
520
Richard Uhler76f5cb62016-04-04 13:30:16 -0700521if [ "$STRIP_DEX" = "y" ]; then
522 strip_cmdline="zip --quiet --delete $DEX_LOCATION/$TEST_NAME.jar classes.dex"
523fi
524
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700525DALVIKVM_ISA_FEATURES_ARGS=""
526if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then
527 DALVIKVM_ISA_FEATURES_ARGS="-Xcompiler-option --instruction-set-features=${INSTRUCTION_SET_FEATURES}"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100528fi
529
Nicolas Geoffrayc5256042015-12-26 19:41:37 +0000530# java.io.tmpdir can only be set at launch time.
531TMP_DIR_OPTION=""
532if [ "$HOST" = "n" ]; then
533 TMP_DIR_OPTION="-Djava.io.tmpdir=/data/local/tmp"
534fi
535
Nicolas Geoffraya73280d2016-02-15 13:05:16 +0000536# We set DumpNativeStackOnSigQuit to false to avoid stressing libunwind.
537# b/27185632
538# b/24664297
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000539dalvikvm_cmdline="$INVOKE_WITH $GDB $ANDROID_ROOT/bin/$DALVIKVM \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100540 $GDB_ARGS \
541 $FLAGS \
Andreas Gampe2b0fa5b2014-10-31 18:12:30 -0700542 $DEX_VERIFY \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100543 -XXlib:$LIB \
544 $PATCHOAT \
545 $DEX2OAT \
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700546 $DALVIKVM_ISA_FEATURES_ARGS \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100547 $ZYGOTE \
548 $JNI_OPTS \
549 $INT_OPTS \
550 $DEBUGGER_OPTS \
551 $DALVIKVM_BOOT_OPT \
Nicolas Geoffrayc5256042015-12-26 19:41:37 +0000552 $TMP_DIR_OPTION \
Nicolas Geoffraya73280d2016-02-15 13:05:16 +0000553 -XX:DumpNativeStackOnSigQuit:false \
Mathieu Chartier031768a2015-08-27 10:25:02 -0700554 -cp $DEX_LOCATION/$TEST_NAME.jar$SECONDARY_DEX $MAIN $ARGS"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100555
Andreas Gampe3ad5d5e2015-02-03 18:26:55 -0800556# Remove whitespace.
557dex2oat_cmdline=$(echo $dex2oat_cmdline)
558dalvikvm_cmdline=$(echo $dalvikvm_cmdline)
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000559vdex_cmdline=$(echo $vdex_cmdline)
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100560
561if [ "$HOST" = "n" ]; then
562 adb root > /dev/null
563 adb wait-for-device
564 if [ "$QUIET" = "n" ]; then
565 adb shell rm -r $DEX_LOCATION
566 adb shell mkdir -p $DEX_LOCATION
567 adb push $TEST_NAME.jar $DEX_LOCATION
568 adb push $TEST_NAME-ex.jar $DEX_LOCATION
569 else
570 adb shell rm -r $DEX_LOCATION >/dev/null 2>&1
571 adb shell mkdir -p $DEX_LOCATION >/dev/null 2>&1
572 adb push $TEST_NAME.jar $DEX_LOCATION >/dev/null 2>&1
573 adb push $TEST_NAME-ex.jar $DEX_LOCATION >/dev/null 2>&1
574 fi
575
Colin Crossafd3c9e2016-09-16 13:47:21 -0700576 LD_LIBRARY_PATH=/data/$TEST_DIRECTORY/art/$ISA
Nicolas Geoffrayeb441dd2014-10-31 15:34:50 +0000577 if [ "$ANDROID_ROOT" != "/system" ]; then
578 # Current default installation is dalvikvm 64bits and dex2oat 32bits,
579 # so we can only use LD_LIBRARY_PATH when testing on a local
580 # installation.
Alex Light7233c7e2016-07-28 10:07:45 -0700581 LD_LIBRARY_PATH=$ANDROID_ROOT/$LIBRARY_DIRECTORY:$LD_LIBRARY_PATH
Nicolas Geoffrayeb441dd2014-10-31 15:34:50 +0000582 fi
583
Dimitry Ivanov90d48f22016-05-05 17:24:28 -0700584 PUBLIC_LIBS=libart.so:libartd.so
585
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100586 # Create a script with the command. The command can get longer than the longest
587 # allowed adb command and there is no way to get the exit status from a adb shell
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700588 # command. Dalvik cache is cleaned before running to make subsequent executions
589 # of the script follow the same runtime path.
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100590 cmdline="cd $DEX_LOCATION && \
591 export ANDROID_DATA=$DEX_LOCATION && \
Dimitry Ivanov90d48f22016-05-05 17:24:28 -0700592 export ANDROID_ADDITIONAL_PUBLIC_LIBRARIES=$PUBLIC_LIBS && \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100593 export DEX_LOCATION=$DEX_LOCATION && \
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000594 export ANDROID_ROOT=$ANDROID_ROOT && \
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700595 rm -rf ${DEX_LOCATION}/dalvik-cache/ && \
Alex Lightafb5d192016-05-24 15:57:45 -0700596 mkdir -p ${mkdir_locations} && \
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100597 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH && \
Nicolas Geoffray4f7fdd22015-04-24 11:57:37 +0100598 export PATH=$ANDROID_ROOT/bin:$PATH && \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100599 $dex2oat_cmdline && \
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000600 $vdex_cmdline && \
Richard Uhler76f5cb62016-04-04 13:30:16 -0700601 $strip_cmdline && \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100602 $dalvikvm_cmdline"
603
604 cmdfile=$(tempfile -p "cmd-" -s "-$TEST_NAME")
605 echo "$cmdline" > $cmdfile
606
607 if [ "$DEV_MODE" = "y" ]; then
608 echo $cmdline
609 fi
610
611 if [ "$QUIET" = "n" ]; then
612 adb push $cmdfile $DEX_LOCATION/cmdline.sh
613 else
614 adb push $cmdfile $DEX_LOCATION/cmdline.sh > /dev/null 2>&1
615 fi
616
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700617 if [ "$DRY_RUN" != "y" ]; then
618 adb shell sh $DEX_LOCATION/cmdline.sh
619 fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100620
621 rm -f $cmdfile
622else
623 export ANDROID_PRINTF_LOG=brief
Andreas Gampea8780822015-03-13 19:51:09 -0700624
625 # By default, and for prebuild dex2oat, we are interested in errors being logged. In dev mode
626 # we want debug messages.
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700627 if [ "$EXTERNAL_LOG_TAGS" = "n" ]; then
628 if [ "$DEV_MODE" = "y" ]; then
629 export ANDROID_LOG_TAGS='*:d'
630 else
631 export ANDROID_LOG_TAGS='*:e'
632 fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100633 fi
Andreas Gampea8780822015-03-13 19:51:09 -0700634
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100635 export ANDROID_DATA="$DEX_LOCATION"
Nicolas Geoffray8eedb472014-10-29 14:05:59 +0000636 export ANDROID_ROOT="${ANDROID_ROOT}"
Colin Crossafd3c9e2016-09-16 13:47:21 -0700637 export LD_LIBRARY_PATH="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}"
638 export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100639 export PATH="$PATH:${ANDROID_ROOT}/bin"
640
David Srbeckyc9ede382015-06-20 06:03:53 +0100641 # Temporarily disable address space layout randomization (ASLR).
642 # This is needed on the host so that the linker loads core.oat at the necessary address.
643 export LD_USE_LOAD_BIAS=1
644
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100645 cmdline="$dalvikvm_cmdline"
646
Hiroshi Yamauchi6ffb9cc2015-08-31 15:14:17 -0700647 if [ "$TIME_OUT" = "gdb" ]; then
648 if [ `uname` = "Darwin" ]; then
649 # Fall back to timeout on Mac.
650 TIME_OUT="timeout"
Hiroshi Yamauchic823eff2015-09-01 16:21:35 -0700651 elif [ "$ISA" = "x86" ]; then
652 # prctl call may fail in 32-bit on an older (3.2) 64-bit Linux kernel. Fall back to timeout.
653 TIME_OUT="timeout"
Hiroshi Yamauchi6ffb9cc2015-08-31 15:14:17 -0700654 else
655 # Check if gdb is available.
656 gdb --eval-command="quit" > /dev/null 2>&1
657 if [ $? != 0 ]; then
658 # gdb isn't available. Fall back to timeout.
659 TIME_OUT="timeout"
660 fi
661 fi
662 fi
663
664 if [ "$TIME_OUT" = "timeout" ]; then
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100665 # Add timeout command if time out is desired.
Andreas Gampe038bb222015-01-13 19:48:14 -0800666 #
Andreas Gampe6fb92562016-08-01 21:53:57 -0700667 # Note: We first send SIGRTMIN+2 (usually 36) to ART, which will induce a full thread dump
668 # before abort. However, dumping threads might deadlock, so we also use the "-k"
669 # option to definitely kill the child.
670 cmdline="timeout -k 120s -s SIGRTMIN+2 ${TIME_OUT_VALUE}s $cmdline"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100671 fi
672
673 if [ "$DEV_MODE" = "y" ]; then
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000674 echo "mkdir -p ${mkdir_locations} && $dex2oat_cmdline && $vdex_cmdline && $strip_cmdline && $cmdline"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100675 fi
676
677 cd $ANDROID_BUILD_TOP
678
David Srbecky2e4afe82016-01-27 18:42:06 +0000679 rm -rf ${DEX_LOCATION}/dalvik-cache/
Alex Lightafb5d192016-05-24 15:57:45 -0700680 mkdir -p ${mkdir_locations} || exit 1
Andreas Gampea8780822015-03-13 19:51:09 -0700681 $dex2oat_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; }
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000682 $vdex_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; }
Richard Uhler76f5cb62016-04-04 13:30:16 -0700683 $strip_cmdline || { echo "Strip failed." >&2 ; exit 3; }
Andreas Gampea8780822015-03-13 19:51:09 -0700684
685 # For running, we must turn off logging when dex2oat or patchoat are missing. Otherwise we use
686 # the same defaults as for prebuilt: everything when --dev, otherwise errors and above only.
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700687 if [ "$EXTERNAL_LOG_TAGS" = "n" ]; then
688 if [ "$DEV_MODE" = "y" ]; then
689 export ANDROID_LOG_TAGS='*:d'
690 elif [ "$USE_DEX2OAT_AND_PATCHOAT" = "n" ]; then
691 # All tests would log the error of failing dex2oat/patchoat. Be silent here and only
692 # log fatal events.
693 export ANDROID_LOG_TAGS='*:s'
694 else
695 # We are interested in LOG(ERROR) output.
696 export ANDROID_LOG_TAGS='*:e'
697 fi
698 fi
699
700 if [ "$DRY_RUN" = "y" ]; then
701 exit 0
Andreas Gampea8780822015-03-13 19:51:09 -0700702 fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100703
704 if [ "$USE_GDB" = "y" ]; then
705 # When running under gdb, we cannot do piping and grepping...
Dmitriy Ivanovf57874d2014-10-07 13:43:23 -0700706 $cmdline "$@"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100707 else
Hiroshi Yamauchi6ffb9cc2015-08-31 15:14:17 -0700708 if [ "$TIME_OUT" != "gdb" ]; then
709 trap 'kill -INT -$pid' INT
710 $cmdline "$@" 2>&1 & pid=$!
711 wait $pid
712 # Add extra detail if time out is enabled.
713 if [ ${PIPESTATUS[0]} = 124 ] && [ "$TIME_OUT" = "timeout" ]; then
714 echo -e "\e[91mTEST TIMED OUT!\e[0m" >&2
715 fi
716 else
717 # With a thread dump that uses gdb if a timeout.
718 trap 'kill -INT -$pid' INT
719 $cmdline "$@" 2>&1 & pid=$!
720 # Spawn a watcher process.
721 ( sleep $TIME_OUT_VALUE && \
722 echo "##### Thread dump using gdb on test timeout" && \
723 ( gdb -q -p $pid --eval-command="info thread" --eval-command="thread apply all bt" \
724 --eval-command="call exit(124)" --eval-command=quit || \
725 kill $pid )) 2> /dev/null & watcher=$!
726 wait $pid
727 test_exit_status=$?
728 pkill -P $watcher 2> /dev/null # kill the sleep which will in turn end the watcher as well
729 if [ $test_exit_status = 0 ]; then
730 # The test finished normally.
731 exit 0
732 else
733 # The test failed or timed out.
734 if [ $test_exit_status = 124 ]; then
735 # The test timed out.
736 echo -e "\e[91mTEST TIMED OUT!\e[0m" >&2
737 fi
738 fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100739 fi
740 fi
741fi