blob: 1233aca0f85fb1f22d45690c42300c9971ed9312 [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=""
Roland Levillain76cfe612017-10-30 13:14:28 +000016CHROOT=
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010017COMPILE_FLAGS=""
18DALVIKVM="dalvikvm32"
19DEBUGGER="n"
Alex Light54dabfb2018-09-19 16:29:09 -070020WITH_AGENT=()
Alex Lightc281ba52017-10-11 11:35:55 -070021DEBUGGER_AGENT=""
22WRAP_DEBUGGER_AGENT="n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010023DEV_MODE="n"
24DEX2OAT=""
Alex Light8a0e0332015-10-26 10:11:58 -070025EXPERIMENTAL=""
Nicolas Geoffray90355fe2017-02-20 09:25:40 +000026FALSE_BIN="false"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010027FLAGS=""
Alex Light7233c7e2016-07-28 10:07:45 -070028ANDROID_FLAGS=""
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010029GDB=""
Nicolas Geoffraybaf91022014-10-08 09:56:45 +010030GDB_ARGS=""
31GDB_SERVER="gdbserver"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010032HAVE_IMAGE="y"
33HOST="n"
Alex Light680cbf22018-10-31 11:00:19 -070034BIONIC="n"
35CREATE_ANDROID_ROOT="n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010036INTERPRETER="n"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080037JIT="n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010038INVOKE_WITH=""
Alex Lighte06b6342017-01-05 14:37:21 -080039IS_JVMTI_TEST="n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010040ISA=x86
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +000041LIBRARY_DIRECTORY="lib"
Colin Crossafd3c9e2016-09-16 13:47:21 -070042TEST_DIRECTORY="nativetest"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +000043MAIN=""
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010044OPTIMIZE="y"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010045PREBUILD="y"
46QUIET="n"
Nicolas Geoffray94e25db2017-01-27 14:54:28 +000047RELOCATE="n"
Richard Uhler76f5cb62016-04-04 13:30:16 -070048STRIP_DEX="n"
Jeff Hao207a37d2014-10-29 17:24:25 -070049SECONDARY_DEX=""
Hiroshi Yamauchi6ffb9cc2015-08-31 15:14:17 -070050TIME_OUT="gdb" # "n" (disabled), "timeout" (use timeout), "gdb" (use gdb)
51# Value in seconds
Hiroshi Yamauchifd3161a2017-01-18 14:47:25 -080052if [ "$ART_USE_READ_BARRIER" != "false" ]; then
Hiroshi Yamauchia9b296c2016-10-07 17:07:03 -070053 TIME_OUT_VALUE=2400 # 40 minutes.
Hiroshi Yamauchidcf0d4b2015-09-09 18:59:42 -070054else
Mathieu Chartier2576be22016-05-24 10:24:53 -070055 TIME_OUT_VALUE=1200 # 20 minutes.
Hiroshi Yamauchidcf0d4b2015-09-09 18:59:42 -070056fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010057USE_GDB="n"
Nicolas Geoffray288a4a22014-10-07 11:02:40 +010058USE_JVM="n"
Alex Lightc281ba52017-10-11 11:35:55 -070059USE_JVMTI="n"
Igor Murashkin7617abd2015-07-10 18:27:47 -070060VERIFY="y" # y=yes,n=no,s=softfail
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010061ZYGOTE=""
Andreas Gampe2b0fa5b2014-10-31 18:12:30 -070062DEX_VERIFY=""
Andreas Gampe4d2ef332015-08-05 09:24:45 -070063INSTRUCTION_SET_FEATURES=""
Mathieu Chartier031768a2015-08-27 10:25:02 -070064ARGS=""
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -070065EXTERNAL_LOG_TAGS="n" # if y respect externally set ANDROID_LOG_TAGS.
66DRY_RUN="n" # if y prepare to run the test but don't run it.
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +000067TEST_VDEX="n"
Nicolas Geoffraybaeaa9b2018-01-26 14:31:17 +000068TEST_DM="n"
Alex Lighte06b6342017-01-05 14:37:21 -080069TEST_IS_NDEBUG="n"
Calin Juravle857f0582016-12-20 14:36:59 +000070APP_IMAGE="y"
Alex Light8f2c6d42017-04-10 16:27:35 -070071JVMTI_STRESS="n"
Alex Lightc38c3692017-06-27 15:45:14 -070072JVMTI_STEP_STRESS="n"
Alex Light43e935d2017-06-19 15:40:40 -070073JVMTI_FIELD_STRESS="n"
Alex Lightb7edcda2017-04-27 13:20:31 -070074JVMTI_TRACE_STRESS="n"
75JVMTI_REDEFINE_STRESS="n"
Nicolas Geoffray74981052017-01-16 17:54:09 +000076VDEX_FILTER=""
Calin Juravle13439f02017-02-21 01:17:21 -080077PROFILE="n"
Jeff Hao002b9312017-03-27 16:23:08 -070078RANDOM_PROFILE="n"
Alex Light483208d2017-09-26 09:31:17 -070079# The normal dex2oat timeout.
Shubham Ajmeraf97cbd62017-10-11 10:00:57 -070080DEX2OAT_TIMEOUT="300" # 5 mins
Alex Light483208d2017-09-26 09:31:17 -070081# The *hard* timeout where we really start trying to kill the dex2oat.
Shubham Ajmeraf97cbd62017-10-11 10:00:57 -070082DEX2OAT_RT_TIMEOUT="360" # 6 mins
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010083
Igor Murashkin271a0f82017-02-14 21:14:17 +000084# if "y", run 'sync' before dalvikvm to make sure all files from
85# build step (e.g. dex2oat) were finished writing.
86SYNC_BEFORE_RUN="n"
87
Andreas Gampe1c5b42f2017-06-15 18:20:45 -070088# When running a debug build, we want to run with all checks.
89ANDROID_FLAGS="${ANDROID_FLAGS} -XX:SlowDebug=true"
Andreas Gampee8f74ca2018-01-02 09:26:16 -080090# The same for dex2oatd, both prebuild and runtime-driven.
91ANDROID_FLAGS="${ANDROID_FLAGS} -Xcompiler-option --runtime-arg -Xcompiler-option -XX:SlowDebug=true"
92COMPILER_FLAGS="${COMPILER_FLAGS} --runtime-arg -XX:SlowDebug=true"
Andreas Gampe1c5b42f2017-06-15 18:20:45 -070093
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010094while true; do
95 if [ "x$1" = "x--quiet" ]; then
96 QUIET="y"
97 shift
Alex Light483208d2017-09-26 09:31:17 -070098 elif [ "x$1" = "x--dex2oat-rt-timeout" ]; then
99 shift
100 if [ "x$1" = "x" ]; then
101 echo "$0 missing argument to --dex2oat-rt-timeout" 1>&2
102 exit 1
103 fi
104 DEX2OAT_RT_TIMEOUT="$1"
105 shift
106 elif [ "x$1" = "x--dex2oat-timeout" ]; then
107 shift
108 if [ "x$1" = "x" ]; then
109 echo "$0 missing argument to --dex2oat-timeout" 1>&2
110 exit 1
111 fi
112 DEX2OAT_TIMEOUT="$1"
113 shift
Alex Lighte06b6342017-01-05 14:37:21 -0800114 elif [ "x$1" = "x--jvmti" ]; then
Alex Lightc281ba52017-10-11 11:35:55 -0700115 USE_JVMTI="y"
Alex Lighte06b6342017-01-05 14:37:21 -0800116 IS_JVMTI_TEST="y"
117 shift
Alex Lightfaf90b62016-08-12 14:43:48 -0700118 elif [ "x$1" = "x-O" ]; then
Alex Lighte06b6342017-01-05 14:37:21 -0800119 TEST_IS_NDEBUG="y"
Alex Lightfaf90b62016-08-12 14:43:48 -0700120 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100121 elif [ "x$1" = "x--lib" ]; then
122 shift
123 if [ "x$1" = "x" ]; then
124 echo "$0 missing argument to --lib" 1>&2
125 exit 1
126 fi
127 LIB="$1"
128 shift
Alex Light97acf192016-03-17 09:59:38 -0700129 elif [ "x$1" = "x--gc-stress" ]; then
130 # Give an extra 5 mins if we are gc-stress.
131 TIME_OUT_VALUE=$((${TIME_OUT_VALUE} + 300))
132 shift
Mathieu Chartier031768a2015-08-27 10:25:02 -0700133 elif [ "x$1" = "x--testlib" ]; then
134 shift
135 if [ "x$1" = "x" ]; then
136 echo "$0 missing argument to --testlib" 1>&2
137 exit 1
138 fi
Mathieu Chartierde286fd2015-09-03 18:10:29 -0700139 ARGS="${ARGS} $1"
Mathieu Chartier031768a2015-08-27 10:25:02 -0700140 shift
David Srbecky52886112016-01-22 13:56:47 +0000141 elif [ "x$1" = "x--args" ]; then
142 shift
143 if [ "x$1" = "x" ]; then
144 echo "$0 missing argument to --args" 1>&2
145 exit 1
146 fi
147 ARGS="${ARGS} $1"
148 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100149 elif [ "x$1" = "x-Xcompiler-option" ]; then
150 shift
151 option="$1"
152 FLAGS="${FLAGS} -Xcompiler-option $option"
153 COMPILE_FLAGS="${COMPILE_FLAGS} $option"
154 shift
Alex Light7233c7e2016-07-28 10:07:45 -0700155 elif [ "x$1" = "x--android-runtime-option" ]; then
156 shift
157 option="$1"
158 ANDROID_FLAGS="${ANDROID_FLAGS} $option"
159 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100160 elif [ "x$1" = "x--runtime-option" ]; then
161 shift
162 option="$1"
163 FLAGS="${FLAGS} $option"
164 shift
165 elif [ "x$1" = "x--boot" ]; then
166 shift
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000167 BOOT_IMAGE="$1"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100168 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100169 elif [ "x$1" = "x--relocate" ]; then
170 RELOCATE="y"
171 shift
172 elif [ "x$1" = "x--no-relocate" ]; then
173 RELOCATE="n"
174 shift
175 elif [ "x$1" = "x--prebuild" ]; then
176 PREBUILD="y"
177 shift
Mathieu Chartierdcd56c92017-11-20 20:30:24 -0800178 elif [ "x$1" = "x--compact-dex-level" ]; then
179 shift
180 COMPILE_FLAGS="${COMPILE_FLAGS} --compact-dex-level=$1"
181 shift
Alex Lightb7edcda2017-04-27 13:20:31 -0700182 elif [ "x$1" = "x--jvmti-redefine-stress" ]; then
183 # APP_IMAGE doesn't really work with jvmti redefine stress
Alex Lightc281ba52017-10-11 11:35:55 -0700184 USE_JVMTI="y"
Alex Light8f2c6d42017-04-10 16:27:35 -0700185 APP_IMAGE="n"
186 JVMTI_STRESS="y"
Alex Lightb7edcda2017-04-27 13:20:31 -0700187 JVMTI_REDEFINE_STRESS="y"
188 shift
Alex Lightc38c3692017-06-27 15:45:14 -0700189 elif [ "x$1" = "x--jvmti-step-stress" ]; then
Alex Lightc281ba52017-10-11 11:35:55 -0700190 USE_JVMTI="y"
Alex Lightc38c3692017-06-27 15:45:14 -0700191 JVMTI_STRESS="y"
192 JVMTI_STEP_STRESS="y"
193 shift
Alex Light43e935d2017-06-19 15:40:40 -0700194 elif [ "x$1" = "x--jvmti-field-stress" ]; then
Alex Lightc281ba52017-10-11 11:35:55 -0700195 USE_JVMTI="y"
Alex Light43e935d2017-06-19 15:40:40 -0700196 JVMTI_STRESS="y"
197 JVMTI_FIELD_STRESS="y"
198 shift
Alex Lightb7edcda2017-04-27 13:20:31 -0700199 elif [ "x$1" = "x--jvmti-trace-stress" ]; then
Alex Lightc281ba52017-10-11 11:35:55 -0700200 USE_JVMTI="y"
Alex Lightb7edcda2017-04-27 13:20:31 -0700201 JVMTI_STRESS="y"
202 JVMTI_TRACE_STRESS="y"
Alex Light8f2c6d42017-04-10 16:27:35 -0700203 shift
Calin Juravle857f0582016-12-20 14:36:59 +0000204 elif [ "x$1" = "x--no-app-image" ]; then
205 APP_IMAGE="n"
206 shift
Richard Uhler76f5cb62016-04-04 13:30:16 -0700207 elif [ "x$1" = "x--strip-dex" ]; then
208 STRIP_DEX="y"
209 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100210 elif [ "x$1" = "x--host" ]; then
211 HOST="y"
Nicolas Geoffray8eedb472014-10-29 14:05:59 +0000212 ANDROID_ROOT="$ANDROID_HOST_OUT"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100213 shift
Alex Light680cbf22018-10-31 11:00:19 -0700214 elif [ "x$1" = "x--bionic" ]; then
215 BIONIC="y"
216 # We need to create an ANDROID_ROOT because currently we cannot create
217 # the frameworks/libcore with linux_bionic so we need to use the normal
218 # host ones which are in a different location.
219 CREATE_ANDROID_ROOT="y"
220 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100221 elif [ "x$1" = "x--no-prebuild" ]; then
222 PREBUILD="n"
223 shift
224 elif [ "x$1" = "x--no-image" ]; then
225 HAVE_IMAGE="n"
226 shift
Jeff Hao207a37d2014-10-29 17:24:25 -0700227 elif [ "x$1" = "x--secondary" ]; then
228 SECONDARY_DEX=":$DEX_LOCATION/$TEST_NAME-ex.jar"
Calin Juravle175dc732015-08-25 15:42:32 +0100229 # Enable cfg-append to make sure we get the dump for both dex files.
230 # (otherwise the runtime compilation of the secondary dex will overwrite
Roland Levillainb0103ca2016-11-01 14:48:47 +0000231 # the dump of the first one).
Calin Juravle175dc732015-08-25 15:42:32 +0100232 FLAGS="${FLAGS} -Xcompiler-option --dump-cfg-append"
233 COMPILE_FLAGS="${COMPILE_FLAGS} --dump-cfg-append"
Jeff Hao207a37d2014-10-29 17:24:25 -0700234 shift
Alex Light0e151e72017-10-25 10:50:35 -0700235 elif [ "x$1" = "x--with-agent" ]; then
236 shift
237 USE_JVMTI="y"
Alex Light54dabfb2018-09-19 16:29:09 -0700238 WITH_AGENT+=("$1")
Alex Light0e151e72017-10-25 10:50:35 -0700239 shift
Alex Lightc281ba52017-10-11 11:35:55 -0700240 elif [ "x$1" = "x--debug-wrap-agent" ]; then
241 WRAP_DEBUGGER_AGENT="y"
242 shift
243 elif [ "x$1" = "x--debug-agent" ]; then
244 shift
245 DEBUGGER="agent"
246 USE_JVMTI="y"
247 DEBUGGER_AGENT="$1"
248 TIME_OUT="n"
249 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100250 elif [ "x$1" = "x--debug" ]; then
251 DEBUGGER="y"
Brian Carlstrom93d6ce52014-11-04 22:31:35 -0800252 TIME_OUT="n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100253 shift
254 elif [ "x$1" = "x--gdb" ]; then
255 USE_GDB="y"
256 DEV_MODE="y"
Brian Carlstrom93d6ce52014-11-04 22:31:35 -0800257 TIME_OUT="n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100258 shift
Mathieu Chartierc0a8a802014-10-17 15:58:01 -0700259 elif [ "x$1" = "x--gdb-arg" ]; then
260 shift
261 gdb_arg="$1"
262 GDB_ARGS="${GDB_ARGS} $gdb_arg"
263 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100264 elif [ "x$1" = "x--zygote" ]; then
265 ZYGOTE="-Xzygote"
266 msg "Spawning from zygote"
267 shift
268 elif [ "x$1" = "x--dev" ]; then
269 DEV_MODE="y"
270 shift
271 elif [ "x$1" = "x--interpreter" ]; then
272 INTERPRETER="y"
273 shift
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800274 elif [ "x$1" = "x--jit" ]; then
275 JIT="y"
276 shift
Nicolas Geoffrayacc56ac2018-10-09 08:45:24 +0100277 elif [ "x$1" = "x--baseline" ]; then
278 FLAGS="${FLAGS} -Xcompiler-option --baseline"
279 shift
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100280 elif [ "x$1" = "x--jvm" ]; then
281 USE_JVM="y"
282 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100283 elif [ "x$1" = "x--invoke-with" ]; then
284 shift
285 if [ "x$1" = "x" ]; then
286 echo "$0 missing argument to --invoke-with" 1>&2
287 exit 1
288 fi
289 if [ "x$INVOKE_WITH" = "x" ]; then
290 INVOKE_WITH="$1"
291 else
292 INVOKE_WITH="$INVOKE_WITH $1"
293 fi
294 shift
295 elif [ "x$1" = "x--no-verify" ]; then
296 VERIFY="n"
297 shift
Igor Murashkin7617abd2015-07-10 18:27:47 -0700298 elif [ "x$1" = "x--verify-soft-fail" ]; then
299 VERIFY="s"
300 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100301 elif [ "x$1" = "x--no-optimize" ]; then
302 OPTIMIZE="n"
303 shift
Roland Levillain76cfe612017-10-30 13:14:28 +0000304 elif [ "x$1" = "x--chroot" ]; then
305 shift
306 CHROOT="$1"
307 shift
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000308 elif [ "x$1" = "x--android-root" ]; then
309 shift
310 ANDROID_ROOT="$1"
311 shift
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700312 elif [ "x$1" = "x--instruction-set-features" ]; then
313 shift
314 INSTRUCTION_SET_FEATURES="$1"
315 shift
Mathieu Chartier2576be22016-05-24 10:24:53 -0700316 elif [ "x$1" = "x--timeout" ]; then
317 shift
318 TIME_OUT_VALUE="$1"
319 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100320 elif [ "x$1" = "x--" ]; then
321 shift
322 break
323 elif [ "x$1" = "x--64" ]; then
324 ISA="x86_64"
325 GDB_SERVER="gdbserver64"
326 DALVIKVM="dalvikvm64"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000327 LIBRARY_DIRECTORY="lib64"
Colin Crossafd3c9e2016-09-16 13:47:21 -0700328 TEST_DIRECTORY="nativetest64"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100329 ARCHITECTURES_PATTERN="${ARCHITECTURES_64}"
330 shift
Alex Light8a0e0332015-10-26 10:11:58 -0700331 elif [ "x$1" = "x--experimental" ]; then
332 if [ "$#" -lt 2 ]; then
333 echo "missing --experimental option" 1>&2
334 exit 1
335 fi
336 EXPERIMENTAL="$EXPERIMENTAL $2"
337 shift 2
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700338 elif [ "x$1" = "x--external-log-tags" ]; then
339 EXTERNAL_LOG_TAGS="y"
340 shift
341 elif [ "x$1" = "x--dry-run" ]; then
342 DRY_RUN="y"
343 shift
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000344 elif [ "x$1" = "x--vdex" ]; then
345 TEST_VDEX="y"
346 shift
Nicolas Geoffraybaeaa9b2018-01-26 14:31:17 +0000347 elif [ "x$1" = "x--dm" ]; then
348 TEST_DM="y"
349 shift
Nicolas Geoffray74981052017-01-16 17:54:09 +0000350 elif [ "x$1" = "x--vdex-filter" ]; then
351 shift
352 option="$1"
353 VDEX_FILTER="--compiler-filter=$option"
354 shift
Igor Murashkin271a0f82017-02-14 21:14:17 +0000355 elif [ "x$1" = "x--sync" ]; then
356 SYNC_BEFORE_RUN="y"
357 shift
Calin Juravle13439f02017-02-21 01:17:21 -0800358 elif [ "x$1" = "x--profile" ]; then
359 PROFILE="y"
360 shift
Jeff Hao002b9312017-03-27 16:23:08 -0700361 elif [ "x$1" = "x--random-profile" ]; then
362 RANDOM_PROFILE="y"
363 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100364 elif expr "x$1" : "x--" >/dev/null 2>&1; then
365 echo "unknown $0 option: $1" 1>&2
366 exit 1
367 else
368 break
369 fi
370done
371
Roland Levillain76cfe612017-10-30 13:14:28 +0000372# The DEX_LOCATION with the chroot prefix, if any.
373CHROOT_DEX_LOCATION="$CHROOT$DEX_LOCATION"
374
Alex Light8a0e0332015-10-26 10:11:58 -0700375if [ "$USE_JVM" = "n" ]; then
Alex Light7233c7e2016-07-28 10:07:45 -0700376 FLAGS="${FLAGS} ${ANDROID_FLAGS}"
Alex Lightbaac7e42018-06-08 15:30:11 +0000377 # we don't want to be trying to get adbconnections since the plugin might
378 # not have been built.
379 FLAGS="${FLAGS} -XjdwpProvider:none"
Alex Light8a0e0332015-10-26 10:11:58 -0700380 for feature in ${EXPERIMENTAL}; do
Alex Lightfa022852015-10-28 09:13:20 -0700381 FLAGS="${FLAGS} -Xexperimental:${feature} -Xcompiler-option --runtime-arg -Xcompiler-option -Xexperimental:${feature}"
Alex Light8a0e0332015-10-26 10:11:58 -0700382 COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xexperimental:${feature}"
383 done
384fi
385
Alex Light680cbf22018-10-31 11:00:19 -0700386if [ "$CREATE_ANDROID_ROOT" = "y" ]; then
387 ANDROID_ROOT=$DEX_LOCATION/android-root
388fi
389
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100390if [ "x$1" = "x" ] ; then
391 MAIN="Main"
392else
393 MAIN="$1"
Andreas Gampef2fdc732014-06-11 08:20:47 -0700394 shift
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100395fi
396
397if [ "$ZYGOTE" = "" ]; then
398 if [ "$OPTIMIZE" = "y" ]; then
399 if [ "$VERIFY" = "y" ]; then
400 DEX_OPTIMIZE="-Xdexopt:verified"
401 else
402 DEX_OPTIMIZE="-Xdexopt:all"
403 fi
404 msg "Performing optimizations"
405 else
406 DEX_OPTIMIZE="-Xdexopt:none"
407 msg "Skipping optimizations"
408 fi
409
410 if [ "$VERIFY" = "y" ]; then
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100411 JVM_VERIFY_ARG="-Xverify:all"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100412 msg "Performing verification"
Igor Murashkin7617abd2015-07-10 18:27:47 -0700413 elif [ "$VERIFY" = "s" ]; then
414 JVM_VERIFY_ARG="Xverify:all"
415 DEX_VERIFY="-Xverify:softfail"
416 msg "Forcing verification to be soft fail"
417 else # VERIFY = "n"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100418 DEX_VERIFY="-Xverify:none"
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100419 JVM_VERIFY_ARG="-Xverify:none"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100420 msg "Skipping verification"
421 fi
422fi
423
424msg "------------------------------"
425
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100426if [ "$DEBUGGER" = "y" ]; then
427 # Use this instead for ddms and connect by running 'ddms':
428 # DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y"
429 # TODO: add a separate --ddms option?
430
431 PORT=12345
432 msg "Waiting for jdb to connect:"
433 if [ "$HOST" = "n" ]; then
434 msg " adb forward tcp:$PORT tcp:$PORT"
435 fi
436 msg " jdb -attach localhost:$PORT"
Alex Light264a4862018-01-31 16:47:58 +0000437 if [ "$USE_JVM" = "n" ]; then
438 # TODO We should switch over to using the jvmti agent by default.
439 # Need to tell the runtime to enable the internal jdwp implementation.
440 DEBUGGER_OPTS="-XjdwpOptions:transport=dt_socket,address=$PORT,server=y,suspend=y -XjdwpProvider:internal"
441 else
442 DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
443 fi
Alex Lightc281ba52017-10-11 11:35:55 -0700444elif [ "$DEBUGGER" = "agent" ]; then
445 PORT=12345
446 # TODO Support ddms connection and support target.
447 if [ "$HOST" = "n" ]; then
448 echo "--debug-agent not supported yet for target!"
449 exit 1
450 fi
451 AGENTPATH=${DEBUGGER_AGENT}
452 if [ "$WRAP_DEBUGGER_AGENT" = "y" ]; then
453 WRAPPROPS="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}/libwrapagentpropertiesd.so"
454 if [ "$TEST_IS_NDEBUG" = "y" ]; then
455 WRAPPROPS="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}/libwrapagentproperties.so"
456 fi
457 AGENTPATH="${WRAPPROPS}=${ANDROID_BUILD_TOP}/art/tools/libjdwp-compat.props,${AGENTPATH}"
458 fi
459 msg "Connect to localhost:$PORT"
460 DEBUGGER_OPTS="-agentpath:${AGENTPATH}=transport=dt_socket,address=$PORT,server=y,suspend=y"
461fi
462
Alex Light54dabfb2018-09-19 16:29:09 -0700463for agent in "${WITH_AGENT[@]}"; do
464 FLAGS="${FLAGS} -agentpath:${agent}"
465done
Alex Light0e151e72017-10-25 10:50:35 -0700466
Alex Lightc281ba52017-10-11 11:35:55 -0700467if [ "$USE_JVMTI" = "y" ]; then
468 if [ "$USE_JVM" = "n" ]; then
469 plugin=libopenjdkjvmtid.so
470 if [[ "$TEST_IS_NDEBUG" = "y" ]]; then
471 plugin=libopenjdkjvmti.so
472 fi
Alex Light2ce6fc82017-12-18 16:42:36 -0800473 # We used to add flags here that made the runtime debuggable but that is not
474 # needed anymore since the plugin can do it for us now.
Alex Lightc281ba52017-10-11 11:35:55 -0700475 FLAGS="${FLAGS} -Xplugin:${plugin}"
Alex Lightc281ba52017-10-11 11:35:55 -0700476 fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100477fi
478
Alex Lightfba89fe2017-01-12 16:11:02 -0800479if [ "$IS_JVMTI_TEST" = "y" ]; then
Alex Lightfba89fe2017-01-12 16:11:02 -0800480 agent=libtiagentd.so
481 lib=tiagentd
482 if [[ "$TEST_IS_NDEBUG" = "y" ]]; then
483 agent=libtiagent.so
Alex Lightfba89fe2017-01-12 16:11:02 -0800484 lib=tiagent
485 fi
486
487 ARGS="${ARGS} ${lib}"
488 if [[ "$USE_JVM" = "y" ]]; then
489 FLAGS="${FLAGS} -agentpath:${ANDROID_HOST_OUT}/nativetest64/${agent}=${TEST_NAME},jvm"
490 else
491 FLAGS="${FLAGS} -agentpath:${agent}=${TEST_NAME},art"
Alex Lightfba89fe2017-01-12 16:11:02 -0800492 fi
493fi
494
Alex Light8f2c6d42017-04-10 16:27:35 -0700495if [[ "$JVMTI_STRESS" = "y" ]]; then
Alex Light42151c02017-04-20 15:54:25 -0700496 agent=libtistressd.so
497 if [[ "$TEST_IS_NDEBUG" = "y" ]]; then
498 agent=libtistress.so
Alex Light42151c02017-04-20 15:54:25 -0700499 fi
Alex Light8f2c6d42017-04-10 16:27:35 -0700500
Alex Lightb7edcda2017-04-27 13:20:31 -0700501 # Just give it a default start so we can always add ',' to it.
502 agent_args="jvmti-stress"
503 if [[ "$JVMTI_REDEFINE_STRESS" = "y" ]]; then
504 # We really cannot do this on RI so don't both passing it in that case.
505 if [[ "$USE_JVM" = "n" ]]; then
Alex Lightceae9542017-09-07 13:28:00 -0700506 agent_args="${agent_args},redefine"
Alex Lightb7edcda2017-04-27 13:20:31 -0700507 fi
508 fi
Alex Light43e935d2017-06-19 15:40:40 -0700509 if [[ "$JVMTI_FIELD_STRESS" = "y" ]]; then
510 agent_args="${agent_args},field"
511 fi
Alex Lightc38c3692017-06-27 15:45:14 -0700512 if [[ "$JVMTI_STEP_STRESS" = "y" ]]; then
513 agent_args="${agent_args},step"
514 fi
Alex Lightb7edcda2017-04-27 13:20:31 -0700515 if [[ "$JVMTI_TRACE_STRESS" = "y" ]]; then
516 agent_args="${agent_args},trace"
517 fi
518 # In the future add onto this;
Alex Light42151c02017-04-20 15:54:25 -0700519 if [[ "$USE_JVM" = "y" ]]; then
Alex Lightb7edcda2017-04-27 13:20:31 -0700520 FLAGS="${FLAGS} -agentpath:${ANDROID_HOST_OUT}/nativetest64/${agent}=${agent_args}"
Alex Light42151c02017-04-20 15:54:25 -0700521 else
Alex Lightb7edcda2017-04-27 13:20:31 -0700522 FLAGS="${FLAGS} -agentpath:${agent}=${agent_args}"
Alex Light8f2c6d42017-04-10 16:27:35 -0700523 fi
524fi
525
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100526if [ "$USE_JVM" = "y" ]; then
Alex Light9c20a142016-08-23 15:05:12 -0700527 export LD_LIBRARY_PATH=${ANDROID_HOST_OUT}/lib64
Alex Light47d49b82017-07-25 14:06:34 -0700528 # Some jvmti tests are flaky without -Xint on the RI.
529 if [ "$IS_JVMTI_TEST" = "y" ]; then
530 FLAGS="${FLAGS} -Xint"
531 fi
Mathieu Chartiera61894d2015-04-23 16:32:54 -0700532 # Xmx is necessary since we don't pass down the ART flags to JVM.
Vladimir Markoc5798bf2016-12-09 10:20:54 +0000533 # We pass the classes2 path whether it's used (src-multidex) or not.
534 cmdline="${JAVA} ${DEBUGGER_OPTS} ${JVM_VERIFY_ARG} -Xmx256m -classpath classes:classes2 ${FLAGS} $MAIN $@ ${ARGS}"
Andreas Gampe3f1dc562015-05-18 15:52:22 -0700535 if [ "$DEV_MODE" = "y" ]; then
536 echo $cmdline
537 fi
538 $cmdline
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100539 exit
540fi
541
542
543if [ "$HAVE_IMAGE" = "n" ]; then
Vladimir Markoe00e5592017-02-24 14:58:29 +0000544 if [ "${HOST}" = "y" ]; then
545 framework="${ANDROID_HOST_OUT}/framework"
546 bpath_suffix="-hostdex"
547 else
548 framework="${ANDROID_ROOT}/framework"
Nicolas Geoffray320ccca2017-03-01 10:03:08 +0000549 bpath_suffix="-testdex"
Vladimir Markoe00e5592017-02-24 14:58:29 +0000550 fi
Vladimir Markoe00e5592017-02-24 14:58:29 +0000551 bpath="${framework}/core-libart${bpath_suffix}.jar"
552 bpath="${bpath}:${framework}/core-oj${bpath_suffix}.jar"
Neil Fuller13913902018-08-24 14:19:06 +0100553 bpath="${bpath}:${framework}/core-simple${bpath_suffix}.jar"
Vladimir Markoe00e5592017-02-24 14:58:29 +0000554 bpath="${bpath}:${framework}/conscrypt${bpath_suffix}.jar"
555 bpath="${bpath}:${framework}/okhttp${bpath_suffix}.jar"
556 bpath="${bpath}:${framework}/bouncycastle${bpath_suffix}.jar"
557 # Pass down the bootclasspath
558 FLAGS="${FLAGS} -Xbootclasspath:${bpath}"
Andreas Gampe1078d152017-11-07 18:00:54 -0800559 # Disable image dex2oat - this will forbid the runtime to patch or compile an image.
560 FLAGS="${FLAGS} -Xnoimage-dex2oat"
561
562 # We'll abuse a second flag here to test different behavior. If --relocate, use the
563 # existing image - relocation will fail as patching is disallowed. If --no-relocate,
564 # pass a non-existent image - compilation will fail as dex2oat is disallowed.
565 if [ "${RELOCATE}" = "y" ] ; then
566 DALVIKVM_BOOT_OPT="-Ximage:${BOOT_IMAGE}"
567 else
Roland Levillainef012222017-06-21 16:28:06 +0100568 DALVIKVM_BOOT_OPT="-Ximage:/system/non-existent/core.art"
Andreas Gampe1078d152017-11-07 18:00:54 -0800569 fi
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000570else
571 DALVIKVM_BOOT_OPT="-Ximage:${BOOT_IMAGE}"
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100572fi
573
574
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100575if [ "$USE_GDB" = "y" ]; then
576 if [ "$HOST" = "n" ]; then
577 GDB="$GDB_SERVER :5039"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100578 else
579 if [ `uname` = "Darwin" ]; then
580 GDB=lldb
Mathieu Chartierc0a8a802014-10-17 15:58:01 -0700581 GDB_ARGS="$GDB_ARGS -- $DALVIKVM"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100582 DALVIKVM=
583 else
584 GDB=gdb
Mathieu Chartierc0a8a802014-10-17 15:58:01 -0700585 GDB_ARGS="$GDB_ARGS --args $DALVIKVM"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100586 # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line.
587 # gdbargs="--annotate=3 $gdbargs"
588 fi
589 fi
590fi
591
592if [ "$INTERPRETER" = "y" ]; then
Nicolas Geoffraya5ca8eb2018-08-24 13:39:13 +0100593 INT_OPTS="${INT_OPTS} -Xint"
Andreas Gampe2b0fa5b2014-10-31 18:12:30 -0700594 if [ "$VERIFY" = "y" ] ; then
Nicolas Geoffray49cda062017-04-21 13:08:25 +0100595 INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=quicken"
596 COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=quicken"
Igor Murashkin7617abd2015-07-10 18:27:47 -0700597 elif [ "$VERIFY" = "s" ]; then
Nicolas Geoffray49cda062017-04-21 13:08:25 +0100598 INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=extract"
599 COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=extract"
Igor Murashkin7617abd2015-07-10 18:27:47 -0700600 DEX_VERIFY="${DEX_VERIFY} -Xverify:softfail"
601 else # VERIFY = "n"
Nicolas Geoffray49cda062017-04-21 13:08:25 +0100602 INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=assume-verified"
603 COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=assume-verified"
Andreas Gampe2b0fa5b2014-10-31 18:12:30 -0700604 DEX_VERIFY="${DEX_VERIFY} -Xverify:none"
605 fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100606fi
607
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800608if [ "$JIT" = "y" ]; then
Nicolas Geoffraya5ca8eb2018-08-24 13:39:13 +0100609 INT_OPTS="${INT_OPTS} -Xusejit:true"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800610 if [ "$VERIFY" = "y" ] ; then
Nicolas Geoffray49cda062017-04-21 13:08:25 +0100611 INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=quicken"
612 COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=quicken"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800613 else
Nicolas Geoffray49cda062017-04-21 13:08:25 +0100614 INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=assume-verified"
615 COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=assume-verified"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800616 DEX_VERIFY="${DEX_VERIFY} -Xverify:none"
617 fi
Nicolas Geoffraya5ca8eb2018-08-24 13:39:13 +0100618else
619 INT_OPTS="${INT_OPTS} -Xusejit:false"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800620fi
621
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100622JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni"
623
Richard Uhler020c0f32017-03-14 16:23:17 +0000624COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xnorelocate"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100625if [ "$RELOCATE" = "y" ]; then
Richard Uhlerc52f3032017-03-02 13:45:45 +0000626 FLAGS="${FLAGS} -Xrelocate"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100627else
628 FLAGS="$FLAGS -Xnorelocate"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100629fi
630
631if [ "$HOST" = "n" ]; then
Nicolas Geoffrayd295bc82016-11-04 13:03:05 +0000632 # Need to be root to query /data/dalvik-cache
633 adb root > /dev/null
634 adb wait-for-device
635 ISA=
636 ISA_adb_invocation=
637 ISA_outcome=
638 # We iterate a few times to workaround an adb issue. b/32655576
639 for i in {1..10}; do
640 ISA_adb_invocation=$(adb shell ls -F /data/dalvik-cache)
641 ISA_outcome=$?
642 ISA=$(echo $ISA_adb_invocation | grep -Ewo "${ARCHITECTURES_PATTERN}")
643 if [ x"$ISA" != "x" ]; then
644 break;
645 fi
646 done
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100647 if [ x"$ISA" = "x" ]; then
648 echo "Unable to determine architecture"
Nicolas Geoffray8f500fa2016-11-03 11:18:48 +0000649 # Print a few things for helping diagnosing the problem.
Nicolas Geoffrayd295bc82016-11-04 13:03:05 +0000650 echo "adb invocation output: $ISA_adb_invocation"
651 echo "adb invocation outcome: $ISA_outcome"
Nicolas Geoffray8f500fa2016-11-03 11:18:48 +0000652 echo $(adb shell ls -F /data/dalvik-cache)
653 echo $(adb shell ls /data/dalvik-cache)
654 echo ${ARCHITECTURES_PATTERN}
655 echo $(adb shell ls -F /data/dalvik-cache | grep -Ewo "${ARCHITECTURES_PATTERN}")
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100656 exit 1
657 fi
658fi
659
Alex Light680cbf22018-10-31 11:00:19 -0700660if [ "$BIONIC" = "y" ]; then
661 # This is the location that soong drops linux_bionic builds. Despite being
662 # called linux_bionic-x86 the build is actually amd64 (x86_64) only.
663 if [ ! -e "$OUT_DIR/soong/host/linux_bionic-x86" ]; then
664 echo "linux_bionic-x86 target doesn't seem to have been built!" >&2
665 exit 1
666 fi
667fi
668
Wojciech Staszkiewicze6636532016-09-23 10:59:55 -0700669# Prevent test from silently falling back to interpreter in no-prebuild mode. This happens
670# when DEX_LOCATION path is too long, because vdex/odex filename is constructed by taking
671# full path to dex, stripping leading '/', appending '@classes.vdex' and changing every
672# remaining '/' into '@'.
673if [ "$HOST" = "y" ]; then
674 max_filename_size=$(getconf NAME_MAX $DEX_LOCATION)
675else
Roland Levillain2ae376f2018-01-30 11:35:11 +0000676 # There is no getconf on device, fallback to standard value.
677 # See NAME_MAX in kernel <linux/limits.h>
Wojciech Staszkiewicze6636532016-09-23 10:59:55 -0700678 max_filename_size=255
679fi
680# Compute VDEX_NAME.
681DEX_LOCATION_STRIPPED="${DEX_LOCATION#/}"
682VDEX_NAME="${DEX_LOCATION_STRIPPED//\//@}@$TEST_NAME.jar@classes.vdex"
683if [ ${#VDEX_NAME} -gt $max_filename_size ]; then
Nicolas Geoffraybea3e312017-03-07 09:59:05 +0000684 echo "Dex location path too long:"
685 echo "$VDEX_NAME is ${#VDEX_NAME} character long, and the limit is $max_filename_size."
Wojciech Staszkiewicze6636532016-09-23 10:59:55 -0700686 exit 1
687fi
688
Calin Juravle13439f02017-02-21 01:17:21 -0800689profman_cmdline="true"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100690dex2oat_cmdline="true"
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000691vdex_cmdline="true"
Nicolas Geoffraybaeaa9b2018-01-26 14:31:17 +0000692dm_cmdline="true"
Andreas Gampeb09abb22018-05-03 11:51:22 -0700693mkdir_locations="${DEX_LOCATION}/dalvik-cache/$ISA"
Richard Uhler76f5cb62016-04-04 13:30:16 -0700694strip_cmdline="true"
Igor Murashkin271a0f82017-02-14 21:14:17 +0000695sync_cmdline="true"
Alex Light680cbf22018-10-31 11:00:19 -0700696linkroot_cmdline="true"
697linkroot_overlay_cmdline="true"
698
699linkdirs() {
700 find "$1" -maxdepth 1 -mindepth 1 -type d | xargs -i ln -sf '{}' "$2"
701}
702
703if [ "$CREATE_ANDROID_ROOT" = "y" ]; then
704 mkdir_locations="${mkdir_locations} ${ANDROID_ROOT}"
705 linkroot_cmdline="linkdirs ${ANDROID_HOST_OUT} ${ANDROID_ROOT}"
706 if [ "${BIONIC}" = "y" ]; then
707 # TODO Make this overlay more generic.
708 linkroot_overlay_cmdline="linkdirs $OUT_DIR/soong/host/linux_bionic-x86 ${ANDROID_ROOT}"
709 fi
710fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100711
Jeff Hao002b9312017-03-27 16:23:08 -0700712# PROFILE takes precedence over RANDOM_PROFILE, since PROFILE tests require a
713# specific profile to run properly.
714if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then
Nicolas Geoffray0b6a6382017-03-10 09:38:35 +0000715 profman_cmdline="${ANDROID_ROOT}/bin/profman \
716 --apk=$DEX_LOCATION/$TEST_NAME.jar \
Jeff Hao002b9312017-03-27 16:23:08 -0700717 --dex-location=$DEX_LOCATION/$TEST_NAME.jar"
Calin Juravle6df62f72017-04-28 19:58:01 -0700718 if [ -f $DEX_LOCATION/$TEST_NAME-ex.jar ]; then
719 profman_cmdline="${profman_cmdline} \
720 --apk=$DEX_LOCATION/$TEST_NAME-ex.jar \
721 --dex-location=$DEX_LOCATION/$TEST_NAME-ex.jar"
722 fi
Nicolas Geoffray0b6a6382017-03-10 09:38:35 +0000723 COMPILE_FLAGS="${COMPILE_FLAGS} --profile-file=$DEX_LOCATION/$TEST_NAME.prof"
724 FLAGS="${FLAGS} -Xcompiler-option --profile-file=$DEX_LOCATION/$TEST_NAME.prof"
Jeff Hao002b9312017-03-27 16:23:08 -0700725 if [ "$PROFILE" = "y" ]; then
726 profman_cmdline="${profman_cmdline} --create-profile-from=$DEX_LOCATION/profile \
727 --reference-profile-file=$DEX_LOCATION/$TEST_NAME.prof"
728 else
729 profman_cmdline="${profman_cmdline} --generate-test-profile=$DEX_LOCATION/$TEST_NAME.prof \
730 --generate-test-profile-seed=0"
731 fi
Nicolas Geoffray0b6a6382017-03-10 09:38:35 +0000732fi
733
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100734if [ "$PREBUILD" = "y" ]; then
Alex Lightafb5d192016-05-24 15:57:45 -0700735 mkdir_locations="${mkdir_locations} ${DEX_LOCATION}/oat/$ISA"
Calin Juravle857f0582016-12-20 14:36:59 +0000736 if [ "$APP_IMAGE" = "y" ]; then
737 # Pick a base that will force the app image to get relocated.
738 app_image="--base=0x4000 --app-image-file=$DEX_LOCATION/oat/$ISA/$TEST_NAME.art"
739 fi
740
Roland Levillain6c3af162017-04-27 11:18:56 +0100741 dex2oat_binary=dex2oatd
742 if [[ "$TEST_IS_NDEBUG" = "y" ]]; then
743 dex2oat_binary=dex2oat
744 fi
745 dex2oat_cmdline="$INVOKE_WITH $ANDROID_ROOT/bin/$dex2oat_binary \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100746 $COMPILE_FLAGS \
Nicolas Geoffray68e25eb2014-10-29 23:02:11 +0000747 --boot-image=${BOOT_IMAGE} \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100748 --dex-file=$DEX_LOCATION/$TEST_NAME.jar \
Andreas Gampe14759242016-03-23 10:54:21 -0700749 --oat-file=$DEX_LOCATION/oat/$ISA/$TEST_NAME.odex \
Jeff Haodcdc85b2015-12-04 14:06:18 -0800750 ${app_image} \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100751 --instruction-set=$ISA"
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700752 if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then
753 dex2oat_cmdline="${dex2oat_cmdline} --instruction-set-features=${INSTRUCTION_SET_FEATURES}"
754 fi
Andreas Gampe2ea7b702015-08-07 08:07:16 -0700755
756 # Add in a timeout. This is important for testing the compilation/verification time of
757 # pathological cases.
758 # Note: as we don't know how decent targets are (e.g., emulator), only do this on the host for
759 # now. We should try to improve this.
760 # The current value is rather arbitrary. run-tests should compile quickly.
Alex Light483208d2017-09-26 09:31:17 -0700761 # Watchdog timeout is in milliseconds so add 3 '0's to the dex2oat timeout.
Andreas Gampe2ea7b702015-08-07 08:07:16 -0700762 if [ "$HOST" != "n" ]; then
763 # Use SIGRTMIN+2 to try to dump threads.
764 # Use -k 1m to SIGKILL it a minute later if it hasn't ended.
Alex Light483208d2017-09-26 09:31:17 -0700765 dex2oat_cmdline="timeout -k ${DEX2OAT_TIMEOUT}s -s SIGRTMIN+2 ${DEX2OAT_RT_TIMEOUT}s ${dex2oat_cmdline} --watchdog-timeout=${DEX2OAT_TIMEOUT}000"
Andreas Gampe2ea7b702015-08-07 08:07:16 -0700766 fi
Nicolas Geoffrayfbc4f112017-04-27 21:45:35 +0100767 if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then
768 vdex_cmdline="${dex2oat_cmdline} ${VDEX_FILTER} --input-vdex=$DEX_LOCATION/oat/$ISA/$TEST_NAME.vdex --output-vdex=$DEX_LOCATION/oat/$ISA/$TEST_NAME.vdex"
769 elif [ "$TEST_VDEX" = "y" ]; then
Nicolas Geoffray74981052017-01-16 17:54:09 +0000770 vdex_cmdline="${dex2oat_cmdline} ${VDEX_FILTER} --input-vdex=$DEX_LOCATION/oat/$ISA/$TEST_NAME.vdex"
Nicolas Geoffraybaeaa9b2018-01-26 14:31:17 +0000771 elif [ "$TEST_DM" = "y" ]; then
772 dex2oat_cmdline="${dex2oat_cmdline} --output-vdex=$DEX_LOCATION/oat/$ISA/primary.vdex"
773 dm_cmdline="zip -qj $DEX_LOCATION/oat/$ISA/$TEST_NAME.dm $DEX_LOCATION/oat/$ISA/primary.vdex"
774 vdex_cmdline="${dex2oat_cmdline} --dump-timings --dm-file=$DEX_LOCATION/oat/$ISA/$TEST_NAME.dm"
Nicolas Geoffraycab65572017-04-21 17:16:44 +0100775 elif [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then
776 vdex_cmdline="${dex2oat_cmdline} --input-vdex=$DEX_LOCATION/oat/$ISA/$TEST_NAME.vdex --output-vdex=$DEX_LOCATION/oat/$ISA/$TEST_NAME.vdex"
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000777 fi
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700778fi
779
Richard Uhler76f5cb62016-04-04 13:30:16 -0700780if [ "$STRIP_DEX" = "y" ]; then
781 strip_cmdline="zip --quiet --delete $DEX_LOCATION/$TEST_NAME.jar classes.dex"
782fi
783
Igor Murashkin271a0f82017-02-14 21:14:17 +0000784if [ "$SYNC_BEFORE_RUN" = "y" ]; then
785 sync_cmdline="sync"
786fi
787
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700788DALVIKVM_ISA_FEATURES_ARGS=""
789if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then
790 DALVIKVM_ISA_FEATURES_ARGS="-Xcompiler-option --instruction-set-features=${INSTRUCTION_SET_FEATURES}"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100791fi
792
Nicolas Geoffrayc5256042015-12-26 19:41:37 +0000793# java.io.tmpdir can only be set at launch time.
794TMP_DIR_OPTION=""
795if [ "$HOST" = "n" ]; then
796 TMP_DIR_OPTION="-Djava.io.tmpdir=/data/local/tmp"
797fi
798
Nicolas Geoffray6ee49712018-03-30 14:39:05 +0000799# We set DumpNativeStackOnSigQuit to false to avoid stressing libunwind.
800# b/27185632
801# b/24664297
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000802dalvikvm_cmdline="$INVOKE_WITH $GDB $ANDROID_ROOT/bin/$DALVIKVM \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100803 $GDB_ARGS \
804 $FLAGS \
Andreas Gampe2b0fa5b2014-10-31 18:12:30 -0700805 $DEX_VERIFY \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100806 -XXlib:$LIB \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100807 $DEX2OAT \
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700808 $DALVIKVM_ISA_FEATURES_ARGS \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100809 $ZYGOTE \
810 $JNI_OPTS \
811 $INT_OPTS \
812 $DEBUGGER_OPTS \
813 $DALVIKVM_BOOT_OPT \
Nicolas Geoffrayc5256042015-12-26 19:41:37 +0000814 $TMP_DIR_OPTION \
Nicolas Geoffray6ee49712018-03-30 14:39:05 +0000815 -XX:DumpNativeStackOnSigQuit:false \
Mathieu Chartier031768a2015-08-27 10:25:02 -0700816 -cp $DEX_LOCATION/$TEST_NAME.jar$SECONDARY_DEX $MAIN $ARGS"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100817
Andreas Gampe3ad5d5e2015-02-03 18:26:55 -0800818# Remove whitespace.
819dex2oat_cmdline=$(echo $dex2oat_cmdline)
820dalvikvm_cmdline=$(echo $dalvikvm_cmdline)
Nicolas Geoffraybaeaa9b2018-01-26 14:31:17 +0000821dm_cmdline=$(echo $dm_cmdline)
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000822vdex_cmdline=$(echo $vdex_cmdline)
Calin Juravle13439f02017-02-21 01:17:21 -0800823profman_cmdline=$(echo $profman_cmdline)
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100824
Andreas Gampeb31a8e72017-05-16 10:30:24 -0700825# Use an empty ASAN_OPTIONS to enable defaults.
826# Note: this is required as envsetup right now exports detect_leaks=0.
827RUN_TEST_ASAN_OPTIONS=""
828
Andreas Gampe58408392017-05-16 10:45:46 -0700829# Multiple shutdown leaks. b/38341789
830if [ "x$RUN_TEST_ASAN_OPTIONS" != "x" ] ; then
831 RUN_TEST_ASAN_OPTIONS="${RUN_TEST_ASAN_OPTIONS}:"
832fi
833RUN_TEST_ASAN_OPTIONS="${RUN_TEST_ASAN_OPTIONS}detect_leaks=0"
834
Vladimir Markoa497a392018-09-26 10:52:50 +0100835# For running, we must turn off logging when dex2oat is missing. Otherwise we use
Nicolas Geoffrayf39f04c2018-03-05 15:42:11 +0000836# the same defaults as for prebuilt: everything when --dev, otherwise errors and above only.
837if [ "$EXTERNAL_LOG_TAGS" = "n" ]; then
838 if [ "$DEV_MODE" = "y" ]; then
839 export ANDROID_LOG_TAGS='*:d'
Nicolas Geoffrayf39f04c2018-03-05 15:42:11 +0000840 elif [ "$HAVE_IMAGE" = "n" ]; then
841 # All tests would log the error of missing image. Be silent here and only log fatal
842 # events.
843 export ANDROID_LOG_TAGS='*:s'
844 else
845 # We are interested in LOG(ERROR) output.
846 export ANDROID_LOG_TAGS='*:e'
847 fi
848fi
849
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100850if [ "$HOST" = "n" ]; then
851 adb root > /dev/null
852 adb wait-for-device
853 if [ "$QUIET" = "n" ]; then
Roland Levillain76cfe612017-10-30 13:14:28 +0000854 adb shell rm -rf $CHROOT_DEX_LOCATION
855 adb shell mkdir -p $CHROOT_DEX_LOCATION
856 adb push $TEST_NAME.jar $CHROOT_DEX_LOCATION
857 adb push $TEST_NAME-ex.jar $CHROOT_DEX_LOCATION
Jeff Hao002b9312017-03-27 16:23:08 -0700858 if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then
Roland Levillain76cfe612017-10-30 13:14:28 +0000859 adb push profile $CHROOT_DEX_LOCATION
Calin Juravle13439f02017-02-21 01:17:21 -0800860 fi
David Brazdil7d2ec612018-01-19 14:19:59 +0000861 # Copy resource folder
862 if [ -d res ]; then
Roland Levillain76cfe612017-10-30 13:14:28 +0000863 adb push res $CHROOT_DEX_LOCATION
David Brazdil7d2ec612018-01-19 14:19:59 +0000864 fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100865 else
Roland Levillain76cfe612017-10-30 13:14:28 +0000866 adb shell rm -rf $CHROOT_DEX_LOCATION >/dev/null 2>&1
867 adb shell mkdir -p $CHROOT_DEX_LOCATION >/dev/null 2>&1
868 adb push $TEST_NAME.jar $CHROOT_DEX_LOCATION >/dev/null 2>&1
869 adb push $TEST_NAME-ex.jar $CHROOT_DEX_LOCATION >/dev/null 2>&1
Jeff Hao002b9312017-03-27 16:23:08 -0700870 if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then
Roland Levillain76cfe612017-10-30 13:14:28 +0000871 adb push profile $CHROOT_DEX_LOCATION >/dev/null 2>&1
Calin Juravle13439f02017-02-21 01:17:21 -0800872 fi
David Brazdil7d2ec612018-01-19 14:19:59 +0000873 # Copy resource folder
874 if [ -d res ]; then
Roland Levillain76cfe612017-10-30 13:14:28 +0000875 adb push res $CHROOT_DEX_LOCATION >/dev/null 2>&1
David Brazdil7d2ec612018-01-19 14:19:59 +0000876 fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100877 fi
878
Colin Crossafd3c9e2016-09-16 13:47:21 -0700879 LD_LIBRARY_PATH=/data/$TEST_DIRECTORY/art/$ISA
Nicolas Geoffrayeb441dd2014-10-31 15:34:50 +0000880 if [ "$ANDROID_ROOT" != "/system" ]; then
881 # Current default installation is dalvikvm 64bits and dex2oat 32bits,
882 # so we can only use LD_LIBRARY_PATH when testing on a local
883 # installation.
Roland Levillain76cfe612017-10-30 13:14:28 +0000884 LD_LIBRARY_PATH="$ANDROID_ROOT/$LIBRARY_DIRECTORY:$LD_LIBRARY_PATH"
Nicolas Geoffrayeb441dd2014-10-31 15:34:50 +0000885 fi
886
Dimitry Ivanov49c2c922017-02-14 11:06:14 -0800887 # System libraries needed by libarttestd.so
Vladimir Marko2da72ed2018-03-07 12:58:11 +0000888 PUBLIC_LIBS=libc++.so:libbacktrace.so:libbase.so:libnativehelper.so
889 if [ "$TEST_IS_NDEBUG" = "y" ]; then
David Sehr1f010162018-05-15 08:59:32 -0700890 PUBLIC_LIBS=$PUBLIC_LIBS:libart.so:libdexfile.so:libprofile.so:libartbase.so
Vladimir Marko2da72ed2018-03-07 12:58:11 +0000891 else
David Sehr1f010162018-05-15 08:59:32 -0700892 PUBLIC_LIBS=$PUBLIC_LIBS:libartd.so:libdexfiled.so:libprofiled.so:libartbased.so
Vladimir Marko2da72ed2018-03-07 12:58:11 +0000893 fi
Dimitry Ivanov90d48f22016-05-05 17:24:28 -0700894
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100895 # Create a script with the command. The command can get longer than the longest
896 # allowed adb command and there is no way to get the exit status from a adb shell
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700897 # command. Dalvik cache is cleaned before running to make subsequent executions
898 # of the script follow the same runtime path.
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100899 cmdline="cd $DEX_LOCATION && \
Andreas Gampeb31a8e72017-05-16 10:30:24 -0700900 export ASAN_OPTIONS=$RUN_TEST_ASAN_OPTIONS && \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100901 export ANDROID_DATA=$DEX_LOCATION && \
Dimitry Ivanov90d48f22016-05-05 17:24:28 -0700902 export ANDROID_ADDITIONAL_PUBLIC_LIBRARIES=$PUBLIC_LIBS && \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100903 export DEX_LOCATION=$DEX_LOCATION && \
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000904 export ANDROID_ROOT=$ANDROID_ROOT && \
Nicolas Geoffrayf39f04c2018-03-05 15:42:11 +0000905 export ANDROID_LOG_TAGS=$ANDROID_LOG_TAGS && \
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700906 rm -rf ${DEX_LOCATION}/dalvik-cache/ && \
Alex Lightafb5d192016-05-24 15:57:45 -0700907 mkdir -p ${mkdir_locations} && \
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100908 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH && \
Nicolas Geoffray4f7fdd22015-04-24 11:57:37 +0100909 export PATH=$ANDROID_ROOT/bin:$PATH && \
Calin Juravle13439f02017-02-21 01:17:21 -0800910 $profman_cmdline && \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100911 $dex2oat_cmdline && \
Nicolas Geoffraybaeaa9b2018-01-26 14:31:17 +0000912 $dm_cmdline && \
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000913 $vdex_cmdline && \
Richard Uhler76f5cb62016-04-04 13:30:16 -0700914 $strip_cmdline && \
Igor Murashkin271a0f82017-02-14 21:14:17 +0000915 $sync_cmdline && \
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100916 $dalvikvm_cmdline"
917
918 cmdfile=$(tempfile -p "cmd-" -s "-$TEST_NAME")
919 echo "$cmdline" > $cmdfile
920
921 if [ "$DEV_MODE" = "y" ]; then
922 echo $cmdline
923 fi
924
925 if [ "$QUIET" = "n" ]; then
Roland Levillain76cfe612017-10-30 13:14:28 +0000926 adb push $cmdfile $CHROOT_DEX_LOCATION/cmdline.sh
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100927 else
Roland Levillain76cfe612017-10-30 13:14:28 +0000928 adb push $cmdfile $CHROOT_DEX_LOCATION/cmdline.sh >/dev/null 2>&1
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100929 fi
930
Alex Light722d6712018-02-12 17:41:12 +0000931 exit_status=0
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700932 if [ "$DRY_RUN" != "y" ]; then
Roland Levillain76cfe612017-10-30 13:14:28 +0000933 if [ -n "$CHROOT" ]; then
934 adb shell chroot "$CHROOT" sh $DEX_LOCATION/cmdline.sh
935 else
936 adb shell sh $DEX_LOCATION/cmdline.sh
937 fi
Alex Light722d6712018-02-12 17:41:12 +0000938 exit_status=$?
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700939 fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100940
941 rm -f $cmdfile
Alex Light722d6712018-02-12 17:41:12 +0000942 exit $exit_status
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100943else
Calin Juravle24bd3f92017-05-11 00:36:53 -0700944 # Host run.
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100945 export ANDROID_PRINTF_LOG=brief
Andreas Gampea8780822015-03-13 19:51:09 -0700946
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100947 export ANDROID_DATA="$DEX_LOCATION"
Nicolas Geoffray8eedb472014-10-29 14:05:59 +0000948 export ANDROID_ROOT="${ANDROID_ROOT}"
Colin Crossafd3c9e2016-09-16 13:47:21 -0700949 export LD_LIBRARY_PATH="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}"
950 export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100951 export PATH="$PATH:${ANDROID_ROOT}/bin"
952
David Srbeckyc9ede382015-06-20 06:03:53 +0100953 # Temporarily disable address space layout randomization (ASLR).
954 # This is needed on the host so that the linker loads core.oat at the necessary address.
955 export LD_USE_LOAD_BIAS=1
956
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100957 cmdline="$dalvikvm_cmdline"
958
Hiroshi Yamauchi6ffb9cc2015-08-31 15:14:17 -0700959 if [ "$TIME_OUT" = "gdb" ]; then
960 if [ `uname` = "Darwin" ]; then
961 # Fall back to timeout on Mac.
962 TIME_OUT="timeout"
Hiroshi Yamauchic823eff2015-09-01 16:21:35 -0700963 elif [ "$ISA" = "x86" ]; then
964 # prctl call may fail in 32-bit on an older (3.2) 64-bit Linux kernel. Fall back to timeout.
965 TIME_OUT="timeout"
Hiroshi Yamauchi6ffb9cc2015-08-31 15:14:17 -0700966 else
967 # Check if gdb is available.
968 gdb --eval-command="quit" > /dev/null 2>&1
969 if [ $? != 0 ]; then
970 # gdb isn't available. Fall back to timeout.
971 TIME_OUT="timeout"
972 fi
973 fi
974 fi
975
976 if [ "$TIME_OUT" = "timeout" ]; then
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100977 # Add timeout command if time out is desired.
Andreas Gampe038bb222015-01-13 19:48:14 -0800978 #
Andreas Gampe6fb92562016-08-01 21:53:57 -0700979 # Note: We first send SIGRTMIN+2 (usually 36) to ART, which will induce a full thread dump
980 # before abort. However, dumping threads might deadlock, so we also use the "-k"
981 # option to definitely kill the child.
982 cmdline="timeout -k 120s -s SIGRTMIN+2 ${TIME_OUT_VALUE}s $cmdline"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100983 fi
984
985 if [ "$DEV_MODE" = "y" ]; then
Orion Hodsonee06c5a2018-04-23 13:46:24 +0100986 for var in ANDROID_PRINTF_LOG ANDROID_DATA ANDROID_ROOT LD_LIBRARY_PATH DYLD_LIBRARY_PATH PATH LD_USE_LOAD_BIAS; do
987 echo EXPORT $var=${!var}
988 done
Alex Light680cbf22018-10-31 11:00:19 -0700989 echo "$(declare -f linkdirs)"
990 echo "mkdir -p ${mkdir_locations} && $linkroot_cmdline && $linkroot_overlay_cmdline && $profman_cmdline && $dex2oat_cmdline && $dm_cmdline && $vdex_cmdline && $strip_cmdline && $sync_cmdline && $cmdline"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100991 fi
992
993 cd $ANDROID_BUILD_TOP
994
Calin Juravle24bd3f92017-05-11 00:36:53 -0700995 # Make sure we delete any existing compiler artifacts.
996 # This enables tests to call the RUN script multiple times in a row
997 # without worrying about interference.
998 rm -rf ${DEX_LOCATION}/oat
David Srbecky2e4afe82016-01-27 18:42:06 +0000999 rm -rf ${DEX_LOCATION}/dalvik-cache/
Calin Juravle24bd3f92017-05-11 00:36:53 -07001000
Andreas Gampeb31a8e72017-05-16 10:30:24 -07001001 export ASAN_OPTIONS=$RUN_TEST_ASAN_OPTIONS
1002
Alex Lightafb5d192016-05-24 15:57:45 -07001003 mkdir -p ${mkdir_locations} || exit 1
Alex Light680cbf22018-10-31 11:00:19 -07001004 $linkroot_cmdline || { echo "create symlink android-root failed." >&2 ; exit 2; }
1005 $linkroot_overlay_cmdline || { echo "overlay android-root failed." >&2 ; exit 2; }
Calin Juravle13439f02017-02-21 01:17:21 -08001006 $profman_cmdline || { echo "Profman failed." >&2 ; exit 2; }
Andreas Gampea8780822015-03-13 19:51:09 -07001007 $dex2oat_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; }
Nicolas Geoffraybaeaa9b2018-01-26 14:31:17 +00001008 $dm_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; }
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +00001009 $vdex_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; }
Richard Uhler76f5cb62016-04-04 13:30:16 -07001010 $strip_cmdline || { echo "Strip failed." >&2 ; exit 3; }
Igor Murashkin271a0f82017-02-14 21:14:17 +00001011 $sync_cmdline || { echo "Sync failed." >&2 ; exit 4; }
Andreas Gampea8780822015-03-13 19:51:09 -07001012
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -07001013 if [ "$DRY_RUN" = "y" ]; then
1014 exit 0
Andreas Gampea8780822015-03-13 19:51:09 -07001015 fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +01001016
1017 if [ "$USE_GDB" = "y" ]; then
1018 # When running under gdb, we cannot do piping and grepping...
Alex Light754e9a62018-09-24 11:39:27 -07001019 echo "Run 'gdbclient.py -p <pid printed below>' to debug."
Dmitriy Ivanovf57874d2014-10-07 13:43:23 -07001020 $cmdline "$@"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +01001021 else
Hiroshi Yamauchi6ffb9cc2015-08-31 15:14:17 -07001022 if [ "$TIME_OUT" != "gdb" ]; then
1023 trap 'kill -INT -$pid' INT
1024 $cmdline "$@" 2>&1 & pid=$!
1025 wait $pid
Alex Light722d6712018-02-12 17:41:12 +00001026 exit_value=$?
Hiroshi Yamauchi6ffb9cc2015-08-31 15:14:17 -07001027 # Add extra detail if time out is enabled.
Alex Light722d6712018-02-12 17:41:12 +00001028 if [ $exit_value = 124 ] && [ "$TIME_OUT" = "timeout" ]; then
Hiroshi Yamauchi6ffb9cc2015-08-31 15:14:17 -07001029 echo -e "\e[91mTEST TIMED OUT!\e[0m" >&2
1030 fi
Alex Light722d6712018-02-12 17:41:12 +00001031 exit $exit_value
Hiroshi Yamauchi6ffb9cc2015-08-31 15:14:17 -07001032 else
1033 # With a thread dump that uses gdb if a timeout.
1034 trap 'kill -INT -$pid' INT
1035 $cmdline "$@" 2>&1 & pid=$!
1036 # Spawn a watcher process.
1037 ( sleep $TIME_OUT_VALUE && \
1038 echo "##### Thread dump using gdb on test timeout" && \
1039 ( gdb -q -p $pid --eval-command="info thread" --eval-command="thread apply all bt" \
1040 --eval-command="call exit(124)" --eval-command=quit || \
1041 kill $pid )) 2> /dev/null & watcher=$!
1042 wait $pid
1043 test_exit_status=$?
1044 pkill -P $watcher 2> /dev/null # kill the sleep which will in turn end the watcher as well
1045 if [ $test_exit_status = 0 ]; then
1046 # The test finished normally.
1047 exit 0
1048 else
1049 # The test failed or timed out.
1050 if [ $test_exit_status = 124 ]; then
1051 # The test timed out.
1052 echo -e "\e[91mTEST TIMED OUT!\e[0m" >&2
1053 fi
Alex Light722d6712018-02-12 17:41:12 +00001054 exit $test_exit_status
Hiroshi Yamauchi6ffb9cc2015-08-31 15:14:17 -07001055 fi
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +01001056 fi
1057 fi
1058fi