blob: dccc9f63e5f2f9ce8e8a9e0d226867bc3ca75d8a [file] [log] [blame]
jeffhao5d1ac922011-09-29 17:41:15 -07001#!/bin/bash
2#
3# Copyright (C) 2007 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Set up prog to be the path of this script, including following symlinks,
18# and set up progdir to be the fully-qualified pathname of its directory.
19prog="$0"
Andreas Gampedeb48a02014-10-22 00:44:35 -070020args="$@"
jeffhao5d1ac922011-09-29 17:41:15 -070021while [ -h "${prog}" ]; do
22 newProg=`/bin/ls -ld "${prog}"`
23 newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
24 if expr "x${newProg}" : 'x/' >/dev/null; then
25 prog="${newProg}"
26 else
27 progdir=`dirname "${prog}"`
28 prog="${progdir}/${newProg}"
29 fi
30done
31oldwd=`pwd`
32progdir=`dirname "${prog}"`
33cd "${progdir}"
34progdir=`pwd`
35prog="${progdir}"/`basename "${prog}"`
Brian Carlstrom105215d2012-06-14 12:50:44 -070036test_dir="test-$$"
Andreas Gampe5a79fde2014-08-06 13:12:26 -070037if [ -z "$TMPDIR" ]; then
38 tmp_dir="/tmp/$USER/${test_dir}"
39else
Andreas Gampe34a8a0f2016-07-20 21:09:29 -070040 tmp_dir="${TMPDIR}/${test_dir}"
Andreas Gampe5a79fde2014-08-06 13:12:26 -070041fi
David Brazdil2c27f2c2015-05-12 18:06:38 +010042checker="${progdir}/../tools/checker/checker.py"
jeffhao5d1ac922011-09-29 17:41:15 -070043export JAVA="java"
Orion Hodson64fe3be2018-06-15 12:50:22 +010044export JAVAC="javac -g -Xlint:-options -source 1.8 -target 1.8"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010045export RUN="${progdir}/etc/run-test-jar"
Brian Carlstrom105215d2012-06-14 12:50:44 -070046export DEX_LOCATION=/data/run-test/${test_dir}
Andreas Gampe8fda9f22014-10-03 16:15:37 -070047
Sebastien Hertz19ac0272015-02-24 17:39:50 +010048# ANDROID_BUILD_TOP is not set in a build environment.
49if [ -z "$ANDROID_BUILD_TOP" ]; then
50 export ANDROID_BUILD_TOP=$oldwd
51fi
52
Dan Willemsen12371e92017-03-06 17:55:20 -080053# OUT_DIR defaults to out, and may be relative to $ANDROID_BUILD_TOP.
54# Convert it to an absolute path, since we cd into the tmp_dir to run the tests.
55export OUT_DIR=${OUT_DIR:-out}
56if [[ "$OUT_DIR" != /* ]]; then
57 export OUT_DIR=$ANDROID_BUILD_TOP/$OUT_DIR
58fi
59
Andreas Gampef47fb2f2016-06-24 22:30:29 -070060# ANDROID_HOST_OUT is not set in a build environment.
61if [ -z "$ANDROID_HOST_OUT" ]; then
Dan Willemsen12371e92017-03-06 17:55:20 -080062 export ANDROID_HOST_OUT=${OUT_DIR}/host/linux-x86
Andreas Gampef47fb2f2016-06-24 22:30:29 -070063fi
64
Alex Light680cbf22018-10-31 11:00:19 -070065host_lib_root=${ANDROID_HOST_OUT}
Roland Levillain76cfe612017-10-30 13:14:28 +000066chroot=
jeffhao5d1ac922011-09-29 17:41:15 -070067info="info.txt"
jeffhao5d1ac922011-09-29 17:41:15 -070068run="run"
Roland Levillainb15e8792020-10-28 12:20:59 +000069expected_stdout="expected-stdout.txt"
70expected_stderr="expected-stderr.txt"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -070071check_cmd="check"
Roland Levillainb15e8792020-10-28 12:20:59 +000072test_stdout="test-stdout.txt"
73test_stderr="test-stderr.txt"
David Brazdil24128c62015-05-21 12:06:13 +010074cfg_output="graph.cfg"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -070075strace_output="strace-output.txt"
Brian Carlstromdc959ea2013-10-28 00:44:49 -070076lib="libartd.so"
Mathieu Chartier031768a2015-08-27 10:25:02 -070077testlib="arttestd"
Andreas Gampe11410de2019-07-02 15:53:53 -070078run_args=(--quiet)
jeffhao5d1ac922011-09-29 17:41:15 -070079
Alex Light91de25f2015-10-28 17:00:06 -070080quiet="no"
Nicolas Geoffraya3d90fb2015-03-16 13:55:40 +000081debuggable="no"
Alex Light9d722532014-07-22 18:07:12 -070082prebuild_mode="yes"
Brian Carlstrom2613de42012-06-15 17:37:16 -070083target_mode="yes"
jeffhao5d1ac922011-09-29 17:41:15 -070084dev_mode="no"
Alex Light8d94ddd2019-12-18 11:13:03 -080085create_runner="no"
jeffhao5d1ac922011-09-29 17:41:15 -070086update_mode="no"
Alex Lighta59dd802014-07-02 16:28:08 -070087debug_mode="no"
Nicolas Geoffray94e25db2017-01-27 14:54:28 +000088relocate="no"
Jeff Hao201803f2013-11-20 18:11:39 -080089runtime="art"
jeffhao5d1ac922011-09-29 17:41:15 -070090usage="no"
Andreas Gampe2fe07922014-04-21 07:50:39 -070091suffix64=""
Jeff Hao85139a32014-07-23 11:52:52 -070092trace="false"
Andreas Gampe7526d782015-06-22 22:53:45 -070093trace_stream="false"
Alex Lighte7873ec2014-08-12 09:53:50 -070094basic_verify="false"
95gc_verify="false"
96gc_stress="false"
Alex Lightb7edcda2017-04-27 13:20:31 -070097jvmti_trace_stress="false"
Alex Light43e935d2017-06-19 15:40:40 -070098jvmti_field_stress="false"
Alex Lightc38c3692017-06-27 15:45:14 -070099jvmti_step_stress="false"
Alex Lightb7edcda2017-04-27 13:20:31 -0700100jvmti_redefine_stress="false"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700101strace="false"
Alex Lightbfac14a2014-07-30 09:41:21 -0700102always_clean="no"
Igor Murashkin05f30e12015-06-10 15:57:17 -0700103never_clean="no"
Alex Light03a112d2014-08-25 13:25:56 -0700104have_image="yes"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000105android_root="/system"
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700106bisection_search="no"
Martin Stjernholm4815e722019-09-24 16:20:09 +0100107timeout=""
Mathieu Chartier3fceaf52017-01-22 13:33:40 -0800108suspend_timeout="500000"
Nicolas Geoffrayacc56ac2018-10-09 08:45:24 +0100109run_optimizing="false"
Stelios Ioannou1b621222021-06-17 14:15:45 +0100110dump_cfg="false"
111dump_cfg_path=""
Alex Light20802ca2018-12-05 15:36:03 -0800112# To cause tests to fail fast, limit the file sizes created by dx, dex2oat and
113# ART output to approximately 128MB. This should be more than sufficient
114# for any test while still catching cases of runaway output.
115# Set a hard limit to encourage ART developers to increase the ulimit here if
116# needed to support a test case rather than resetting the limit in the run
117# script for the particular test in question. Adjust this if needed for
118# particular configurations.
119file_ulimit=128000
120
Andreas Gampe11410de2019-07-02 15:53:53 -0700121
jeffhao5d1ac922011-09-29 17:41:15 -0700122while true; do
123 if [ "x$1" = "x--host" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -0700124 target_mode="no"
TDYa127b92bcab2012-04-08 00:09:51 -0700125 DEX_LOCATION=$tmp_dir
Andreas Gampe11410de2019-07-02 15:53:53 -0700126 run_args+=(--host)
jeffhao5d1ac922011-09-29 17:41:15 -0700127 shift
Alex Light91de25f2015-10-28 17:00:06 -0700128 elif [ "x$1" = "x--quiet" ]; then
129 quiet="yes"
130 shift
Alex Lighteb7c1442015-08-31 13:17:42 -0700131 elif [ "x$1" = "x--use-java-home" ]; then
132 if [ -n "${JAVA_HOME}" ]; then
133 export JAVA="${JAVA_HOME}/bin/java"
134 export JAVAC="${JAVA_HOME}/bin/javac -g"
135 else
136 echo "Passed --use-java-home without JAVA_HOME variable set!"
137 usage="yes"
138 fi
139 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -0800140 elif [ "x$1" = "x--jvm" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -0700141 target_mode="no"
Alex Light2c7aaeb2017-01-27 14:08:17 -0800142 DEX_LOCATION="$tmp_dir"
Jeff Hao201803f2013-11-20 18:11:39 -0800143 runtime="jvm"
Brian Carlstrom01afdba2014-10-03 10:28:47 -0700144 prebuild_mode="no"
Andreas Gampe11410de2019-07-02 15:53:53 -0700145 run_args+=(--jvm)
jeffhao5d1ac922011-09-29 17:41:15 -0700146 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -0800147 elif [ "x$1" = "x-O" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700148 lib="libart.so"
Mathieu Chartier031768a2015-08-27 10:25:02 -0700149 testlib="arttest"
Andreas Gampe11410de2019-07-02 15:53:53 -0700150 run_args+=(-O)
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700151 shift
152 elif [ "x$1" = "x--dalvik" ]; then
153 lib="libdvm.so"
Jeff Hao201803f2013-11-20 18:11:39 -0800154 runtime="dalvik"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700155 shift
Alex Light03a112d2014-08-25 13:25:56 -0700156 elif [ "x$1" = "x--no-image" ]; then
157 have_image="no"
158 shift
Alex Lighta59dd802014-07-02 16:28:08 -0700159 elif [ "x$1" = "x--relocate" ]; then
160 relocate="yes"
161 shift
162 elif [ "x$1" = "x--no-relocate" ]; then
163 relocate="no"
164 shift
165 elif [ "x$1" = "x--prebuild" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700166 run_args+=(--prebuild)
Alex Lighta59dd802014-07-02 16:28:08 -0700167 prebuild_mode="yes"
168 shift;
Mathieu Chartierdcd56c92017-11-20 20:30:24 -0800169 elif [ "x$1" = "x--compact-dex-level" ]; then
170 option="$1"
171 shift
Andreas Gampe11410de2019-07-02 15:53:53 -0700172 run_args+=("$option" "$1")
Mathieu Chartierdcd56c92017-11-20 20:30:24 -0800173 shift;
Richard Uhler76f5cb62016-04-04 13:30:16 -0700174 elif [ "x$1" = "x--strip-dex" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700175 run_args+=(--strip-dex)
Richard Uhler76f5cb62016-04-04 13:30:16 -0700176 shift;
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000177 elif [ "x$1" = "x--debuggable" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700178 run_args+=(-Xcompiler-option --debuggable)
Nicolas Geoffraya3d90fb2015-03-16 13:55:40 +0000179 debuggable="yes"
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000180 shift;
Alex Lighta59dd802014-07-02 16:28:08 -0700181 elif [ "x$1" = "x--no-prebuild" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700182 run_args+=(--no-prebuild)
Alex Lighta59dd802014-07-02 16:28:08 -0700183 prebuild_mode="no"
184 shift;
Alex Lighte7873ec2014-08-12 09:53:50 -0700185 elif [ "x$1" = "x--gcverify" ]; then
186 basic_verify="true"
187 gc_verify="true"
188 shift
189 elif [ "x$1" = "x--gcstress" ]; then
190 basic_verify="true"
191 gc_stress="true"
192 shift
Alex Lightc38c3692017-06-27 15:45:14 -0700193 elif [ "x$1" = "x--jvmti-step-stress" ]; then
194 jvmti_step_stress="true"
195 shift
Alex Lightb7edcda2017-04-27 13:20:31 -0700196 elif [ "x$1" = "x--jvmti-redefine-stress" ]; then
197 jvmti_redefine_stress="true"
198 shift
Alex Light43e935d2017-06-19 15:40:40 -0700199 elif [ "x$1" = "x--jvmti-field-stress" ]; then
200 jvmti_field_stress="true"
201 shift
Alex Lightb7edcda2017-04-27 13:20:31 -0700202 elif [ "x$1" = "x--jvmti-trace-stress" ]; then
203 jvmti_trace_stress="true"
Alex Light8f2c6d42017-04-10 16:27:35 -0700204 shift
Mathieu Chartier3fceaf52017-01-22 13:33:40 -0800205 elif [ "x$1" = "x--suspend-timeout" ]; then
206 shift
207 suspend_timeout="$1"
208 shift
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700209 elif [ "x$1" = "x--image" ]; then
210 shift
211 image="$1"
Andreas Gampe11410de2019-07-02 15:53:53 -0700212 run_args+=(--image "$image")
Elliott Hughes7c046102011-10-19 18:16:03 -0700213 shift
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000214 elif [ "x$1" = "x-Xcompiler-option" ]; then
215 shift
216 option="$1"
Andreas Gampe11410de2019-07-02 15:53:53 -0700217 run_args+=(-Xcompiler-option "$option")
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000218 shift
Mathieu Chartier769a5ad2014-05-18 15:30:10 -0700219 elif [ "x$1" = "x--runtime-option" ]; then
220 shift
221 option="$1"
Andreas Gampe11410de2019-07-02 15:53:53 -0700222 run_args+=(--runtime-option "$option")
Mathieu Chartier769a5ad2014-05-18 15:30:10 -0700223 shift
Mathieu Chartierc0a8a802014-10-17 15:58:01 -0700224 elif [ "x$1" = "x--gdb-arg" ]; then
225 shift
226 gdb_arg="$1"
Andreas Gampe11410de2019-07-02 15:53:53 -0700227 run_args+=(--gdb-arg "$gdb_arg")
Mathieu Chartierc0a8a802014-10-17 15:58:01 -0700228 shift
Stelios Ioannou816b0da2021-06-03 13:25:50 +0100229 elif [ "x$1" = "x--gdb-dex2oat-args" ]; then
230 shift
231 gdb_dex2oat_args="$1"
232 run_args+=(--gdb-dex2oat-args "$gdb_dex2oat_args")
233 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700234 elif [ "x$1" = "x--debug" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700235 run_args+=(--debug)
jeffhao5d1ac922011-09-29 17:41:15 -0700236 shift
Alex Lightc281ba52017-10-11 11:35:55 -0700237 elif [ "x$1" = "x--debug-wrap-agent" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700238 run_args+=(--debug-wrap-agent)
Alex Lightc281ba52017-10-11 11:35:55 -0700239 shift
Alex Light0e151e72017-10-25 10:50:35 -0700240 elif [ "x$1" = "x--with-agent" ]; then
241 shift
242 option="$1"
Andreas Gampe11410de2019-07-02 15:53:53 -0700243 run_args+=(--with-agent "$1")
Alex Light0e151e72017-10-25 10:50:35 -0700244 shift
Alex Lightc281ba52017-10-11 11:35:55 -0700245 elif [ "x$1" = "x--debug-agent" ]; then
246 shift
247 option="$1"
Andreas Gampe11410de2019-07-02 15:53:53 -0700248 run_args+=(--debug-agent "$1")
Alex Lightc281ba52017-10-11 11:35:55 -0700249 shift
Stelios Ioannou1b621222021-06-17 14:15:45 +0100250 elif [ "x$1" = "x--dump-cfg" ]; then
251 shift
252 dump_cfg="true"
253 dump_cfg_path="$1"
254 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700255 elif [ "x$1" = "x--gdb" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700256 run_args+=(--gdb)
jeffhao5d1ac922011-09-29 17:41:15 -0700257 dev_mode="yes"
258 shift
Stelios Ioannou816b0da2021-06-03 13:25:50 +0100259 elif [ "x$1" = "x--gdb-dex2oat" ]; then
260 run_args+=(--gdb-dex2oat)
261 dev_mode="yes"
262 shift
Alex Lighte4b4a182019-02-12 14:19:49 -0800263 elif [ "x$1" = "x--gdbserver-bin" ]; then
264 shift
Andreas Gampe11410de2019-07-02 15:53:53 -0700265 run_args+=(--gdbserver-bin "$1")
Alex Lighte4b4a182019-02-12 14:19:49 -0800266 shift
267 elif [ "x$1" = "x--gdbserver-port" ]; then
268 shift
Andreas Gampe11410de2019-07-02 15:53:53 -0700269 run_args+=(--gdbserver-port "$1")
Alex Lighte4b4a182019-02-12 14:19:49 -0800270 shift
271 elif [ "x$1" = "x--gdbserver" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700272 run_args+=(--gdbserver)
Alex Lighte4b4a182019-02-12 14:19:49 -0800273 dev_mode="yes"
274 shift
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700275 elif [ "x$1" = "x--strace" ]; then
276 strace="yes"
Martin Stjernholm4815e722019-09-24 16:20:09 +0100277 run_args+=(--invoke-with strace --invoke-with -o --invoke-with "$tmp_dir/$strace_output")
278 timeout="${timeout:-1800}"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700279 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700280 elif [ "x$1" = "x--zygote" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700281 run_args+=(--zygote)
jeffhao5d1ac922011-09-29 17:41:15 -0700282 shift
jeffhao0dff3f42012-11-20 15:13:43 -0800283 elif [ "x$1" = "x--interpreter" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700284 run_args+=(--interpreter)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700285 shift
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800286 elif [ "x$1" = "x--jit" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700287 run_args+=(--jit)
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800288 shift
Nicolas Geoffrayacc56ac2018-10-09 08:45:24 +0100289 elif [ "x$1" = "x--baseline" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700290 run_args+=(--baseline)
Nicolas Geoffrayacc56ac2018-10-09 08:45:24 +0100291 shift
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700292 elif [ "x$1" = "x--optimizing" ]; then
Nicolas Geoffrayacc56ac2018-10-09 08:45:24 +0100293 run_optimizing="true"
jeffhao0dff3f42012-11-20 15:13:43 -0800294 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700295 elif [ "x$1" = "x--no-verify" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700296 run_args+=(--no-verify)
jeffhao5d1ac922011-09-29 17:41:15 -0700297 shift
Igor Murashkin7617abd2015-07-10 18:27:47 -0700298 elif [ "x$1" = "x--verify-soft-fail" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700299 run_args+=(--verify-soft-fail)
Igor Murashkin7617abd2015-07-10 18:27:47 -0700300 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700301 elif [ "x$1" = "x--no-optimize" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700302 run_args+=(--no-optimize)
jeffhao5d1ac922011-09-29 17:41:15 -0700303 shift
304 elif [ "x$1" = "x--no-precise" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700305 run_args+=(--no-precise)
jeffhao5d1ac922011-09-29 17:41:15 -0700306 shift
Orion Hodson9ca92fb2020-10-28 15:08:11 +0000307 elif [ "x$1" = "x--external-log-tags" ]; then
308 run_args+=(--external-log-tags)
309 shift
Elliott Hughes7c046102011-10-19 18:16:03 -0700310 elif [ "x$1" = "x--invoke-with" ]; then
311 shift
312 what="$1"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700313 if [ "x$what" = "x" ]; then
314 echo "$0 missing argument to --invoke-with" 1>&2
315 usage="yes"
316 break
317 fi
Andreas Gampe11410de2019-07-02 15:53:53 -0700318 run_args+=(--invoke-with "${what}")
jeffhao5d1ac922011-09-29 17:41:15 -0700319 shift
Alex Light8d94ddd2019-12-18 11:13:03 -0800320 elif [ "x$1" = "x--create-runner" ]; then
321 run_args+=(--create-runner --dry-run)
322 dev_mode="yes"
323 never_clean="yes"
324 create_runner="yes"
325 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700326 elif [ "x$1" = "x--dev" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700327 run_args+=(--dev)
jeffhao5d1ac922011-09-29 17:41:15 -0700328 dev_mode="yes"
329 shift
David Srbeckyca15b8d2021-04-23 12:25:08 +0100330 elif [ "x$1" = "x--temp-path" ]; then
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700331 shift
332 tmp_dir=$1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700333 if [ "x$tmp_dir" = "x" ]; then
David Srbeckyca15b8d2021-04-23 12:25:08 +0100334 echo "$0 missing argument to --temp-path" 1>&2
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700335 usage="yes"
336 break
337 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700338 shift
Roland Levillain76cfe612017-10-30 13:14:28 +0000339 elif [ "x$1" = "x--chroot" ]; then
340 shift
341 if [ "x$1" = "x" ]; then
342 echo "$0 missing argument to --chroot" 1>&2
343 usage="yes"
344 break
345 fi
346 chroot="$1"
Andreas Gampe11410de2019-07-02 15:53:53 -0700347 run_args+=(--chroot "$1")
Roland Levillain76cfe612017-10-30 13:14:28 +0000348 shift
Ulya Trafimovich7f7f6442021-11-05 15:26:13 +0000349 elif [ "x$1" = "x--simpleperf" ]; then
350 run_args+=(--simpleperf)
351 shift
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000352 elif [ "x$1" = "x--android-root" ]; then
353 shift
354 if [ "x$1" = "x" ]; then
355 echo "$0 missing argument to --android-root" 1>&2
356 usage="yes"
357 break
358 fi
359 android_root="$1"
Andreas Gampe11410de2019-07-02 15:53:53 -0700360 run_args+=(--android-root "$1")
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000361 shift
Martin Stjernholme58624f2019-09-20 15:53:40 +0100362 elif [ "x$1" = "x--android-art-root" ]; then
Roland Levillain28076142019-01-10 16:39:25 +0000363 shift
364 if [ "x$1" = "x" ]; then
Martin Stjernholme58624f2019-09-20 15:53:40 +0100365 echo "$0 missing argument to --android-art-root" 1>&2
Roland Levillain28076142019-01-10 16:39:25 +0000366 usage="yes"
367 break
368 fi
Martin Stjernholme58624f2019-09-20 15:53:40 +0100369 run_args+=(--android-art-root "$1")
Roland Levillain28076142019-01-10 16:39:25 +0000370 shift
Roland Levillain90b34572019-06-14 15:23:15 +0100371 elif [ "x$1" = "x--android-tzdata-root" ]; then
372 shift
373 if [ "x$1" = "x" ]; then
374 echo "$0 missing argument to --android-tzdata-root" 1>&2
375 usage="yes"
376 break
377 fi
Andreas Gampe11410de2019-07-02 15:53:53 -0700378 run_args+=(--android-tzdata-root "$1")
Roland Levillain90b34572019-06-14 15:23:15 +0100379 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700380 elif [ "x$1" = "x--update" ]; then
381 update_mode="yes"
382 shift
383 elif [ "x$1" = "x--help" ]; then
384 usage="yes"
385 shift
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700386 elif [ "x$1" = "x--64" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700387 run_args+=(--64)
Andreas Gampe2fe07922014-04-21 07:50:39 -0700388 suffix64="64"
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700389 shift
Alex Light680cbf22018-10-31 11:00:19 -0700390 elif [ "x$1" = "x--bionic" ]; then
391 # soong linux_bionic builds are 64bit only.
Andreas Gampe11410de2019-07-02 15:53:53 -0700392 run_args+=(--bionic --host --64)
Alex Light680cbf22018-10-31 11:00:19 -0700393 suffix64="64"
394 target_mode="no"
395 DEX_LOCATION=$tmp_dir
396 host_lib_root=$OUT_DIR/soong/host/linux_bionic-x86
397 shift
Alex Light6f342dd2019-03-27 17:15:42 +0000398 elif [ "x$1" = "x--runtime-extracted-zipapex" ]; then
399 shift
400 # TODO Should we allow the java.library.path to search the zipapex too?
401 # Not needed at the moment and adding it will be complicated so for now
402 # we'll ignore this.
Andreas Gampe11410de2019-07-02 15:53:53 -0700403 run_args+=(--host --runtime-extracted-zipapex "$1")
Alex Light6f342dd2019-03-27 17:15:42 +0000404 target_mode="no"
405 DEX_LOCATION=$tmp_dir
406 shift
Alex Light20802ca2018-12-05 15:36:03 -0800407 elif [ "x$1" = "x--runtime-zipapex" ]; then
408 shift
409 # TODO Should we allow the java.library.path to search the zipapex too?
410 # Not needed at the moment and adding it will be complicated so for now
411 # we'll ignore this.
Andreas Gampe11410de2019-07-02 15:53:53 -0700412 run_args+=(--host --runtime-zipapex "$1")
Alex Light20802ca2018-12-05 15:36:03 -0800413 target_mode="no"
414 DEX_LOCATION=$tmp_dir
415 # apex_payload.zip is quite large we need a high enough ulimit to
416 # extract it. 512mb should be good enough.
417 file_ulimit=512000
418 shift
Martin Stjernholm4815e722019-09-24 16:20:09 +0100419 elif [ "x$1" = "x--timeout" ]; then
420 shift
421 if [ "x$1" = "x" ]; then
422 echo "$0 missing argument to --timeout" 1>&2
423 usage="yes"
424 break
425 fi
426 timeout="$1"
427 shift
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200428 elif [ "x$1" = "x--trace" ]; then
Jeff Hao85139a32014-07-23 11:52:52 -0700429 trace="true"
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200430 shift
Andreas Gampe7526d782015-06-22 22:53:45 -0700431 elif [ "x$1" = "x--stream" ]; then
432 trace_stream="true"
433 shift
Alex Lightbfac14a2014-07-30 09:41:21 -0700434 elif [ "x$1" = "x--always-clean" ]; then
435 always_clean="yes"
436 shift
Igor Murashkin05f30e12015-06-10 15:57:17 -0700437 elif [ "x$1" = "x--never-clean" ]; then
438 never_clean="yes"
439 shift
Andreas Gampee21dc3d2014-12-08 16:59:43 -0800440 elif [ "x$1" = "x--dex2oat-swap" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700441 run_args+=(--dex2oat-swap)
Andreas Gampee21dc3d2014-12-08 16:59:43 -0800442 shift
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700443 elif [ "x$1" = "x--instruction-set-features" ]; then
444 shift
Andreas Gampe11410de2019-07-02 15:53:53 -0700445 run_args+=(--instruction-set-features "$1")
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700446 shift
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700447 elif [ "x$1" = "x--bisection-search" ]; then
448 bisection_search="yes"
449 shift
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000450 elif [ "x$1" = "x--vdex" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700451 run_args+=(--vdex)
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000452 shift
Nicolas Geoffraybaeaa9b2018-01-26 14:31:17 +0000453 elif [ "x$1" = "x--dm" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700454 run_args+=(--dm)
Nicolas Geoffraybaeaa9b2018-01-26 14:31:17 +0000455 shift
Nicolas Geoffray74981052017-01-16 17:54:09 +0000456 elif [ "x$1" = "x--vdex-filter" ]; then
457 shift
458 filter=$1
Andreas Gampe11410de2019-07-02 15:53:53 -0700459 run_args+=(--vdex-filter "$filter")
Nicolas Geoffray74981052017-01-16 17:54:09 +0000460 shift
Jeff Hao002b9312017-03-27 16:23:08 -0700461 elif [ "x$1" = "x--random-profile" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700462 run_args+=(--random-profile)
Jeff Hao002b9312017-03-27 16:23:08 -0700463 shift
Shubham Ajmera981d99c2017-08-17 14:11:08 -0700464 elif [ "x$1" = "x--dex2oat-jobs" ]; then
465 shift
Andreas Gampe11410de2019-07-02 15:53:53 -0700466 run_args+=(-Xcompiler-option "-j$1")
Shubham Ajmera981d99c2017-08-17 14:11:08 -0700467 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700468 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -0700469 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700470 usage="yes"
471 break
472 else
473 break
474 fi
475done
Andreas Gampe3a12cfe2014-08-13 15:40:22 -0700476
Orion Hodson6aa4e0d2018-05-25 09:39:16 +0100477if [ "$usage" = "no" -a "x$1" = "x" ]; then
478 echo "missing test to run" 1>&2
479 usage="yes"
480fi
481
Roland Levillain76cfe612017-10-30 13:14:28 +0000482# The DEX_LOCATION with the chroot prefix, if any.
483chroot_dex_location="$chroot$DEX_LOCATION"
484
Alex Light91de25f2015-10-28 17:00:06 -0700485# Allocate file descriptor real_stderr and redirect it to the shell's error
486# output (fd 2).
487if [ ${BASH_VERSINFO[1]} -ge 4 ] && [ ${BASH_VERSINFO[2]} -ge 1 ]; then
488 exec {real_stderr}>&2
489else
490 # In bash before version 4.1 we need to do a manual search for free file
491 # descriptors.
492 FD=3
493 while [ -e /dev/fd/$FD ]; do FD=$((FD + 1)); done
494 real_stderr=$FD
495 eval "exec ${real_stderr}>&2"
496fi
497if [ "$quiet" = "yes" ]; then
498 # Force the default standard output and error to go to /dev/null so we will
499 # not print them.
500 exec 1>/dev/null
501 exec 2>/dev/null
502fi
503
504function err_echo() {
505 echo "$@" 1>&${real_stderr}
506}
507
Andreas Gampe3a12cfe2014-08-13 15:40:22 -0700508# tmp_dir may be relative, resolve.
509#
510# Cannot use realpath, as it does not exist on Mac.
Roland Levillain76cfe612017-10-30 13:14:28 +0000511# Cannot use a simple "cd", as the path might not be created yet.
Brian Carlstromc580e042014-09-08 21:37:39 -0700512# Cannot use readlink -m, as it does not exist on Mac.
513# Fallback to nuclear option:
Andreas Gampe907b6992014-08-18 22:26:49 -0700514noncanonical_tmp_dir=$tmp_dir
Vladimir Markoefbc6592021-04-16 10:29:13 +0000515tmp_dir="`cd $oldwd ; python3 -c "import os; import sys; sys.stdout.write(os.path.realpath('$tmp_dir'))"`"
Andreas Gampe86459c02019-08-29 14:01:18 -0700516if [ -z $tmp_dir ] ; then
517 err_echo "Failed to resolve $tmp_dir"
518 exit 1
519fi
Dmitry Petrochenko81c56e72014-03-05 15:05:46 +0700520mkdir -p $tmp_dir
jeffhao5d1ac922011-09-29 17:41:15 -0700521
Mathieu Chartier3fceaf52017-01-22 13:33:40 -0800522# Add thread suspend timeout flag
Narayan Kamathf86c3932017-01-24 17:40:47 +0000523if [ ! "$runtime" = "jvm" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700524 run_args+=(--runtime-option "-XX:ThreadSuspendTimeout=$suspend_timeout")
Narayan Kamathf86c3932017-01-24 17:40:47 +0000525fi
Mathieu Chartier3fceaf52017-01-22 13:33:40 -0800526
Alex Lighte7873ec2014-08-12 09:53:50 -0700527if [ "$basic_verify" = "true" ]; then
Hiroshi Yamauchi312baf12015-01-12 12:11:05 -0800528 # Set HspaceCompactForOOMMinIntervalMs to zero to run hspace compaction for OOM more frequently in tests.
Andreas Gampe11410de2019-07-02 15:53:53 -0700529 run_args+=(--runtime-option -Xgc:preverify --runtime-option -Xgc:postverify --runtime-option -XX:HspaceCompactForOOMMinIntervalMs=0)
Alex Lighte7873ec2014-08-12 09:53:50 -0700530fi
531if [ "$gc_verify" = "true" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700532 run_args+=(--runtime-option -Xgc:preverify_rosalloc --runtime-option -Xgc:postverify_rosalloc)
Alex Lighte7873ec2014-08-12 09:53:50 -0700533fi
534if [ "$gc_stress" = "true" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700535 run_args+=(--gc-stress --runtime-option -Xgc:gcstress --runtime-option -Xms2m --runtime-option -Xmx16m)
Alex Lighte7873ec2014-08-12 09:53:50 -0700536fi
Alex Lightb7edcda2017-04-27 13:20:31 -0700537if [ "$jvmti_redefine_stress" = "true" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700538 run_args+=(--no-app-image --jvmti-redefine-stress)
Alex Lightb7edcda2017-04-27 13:20:31 -0700539fi
Alex Lightc38c3692017-06-27 15:45:14 -0700540if [ "$jvmti_step_stress" = "true" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700541 run_args+=(--no-app-image --jvmti-step-stress)
Alex Lightc38c3692017-06-27 15:45:14 -0700542fi
Alex Light43e935d2017-06-19 15:40:40 -0700543if [ "$jvmti_field_stress" = "true" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700544 run_args+=(--no-app-image --jvmti-field-stress)
Alex Light43e935d2017-06-19 15:40:40 -0700545fi
Alex Lightb7edcda2017-04-27 13:20:31 -0700546if [ "$jvmti_trace_stress" = "true" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700547 run_args+=(--no-app-image --jvmti-trace-stress)
Alex Light8f2c6d42017-04-10 16:27:35 -0700548fi
Jeff Hao85139a32014-07-23 11:52:52 -0700549if [ "$trace" = "true" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700550 run_args+=(--runtime-option -Xmethod-trace --runtime-option -Xmethod-trace-file-size:2000000)
Andreas Gampe7526d782015-06-22 22:53:45 -0700551 if [ "$trace_stream" = "true" ]; then
552 # Streaming mode uses the file size as the buffer size. So output gets really large. Drop
553 # the ability to analyze the file and just write to /dev/null.
Andreas Gampe11410de2019-07-02 15:53:53 -0700554 run_args+=(--runtime-option -Xmethod-trace-file:/dev/null)
Andreas Gampe7526d782015-06-22 22:53:45 -0700555 # Enable streaming mode.
Andreas Gampe11410de2019-07-02 15:53:53 -0700556 run_args+=(--runtime-option -Xmethod-trace-stream)
Andreas Gampe7526d782015-06-22 22:53:45 -0700557 else
Andreas Gampe11410de2019-07-02 15:53:53 -0700558 run_args+=(--runtime-option "-Xmethod-trace-file:${DEX_LOCATION}/trace.bin")
Andreas Gampe7526d782015-06-22 22:53:45 -0700559 fi
560elif [ "$trace_stream" = "true" ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700561 err_echo "Cannot use --stream without --trace."
Andreas Gampe7526d782015-06-22 22:53:45 -0700562 exit 1
Jeff Hao85139a32014-07-23 11:52:52 -0700563fi
Martin Stjernholm4815e722019-09-24 16:20:09 +0100564if [ -n "$timeout" ]; then
565 run_args+=(--timeout "$timeout")
566fi
Jeff Hao85139a32014-07-23 11:52:52 -0700567
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700568# Most interesting target architecture variables are Makefile variables, not environment variables.
Nicolas Geoffray93d68462018-01-02 11:59:45 +0000569# Try to map the suffix64 flag and what we find in ${ANDROID_PRODUCT_OUT}/data/art-test to an architecture name.
David Brazdil853a4c32015-09-28 16:15:50 +0100570function guess_target_arch_name() {
Andreas Gamped0566d42018-06-06 09:54:34 -0700571 # Check whether this is a device with native bridge. Currently this is hardcoded
572 # to x86 + arm.
Jiakai Zhang76c01df2022-02-18 13:11:10 +0000573 local guess_path=$chroot/system/framework/art_boot_images
574 local x86_arm=`adb shell ls ${guess_path} | sort | grep -E '^(arm|x86)$'`
Andreas Gamped0566d42018-06-06 09:54:34 -0700575 # Collapse line-breaks into spaces
576 x86_arm=$(echo $x86_arm)
577 if [ "x$x86_arm" = "xarm x86" ] ; then
578 err_echo "Native-bridge configuration detected."
579 # We only support the main arch for tests.
580 if [ "x${suffix64}" = "x64" ]; then
581 target_arch_name=""
582 else
583 target_arch_name=x86
584 fi
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700585 else
Jiakai Zhang76c01df2022-02-18 13:11:10 +0000586 local grep32bit=`adb shell ls ${guess_path} | grep -E '^(arm|x86)$'`
587 local grep64bit=`adb shell ls ${guess_path} | grep -E '^(arm64|x86_64)$'`
Andreas Gamped0566d42018-06-06 09:54:34 -0700588 if [ "x${suffix64}" = "x64" ]; then
589 target_arch_name=${grep64bit}
590 else
591 target_arch_name=${grep32bit}
592 fi
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700593 fi
594}
595
David Brazdil853a4c32015-09-28 16:15:50 +0100596function guess_host_arch_name() {
597 if [ "x${suffix64}" = "x64" ]; then
598 host_arch_name="x86_64"
599 else
600 host_arch_name="x86"
601 fi
602}
603
Alex Lighta59dd802014-07-02 16:28:08 -0700604if [ "$target_mode" = "no" ]; then
605 if [ "$runtime" = "jvm" ]; then
Alex Lighta59dd802014-07-02 16:28:08 -0700606 if [ "$prebuild_mode" = "yes" ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700607 err_echo "--prebuild with --jvm is unsupported"
Roland Levillain76cfe612017-10-30 13:14:28 +0000608 exit 1
609 fi
610 else
611 # ART/Dalvik host mode.
612 if [ -n "$chroot" ]; then
613 err_echo "--chroot with --host is unsupported"
614 exit 1
Alex Lighta59dd802014-07-02 16:28:08 -0700615 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700616 fi
617fi
618
Jeff Hao201803f2013-11-20 18:11:39 -0800619if [ ! "$runtime" = "jvm" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700620 run_args+=(--lib "$lib")
Jeff Hao201803f2013-11-20 18:11:39 -0800621fi
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700622
Jeff Hao201803f2013-11-20 18:11:39 -0800623if [ "$runtime" = "dalvik" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700624 if [ "$target_mode" = "no" ]; then
Nicolas Geoffray93d68462018-01-02 11:59:45 +0000625 framework="${ANDROID_PRODUCT_OUT}/system/framework"
Victor Chang759845f2019-08-06 16:04:36 +0100626 bpath="${framework}/core-icu4j.jar:${framework}/core-libart.jar:${framework}/core-oj.jar:${framework}/conscrypt.jar:${framework}/okhttp.jar:${framework}/bouncycastle.jar:${framework}/ext.jar"
Andreas Gampe11410de2019-07-02 15:53:53 -0700627 run_args+=(--boot --runtime-option "-Xbootclasspath:${bpath}")
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700628 else
629 true # defaults to using target BOOTCLASSPATH
630 fi
Jeff Hao201803f2013-11-20 18:11:39 -0800631elif [ "$runtime" = "art" ]; then
Ulya Trafimovich5439f052020-07-29 10:03:46 +0100632 if [ "$target_mode" = "no" ]; then
David Brazdil853a4c32015-09-28 16:15:50 +0100633 guess_host_arch_name
Martin Stjernholm9fde2db2020-10-15 16:03:29 +0100634 run_args+=(--boot "${ANDROID_HOST_OUT}/apex/art_boot_images/javalib/boot.art")
Andreas Gampe11410de2019-07-02 15:53:53 -0700635 run_args+=(--runtime-option "-Djava.library.path=${host_lib_root}/lib${suffix64}:${host_lib_root}/nativetest${suffix64}")
Jeff Hao201803f2013-11-20 18:11:39 -0800636 else
David Brazdil853a4c32015-09-28 16:15:50 +0100637 guess_target_arch_name
Martin Stjernholm0d0f8df2021-04-28 16:47:01 +0100638 # Note that libarttest(d).so and other test libraries that depend on ART
639 # internal libraries must not be in this path for JNI libraries - they
640 # need to be loaded through LD_LIBRARY_PATH and
641 # NATIVELOADER_DEFAULT_NAMESPACE_LIBS instead.
Andreas Gampe11410de2019-07-02 15:53:53 -0700642 run_args+=(--runtime-option "-Djava.library.path=/data/nativetest${suffix64}/art/${target_arch_name}")
Jiakai Zhang61c0d222022-02-16 10:28:38 +0000643 run_args+=(--boot "/system/framework/art_boot_images/boot.art")
Jeff Hao201803f2013-11-20 18:11:39 -0800644 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700645 if [ "$relocate" = "yes" ]; then
Andreas Gampe11410de2019-07-02 15:53:53 -0700646 run_args+=(--relocate)
Alex Lighta59dd802014-07-02 16:28:08 -0700647 else
Andreas Gampe11410de2019-07-02 15:53:53 -0700648 run_args+=(--no-relocate)
Alex Lighta59dd802014-07-02 16:28:08 -0700649 fi
Andreas Gampe3f1dc562015-05-18 15:52:22 -0700650elif [ "$runtime" = "jvm" ]; then
651 # TODO: Detect whether the host is 32-bit or 64-bit.
Andreas Gampe11410de2019-07-02 15:53:53 -0700652 run_args+=(--runtime-option "-Djava.library.path=${ANDROID_HOST_OUT}/lib64:${ANDROID_HOST_OUT}/nativetest64")
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700653fi
654
Alex Light03a112d2014-08-25 13:25:56 -0700655if [ "$have_image" = "no" ]; then
Alex Light1ef4ce82014-08-27 11:13:47 -0700656 if [ "$runtime" != "art" ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700657 err_echo "--no-image is only supported on the art runtime"
Alex Light1ef4ce82014-08-27 11:13:47 -0700658 exit 1
659 fi
Andreas Gampe11410de2019-07-02 15:53:53 -0700660 run_args+=(--no-image)
Alex Light03a112d2014-08-25 13:25:56 -0700661fi
662
Alex Light8d94ddd2019-12-18 11:13:03 -0800663if [ "$create_runner" = "yes" -a "$target_mode" = "yes" ]; then
664 err_echo "--create-runner does not function for non --host tests"
665 usage="yes"
666fi
667
jeffhao5d1ac922011-09-29 17:41:15 -0700668if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700669 err_echo "--dev and --update are mutually exclusive"
670 usage="yes"
671fi
672
673if [ "$dev_mode" = "yes" -a "$quiet" = "yes" ]; then
674 err_echo "--dev and --quiet are mutually exclusive"
jeffhao5d1ac922011-09-29 17:41:15 -0700675 usage="yes"
676fi
677
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700678if [ "$bisection_search" = "yes" -a "$prebuild_mode" = "yes" ]; then
679 err_echo "--bisection-search and --prebuild are mutually exclusive"
680 usage="yes"
681fi
682
Roland Levillain76cfe612017-10-30 13:14:28 +0000683# TODO: Chroot-based bisection search is not supported yet (see below); implement it.
684if [ "$bisection_search" = "yes" -a -n "$chroot" ]; then
685 err_echo "--chroot with --bisection-search is unsupported"
686 exit 1
687fi
688
jeffhao5d1ac922011-09-29 17:41:15 -0700689if [ "$usage" = "no" ]; then
690 if [ "x$1" = "x" -o "x$1" = "x-" ]; then
691 test_dir=`basename "$oldwd"`
692 else
693 test_dir="$1"
694 fi
695
696 if [ '!' -d "$test_dir" ]; then
697 td2=`echo ${test_dir}-*`
698 if [ '!' -d "$td2" ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700699 err_echo "${test_dir}: no such test directory"
jeffhao5d1ac922011-09-29 17:41:15 -0700700 usage="yes"
701 fi
702 test_dir="$td2"
703 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700704 # Shift to get rid of the test name argument. The rest of the arguments
705 # will get passed to the test run.
706 shift
707fi
708
709if [ "$usage" = "yes" ]; then
710 prog=`basename $prog`
711 (
712 echo "usage:"
713 echo " $prog --help Print this message."
714 echo " $prog [options] [test-name] Run test normally."
715 echo " $prog --dev [options] [test-name] Development mode" \
716 "(dumps to stdout)."
Alex Light8d94ddd2019-12-18 11:13:03 -0800717 echo " $prog --create-runner [options] [test-name]"
718 echo " Creates a runner script for use with other " \
719 "tools (e.g. parallel_run.py)."
720 echo " The script will only run the test portion, and " \
721 "share oat and dex files."
jeffhao5d1ac922011-09-29 17:41:15 -0700722 echo " $prog --update [options] [test-name] Update mode" \
Roland Levillainb15e8792020-10-28 12:20:59 +0000723 "(replaces expected-stdout.txt and expected-stderr.txt)."
jeffhao5d1ac922011-09-29 17:41:15 -0700724 echo ' Omitting the test name or specifying "-" will use the' \
725 "current directory."
726 echo " Runtime Options:"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000727 echo " -O Run non-debug rather than debug build (off by default)."
728 echo " -Xcompiler-option Pass an option to the compiler."
729 echo " --runtime-option Pass an option to the runtime."
Mathieu Chartierdcd56c92017-11-20 20:30:24 -0800730 echo " --compact-dex-level Specify a compact dex level to the compiler."
Alex Lightc281ba52017-10-11 11:35:55 -0700731 echo " --debug Wait for the default debugger to attach."
732 echo " --debug-agent <agent-path>"
733 echo " Wait for the given debugger agent to attach. Currently"
734 echo " only supported on host."
735 echo " --debug-wrap-agent use libwrapagentproperties and tools/libjdwp-compat.props"
736 echo " to load the debugger agent specified by --debug-agent."
Alex Light0e151e72017-10-25 10:50:35 -0700737 echo " --with-agent <agent> Run the test with the given agent loaded with -agentpath:"
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000738 echo " --debuggable Whether to compile Java code for a debugger."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000739 echo " --gdb Run under gdb; incompatible with some tests."
Stelios Ioannou816b0da2021-06-03 13:25:50 +0100740 echo " --gdb-dex2oat Run dex2oat under the prebuilt lldb."
Alex Lighte4b4a182019-02-12 14:19:49 -0800741 echo " --gdbserver Start gdbserver (defaults to port :5039)."
742 echo " --gdbserver-port <port>"
743 echo " Start gdbserver with the given COMM (see man gdbserver)."
744 echo " --gdbserver-bin <binary>"
745 echo " Use the given binary as gdbserver."
746 echo " --gdb-arg Pass an option to gdb or gdbserver."
Stelios Ioannou816b0da2021-06-03 13:25:50 +0100747 echo " --gdb-dex2oat-args Pass options separated by ';' to lldb for dex2oat."
Ulya Trafimovich6806d3c2021-11-09 17:33:51 +0000748 echo " --simpleperf Wraps the dalvikvm invocation in 'simpleperf record ..."
749 echo " ... simpleperf report' and dumps stats to stdout."
David Srbeckyca15b8d2021-04-23 12:25:08 +0100750 echo " --temp-path [path] Location where to execute the tests."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000751 echo " --interpreter Enable interpreter only mode (off by default)."
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800752 echo " --jit Enable jit (off by default)."
Nicolas Geoffray0e071252015-03-21 13:43:15 +0000753 echo " --optimizing Enable optimizing compiler (default)."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000754 echo " --no-verify Turn off verification (on by default)."
Igor Murashkin7617abd2015-07-10 18:27:47 -0700755 echo " --verify-soft-fail Force soft fail verification (off by default)."
756 echo " Verification is enabled if neither --no-verify"
757 echo " nor --verify-soft-fail is specified."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000758 echo " --no-optimize Turn off optimization (on by default)."
759 echo " --no-precise Turn off precise GC (on by default)."
760 echo " --zygote Spawn the process from the Zygote." \
jeffhao5d1ac922011-09-29 17:41:15 -0700761 "If used, then the"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000762 echo " other runtime options are ignored."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000763 echo " --prebuild Run dex2oat on the files before starting test. (default)"
764 echo " --no-prebuild Do not run dex2oat on the files before starting"
765 echo " the test."
Richard Uhler76f5cb62016-04-04 13:30:16 -0700766 echo " --strip-dex Strip the dex files before starting test."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000767 echo " --relocate Force the use of relocating in the test, making"
768 echo " the image and oat files be relocated to a random"
Nicolas Geoffray94e25db2017-01-27 14:54:28 +0000769 echo " address before running."
770 echo " --no-relocate Force the use of no relocating in the test. (default)"
Alex Lightfadfee92015-10-28 09:40:10 -0700771 echo " --image Run the test using a precompiled boot image. (default)"
772 echo " --no-image Run the test without a precompiled boot image."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000773 echo " --host Use the host-mode virtual machine."
774 echo " --invoke-with Pass --invoke-with option to runtime."
775 echo " --dalvik Use Dalvik (off by default)."
776 echo " --jvm Use a host-local RI virtual machine."
Alex Lighteb7c1442015-08-31 13:17:42 -0700777 echo " --use-java-home Use the JAVA_HOME environment variable"
778 echo " to find the java compiler and runtime"
779 echo " (if applicable) to run the test with."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000780 echo " --64 Run the test in 64-bit mode"
Alex Light680cbf22018-10-31 11:00:19 -0700781 echo " --bionic Use the (host, 64-bit only) linux_bionic libc runtime"
Alex Light20802ca2018-12-05 15:36:03 -0800782 echo " --runtime-zipapex [file]"
783 echo " Use the given zipapex file to provide runtime binaries"
Alex Light6f342dd2019-03-27 17:15:42 +0000784 echo " --runtime-extracted-zipapex [dir]"
785 echo " Use the given extracted zipapex directory to provide"
786 echo " runtime binaries"
Martin Stjernholm4815e722019-09-24 16:20:09 +0100787 echo " --timeout n Test timeout in seconds"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000788 echo " --trace Run with method tracing"
Alex Lightfadfee92015-10-28 09:40:10 -0700789 echo " --strace Run with syscall tracing from strace."
Andreas Gampe7526d782015-06-22 22:53:45 -0700790 echo " --stream Run method tracing in streaming mode (requires --trace)"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000791 echo " --gcstress Run with gc stress testing"
792 echo " --gcverify Run with gc verification"
Alex Lightb7edcda2017-04-27 13:20:31 -0700793 echo " --jvmti-trace-stress Run with jvmti method tracing stress testing"
Alex Lightc38c3692017-06-27 15:45:14 -0700794 echo " --jvmti-step-stress Run with jvmti single step stress testing"
Alex Lightb7edcda2017-04-27 13:20:31 -0700795 echo " --jvmti-redefine-stress"
796 echo " Run with jvmti method redefinition stress testing"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000797 echo " --always-clean Delete the test files even if the test fails."
Igor Murashkin05f30e12015-06-10 15:57:17 -0700798 echo " --never-clean Keep the test files even if the test succeeds."
Roland Levillain76cfe612017-10-30 13:14:28 +0000799 echo " --chroot [newroot] Run with root directory set to newroot."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000800 echo " --android-root [path] The path on target for the android root. (/system by default)."
Victor Chang64611242019-07-05 16:32:41 +0100801 echo " --android-i18n-root [path]"
802 echo " The path on target for the i18n module root."
803 echo " (/apex/com.android.i18n by default)."
Martin Stjernholme58624f2019-09-20 15:53:40 +0100804 echo " --android-art-root [path]"
805 echo " The path on target for the ART module root."
Martin Stjernholmd6be5da2019-07-16 17:14:46 +0100806 echo " (/apex/com.android.art by default)."
Roland Levillain90b34572019-06-14 15:23:15 +0100807 echo " --android-tzdata-root [path]"
808 echo " The path on target for the Android Time Zone Data root."
809 echo " (/apex/com.android.tzdata by default)."
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000810 echo " --dex2oat-swap Use a dex2oat swap file."
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700811 echo " --instruction-set-features [string]"
812 echo " Set instruction-set-features for compilation."
Alex Light91de25f2015-10-28 17:00:06 -0700813 echo " --quiet Don't print anything except failure messages"
Orion Hodson9ca92fb2020-10-28 15:08:11 +0000814 echo " --external-log-tags Use ANDROID_LOG_TAGS to set a custom logging level for"
815 echo " a test run."
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -0700816 echo " --bisection-search Perform bisection bug search."
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +0000817 echo " --vdex Test using vdex as in input to dex2oat. Only works with --prebuild."
Mathieu Chartier3fceaf52017-01-22 13:33:40 -0800818 echo " --suspend-timeout Change thread suspend timeout ms (default 500000)."
Shubham Ajmera981d99c2017-08-17 14:11:08 -0700819 echo " --dex2oat-jobs Number of dex2oat jobs."
Alex Light91de25f2015-10-28 17:00:06 -0700820 ) 1>&2 # Direct to stderr so usage is not printed if --quiet is set.
jeffhao5d1ac922011-09-29 17:41:15 -0700821 exit 1
822fi
823
824cd "$test_dir"
825test_dir=`pwd`
826
827td_info="${test_dir}/${info}"
Roland Levillainb15e8792020-10-28 12:20:59 +0000828td_expected_stdout="${test_dir}/${expected_stdout}"
829td_expected_stderr="${test_dir}/${expected_stderr}"
jeffhao5d1ac922011-09-29 17:41:15 -0700830
Roland Levillainb15e8792020-10-28 12:20:59 +0000831for td_file in "$td_info" "$td_expected_stdout" "$td_expected_stderr"; do
832 if [ ! -r "$td_file" ]; then
833 err_echo "${test_dir}: missing file $td_file"
834 exit 1
835 fi
836done
jeffhao5d1ac922011-09-29 17:41:15 -0700837
Elliott Hughes8cbc8bc2011-10-04 11:19:45 -0700838export TEST_NAME=`basename ${test_dir}`
839
Nicolas Geoffray1949baf2017-10-17 12:14:53 +0000840# Tests named '<number>-checker-*' will also have their CFGs verified with
841# Checker when compiled with Optimizing on host.
Stelios Ioannou1b621222021-06-17 14:15:45 +0100842# Additionally, if the user specifies that the CFG must be dumped, it will
843# run the checker for any type of test to generate the CFG.
844if [[ "$TEST_NAME" =~ ^[0-9]+-checker- ]] || [ "$dump_cfg" = "true" ]; then
Nicolas Geoffray8c41a0b2020-02-06 16:52:11 +0000845 if [ "$runtime" = "art" -a "$run_optimizing" = "true" ]; then
Nicolas Geoffray1949baf2017-10-17 12:14:53 +0000846 # In no-prebuild or no-image mode, the compiler only quickens so disable the checker.
Nicolas Geoffray48eb8392022-02-24 16:20:18 +0000847 if [ "$prebuild_mode" = "yes" ]; then
Nicolas Geoffray1949baf2017-10-17 12:14:53 +0000848 run_checker="yes"
849
Ulya Trafimovich5439f052020-07-29 10:03:46 +0100850 if [ "$target_mode" = "no" ]; then
Nicolas Geoffray1949baf2017-10-17 12:14:53 +0000851 cfg_output_dir="$tmp_dir"
852 checker_args="--arch=${host_arch_name^^}"
853 else
854 cfg_output_dir="$DEX_LOCATION"
855 checker_args="--arch=${target_arch_name^^}"
856 fi
857
858 if [ "$debuggable" = "yes" ]; then
859 checker_args="$checker_args --debuggable"
860 fi
861
Andreas Gampe11410de2019-07-02 15:53:53 -0700862 run_args+=(-Xcompiler-option "--dump-cfg=$cfg_output_dir/$cfg_output" -Xcompiler-option -j1)
Daniil Riazanovskiybfe8fc82020-10-05 15:07:15 +0000863 checker_args="$checker_args --print-cfg"
Nicolas Geoffray1949baf2017-10-17 12:14:53 +0000864 fi
865 fi
866fi
867
Andreas Gampe11410de2019-07-02 15:53:53 -0700868run_args+=(--testlib "${testlib}")
Mathieu Chartier031768a2015-08-27 10:25:02 -0700869
Alex Light20802ca2018-12-05 15:36:03 -0800870if ! ulimit -f ${file_ulimit}; then
Richard Uhler020c0f32017-03-14 16:23:17 +0000871 err_echo "ulimit file size setting failed"
Ian Rogers997f0f92014-06-21 22:58:05 -0700872fi
873
David Srbecky7cf6c582021-07-20 16:56:06 +0100874# Extract run-test data from the zip file.
David Srbeckyca15b8d2021-04-23 12:25:08 +0100875rm -rf "$tmp_dir"
David Srbecky7cf6c582021-07-20 16:56:06 +0100876mkdir -p "$tmp_dir/.unzipped"
David Srbeckyca15b8d2021-04-23 12:25:08 +0100877cd "$tmp_dir"
David Srbecky7cf6c582021-07-20 16:56:06 +0100878if [[ "$target_mode" == "yes" ]]; then
879 zip_file="${ANDROID_HOST_OUT}/etc/art/art-run-test-target-data.zip"
880 zip_entry="target/${TEST_NAME}"
881elif [[ $runtime == "jvm" ]]; then
882 zip_file="${ANDROID_HOST_OUT}/etc/art/art-run-test-jvm-data.zip"
883 zip_entry="jvm/${TEST_NAME}"
884else
885 zip_file="${ANDROID_HOST_OUT}/etc/art/art-run-test-host-data.zip"
886 zip_entry="host/${TEST_NAME}"
887fi
888unzip -q "${zip_file}" "${zip_entry}/*" -d "$tmp_dir/.unzipped"
889mv "$tmp_dir"/.unzipped/${zip_entry}/* "$tmp_dir"
David Srbeckyca15b8d2021-04-23 12:25:08 +0100890
jeffhao5d1ac922011-09-29 17:41:15 -0700891good="no"
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000892good_run="yes"
Alex Light77fee872017-09-05 14:51:49 -0700893export TEST_RUNTIME="${runtime}"
jeffhao5d1ac922011-09-29 17:41:15 -0700894if [ "$dev_mode" = "yes" ]; then
David Srbecky7cf6c582021-07-20 16:56:06 +0100895 echo "${test_dir}: running..." 1>&2
896 "./${run}" "${run_args[@]}" "$@"
897 run_exit="$?"
Calin Juravle3cf48772015-01-26 16:47:33 +0000898
David Srbecky7cf6c582021-07-20 16:56:06 +0100899 if [ "$run_exit" = "0" ]; then
David Brazdil4846d132015-01-15 19:07:08 +0000900 if [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100901 if [ "$target_mode" = "yes" ]; then
Roland Levillain76cfe612017-10-30 13:14:28 +0000902 adb pull "$chroot/$cfg_output_dir/$cfg_output" &> /dev/null
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100903 fi
David Srbecky7cf6c582021-07-20 16:56:06 +0100904 "$checker" $checker_args "$cfg_output" "$tmp_dir" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000905 checker_exit="$?"
David Srbecky7cf6c582021-07-20 16:56:06 +0100906 if [ "$checker_exit" = "0" ]; then
907 good="yes"
David Brazdil4846d132015-01-15 19:07:08 +0000908 fi
David Srbecky7cf6c582021-07-20 16:56:06 +0100909 err_echo "checker exit status: $checker_exit"
910 else
911 good="yes"
912 fi
913 fi
914 echo "run exit status: $run_exit" 1>&2
915elif [ "$update_mode" = "yes" ]; then
916 echo "${test_dir}: running..." 1>&2
917 "./${run}" "${run_args[@]}" "$@" >"$test_stdout" 2>"$test_stderr"
918 if [ "$run_checker" = "yes" ]; then
919 if [ "$target_mode" = "yes" ]; then
920 adb pull "$chroot/$cfg_output_dir/$cfg_output" &> /dev/null
921 fi
922 "$checker" -q $checker_args "$cfg_output" "$tmp_dir" >>"$test_stdout" 2>>"$test_stderr"
923 fi
924 sed -e 's/[[:cntrl:]]$//g' <"$test_stdout" >"${td_expected_stdout}"
925 sed -e 's/[[:cntrl:]]$//g' <"$test_stderr" >"${td_expected_stderr}"
926 good="yes"
927else
928 echo "${test_dir}: running..." 1>&2
929 "./${run}" "${run_args[@]}" "$@" >"$test_stdout" 2>"$test_stderr"
930 run_exit="$?"
931 if [ "$run_exit" != "0" ]; then
932 err_echo "run exit status: $run_exit"
933 good_run="no"
934 elif [ "$run_checker" = "yes" ]; then
935 if [ "$target_mode" = "yes" ]; then
936 adb pull "$chroot/$cfg_output_dir/$cfg_output" &> /dev/null
937 fi
938 "$checker" -q $checker_args "$cfg_output" "$tmp_dir" >>"$test_stdout" 2>>"$test_stderr"
939 checker_exit="$?"
940 if [ "$checker_exit" != "0" ]; then
941 err_echo "checker exit status: $checker_exit"
942 good_run="no"
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000943 else
944 good_run="yes"
945 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700946 else
David Srbecky7cf6c582021-07-20 16:56:06 +0100947 good_run="yes"
jeffhao5d1ac922011-09-29 17:41:15 -0700948 fi
Roland Levillainb15e8792020-10-28 12:20:59 +0000949 ./$check_cmd "$expected_stdout" "$test_stdout" "$expected_stderr" "$test_stderr"
jeffhao5d1ac922011-09-29 17:41:15 -0700950 if [ "$?" = "0" ]; then
David Srbecky7cf6c582021-07-20 16:56:06 +0100951 if [ "$good_run" = "yes" ]; then
Roland Levillainb15e8792020-10-28 12:20:59 +0000952 # test_stdout == expected_stdout && test_stderr == expected_stderr
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000953 good="yes"
954 echo "${test_dir}: succeeded!" 1>&2
955 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700956 fi
957fi
958
jeffhao5d1ac922011-09-29 17:41:15 -0700959(
Alex Lightbfac14a2014-07-30 09:41:21 -0700960 if [ "$good" != "yes" -a "$update_mode" != "yes" ]; then
jeffhao5d1ac922011-09-29 17:41:15 -0700961 echo "${test_dir}: FAILED!"
962 echo ' '
963 echo '#################### info'
964 cat "${td_info}" | sed 's/^/# /g'
Roland Levillainb15e8792020-10-28 12:20:59 +0000965 echo '#################### stdout diffs'
Nicolas Geoffray30a11eb2020-01-28 16:04:01 +0000966 if [ "$run_checker" == "yes" ]; then
967 # Checker failures dump the whole CFG, so we output the whole diff.
Roland Levillainb15e8792020-10-28 12:20:59 +0000968 diff --strip-trailing-cr -u "$expected_stdout" "$test_stdout"
Nicolas Geoffray30a11eb2020-01-28 16:04:01 +0000969 else
Roland Levillainb15e8792020-10-28 12:20:59 +0000970 diff --strip-trailing-cr -u "$expected_stdout" "$test_stdout" | tail -n 10000
Nicolas Geoffray30a11eb2020-01-28 16:04:01 +0000971 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700972 echo '####################'
Roland Levillainb15e8792020-10-28 12:20:59 +0000973 echo '#################### stderr diffs'
974 diff --strip-trailing-cr -u "$expected_stderr" "$test_stderr" | tail -n 10000
975 echo '####################'
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700976 if [ "$strace" = "yes" ]; then
977 echo '#################### strace output'
Hiroshi Yamauchid630fd62015-09-04 12:52:03 -0700978 tail -n 3000 "$tmp_dir/$strace_output"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700979 echo '####################'
980 fi
Andreas Gampee79ca192017-07-31 10:30:16 -0700981 if [ "x$target_mode" = "xno" -a "x$SANITIZE_HOST" = "xaddress" ]; then
982 # Run the stack script to symbolize any ASAN aborts on the host for SANITIZE_HOST. The
983 # tools used by the given ABI work for both x86 and x86-64.
Roland Levillainb15e8792020-10-28 12:20:59 +0000984 echo "ABI: 'x86_64'" | cat - "$test_stdout" "$test_stderr" \
985 | $ANDROID_BUILD_TOP/development/scripts/stack | tail -n 3000
Andreas Gampee79ca192017-07-31 10:30:16 -0700986 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700987 echo ' '
988 fi
Alex Lightbfac14a2014-07-30 09:41:21 -0700989
Alex Light91de25f2015-10-28 17:00:06 -0700990) 2>&${real_stderr} 1>&2
Alex Lightbfac14a2014-07-30 09:41:21 -0700991
Stelios Ioannou1b621222021-06-17 14:15:45 +0100992# Copy the generated CFG to the specified path.
993if [ $dump_cfg = "true" ]; then
994 if [ $run_optimizing != "true" ]; then
995 err_echo "Can't dump the .cfg if the compiler type isn't set to \"optimizing\"."
996 else
997 if [ "$target_mode" = "yes" ]; then
998 adb pull $chroot/$cfg_output_dir/$cfg_output $dump_cfg_path
999 else
1000 cp $cfg_output_dir/$cfg_output $dump_cfg_path
1001 fi
1002 fi
1003fi
1004
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -07001005# Attempt bisection only if the test failed.
Roland Levillain76cfe612017-10-30 13:14:28 +00001006# TODO: Implement support for chroot-based bisection search.
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -07001007if [ "$bisection_search" = "yes" -a "$good" != "yes" ]; then
1008 # Bisecting works by skipping different optimization passes which breaks checker assertions.
1009 if [ "$run_checker" == "yes" ]; then
1010 echo "${test_dir}: not bisecting, checker test." 1>&2
1011 else
1012 # Increase file size limit, bisection search can generate large logfiles.
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -07001013 echo "${test_dir}: bisecting..." 1>&2
1014 cwd=`pwd`
1015 maybe_device_mode=""
1016 raw_cmd=""
1017 if [ "$target_mode" = "yes" ]; then
Roland Levillain76cfe612017-10-30 13:14:28 +00001018 # Produce cmdline.sh in $chroot_dex_location. "$@" is passed as a runtime option
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -07001019 # so that cmdline.sh forwards its arguments to dalvikvm. invoke-with is set
1020 # to exec in order to preserve pid when calling dalvikvm. This is required
1021 # for bisection search to correctly retrieve logs from device.
Andreas Gampe11410de2019-07-02 15:53:53 -07001022 "./${run}" "${run_args[@]}" --runtime-option '"$@"' --invoke-with exec --dry-run "$@" &> /dev/null
Roland Levillain76cfe612017-10-30 13:14:28 +00001023 adb shell chmod u+x "$chroot_dex_location/cmdline.sh"
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -07001024 maybe_device_mode="--device"
1025 raw_cmd="$DEX_LOCATION/cmdline.sh"
1026 else
Andreas Gampe11410de2019-07-02 15:53:53 -07001027 raw_cmd="$cwd/${run} --external-log-tags "${run_args[@]}" $@"
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -07001028 fi
Roland Levillain76cfe612017-10-30 13:14:28 +00001029 # TODO: Pass a `--chroot` option to the bisection_search.py script and use it there.
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -07001030 $ANDROID_BUILD_TOP/art/tools/bisection_search/bisection_search.py \
1031 $maybe_device_mode \
1032 --raw-cmd="$raw_cmd" \
1033 --check-script="$cwd/check" \
Roland Levillaina073f462020-10-28 12:48:24 +00001034 --expected-output="$cwd/expected-stdout.txt" \
Wojciech Staszkiewicz0c883832016-09-26 17:51:52 -07001035 --logfile="$cwd/bisection_log.txt" \
Martin Stjernholm4815e722019-09-24 16:20:09 +01001036 --timeout=${timeout:-300}
Wojciech Staszkiewiczd7a819a2016-09-01 14:43:39 -07001037 fi
1038fi
1039
Alex Lightbfac14a2014-07-30 09:41:21 -07001040# Clean up test files.
Igor Murashkin05f30e12015-06-10 15:57:17 -07001041if [ "$always_clean" = "yes" -o "$good" = "yes" ] && [ "$never_clean" = "no" ]; then
Alex Lightbfac14a2014-07-30 09:41:21 -07001042 cd "$oldwd"
1043 rm -rf "$tmp_dir"
1044 if [ "$target_mode" = "yes" -a "$build_exit" = "0" ]; then
Roland Levillain76cfe612017-10-30 13:14:28 +00001045 adb shell rm -rf $chroot_dex_location
Alex Lightbfac14a2014-07-30 09:41:21 -07001046 fi
1047 if [ "$good" = "yes" ]; then
1048 exit 0
1049 fi
1050fi
1051
1052
1053(
1054 if [ "$always_clean" = "yes" ]; then
1055 echo "${TEST_NAME} files deleted from host "
1056 if [ "$target_mode" == "yes" ]; then
1057 echo "and from target"
1058 fi
1059 else
1060 echo "${TEST_NAME} files left in ${tmp_dir} on host"
1061 if [ "$target_mode" == "yes" ]; then
Roland Levillain76cfe612017-10-30 13:14:28 +00001062 echo "and in ${chroot_dex_location} on target"
Alex Lightbfac14a2014-07-30 09:41:21 -07001063 fi
Brian Carlstrom105215d2012-06-14 12:50:44 -07001064 fi
1065
Alex Light91de25f2015-10-28 17:00:06 -07001066) 2>&${real_stderr} 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -07001067
Alex Light6a870fa2016-05-31 16:36:19 -07001068if [ "$never_clean" = "yes" ] && [ "$good" = "yes" ]; then
1069 exit 0
1070else
1071 exit 1
1072fi