blob: 424c54f2c9061cec6e4229a44ff2613585510654 [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
40 tmp_dir="${TMPDIR}/$USER/${test_dir}"
41fi
David Brazdil2c27f2c2015-05-12 18:06:38 +010042checker="${progdir}/../tools/checker/checker.py"
jeffhao5d1ac922011-09-29 17:41:15 -070043export JAVA="java"
Vladimir Markof45c3f82015-12-15 16:36:24 +000044export JAVAC="javac -g -source 1.7 -target 1.7 -Xlint:-options"
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}
Elliott Hughesc717eef2012-06-15 16:01:26 -070047export NEED_DEX="true"
Nicolas Geoffray1c5b6da2016-03-16 10:55:57 +000048export USE_JACK="true"
Alex Lightb55f1ac2016-04-12 15:50:55 -070049export SMALI_ARGS="--experimental"
jeffhao5d1ac922011-09-29 17:41:15 -070050
Tsu Chiang Chuang4407e612012-07-19 16:13:43 -070051# If dx was not set by the environment variable, assume it is in the path.
52if [ -z "$DX" ]; then
53 export DX="dx"
54fi
55
Tsu Chiang Chuang6674f8a2013-01-16 15:41:21 -080056# If jasmin was not set by the environment variable, assume it is in the path.
57if [ -z "$JASMIN" ]; then
58 export JASMIN="jasmin"
59fi
60
Andreas Gampe8fda9f22014-10-03 16:15:37 -070061# If smali was not set by the environment variable, assume it is in the path.
62if [ -z "$SMALI" ]; then
63 export SMALI="smali"
64fi
65
66# If dexmerger was not set by the environment variable, assume it is in the path.
67if [ -z "$DXMERGER" ]; then
68 export DXMERGER="dexmerger"
69fi
70
Sebastien Hertz19ac0272015-02-24 17:39:50 +010071# If jack was not set by the environment variable, assume it is in the path.
72if [ -z "$JACK" ]; then
73 export JACK="jack"
74fi
75
Sebastien Hertz19ac0272015-02-24 17:39:50 +010076# ANDROID_BUILD_TOP is not set in a build environment.
77if [ -z "$ANDROID_BUILD_TOP" ]; then
78 export ANDROID_BUILD_TOP=$oldwd
79fi
80
Sebastien Hertz19ac0272015-02-24 17:39:50 +010081# If JACK_CLASSPATH is not set, assume it only contains core-libart.
82if [ -z "$JACK_CLASSPATH" ]; then
Przemyslaw Szczepaniak121b25e2015-11-20 11:24:33 +000083 export JACK_CLASSPATH="${OUT_DIR:-$ANDROID_BUILD_TOP/out}/host/common/obj/JAVA_LIBRARIES/core-libart-hostdex_intermediates/classes.jack:${OUT_DIR:-$ANDROID_BUILD_TOP/out}/host/common/obj/JAVA_LIBRARIES/core-oj-hostdex_intermediates/classes.jack"
Sebastien Hertz19ac0272015-02-24 17:39:50 +010084fi
85
Sebastien Hertz19ac0272015-02-24 17:39:50 +010086export JACK="$JACK -g -cp $JACK_CLASSPATH"
Tsu Chiang Chuang6674f8a2013-01-16 15:41:21 -080087
jeffhao5d1ac922011-09-29 17:41:15 -070088info="info.txt"
89build="build"
90run="run"
91expected="expected.txt"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -070092check_cmd="check"
jeffhao5d1ac922011-09-29 17:41:15 -070093output="output.txt"
94build_output="build-output.txt"
David Brazdil24128c62015-05-21 12:06:13 +010095cfg_output="graph.cfg"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -070096strace_output="strace-output.txt"
Brian Carlstromdc959ea2013-10-28 00:44:49 -070097lib="libartd.so"
Mathieu Chartier031768a2015-08-27 10:25:02 -070098testlib="arttestd"
jeffhao5d1ac922011-09-29 17:41:15 -070099run_args="--quiet"
David Brazdil4846d132015-01-15 19:07:08 +0000100build_args=""
jeffhao5d1ac922011-09-29 17:41:15 -0700101
Alex Light91de25f2015-10-28 17:00:06 -0700102quiet="no"
Nicolas Geoffraya3d90fb2015-03-16 13:55:40 +0000103debuggable="no"
Alex Light9d722532014-07-22 18:07:12 -0700104prebuild_mode="yes"
Brian Carlstrom2613de42012-06-15 17:37:16 -0700105target_mode="yes"
jeffhao5d1ac922011-09-29 17:41:15 -0700106dev_mode="no"
107update_mode="no"
Alex Lighta59dd802014-07-02 16:28:08 -0700108debug_mode="no"
109relocate="yes"
Jeff Hao201803f2013-11-20 18:11:39 -0800110runtime="art"
jeffhao5d1ac922011-09-29 17:41:15 -0700111usage="no"
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700112build_only="no"
Andreas Gampe2fe07922014-04-21 07:50:39 -0700113suffix64=""
Jeff Hao85139a32014-07-23 11:52:52 -0700114trace="false"
Andreas Gampe7526d782015-06-22 22:53:45 -0700115trace_stream="false"
Alex Lighte7873ec2014-08-12 09:53:50 -0700116basic_verify="false"
117gc_verify="false"
118gc_stress="false"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700119strace="false"
Alex Lightbfac14a2014-07-30 09:41:21 -0700120always_clean="no"
Igor Murashkin05f30e12015-06-10 15:57:17 -0700121never_clean="no"
Alex Light03a112d2014-08-25 13:25:56 -0700122have_dex2oat="yes"
123have_patchoat="yes"
124have_image="yes"
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700125image_suffix=""
Andreas Gampec23c9c92014-10-28 14:47:25 -0700126pic_image_suffix=""
Jeff Haodcdc85b2015-12-04 14:06:18 -0800127multi_image_suffix=""
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000128android_root="/system"
jeffhao5d1ac922011-09-29 17:41:15 -0700129
130while true; do
131 if [ "x$1" = "x--host" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -0700132 target_mode="no"
TDYa127b92bcab2012-04-08 00:09:51 -0700133 DEX_LOCATION=$tmp_dir
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100134 run_args="${run_args} --host"
jeffhao5d1ac922011-09-29 17:41:15 -0700135 shift
Alex Light91de25f2015-10-28 17:00:06 -0700136 elif [ "x$1" = "x--quiet" ]; then
137 quiet="yes"
138 shift
Alex Lighteb7c1442015-08-31 13:17:42 -0700139 elif [ "x$1" = "x--use-java-home" ]; then
140 if [ -n "${JAVA_HOME}" ]; then
141 export JAVA="${JAVA_HOME}/bin/java"
142 export JAVAC="${JAVA_HOME}/bin/javac -g"
143 else
144 echo "Passed --use-java-home without JAVA_HOME variable set!"
145 usage="yes"
146 fi
147 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -0800148 elif [ "x$1" = "x--jvm" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -0700149 target_mode="no"
Jeff Hao201803f2013-11-20 18:11:39 -0800150 runtime="jvm"
Brian Carlstrom01afdba2014-10-03 10:28:47 -0700151 prebuild_mode="no"
Elliott Hughesc717eef2012-06-15 16:01:26 -0700152 NEED_DEX="false"
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100153 USE_JACK="false"
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100154 run_args="${run_args} --jvm"
Alex Lighteb7c1442015-08-31 13:17:42 -0700155 build_args="${build_args} --jvm"
jeffhao5d1ac922011-09-29 17:41:15 -0700156 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -0800157 elif [ "x$1" = "x-O" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700158 lib="libart.so"
Mathieu Chartier031768a2015-08-27 10:25:02 -0700159 testlib="arttest"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700160 shift
161 elif [ "x$1" = "x--dalvik" ]; then
162 lib="libdvm.so"
Jeff Hao201803f2013-11-20 18:11:39 -0800163 runtime="dalvik"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700164 shift
Alex Light03a112d2014-08-25 13:25:56 -0700165 elif [ "x$1" = "x--no-dex2oat" ]; then
166 have_dex2oat="no"
167 shift
168 elif [ "x$1" = "x--no-patchoat" ]; then
169 have_patchoat="no"
170 shift
171 elif [ "x$1" = "x--no-image" ]; then
172 have_image="no"
173 shift
Andreas Gampec23c9c92014-10-28 14:47:25 -0700174 elif [ "x$1" = "x--pic-image" ]; then
175 pic_image_suffix="-pic"
176 shift
Jeff Haodcdc85b2015-12-04 14:06:18 -0800177 elif [ "x$1" = "x--multi-image" ]; then
178 multi_image_suffix="-multi"
179 shift
Andreas Gampec23c9c92014-10-28 14:47:25 -0700180 elif [ "x$1" = "x--pic-test" ]; then
181 run_args="${run_args} --pic-test"
182 shift
Alex Lighta59dd802014-07-02 16:28:08 -0700183 elif [ "x$1" = "x--relocate" ]; then
184 relocate="yes"
185 shift
186 elif [ "x$1" = "x--no-relocate" ]; then
187 relocate="no"
188 shift
189 elif [ "x$1" = "x--prebuild" ]; then
Nicolas Geoffray5fd18ba2014-10-03 12:08:38 +0100190 run_args="${run_args} --prebuild"
Alex Lighta59dd802014-07-02 16:28:08 -0700191 prebuild_mode="yes"
192 shift;
Richard Uhler76f5cb62016-04-04 13:30:16 -0700193 elif [ "x$1" = "x--strip-dex" ]; then
194 run_args="${run_args} --strip-dex"
195 shift;
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000196 elif [ "x$1" = "x--debuggable" ]; then
197 run_args="${run_args} -Xcompiler-option --debuggable"
Nicolas Geoffraya3d90fb2015-03-16 13:55:40 +0000198 debuggable="yes"
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000199 shift;
Alex Lighta59dd802014-07-02 16:28:08 -0700200 elif [ "x$1" = "x--no-prebuild" ]; then
Nicolas Geoffray5fd18ba2014-10-03 12:08:38 +0100201 run_args="${run_args} --no-prebuild"
Alex Lighta59dd802014-07-02 16:28:08 -0700202 prebuild_mode="no"
203 shift;
Alex Lighte7873ec2014-08-12 09:53:50 -0700204 elif [ "x$1" = "x--gcverify" ]; then
205 basic_verify="true"
206 gc_verify="true"
207 shift
208 elif [ "x$1" = "x--gcstress" ]; then
209 basic_verify="true"
210 gc_stress="true"
211 shift
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700212 elif [ "x$1" = "x--image" ]; then
213 shift
214 image="$1"
215 run_args="${run_args} --image $image"
Elliott Hughes7c046102011-10-19 18:16:03 -0700216 shift
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000217 elif [ "x$1" = "x-Xcompiler-option" ]; then
218 shift
219 option="$1"
220 run_args="${run_args} -Xcompiler-option $option"
221 shift
Mathieu Chartier769a5ad2014-05-18 15:30:10 -0700222 elif [ "x$1" = "x--runtime-option" ]; then
223 shift
224 option="$1"
225 run_args="${run_args} --runtime-option $option"
226 shift
Mathieu Chartierc0a8a802014-10-17 15:58:01 -0700227 elif [ "x$1" = "x--gdb-arg" ]; then
228 shift
229 gdb_arg="$1"
230 run_args="${run_args} --gdb-arg $gdb_arg"
231 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700232 elif [ "x$1" = "x--debug" ]; then
233 run_args="${run_args} --debug"
234 shift
235 elif [ "x$1" = "x--gdb" ]; then
236 run_args="${run_args} --gdb"
237 dev_mode="yes"
238 shift
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700239 elif [ "x$1" = "x--strace" ]; then
240 strace="yes"
241 run_args="${run_args} --invoke-with strace --invoke-with -o --invoke-with $tmp_dir/$strace_output"
242 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700243 elif [ "x$1" = "x--zygote" ]; then
244 run_args="${run_args} --zygote"
245 shift
jeffhao0dff3f42012-11-20 15:13:43 -0800246 elif [ "x$1" = "x--interpreter" ]; then
Nicolas Geoffray4650c932016-05-10 09:13:13 +0000247 run_args="${run_args} --interpreter"
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700248 image_suffix="-interpreter"
249 shift
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800250 elif [ "x$1" = "x--jit" ]; then
Nicolas Geoffray4650c932016-05-10 09:13:13 +0000251 run_args="${run_args} --jit"
Andreas Gampe8a159fd2015-09-21 15:14:38 -0700252 image_suffix="-jit"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800253 shift
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700254 elif [ "x$1" = "x--optimizing" ]; then
Nicolas Geoffray4650c932016-05-10 09:13:13 +0000255 run_args="${run_args} -Xcompiler-option --compiler-backend=Optimizing"
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700256 image_suffix="-optimizing"
jeffhao0dff3f42012-11-20 15:13:43 -0800257 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700258 elif [ "x$1" = "x--no-verify" ]; then
Richard Uhlerf4b34872016-04-13 11:03:46 -0700259 run_args="${run_args} --no-verify"
jeffhao5d1ac922011-09-29 17:41:15 -0700260 shift
Igor Murashkin7617abd2015-07-10 18:27:47 -0700261 elif [ "x$1" = "x--verify-soft-fail" ]; then
Nicolas Geoffray4650c932016-05-10 09:13:13 +0000262 run_args="${run_args} --verify-soft-fail"
Andreas Gampe825570c2015-07-26 10:26:03 -0700263 image_suffix="-interp-ac"
Igor Murashkin7617abd2015-07-10 18:27:47 -0700264 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700265 elif [ "x$1" = "x--no-optimize" ]; then
266 run_args="${run_args} --no-optimize"
267 shift
268 elif [ "x$1" = "x--no-precise" ]; then
269 run_args="${run_args} --no-precise"
270 shift
Elliott Hughes7c046102011-10-19 18:16:03 -0700271 elif [ "x$1" = "x--invoke-with" ]; then
272 shift
273 what="$1"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700274 if [ "x$what" = "x" ]; then
275 echo "$0 missing argument to --invoke-with" 1>&2
276 usage="yes"
277 break
278 fi
Ian Rogers0e033672013-04-19 10:22:46 -0700279 run_args="${run_args} --invoke-with ${what}"
jeffhao5d1ac922011-09-29 17:41:15 -0700280 shift
281 elif [ "x$1" = "x--dev" ]; then
282 run_args="${run_args} --dev"
283 dev_mode="yes"
284 shift
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700285 elif [ "x$1" = "x--build-only" ]; then
286 build_only="yes"
287 shift
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100288 elif [ "x$1" = "x--build-with-javac-dx" ]; then
289 USE_JACK="false"
290 shift
291 elif [ "x$1" = "x--build-with-jack" ]; then
292 USE_JACK="true"
293 shift
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700294 elif [ "x$1" = "x--output-path" ]; then
295 shift
296 tmp_dir=$1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700297 if [ "x$tmp_dir" = "x" ]; then
298 echo "$0 missing argument to --output-path" 1>&2
299 usage="yes"
300 break
301 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700302 shift
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000303 elif [ "x$1" = "x--android-root" ]; then
304 shift
305 if [ "x$1" = "x" ]; then
306 echo "$0 missing argument to --android-root" 1>&2
307 usage="yes"
308 break
309 fi
310 android_root="$1"
311 run_args="${run_args} --android-root $1"
312 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700313 elif [ "x$1" = "x--update" ]; then
314 update_mode="yes"
315 shift
316 elif [ "x$1" = "x--help" ]; then
317 usage="yes"
318 shift
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700319 elif [ "x$1" = "x--64" ]; then
320 run_args="${run_args} --64"
Andreas Gampe2fe07922014-04-21 07:50:39 -0700321 suffix64="64"
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700322 shift
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200323 elif [ "x$1" = "x--trace" ]; then
Jeff Hao85139a32014-07-23 11:52:52 -0700324 trace="true"
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200325 shift
Andreas Gampe7526d782015-06-22 22:53:45 -0700326 elif [ "x$1" = "x--stream" ]; then
327 trace_stream="true"
328 shift
Alex Lightbfac14a2014-07-30 09:41:21 -0700329 elif [ "x$1" = "x--always-clean" ]; then
330 always_clean="yes"
331 shift
Igor Murashkin05f30e12015-06-10 15:57:17 -0700332 elif [ "x$1" = "x--never-clean" ]; then
333 never_clean="yes"
334 shift
Andreas Gampee21dc3d2014-12-08 16:59:43 -0800335 elif [ "x$1" = "x--dex2oat-swap" ]; then
336 run_args="${run_args} --dex2oat-swap"
337 shift
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700338 elif [ "x$1" = "x--instruction-set-features" ]; then
339 shift
340 run_args="${run_args} --instruction-set-features $1"
341 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700342 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -0700343 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700344 usage="yes"
345 break
346 else
347 break
348 fi
349done
Andreas Gampe3a12cfe2014-08-13 15:40:22 -0700350
Alex Light91de25f2015-10-28 17:00:06 -0700351# Allocate file descriptor real_stderr and redirect it to the shell's error
352# output (fd 2).
353if [ ${BASH_VERSINFO[1]} -ge 4 ] && [ ${BASH_VERSINFO[2]} -ge 1 ]; then
354 exec {real_stderr}>&2
355else
356 # In bash before version 4.1 we need to do a manual search for free file
357 # descriptors.
358 FD=3
359 while [ -e /dev/fd/$FD ]; do FD=$((FD + 1)); done
360 real_stderr=$FD
361 eval "exec ${real_stderr}>&2"
362fi
363if [ "$quiet" = "yes" ]; then
364 # Force the default standard output and error to go to /dev/null so we will
365 # not print them.
366 exec 1>/dev/null
367 exec 2>/dev/null
368fi
369
370function err_echo() {
371 echo "$@" 1>&${real_stderr}
372}
373
Andreas Gampe3a12cfe2014-08-13 15:40:22 -0700374# tmp_dir may be relative, resolve.
375#
376# Cannot use realpath, as it does not exist on Mac.
377# Cannot us a simple "cd", as the path might not be created yet.
Brian Carlstromc580e042014-09-08 21:37:39 -0700378# Cannot use readlink -m, as it does not exist on Mac.
379# Fallback to nuclear option:
Andreas Gampe907b6992014-08-18 22:26:49 -0700380noncanonical_tmp_dir=$tmp_dir
Brian Carlstromc580e042014-09-08 21:37:39 -0700381tmp_dir="`cd $oldwd ; python -c "import os; print os.path.realpath('$tmp_dir')"`"
Dmitry Petrochenko81c56e72014-03-05 15:05:46 +0700382mkdir -p $tmp_dir
jeffhao5d1ac922011-09-29 17:41:15 -0700383
Alex Lighte7873ec2014-08-12 09:53:50 -0700384if [ "$basic_verify" = "true" ]; then
Hiroshi Yamauchi312baf12015-01-12 12:11:05 -0800385 # Set HspaceCompactForOOMMinIntervalMs to zero to run hspace compaction for OOM more frequently in tests.
386 run_args="${run_args} --runtime-option -Xgc:preverify --runtime-option -Xgc:postverify --runtime-option -XX:HspaceCompactForOOMMinIntervalMs=0"
Alex Lighte7873ec2014-08-12 09:53:50 -0700387fi
388if [ "$gc_verify" = "true" ]; then
389 run_args="${run_args} --runtime-option -Xgc:preverify_rosalloc --runtime-option -Xgc:postverify_rosalloc"
390fi
391if [ "$gc_stress" = "true" ]; then
Alex Light97acf192016-03-17 09:59:38 -0700392 run_args="${run_args} --gc-stress --runtime-option -Xgc:SS,gcstress --runtime-option -Xms2m --runtime-option -Xmx16m"
Alex Lighte7873ec2014-08-12 09:53:50 -0700393fi
Jeff Hao85139a32014-07-23 11:52:52 -0700394if [ "$trace" = "true" ]; then
Andreas Gampe7526d782015-06-22 22:53:45 -0700395 run_args="${run_args} --runtime-option -Xmethod-trace --runtime-option -Xmethod-trace-file-size:2000000"
396 if [ "$trace_stream" = "true" ]; then
397 # Streaming mode uses the file size as the buffer size. So output gets really large. Drop
398 # the ability to analyze the file and just write to /dev/null.
399 run_args="${run_args} --runtime-option -Xmethod-trace-file:/dev/null"
400 # Enable streaming mode.
401 run_args="${run_args} --runtime-option -Xmethod-trace-stream"
402 else
403 run_args="${run_args} --runtime-option -Xmethod-trace-file:${DEX_LOCATION}/trace.bin"
404 fi
405elif [ "$trace_stream" = "true" ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700406 err_echo "Cannot use --stream without --trace."
Andreas Gampe7526d782015-06-22 22:53:45 -0700407 exit 1
Jeff Hao85139a32014-07-23 11:52:52 -0700408fi
409
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700410# Most interesting target architecture variables are Makefile variables, not environment variables.
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100411# 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 +0100412function guess_target_arch_name() {
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100413 grep32bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm|x86|mips)$'`
Andreas Gampe1a5c4062015-01-15 12:10:47 -0800414 grep64bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm64|x86_64|mips64)$'`
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700415 if [ "x${suffix64}" = "x64" ]; then
416 target_arch_name=${grep64bit}
417 else
418 target_arch_name=${grep32bit}
419 fi
420}
421
David Brazdil853a4c32015-09-28 16:15:50 +0100422function guess_host_arch_name() {
423 if [ "x${suffix64}" = "x64" ]; then
424 host_arch_name="x86_64"
425 else
426 host_arch_name="x86"
427 fi
428}
429
Alex Lighta59dd802014-07-02 16:28:08 -0700430if [ "$target_mode" = "no" ]; then
431 if [ "$runtime" = "jvm" ]; then
Alex Lighta59dd802014-07-02 16:28:08 -0700432 if [ "$prebuild_mode" = "yes" ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700433 err_echo "--prebuild with --jvm is unsupported"
Alex Lighta59dd802014-07-02 16:28:08 -0700434 exit 1;
435 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700436 fi
437fi
438
Alex Light03a112d2014-08-25 13:25:56 -0700439if [ "$have_patchoat" = "no" ]; then
440 run_args="${run_args} --no-patchoat"
441fi
442
443if [ "$have_dex2oat" = "no" ]; then
444 run_args="${run_args} --no-dex2oat"
445fi
446
Jeff Hao201803f2013-11-20 18:11:39 -0800447if [ ! "$runtime" = "jvm" ]; then
448 run_args="${run_args} --lib $lib"
449fi
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700450
Jeff Hao201803f2013-11-20 18:11:39 -0800451if [ "$runtime" = "dalvik" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700452 if [ "$target_mode" = "no" ]; then
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100453 framework="${ANDROID_PRODUCT_OUT}/system/framework"
Andreas Gampe50be66f2015-12-28 14:31:06 -0800454 bpath="${framework}/core-libart.jar:${framework}/core-oj.jar:${framework}/conscrypt.jar:${framework}/okhttp.jar:${framework}/bouncycastle.jar:${framework}/ext.jar"
Richard Uhler76f5cb62016-04-04 13:30:16 -0700455 run_args="${run_args} --boot --runtime-option -Xbootclasspath:${bpath}"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700456 else
457 true # defaults to using target BOOTCLASSPATH
458 fi
Jeff Hao201803f2013-11-20 18:11:39 -0800459elif [ "$runtime" = "art" ]; then
460 if [ "$target_mode" = "no" ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100461 # ANDROID_HOST_OUT is not set in a build environment.
Brian Carlstrom43534862014-02-19 01:13:52 -0800462 if [ -z "$ANDROID_HOST_OUT" ]; then
Alex Light6a439bc2015-10-26 17:52:36 -0700463 export ANDROID_HOST_OUT=${OUT_DIR:-$ANDROID_BUILD_TOP/out/}host/linux-x86
Brian Carlstrom43534862014-02-19 01:13:52 -0800464 fi
David Brazdil853a4c32015-09-28 16:15:50 +0100465 guess_host_arch_name
Jeff Haodcdc85b2015-12-04 14:06:18 -0800466 run_args="${run_args} --boot ${ANDROID_HOST_OUT}/framework/core${image_suffix}${pic_image_suffix}${multi_image_suffix}.art"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700467 run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib${suffix64}"
Jeff Hao201803f2013-11-20 18:11:39 -0800468 else
David Brazdil853a4c32015-09-28 16:15:50 +0100469 guess_target_arch_name
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700470 run_args="${run_args} --runtime-option -Djava.library.path=/data/art-test/${target_arch_name}"
Jeff Haodcdc85b2015-12-04 14:06:18 -0800471 run_args="${run_args} --boot /data/art-test/core${image_suffix}${pic_image_suffix}${multi_image_suffix}.art"
Jeff Hao201803f2013-11-20 18:11:39 -0800472 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700473 if [ "$relocate" = "yes" ]; then
474 run_args="${run_args} --relocate"
475 else
476 run_args="${run_args} --no-relocate"
477 fi
Andreas Gampe3f1dc562015-05-18 15:52:22 -0700478elif [ "$runtime" = "jvm" ]; then
479 # TODO: Detect whether the host is 32-bit or 64-bit.
480 run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib64"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700481fi
482
Alex Light03a112d2014-08-25 13:25:56 -0700483if [ "$have_image" = "no" ]; then
Alex Light1ef4ce82014-08-27 11:13:47 -0700484 if [ "$runtime" != "art" ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700485 err_echo "--no-image is only supported on the art runtime"
Alex Light1ef4ce82014-08-27 11:13:47 -0700486 exit 1
487 fi
488 if [ "$target_mode" = "no" ]; then
489 framework="${ANDROID_HOST_OUT}/framework"
490 bpath_suffix="-hostdex"
491 else
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000492 framework="${android_root}/framework"
Alex Light1ef4ce82014-08-27 11:13:47 -0700493 bpath_suffix=""
494 fi
495 # TODO If the target was compiled WITH_DEXPREOPT=true then these tests will
496 # fail since these jar files will be stripped.
497 bpath="${framework}/core-libart${bpath_suffix}.jar"
Narayan Kamathd50687e2015-11-17 12:37:27 +0000498 bpath="${bpath}:${framework}/core-oj${bpath_suffix}.jar"
Alex Light1ef4ce82014-08-27 11:13:47 -0700499 bpath="${bpath}:${framework}/conscrypt${bpath_suffix}.jar"
500 bpath="${bpath}:${framework}/okhttp${bpath_suffix}.jar"
Alex Light1ef4ce82014-08-27 11:13:47 -0700501 bpath="${bpath}:${framework}/bouncycastle${bpath_suffix}.jar"
502 # Pass down the bootclasspath
503 run_args="${run_args} --runtime-option -Xbootclasspath:${bpath}"
Alex Light03a112d2014-08-25 13:25:56 -0700504 run_args="${run_args} --no-image"
505fi
506
jeffhao5d1ac922011-09-29 17:41:15 -0700507if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700508 err_echo "--dev and --update are mutually exclusive"
509 usage="yes"
510fi
511
512if [ "$dev_mode" = "yes" -a "$quiet" = "yes" ]; then
513 err_echo "--dev and --quiet are mutually exclusive"
jeffhao5d1ac922011-09-29 17:41:15 -0700514 usage="yes"
515fi
516
517if [ "$usage" = "no" ]; then
518 if [ "x$1" = "x" -o "x$1" = "x-" ]; then
519 test_dir=`basename "$oldwd"`
520 else
521 test_dir="$1"
522 fi
523
524 if [ '!' -d "$test_dir" ]; then
525 td2=`echo ${test_dir}-*`
526 if [ '!' -d "$td2" ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700527 err_echo "${test_dir}: no such test directory"
jeffhao5d1ac922011-09-29 17:41:15 -0700528 usage="yes"
529 fi
530 test_dir="$td2"
531 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700532 # Shift to get rid of the test name argument. The rest of the arguments
533 # will get passed to the test run.
534 shift
535fi
536
537if [ "$usage" = "yes" ]; then
538 prog=`basename $prog`
539 (
540 echo "usage:"
541 echo " $prog --help Print this message."
542 echo " $prog [options] [test-name] Run test normally."
543 echo " $prog --dev [options] [test-name] Development mode" \
544 "(dumps to stdout)."
545 echo " $prog --update [options] [test-name] Update mode" \
546 "(replaces expected.txt)."
547 echo ' Omitting the test name or specifying "-" will use the' \
548 "current directory."
549 echo " Runtime Options:"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000550 echo " -O Run non-debug rather than debug build (off by default)."
551 echo " -Xcompiler-option Pass an option to the compiler."
552 echo " --runtime-option Pass an option to the runtime."
553 echo " --debug Wait for a debugger to attach."
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000554 echo " --debuggable Whether to compile Java code for a debugger."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000555 echo " --gdb Run under gdb; incompatible with some tests."
Alex Lightfadfee92015-10-28 09:40:10 -0700556 echo " --gdb-arg Pass an option to gdb."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000557 echo " --build-only Build test files only (off by default)."
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100558 echo " --build-with-javac-dx Build test files with javac and dx (on by default)."
559 echo " --build-with-jack Build test files with jack and jill (off by default)."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000560 echo " --interpreter Enable interpreter only mode (off by default)."
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800561 echo " --jit Enable jit (off by default)."
Nicolas Geoffray0e071252015-03-21 13:43:15 +0000562 echo " --optimizing Enable optimizing compiler (default)."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000563 echo " --no-verify Turn off verification (on by default)."
Igor Murashkin7617abd2015-07-10 18:27:47 -0700564 echo " --verify-soft-fail Force soft fail verification (off by default)."
565 echo " Verification is enabled if neither --no-verify"
566 echo " nor --verify-soft-fail is specified."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000567 echo " --no-optimize Turn off optimization (on by default)."
568 echo " --no-precise Turn off precise GC (on by default)."
569 echo " --zygote Spawn the process from the Zygote." \
jeffhao5d1ac922011-09-29 17:41:15 -0700570 "If used, then the"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000571 echo " other runtime options are ignored."
572 echo " --no-dex2oat Run as though dex2oat was failing."
573 echo " --no-patchoat Run as though patchoat was failing."
574 echo " --prebuild Run dex2oat on the files before starting test. (default)"
575 echo " --no-prebuild Do not run dex2oat on the files before starting"
576 echo " the test."
Richard Uhler76f5cb62016-04-04 13:30:16 -0700577 echo " --strip-dex Strip the dex files before starting test."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000578 echo " --relocate Force the use of relocating in the test, making"
579 echo " the image and oat files be relocated to a random"
580 echo " address before running. (default)"
581 echo " --no-relocate Force the use of no relocating in the test"
Alex Lightfadfee92015-10-28 09:40:10 -0700582 echo " --image Run the test using a precompiled boot image. (default)"
583 echo " --no-image Run the test without a precompiled boot image."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000584 echo " --host Use the host-mode virtual machine."
585 echo " --invoke-with Pass --invoke-with option to runtime."
586 echo " --dalvik Use Dalvik (off by default)."
587 echo " --jvm Use a host-local RI virtual machine."
Alex Lighteb7c1442015-08-31 13:17:42 -0700588 echo " --use-java-home Use the JAVA_HOME environment variable"
589 echo " to find the java compiler and runtime"
590 echo " (if applicable) to run the test with."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000591 echo " --output-path [path] Location where to store the build" \
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700592 "files."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000593 echo " --64 Run the test in 64-bit mode"
594 echo " --trace Run with method tracing"
Alex Lightfadfee92015-10-28 09:40:10 -0700595 echo " --strace Run with syscall tracing from strace."
Andreas Gampe7526d782015-06-22 22:53:45 -0700596 echo " --stream Run method tracing in streaming mode (requires --trace)"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000597 echo " --gcstress Run with gc stress testing"
598 echo " --gcverify Run with gc verification"
599 echo " --always-clean Delete the test files even if the test fails."
Igor Murashkin05f30e12015-06-10 15:57:17 -0700600 echo " --never-clean Keep the test files even if the test succeeds."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000601 echo " --android-root [path] The path on target for the android root. (/system by default)."
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000602 echo " --dex2oat-swap Use a dex2oat swap file."
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700603 echo " --instruction-set-features [string]"
604 echo " Set instruction-set-features for compilation."
Alex Lightfadfee92015-10-28 09:40:10 -0700605 echo " --pic-image Use an image compiled with position independent code for the"
606 echo " boot class path."
Jeff Haodcdc85b2015-12-04 14:06:18 -0800607 echo " --multi-image Use a set of images compiled with dex2oat multi-image for"
608 echo " the boot class path."
Alex Lightfadfee92015-10-28 09:40:10 -0700609 echo " --pic-test Compile the test code position independent."
Alex Light91de25f2015-10-28 17:00:06 -0700610 echo " --quiet Don't print anything except failure messages"
611 ) 1>&2 # Direct to stderr so usage is not printed if --quiet is set.
jeffhao5d1ac922011-09-29 17:41:15 -0700612 exit 1
613fi
614
615cd "$test_dir"
616test_dir=`pwd`
617
618td_info="${test_dir}/${info}"
619td_expected="${test_dir}/${expected}"
620
Brian Carlstrom22469aa2012-09-07 10:34:57 -0700621if [ ! -r $td_info ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700622 err_echo "${test_dir}: missing file $td_info"
Brian Carlstrom22469aa2012-09-07 10:34:57 -0700623 exit 1
624fi
625
626if [ ! -r $td_expected ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700627 err_echo "${test_dir}: missing file $td_expected"
jeffhao5d1ac922011-09-29 17:41:15 -0700628 exit 1
629fi
630
631# copy the test to a temp dir and run it
632
Elliott Hughes510c8782011-10-06 10:57:34 -0700633echo "${test_dir}: building..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700634
635rm -rf "$tmp_dir"
636cp -Rp "$test_dir" "$tmp_dir"
637cd "$tmp_dir"
638
639if [ '!' -r "$build" ]; then
640 cp "${progdir}/etc/default-build" build
Zheng Xuc6667102015-05-15 16:08:45 +0800641else
642 cp "${progdir}/etc/default-build" .
jeffhao5d1ac922011-09-29 17:41:15 -0700643fi
644
645if [ '!' -r "$run" ]; then
646 cp "${progdir}/etc/default-run" run
Zheng Xuc6667102015-05-15 16:08:45 +0800647else
648 cp "${progdir}/etc/default-run" .
jeffhao5d1ac922011-09-29 17:41:15 -0700649fi
650
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700651if [ '!' -r "$check_cmd" ]; then
652 cp "${progdir}/etc/default-check" check
Zheng Xuc6667102015-05-15 16:08:45 +0800653else
654 cp "${progdir}/etc/default-check" .
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700655fi
656
jeffhao5d1ac922011-09-29 17:41:15 -0700657chmod 755 "$build"
658chmod 755 "$run"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700659chmod 755 "$check_cmd"
jeffhao5d1ac922011-09-29 17:41:15 -0700660
Elliott Hughes8cbc8bc2011-10-04 11:19:45 -0700661export TEST_NAME=`basename ${test_dir}`
662
Roland Levillain0d5a2812015-11-13 10:07:31 +0000663# arch_supports_read_barrier ARCH
664# -------------------------------
665# Return whether the Optimizing compiler has read barrier support for ARCH.
666function arch_supports_read_barrier() {
Roland Levillain22ccc3a2015-11-24 13:10:05 +0000667 # Optimizing has read barrier support for ARM, ARM64, x86 and x86-64 at the
Roland Levillain0d5a2812015-11-13 10:07:31 +0000668 # moment.
Roland Levillain22ccc3a2015-11-24 13:10:05 +0000669 [ "x$1" = xarm ] || [ "x$1" = xarm64 ] || [ "x$1" = xx86 ] || [ "x$1" = xx86_64 ]
Roland Levillain0d5a2812015-11-13 10:07:31 +0000670}
671
David Brazdil4846d132015-01-15 19:07:08 +0000672# Tests named '<number>-checker-*' will also have their CFGs verified with
673# Checker when compiled with Optimizing on host.
674if [[ "$TEST_NAME" =~ ^[0-9]+-checker- ]]; then
David Brazdilf02c3cf2016-02-29 09:14:51 +0000675 if [ "$runtime" = "art" -a "$image_suffix" = "-optimizing" -a "$USE_JACK" = "true" ]; then
Roland Levillain0d5a2812015-11-13 10:07:31 +0000676 # Optimizing has read barrier support for certain architectures
677 # only. On other architectures, compiling is disabled when read
678 # barriers are enabled, meaning that we do not produce a CFG file
679 # as a side-effect of compilation, thus the Checker assertions
680 # cannot be checked. Disable Checker for those cases.
681 #
682 # TODO: Enable Checker when read barrier support is added to more
683 # architectures (b/12687968).
684 if [ "x$ART_USE_READ_BARRIER" = xtrue ] \
685 && (([ "x$host_mode" = "xyes" ] \
686 && ! arch_supports_read_barrier "$host_arch_name") \
687 || ([ "x$target_mode" = "xyes" ] \
688 && ! arch_supports_read_barrier "$target_arch_name")); then
689 run_checker="no"
David Brazdil80fb3942015-07-23 11:53:42 +0100690 # In no-prebuild mode, the compiler is only invoked if both dex2oat and
691 # patchoat are available. Disable Checker otherwise (b/22552692).
Roland Levillain0d5a2812015-11-13 10:07:31 +0000692 elif [ "$prebuild_mode" = "yes" ] \
693 || [ "$have_patchoat" = "yes" -a "$have_dex2oat" = "yes" ]; then
David Brazdil80fb3942015-07-23 11:53:42 +0100694 run_checker="yes"
David Brazdil5cc343d2015-10-08 11:35:32 +0100695
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100696 if [ "$target_mode" = "no" ]; then
697 cfg_output_dir="$tmp_dir"
David Brazdil5cc343d2015-10-08 11:35:32 +0100698 checker_args="--arch=${host_arch_name^^}"
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100699 else
700 cfg_output_dir="$DEX_LOCATION"
David Brazdil5cc343d2015-10-08 11:35:32 +0100701 checker_args="--arch=${target_arch_name^^}"
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100702 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100703
704 if [ "$debuggable" = "yes" ]; then
705 checker_args="$checker_args --debuggable"
706 fi
707
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100708 run_args="${run_args} -Xcompiler-option --dump-cfg=$cfg_output_dir/$cfg_output \
David Brazdil80fb3942015-07-23 11:53:42 +0100709 -Xcompiler-option -j1"
710 fi
David Brazdil4846d132015-01-15 19:07:08 +0000711 fi
712fi
713
Mathieu Chartier031768a2015-08-27 10:25:02 -0700714if [ "$runtime" != "jvm" ]; then
715 run_args="${run_args} --testlib ${testlib}"
716fi
717
Ian Rogers997f0f92014-06-21 22:58:05 -0700718# To cause tests to fail fast, limit the file sizes created by dx, dex2oat and ART output to 2MB.
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100719build_file_size_limit=2048
720run_file_size_limit=2048
Alex Light4694e822016-01-22 10:09:40 -0800721
722# Add tests requiring a higher ulimit to this list. Ulimits might need to be raised to deal with
723# large amounts of expected output or large generated files.
724if echo "$test_dir" | grep -Eq "(083|089|961|964|971)" > /dev/null; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100725 build_file_size_limit=5120
726 run_file_size_limit=5120
Ian Rogers997f0f92014-06-21 22:58:05 -0700727fi
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100728if [ "$run_checker" = "yes" -a "$target_mode" = "yes" ]; then
729 # We will need to `adb pull` the .cfg output from the target onto the host to
730 # run checker on it. This file can be big.
Roland Levillain22ccc3a2015-11-24 13:10:05 +0000731 build_file_size_limit=24576
732 run_file_size_limit=24576
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100733fi
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100734if [ ${USE_JACK} = "false" ]; then
735 # Set ulimit if we build with dx only, Jack can generate big temp files.
736 if ! ulimit -S "$build_file_size_limit"; then
Alex Light91de25f2015-10-28 17:00:06 -0700737 err_echo "ulimit file size setting failed"
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100738 fi
Ian Rogers997f0f92014-06-21 22:58:05 -0700739fi
740
jeffhao5d1ac922011-09-29 17:41:15 -0700741good="no"
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000742good_build="yes"
743good_run="yes"
jeffhao5d1ac922011-09-29 17:41:15 -0700744if [ "$dev_mode" = "yes" ]; then
David Brazdil4846d132015-01-15 19:07:08 +0000745 "./${build}" $build_args 2>&1
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700746 build_exit="$?"
747 echo "build exit status: $build_exit" 1>&2
748 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100749 if ! ulimit -S "$run_file_size_limit"; then
Alex Light91de25f2015-10-28 17:00:06 -0700750 err_echo "ulimit file size setting failed"
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100751 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800752 echo "${test_dir}: running..." 1>&2
753 "./${run}" $run_args "$@" 2>&1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700754 run_exit="$?"
Calin Juravle3cf48772015-01-26 16:47:33 +0000755
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800756 if [ "$run_exit" = "0" ]; then
Calin Juravle3cf48772015-01-26 16:47:33 +0000757 if [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100758 if [ "$target_mode" = "yes" ]; then
759 adb pull $cfg_output_dir/$cfg_output &> /dev/null
760 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100761 "$checker" $checker_args "$cfg_output" "$tmp_dir" 2>&1
Calin Juravle3cf48772015-01-26 16:47:33 +0000762 checker_exit="$?"
763 if [ "$checker_exit" = "0" ]; then
764 good="yes"
765 fi
Alex Light91de25f2015-10-28 17:00:06 -0700766 err_echo "checker exit status: $checker_exit"
Calin Juravle3cf48772015-01-26 16:47:33 +0000767 else
768 good="yes"
769 fi
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800770 fi
Calin Juravle3cf48772015-01-26 16:47:33 +0000771 echo "run exit status: $run_exit" 1>&2
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700772 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700773elif [ "$update_mode" = "yes" ]; then
David Brazdil4846d132015-01-15 19:07:08 +0000774 "./${build}" $build_args >"$build_output" 2>&1
jeffhao5d1ac922011-09-29 17:41:15 -0700775 build_exit="$?"
776 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100777 if ! ulimit -S "$run_file_size_limit"; then
Alex Light91de25f2015-10-28 17:00:06 -0700778 err_echo "ulimit file size setting failed"
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100779 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800780 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700781 "./${run}" $run_args "$@" >"$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000782 if [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100783 if [ "$target_mode" = "yes" ]; then
784 adb pull $cfg_output_dir/$cfg_output &> /dev/null
785 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100786 "$checker" -q $checker_args "$cfg_output" "$tmp_dir" >> "$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000787 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700788 sed -e 's/[[:cntrl:]]$//g' < "$output" >"${td_expected}"
789 good="yes"
790 else
Alex Light91de25f2015-10-28 17:00:06 -0700791 cat "$build_output" 1>&${real_stderr} 1>&2
792 err_echo "build exit status: $build_exit"
jeffhao5d1ac922011-09-29 17:41:15 -0700793 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700794elif [ "$build_only" = "yes" ]; then
795 good="yes"
David Brazdil4846d132015-01-15 19:07:08 +0000796 "./${build}" $build_args >"$build_output" 2>&1
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700797 build_exit="$?"
798 if [ "$build_exit" '!=' '0' ]; then
799 cp "$build_output" "$output"
800 echo "build exit status: $build_exit" >>"$output"
801 diff --strip-trailing-cr -q "$expected" "$output" >/dev/null
802 if [ "$?" '!=' "0" ]; then
803 good="no"
Alex Light91de25f2015-10-28 17:00:06 -0700804 err_echo "BUILD FAILED For ${TEST_NAME}"
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700805 fi
806 fi
Tsu Chiang Chuang379e2f52013-08-20 12:24:52 -0700807 # Clean up extraneous files that are not used by tests.
Tsu Chiang Chuang0160d992013-09-13 14:17:42 -0700808 find $tmp_dir -mindepth 1 ! -regex ".*/\(.*jar\|$output\|$expected\)" | xargs rm -rf
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700809 exit 0
jeffhao5d1ac922011-09-29 17:41:15 -0700810else
David Brazdil4846d132015-01-15 19:07:08 +0000811 "./${build}" $build_args >"$build_output" 2>&1
jeffhao5d1ac922011-09-29 17:41:15 -0700812 build_exit="$?"
813 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100814 if ! ulimit -S "$run_file_size_limit"; then
Alex Light91de25f2015-10-28 17:00:06 -0700815 err_echo "ulimit file size setting failed"
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100816 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800817 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700818 "./${run}" $run_args "$@" >"$output" 2>&1
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000819 run_exit="$?"
820 if [ "$run_exit" != "0" ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700821 err_echo "run exit status: $run_exit"
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000822 good_run="no"
David Brazdil4846d132015-01-15 19:07:08 +0000823 elif [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100824 if [ "$target_mode" = "yes" ]; then
825 adb pull $cfg_output_dir/$cfg_output &> /dev/null
826 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100827 "$checker" -q $checker_args "$cfg_output" "$tmp_dir" >> "$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000828 checker_exit="$?"
829 if [ "$checker_exit" != "0" ]; then
Alex Light91de25f2015-10-28 17:00:06 -0700830 err_echo "checker exit status: $checker_exit"
David Brazdil4846d132015-01-15 19:07:08 +0000831 good_run="no"
832 else
833 good_run="yes"
834 fi
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000835 else
836 good_run="yes"
837 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700838 else
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000839 good_build="no"
jeffhao5d1ac922011-09-29 17:41:15 -0700840 cp "$build_output" "$output"
Andreas Gampef6930a82014-10-21 09:33:08 -0700841 echo "Failed to build in tmpdir=${tmp_dir} from oldwd=${oldwd} and cwd=`pwd`" >> "$output"
842 echo "Non-canonical tmpdir was ${noncanonical_tmp_dir}" >> "$output"
Ian Rogersd9ad27d2014-10-27 13:48:21 -0700843 echo "Args: ${args}" >> "$output"
Andreas Gampef6930a82014-10-21 09:33:08 -0700844 echo "build exit status: $build_exit" >> "$output"
Andreas Gampe5c114902014-10-27 17:03:58 -0700845 max_name_length=$(getconf NAME_MAX ${tmp_dir})
846 echo "Max filename (NAME_MAX): ${max_name_length}" >> "$output"
847 max_path_length=$(getconf PATH_MAX ${tmp_dir})
Andreas Gampe602fbcd2014-10-27 17:06:29 -0700848 echo "Max pathlength (PATH_MAX): ${max_path_length}" >> "$output"
jeffhao5d1ac922011-09-29 17:41:15 -0700849 fi
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700850 ./$check_cmd "$expected" "$output"
jeffhao5d1ac922011-09-29 17:41:15 -0700851 if [ "$?" = "0" ]; then
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000852 if [ "$good_build" = "no" -o "$good_run" = "yes" ]; then
853 # output == expected
854 good="yes"
855 echo "${test_dir}: succeeded!" 1>&2
856 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700857 fi
858fi
859
jeffhao5d1ac922011-09-29 17:41:15 -0700860(
Alex Lightbfac14a2014-07-30 09:41:21 -0700861 if [ "$good" != "yes" -a "$update_mode" != "yes" ]; then
jeffhao5d1ac922011-09-29 17:41:15 -0700862 echo "${test_dir}: FAILED!"
863 echo ' '
864 echo '#################### info'
865 cat "${td_info}" | sed 's/^/# /g'
866 echo '#################### diffs'
Hiroshi Yamauchid630fd62015-09-04 12:52:03 -0700867 diff --strip-trailing-cr -u "$expected" "$output" | tail -n 3000
jeffhao5d1ac922011-09-29 17:41:15 -0700868 echo '####################'
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700869 if [ "$strace" = "yes" ]; then
870 echo '#################### strace output'
Hiroshi Yamauchid630fd62015-09-04 12:52:03 -0700871 tail -n 3000 "$tmp_dir/$strace_output"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700872 echo '####################'
873 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700874 echo ' '
875 fi
Alex Lightbfac14a2014-07-30 09:41:21 -0700876
Alex Light91de25f2015-10-28 17:00:06 -0700877) 2>&${real_stderr} 1>&2
Alex Lightbfac14a2014-07-30 09:41:21 -0700878
879# Clean up test files.
Igor Murashkin05f30e12015-06-10 15:57:17 -0700880if [ "$always_clean" = "yes" -o "$good" = "yes" ] && [ "$never_clean" = "no" ]; then
Alex Lightbfac14a2014-07-30 09:41:21 -0700881 cd "$oldwd"
882 rm -rf "$tmp_dir"
883 if [ "$target_mode" = "yes" -a "$build_exit" = "0" ]; then
884 adb shell rm -rf $DEX_LOCATION
885 fi
886 if [ "$good" = "yes" ]; then
887 exit 0
888 fi
889fi
890
891
892(
893 if [ "$always_clean" = "yes" ]; then
894 echo "${TEST_NAME} files deleted from host "
895 if [ "$target_mode" == "yes" ]; then
896 echo "and from target"
897 fi
898 else
899 echo "${TEST_NAME} files left in ${tmp_dir} on host"
900 if [ "$target_mode" == "yes" ]; then
901 echo "and in ${DEX_LOCATION} on target"
902 fi
Brian Carlstrom105215d2012-06-14 12:50:44 -0700903 fi
904
Alex Light91de25f2015-10-28 17:00:06 -0700905) 2>&${real_stderr} 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700906
907exit 1