blob: 293779f7c376a10a2c9a614bf709d8cbe673fc5d [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"
Brian Carlstrom5103ce62014-03-30 16:17:42 -070044export JAVAC="javac -g"
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"
Sebastien Hertz19ac0272015-02-24 17:39:50 +010048export USE_JACK="false"
jeffhao5d1ac922011-09-29 17:41:15 -070049
Tsu Chiang Chuang4407e612012-07-19 16:13:43 -070050# If dx was not set by the environment variable, assume it is in the path.
51if [ -z "$DX" ]; then
52 export DX="dx"
53fi
54
Tsu Chiang Chuang6674f8a2013-01-16 15:41:21 -080055# If jasmin was not set by the environment variable, assume it is in the path.
56if [ -z "$JASMIN" ]; then
57 export JASMIN="jasmin"
58fi
59
Andreas Gampe8fda9f22014-10-03 16:15:37 -070060# If smali was not set by the environment variable, assume it is in the path.
61if [ -z "$SMALI" ]; then
62 export SMALI="smali"
63fi
64
65# If dexmerger was not set by the environment variable, assume it is in the path.
66if [ -z "$DXMERGER" ]; then
67 export DXMERGER="dexmerger"
68fi
69
Sebastien Hertz19ac0272015-02-24 17:39:50 +010070# If jack was not set by the environment variable, assume it is in the path.
71if [ -z "$JACK" ]; then
72 export JACK="jack"
73fi
74
75# If the tree is compiled with Jack, build test with Jack by default.
76if [ "$ANDROID_COMPILE_WITH_JACK" = "true" ]; then
77 USE_JACK="true"
78fi
79
80# ANDROID_BUILD_TOP is not set in a build environment.
81if [ -z "$ANDROID_BUILD_TOP" ]; then
82 export ANDROID_BUILD_TOP=$oldwd
83fi
84
Sebastien Hertz19ac0272015-02-24 17:39:50 +010085# If JACK_CLASSPATH is not set, assume it only contains core-libart.
86if [ -z "$JACK_CLASSPATH" ]; then
87 export JACK_CLASSPATH="$ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/core-libart-hostdex_intermediates/classes.jack"
88fi
89
Sebastien Hertz19ac0272015-02-24 17:39:50 +010090# If JILL_JAR is not set, assume it is located in the prebuilts directory.
91if [ -z "$JILL_JAR" ]; then
92 export JILL_JAR="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/jill.jar"
93fi
94
95export JACK="$JACK -g -cp $JACK_CLASSPATH"
96export JILL="java -jar $JILL_JAR"
Tsu Chiang Chuang6674f8a2013-01-16 15:41:21 -080097
jeffhao5d1ac922011-09-29 17:41:15 -070098info="info.txt"
99build="build"
100run="run"
101expected="expected.txt"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700102check_cmd="check"
jeffhao5d1ac922011-09-29 17:41:15 -0700103output="output.txt"
104build_output="build-output.txt"
David Brazdil24128c62015-05-21 12:06:13 +0100105cfg_output="graph.cfg"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700106strace_output="strace-output.txt"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700107lib="libartd.so"
Mathieu Chartier031768a2015-08-27 10:25:02 -0700108testlib="arttestd"
jeffhao5d1ac922011-09-29 17:41:15 -0700109run_args="--quiet"
David Brazdil4846d132015-01-15 19:07:08 +0000110build_args=""
jeffhao5d1ac922011-09-29 17:41:15 -0700111
Nicolas Geoffraya3d90fb2015-03-16 13:55:40 +0000112debuggable="no"
Alex Light9d722532014-07-22 18:07:12 -0700113prebuild_mode="yes"
Brian Carlstrom2613de42012-06-15 17:37:16 -0700114target_mode="yes"
jeffhao5d1ac922011-09-29 17:41:15 -0700115dev_mode="no"
116update_mode="no"
Alex Lighta59dd802014-07-02 16:28:08 -0700117debug_mode="no"
118relocate="yes"
Jeff Hao201803f2013-11-20 18:11:39 -0800119runtime="art"
jeffhao5d1ac922011-09-29 17:41:15 -0700120usage="no"
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700121build_only="no"
Andreas Gampe2fe07922014-04-21 07:50:39 -0700122suffix64=""
Jeff Hao85139a32014-07-23 11:52:52 -0700123trace="false"
Andreas Gampe7526d782015-06-22 22:53:45 -0700124trace_stream="false"
Alex Lighte7873ec2014-08-12 09:53:50 -0700125basic_verify="false"
126gc_verify="false"
127gc_stress="false"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700128strace="false"
Alex Lightbfac14a2014-07-30 09:41:21 -0700129always_clean="no"
Igor Murashkin05f30e12015-06-10 15:57:17 -0700130never_clean="no"
Alex Light03a112d2014-08-25 13:25:56 -0700131have_dex2oat="yes"
132have_patchoat="yes"
133have_image="yes"
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700134image_suffix=""
Andreas Gampec23c9c92014-10-28 14:47:25 -0700135pic_image_suffix=""
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000136android_root="/system"
jeffhao5d1ac922011-09-29 17:41:15 -0700137
138while true; do
139 if [ "x$1" = "x--host" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -0700140 target_mode="no"
TDYa127b92bcab2012-04-08 00:09:51 -0700141 DEX_LOCATION=$tmp_dir
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100142 run_args="${run_args} --host"
jeffhao5d1ac922011-09-29 17:41:15 -0700143 shift
Alex Lighteb7c1442015-08-31 13:17:42 -0700144 elif [ "x$1" = "x--use-java-home" ]; then
145 if [ -n "${JAVA_HOME}" ]; then
146 export JAVA="${JAVA_HOME}/bin/java"
147 export JAVAC="${JAVA_HOME}/bin/javac -g"
148 else
149 echo "Passed --use-java-home without JAVA_HOME variable set!"
150 usage="yes"
151 fi
152 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -0800153 elif [ "x$1" = "x--jvm" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -0700154 target_mode="no"
Jeff Hao201803f2013-11-20 18:11:39 -0800155 runtime="jvm"
Brian Carlstrom01afdba2014-10-03 10:28:47 -0700156 prebuild_mode="no"
Elliott Hughesc717eef2012-06-15 16:01:26 -0700157 NEED_DEX="false"
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100158 USE_JACK="false"
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100159 run_args="${run_args} --jvm"
Alex Lighteb7c1442015-08-31 13:17:42 -0700160 build_args="${build_args} --jvm"
jeffhao5d1ac922011-09-29 17:41:15 -0700161 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -0800162 elif [ "x$1" = "x-O" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700163 lib="libart.so"
Mathieu Chartier031768a2015-08-27 10:25:02 -0700164 testlib="arttest"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700165 shift
166 elif [ "x$1" = "x--dalvik" ]; then
167 lib="libdvm.so"
Jeff Hao201803f2013-11-20 18:11:39 -0800168 runtime="dalvik"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700169 shift
Alex Light03a112d2014-08-25 13:25:56 -0700170 elif [ "x$1" = "x--no-dex2oat" ]; then
171 have_dex2oat="no"
172 shift
173 elif [ "x$1" = "x--no-patchoat" ]; then
174 have_patchoat="no"
175 shift
176 elif [ "x$1" = "x--no-image" ]; then
177 have_image="no"
178 shift
Andreas Gampec23c9c92014-10-28 14:47:25 -0700179 elif [ "x$1" = "x--pic-image" ]; then
180 pic_image_suffix="-pic"
181 shift
182 elif [ "x$1" = "x--pic-test" ]; then
183 run_args="${run_args} --pic-test"
184 shift
Alex Lighta59dd802014-07-02 16:28:08 -0700185 elif [ "x$1" = "x--relocate" ]; then
186 relocate="yes"
187 shift
188 elif [ "x$1" = "x--no-relocate" ]; then
189 relocate="no"
190 shift
191 elif [ "x$1" = "x--prebuild" ]; then
Nicolas Geoffray5fd18ba2014-10-03 12:08:38 +0100192 run_args="${run_args} --prebuild"
Alex Lighta59dd802014-07-02 16:28:08 -0700193 prebuild_mode="yes"
194 shift;
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000195 elif [ "x$1" = "x--debuggable" ]; then
196 run_args="${run_args} -Xcompiler-option --debuggable"
Nicolas Geoffraya3d90fb2015-03-16 13:55:40 +0000197 debuggable="yes"
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000198 shift;
Alex Lighta59dd802014-07-02 16:28:08 -0700199 elif [ "x$1" = "x--no-prebuild" ]; then
Nicolas Geoffray5fd18ba2014-10-03 12:08:38 +0100200 run_args="${run_args} --no-prebuild"
Alex Lighta59dd802014-07-02 16:28:08 -0700201 prebuild_mode="no"
202 shift;
Alex Lighte7873ec2014-08-12 09:53:50 -0700203 elif [ "x$1" = "x--gcverify" ]; then
204 basic_verify="true"
205 gc_verify="true"
206 shift
207 elif [ "x$1" = "x--gcstress" ]; then
208 basic_verify="true"
209 gc_stress="true"
210 shift
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700211 elif [ "x$1" = "x--image" ]; then
212 shift
213 image="$1"
214 run_args="${run_args} --image $image"
Elliott Hughes7c046102011-10-19 18:16:03 -0700215 shift
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000216 elif [ "x$1" = "x-Xcompiler-option" ]; then
217 shift
218 option="$1"
219 run_args="${run_args} -Xcompiler-option $option"
220 shift
Mathieu Chartier769a5ad2014-05-18 15:30:10 -0700221 elif [ "x$1" = "x--runtime-option" ]; then
222 shift
223 option="$1"
224 run_args="${run_args} --runtime-option $option"
225 shift
Mathieu Chartierc0a8a802014-10-17 15:58:01 -0700226 elif [ "x$1" = "x--gdb-arg" ]; then
227 shift
228 gdb_arg="$1"
229 run_args="${run_args} --gdb-arg $gdb_arg"
230 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700231 elif [ "x$1" = "x--debug" ]; then
232 run_args="${run_args} --debug"
233 shift
234 elif [ "x$1" = "x--gdb" ]; then
235 run_args="${run_args} --gdb"
236 dev_mode="yes"
237 shift
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700238 elif [ "x$1" = "x--strace" ]; then
239 strace="yes"
240 run_args="${run_args} --invoke-with strace --invoke-with -o --invoke-with $tmp_dir/$strace_output"
241 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700242 elif [ "x$1" = "x--zygote" ]; then
243 run_args="${run_args} --zygote"
244 shift
jeffhao0dff3f42012-11-20 15:13:43 -0800245 elif [ "x$1" = "x--interpreter" ]; then
246 run_args="${run_args} --interpreter"
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700247 image_suffix="-interpreter"
248 shift
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800249 elif [ "x$1" = "x--jit" ]; then
250 run_args="${run_args} --jit"
Andreas Gampe8a159fd2015-09-21 15:14:38 -0700251 image_suffix="-jit"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800252 shift
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700253 elif [ "x$1" = "x--optimizing" ]; then
254 run_args="${run_args} -Xcompiler-option --compiler-backend=Optimizing"
255 image_suffix="-optimizing"
jeffhao0dff3f42012-11-20 15:13:43 -0800256 shift
Nicolas Geoffrayc9338b92014-12-03 13:36:10 +0000257 elif [ "x$1" = "x--quick" ]; then
258 run_args="${run_args} -Xcompiler-option --compiler-backend=Quick"
259 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700260 elif [ "x$1" = "x--no-verify" ]; then
261 run_args="${run_args} --no-verify"
262 shift
Igor Murashkin7617abd2015-07-10 18:27:47 -0700263 elif [ "x$1" = "x--verify-soft-fail" ]; then
264 run_args="${run_args} --verify-soft-fail"
Andreas Gampe825570c2015-07-26 10:26:03 -0700265 image_suffix="-interp-ac"
Igor Murashkin7617abd2015-07-10 18:27:47 -0700266 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700267 elif [ "x$1" = "x--no-optimize" ]; then
268 run_args="${run_args} --no-optimize"
269 shift
270 elif [ "x$1" = "x--no-precise" ]; then
271 run_args="${run_args} --no-precise"
272 shift
Elliott Hughes7c046102011-10-19 18:16:03 -0700273 elif [ "x$1" = "x--invoke-with" ]; then
274 shift
275 what="$1"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700276 if [ "x$what" = "x" ]; then
277 echo "$0 missing argument to --invoke-with" 1>&2
278 usage="yes"
279 break
280 fi
Ian Rogers0e033672013-04-19 10:22:46 -0700281 run_args="${run_args} --invoke-with ${what}"
jeffhao5d1ac922011-09-29 17:41:15 -0700282 shift
283 elif [ "x$1" = "x--dev" ]; then
284 run_args="${run_args} --dev"
285 dev_mode="yes"
286 shift
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700287 elif [ "x$1" = "x--build-only" ]; then
288 build_only="yes"
289 shift
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100290 elif [ "x$1" = "x--build-with-javac-dx" ]; then
291 USE_JACK="false"
292 shift
293 elif [ "x$1" = "x--build-with-jack" ]; then
294 USE_JACK="true"
295 shift
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700296 elif [ "x$1" = "x--output-path" ]; then
297 shift
298 tmp_dir=$1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700299 if [ "x$tmp_dir" = "x" ]; then
300 echo "$0 missing argument to --output-path" 1>&2
301 usage="yes"
302 break
303 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700304 shift
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000305 elif [ "x$1" = "x--android-root" ]; then
306 shift
307 if [ "x$1" = "x" ]; then
308 echo "$0 missing argument to --android-root" 1>&2
309 usage="yes"
310 break
311 fi
312 android_root="$1"
313 run_args="${run_args} --android-root $1"
314 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700315 elif [ "x$1" = "x--update" ]; then
316 update_mode="yes"
317 shift
318 elif [ "x$1" = "x--help" ]; then
319 usage="yes"
320 shift
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700321 elif [ "x$1" = "x--64" ]; then
322 run_args="${run_args} --64"
Andreas Gampe2fe07922014-04-21 07:50:39 -0700323 suffix64="64"
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700324 shift
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200325 elif [ "x$1" = "x--trace" ]; then
Jeff Hao85139a32014-07-23 11:52:52 -0700326 trace="true"
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200327 shift
Andreas Gampe7526d782015-06-22 22:53:45 -0700328 elif [ "x$1" = "x--stream" ]; then
329 trace_stream="true"
330 shift
Alex Lightbfac14a2014-07-30 09:41:21 -0700331 elif [ "x$1" = "x--always-clean" ]; then
332 always_clean="yes"
333 shift
Igor Murashkin05f30e12015-06-10 15:57:17 -0700334 elif [ "x$1" = "x--never-clean" ]; then
335 never_clean="yes"
336 shift
Andreas Gampee21dc3d2014-12-08 16:59:43 -0800337 elif [ "x$1" = "x--dex2oat-swap" ]; then
338 run_args="${run_args} --dex2oat-swap"
339 shift
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700340 elif [ "x$1" = "x--instruction-set-features" ]; then
341 shift
342 run_args="${run_args} --instruction-set-features $1"
343 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700344 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -0700345 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700346 usage="yes"
347 break
348 else
349 break
350 fi
351done
Andreas Gampe3a12cfe2014-08-13 15:40:22 -0700352
353# tmp_dir may be relative, resolve.
354#
355# Cannot use realpath, as it does not exist on Mac.
356# Cannot us a simple "cd", as the path might not be created yet.
Brian Carlstromc580e042014-09-08 21:37:39 -0700357# Cannot use readlink -m, as it does not exist on Mac.
358# Fallback to nuclear option:
Andreas Gampe907b6992014-08-18 22:26:49 -0700359noncanonical_tmp_dir=$tmp_dir
Brian Carlstromc580e042014-09-08 21:37:39 -0700360tmp_dir="`cd $oldwd ; python -c "import os; print os.path.realpath('$tmp_dir')"`"
Dmitry Petrochenko81c56e72014-03-05 15:05:46 +0700361mkdir -p $tmp_dir
jeffhao5d1ac922011-09-29 17:41:15 -0700362
Alex Lighte7873ec2014-08-12 09:53:50 -0700363if [ "$basic_verify" = "true" ]; then
Hiroshi Yamauchi312baf12015-01-12 12:11:05 -0800364 # Set HspaceCompactForOOMMinIntervalMs to zero to run hspace compaction for OOM more frequently in tests.
365 run_args="${run_args} --runtime-option -Xgc:preverify --runtime-option -Xgc:postverify --runtime-option -XX:HspaceCompactForOOMMinIntervalMs=0"
Alex Lighte7873ec2014-08-12 09:53:50 -0700366fi
367if [ "$gc_verify" = "true" ]; then
368 run_args="${run_args} --runtime-option -Xgc:preverify_rosalloc --runtime-option -Xgc:postverify_rosalloc"
369fi
370if [ "$gc_stress" = "true" ]; then
Mathieu Chartiereb193622015-06-27 15:42:27 -0700371 run_args="${run_args} --runtime-option -Xgc:SS,gcstress --runtime-option -Xms2m --runtime-option -Xmx16m"
Alex Lighte7873ec2014-08-12 09:53:50 -0700372fi
Jeff Hao85139a32014-07-23 11:52:52 -0700373if [ "$trace" = "true" ]; then
Andreas Gampe7526d782015-06-22 22:53:45 -0700374 run_args="${run_args} --runtime-option -Xmethod-trace --runtime-option -Xmethod-trace-file-size:2000000"
375 if [ "$trace_stream" = "true" ]; then
376 # Streaming mode uses the file size as the buffer size. So output gets really large. Drop
377 # the ability to analyze the file and just write to /dev/null.
378 run_args="${run_args} --runtime-option -Xmethod-trace-file:/dev/null"
379 # Enable streaming mode.
380 run_args="${run_args} --runtime-option -Xmethod-trace-stream"
381 else
382 run_args="${run_args} --runtime-option -Xmethod-trace-file:${DEX_LOCATION}/trace.bin"
383 fi
384elif [ "$trace_stream" = "true" ]; then
385 echo "Cannot use --stream without --trace."
386 exit 1
Jeff Hao85139a32014-07-23 11:52:52 -0700387fi
388
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700389# Most interesting target architecture variables are Makefile variables, not environment variables.
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100390# 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 +0100391function guess_target_arch_name() {
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100392 grep32bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm|x86|mips)$'`
Andreas Gampe1a5c4062015-01-15 12:10:47 -0800393 grep64bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm64|x86_64|mips64)$'`
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700394 if [ "x${suffix64}" = "x64" ]; then
395 target_arch_name=${grep64bit}
396 else
397 target_arch_name=${grep32bit}
398 fi
399}
400
David Brazdil853a4c32015-09-28 16:15:50 +0100401function guess_host_arch_name() {
402 if [ "x${suffix64}" = "x64" ]; then
403 host_arch_name="x86_64"
404 else
405 host_arch_name="x86"
406 fi
407}
408
Alex Lighta59dd802014-07-02 16:28:08 -0700409if [ "$target_mode" = "no" ]; then
410 if [ "$runtime" = "jvm" ]; then
Alex Lighta59dd802014-07-02 16:28:08 -0700411 if [ "$prebuild_mode" = "yes" ]; then
412 echo "--prebuild with --jvm is unsupported";
413 exit 1;
414 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700415 fi
416fi
417
Alex Light03a112d2014-08-25 13:25:56 -0700418if [ "$have_patchoat" = "no" ]; then
419 run_args="${run_args} --no-patchoat"
420fi
421
422if [ "$have_dex2oat" = "no" ]; then
423 run_args="${run_args} --no-dex2oat"
424fi
425
Jeff Hao201803f2013-11-20 18:11:39 -0800426if [ ! "$runtime" = "jvm" ]; then
427 run_args="${run_args} --lib $lib"
428fi
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700429
Jeff Hao201803f2013-11-20 18:11:39 -0800430if [ "$runtime" = "dalvik" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700431 if [ "$target_mode" = "no" ]; then
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100432 framework="${ANDROID_PRODUCT_OUT}/system/framework"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700433 bpath="${framework}/core.jar:${framework}/conscrypt.jar:${framework}/okhttp.jar:${framework}/core-junit.jar:${framework}/bouncycastle.jar:${framework}/ext.jar"
434 run_args="${run_args} --boot -Xbootclasspath:${bpath}"
435 else
436 true # defaults to using target BOOTCLASSPATH
437 fi
Jeff Hao201803f2013-11-20 18:11:39 -0800438elif [ "$runtime" = "art" ]; then
439 if [ "$target_mode" = "no" ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100440 # ANDROID_HOST_OUT is not set in a build environment.
Brian Carlstrom43534862014-02-19 01:13:52 -0800441 if [ -z "$ANDROID_HOST_OUT" ]; then
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100442 export ANDROID_HOST_OUT=$ANDROID_BUILD_TOP/out/host/linux-x86
Brian Carlstrom43534862014-02-19 01:13:52 -0800443 fi
David Brazdil853a4c32015-09-28 16:15:50 +0100444 guess_host_arch_name
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000445 run_args="${run_args} --boot ${ANDROID_HOST_OUT}/framework/core${image_suffix}${pic_image_suffix}.art"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700446 run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib${suffix64}"
Jeff Hao201803f2013-11-20 18:11:39 -0800447 else
David Brazdil853a4c32015-09-28 16:15:50 +0100448 guess_target_arch_name
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700449 run_args="${run_args} --runtime-option -Djava.library.path=/data/art-test/${target_arch_name}"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000450 run_args="${run_args} --boot /data/art-test/core${image_suffix}${pic_image_suffix}.art"
Jeff Hao201803f2013-11-20 18:11:39 -0800451 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700452 if [ "$relocate" = "yes" ]; then
453 run_args="${run_args} --relocate"
454 else
455 run_args="${run_args} --no-relocate"
456 fi
Andreas Gampe3f1dc562015-05-18 15:52:22 -0700457elif [ "$runtime" = "jvm" ]; then
458 # TODO: Detect whether the host is 32-bit or 64-bit.
459 run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib64"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700460fi
461
Alex Light03a112d2014-08-25 13:25:56 -0700462if [ "$have_image" = "no" ]; then
Alex Light1ef4ce82014-08-27 11:13:47 -0700463 if [ "$runtime" != "art" ]; then
464 echo "--no-image is only supported on the art runtime"
465 exit 1
466 fi
467 if [ "$target_mode" = "no" ]; then
468 framework="${ANDROID_HOST_OUT}/framework"
469 bpath_suffix="-hostdex"
470 else
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000471 framework="${android_root}/framework"
Alex Light1ef4ce82014-08-27 11:13:47 -0700472 bpath_suffix=""
473 fi
474 # TODO If the target was compiled WITH_DEXPREOPT=true then these tests will
475 # fail since these jar files will be stripped.
476 bpath="${framework}/core-libart${bpath_suffix}.jar"
477 bpath="${bpath}:${framework}/conscrypt${bpath_suffix}.jar"
478 bpath="${bpath}:${framework}/okhttp${bpath_suffix}.jar"
479 bpath="${bpath}:${framework}/core-junit${bpath_suffix}.jar"
480 bpath="${bpath}:${framework}/bouncycastle${bpath_suffix}.jar"
481 # Pass down the bootclasspath
482 run_args="${run_args} --runtime-option -Xbootclasspath:${bpath}"
Alex Light03a112d2014-08-25 13:25:56 -0700483 run_args="${run_args} --no-image"
484fi
485
jeffhao5d1ac922011-09-29 17:41:15 -0700486if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then
487 echo "--dev and --update are mutually exclusive" 1>&2
488 usage="yes"
489fi
490
491if [ "$usage" = "no" ]; then
492 if [ "x$1" = "x" -o "x$1" = "x-" ]; then
493 test_dir=`basename "$oldwd"`
494 else
495 test_dir="$1"
496 fi
497
498 if [ '!' -d "$test_dir" ]; then
499 td2=`echo ${test_dir}-*`
500 if [ '!' -d "$td2" ]; then
501 echo "${test_dir}: no such test directory" 1>&2
502 usage="yes"
503 fi
504 test_dir="$td2"
505 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700506 # Shift to get rid of the test name argument. The rest of the arguments
507 # will get passed to the test run.
508 shift
509fi
510
511if [ "$usage" = "yes" ]; then
512 prog=`basename $prog`
513 (
514 echo "usage:"
515 echo " $prog --help Print this message."
516 echo " $prog [options] [test-name] Run test normally."
517 echo " $prog --dev [options] [test-name] Development mode" \
518 "(dumps to stdout)."
519 echo " $prog --update [options] [test-name] Update mode" \
520 "(replaces expected.txt)."
521 echo ' Omitting the test name or specifying "-" will use the' \
522 "current directory."
523 echo " Runtime Options:"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000524 echo " -O Run non-debug rather than debug build (off by default)."
525 echo " -Xcompiler-option Pass an option to the compiler."
526 echo " --runtime-option Pass an option to the runtime."
527 echo " --debug Wait for a debugger to attach."
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000528 echo " --debuggable Whether to compile Java code for a debugger."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000529 echo " --gdb Run under gdb; incompatible with some tests."
530 echo " --build-only Build test files only (off by default)."
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100531 echo " --build-with-javac-dx Build test files with javac and dx (on by default)."
532 echo " --build-with-jack Build test files with jack and jill (off by default)."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000533 echo " --interpreter Enable interpreter only mode (off by default)."
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800534 echo " --jit Enable jit (off by default)."
Nicolas Geoffray0e071252015-03-21 13:43:15 +0000535 echo " --optimizing Enable optimizing compiler (default)."
536 echo " --quick Use Quick compiler (off by default)."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000537 echo " --no-verify Turn off verification (on by default)."
Igor Murashkin7617abd2015-07-10 18:27:47 -0700538 echo " --verify-soft-fail Force soft fail verification (off by default)."
539 echo " Verification is enabled if neither --no-verify"
540 echo " nor --verify-soft-fail is specified."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000541 echo " --no-optimize Turn off optimization (on by default)."
542 echo " --no-precise Turn off precise GC (on by default)."
543 echo " --zygote Spawn the process from the Zygote." \
jeffhao5d1ac922011-09-29 17:41:15 -0700544 "If used, then the"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000545 echo " other runtime options are ignored."
546 echo " --no-dex2oat Run as though dex2oat was failing."
547 echo " --no-patchoat Run as though patchoat was failing."
548 echo " --prebuild Run dex2oat on the files before starting test. (default)"
549 echo " --no-prebuild Do not run dex2oat on the files before starting"
550 echo " the test."
551 echo " --relocate Force the use of relocating in the test, making"
552 echo " the image and oat files be relocated to a random"
553 echo " address before running. (default)"
554 echo " --no-relocate Force the use of no relocating in the test"
555 echo " --host Use the host-mode virtual machine."
556 echo " --invoke-with Pass --invoke-with option to runtime."
557 echo " --dalvik Use Dalvik (off by default)."
558 echo " --jvm Use a host-local RI virtual machine."
Alex Lighteb7c1442015-08-31 13:17:42 -0700559 echo " --use-java-home Use the JAVA_HOME environment variable"
560 echo " to find the java compiler and runtime"
561 echo " (if applicable) to run the test with."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000562 echo " --output-path [path] Location where to store the build" \
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700563 "files."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000564 echo " --64 Run the test in 64-bit mode"
565 echo " --trace Run with method tracing"
Andreas Gampe7526d782015-06-22 22:53:45 -0700566 echo " --stream Run method tracing in streaming mode (requires --trace)"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000567 echo " --gcstress Run with gc stress testing"
568 echo " --gcverify Run with gc verification"
569 echo " --always-clean Delete the test files even if the test fails."
Igor Murashkin05f30e12015-06-10 15:57:17 -0700570 echo " --never-clean Keep the test files even if the test succeeds."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000571 echo " --android-root [path] The path on target for the android root. (/system by default)."
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000572 echo " --dex2oat-swap Use a dex2oat swap file."
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700573 echo " --instruction-set-features [string]"
574 echo " Set instruction-set-features for compilation."
jeffhao5d1ac922011-09-29 17:41:15 -0700575 ) 1>&2
576 exit 1
577fi
578
579cd "$test_dir"
580test_dir=`pwd`
581
582td_info="${test_dir}/${info}"
583td_expected="${test_dir}/${expected}"
584
Brian Carlstrom22469aa2012-09-07 10:34:57 -0700585if [ ! -r $td_info ]; then
586 echo "${test_dir}: missing file $td_info" 1>&2
587 exit 1
588fi
589
590if [ ! -r $td_expected ]; then
591 echo "${test_dir}: missing file $td_expected" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700592 exit 1
593fi
594
595# copy the test to a temp dir and run it
596
Elliott Hughes510c8782011-10-06 10:57:34 -0700597echo "${test_dir}: building..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700598
599rm -rf "$tmp_dir"
600cp -Rp "$test_dir" "$tmp_dir"
601cd "$tmp_dir"
602
603if [ '!' -r "$build" ]; then
604 cp "${progdir}/etc/default-build" build
Zheng Xuc6667102015-05-15 16:08:45 +0800605else
606 cp "${progdir}/etc/default-build" .
jeffhao5d1ac922011-09-29 17:41:15 -0700607fi
608
609if [ '!' -r "$run" ]; then
610 cp "${progdir}/etc/default-run" run
Zheng Xuc6667102015-05-15 16:08:45 +0800611else
612 cp "${progdir}/etc/default-run" .
jeffhao5d1ac922011-09-29 17:41:15 -0700613fi
614
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700615if [ '!' -r "$check_cmd" ]; then
616 cp "${progdir}/etc/default-check" check
Zheng Xuc6667102015-05-15 16:08:45 +0800617else
618 cp "${progdir}/etc/default-check" .
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700619fi
620
jeffhao5d1ac922011-09-29 17:41:15 -0700621chmod 755 "$build"
622chmod 755 "$run"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700623chmod 755 "$check_cmd"
jeffhao5d1ac922011-09-29 17:41:15 -0700624
Elliott Hughes8cbc8bc2011-10-04 11:19:45 -0700625export TEST_NAME=`basename ${test_dir}`
626
David Brazdil4846d132015-01-15 19:07:08 +0000627# Tests named '<number>-checker-*' will also have their CFGs verified with
628# Checker when compiled with Optimizing on host.
629if [[ "$TEST_NAME" =~ ^[0-9]+-checker- ]]; then
630 # Build Checker DEX files without dx's optimizations so the input to dex2oat
631 # better resembles the Java source. We always build the DEX the same way, even
632 # if Checker is not invoked and the test only runs the program.
633 build_args="${build_args} --dx-option --no-optimize"
634
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100635 # Jack does not necessarily generate the same DEX output than dx. Because these tests depend
636 # on a particular DEX output, keep building them with dx for now (b/19467889).
637 USE_JACK="false"
638
David Brazdil5cc343d2015-10-08 11:35:32 +0100639 if [ "$runtime" = "art" -a "$image_suffix" = "-optimizing" ]; then
David Brazdil80fb3942015-07-23 11:53:42 +0100640 # In no-prebuild mode, the compiler is only invoked if both dex2oat and
641 # patchoat are available. Disable Checker otherwise (b/22552692).
642 if [ "$prebuild_mode" = "yes" ] || [ "$have_patchoat" = "yes" -a "$have_dex2oat" = "yes" ]; then
643 run_checker="yes"
David Brazdil5cc343d2015-10-08 11:35:32 +0100644
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100645 if [ "$target_mode" = "no" ]; then
646 cfg_output_dir="$tmp_dir"
David Brazdil5cc343d2015-10-08 11:35:32 +0100647 checker_args="--arch=${host_arch_name^^}"
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100648 else
649 cfg_output_dir="$DEX_LOCATION"
David Brazdil5cc343d2015-10-08 11:35:32 +0100650 checker_args="--arch=${target_arch_name^^}"
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100651 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100652
653 if [ "$debuggable" = "yes" ]; then
654 checker_args="$checker_args --debuggable"
655 fi
656
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100657 run_args="${run_args} -Xcompiler-option --dump-cfg=$cfg_output_dir/$cfg_output \
David Brazdil80fb3942015-07-23 11:53:42 +0100658 -Xcompiler-option -j1"
659 fi
David Brazdil4846d132015-01-15 19:07:08 +0000660 fi
661fi
662
Mathieu Chartier031768a2015-08-27 10:25:02 -0700663if [ "$runtime" != "jvm" ]; then
664 run_args="${run_args} --testlib ${testlib}"
665fi
666
Ian Rogers997f0f92014-06-21 22:58:05 -0700667# 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 +0100668build_file_size_limit=2048
669run_file_size_limit=2048
Ian Rogers997f0f92014-06-21 22:58:05 -0700670if echo "$test_dir" | grep 089; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100671 build_file_size_limit=5120
672 run_file_size_limit=5120
Ian Rogers997f0f92014-06-21 22:58:05 -0700673elif echo "$test_dir" | grep 083; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100674 build_file_size_limit=5120
675 run_file_size_limit=5120
Ian Rogers997f0f92014-06-21 22:58:05 -0700676fi
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100677if [ "$run_checker" = "yes" -a "$target_mode" = "yes" ]; then
678 # We will need to `adb pull` the .cfg output from the target onto the host to
679 # run checker on it. This file can be big.
680 build_file_size_limit=16384
681 run_file_size_limit=16384
682fi
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100683if [ ${USE_JACK} = "false" ]; then
684 # Set ulimit if we build with dx only, Jack can generate big temp files.
685 if ! ulimit -S "$build_file_size_limit"; then
686 echo "ulimit file size setting failed"
687 fi
Ian Rogers997f0f92014-06-21 22:58:05 -0700688fi
689
jeffhao5d1ac922011-09-29 17:41:15 -0700690good="no"
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000691good_build="yes"
692good_run="yes"
jeffhao5d1ac922011-09-29 17:41:15 -0700693if [ "$dev_mode" = "yes" ]; then
David Brazdil4846d132015-01-15 19:07:08 +0000694 "./${build}" $build_args 2>&1
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700695 build_exit="$?"
696 echo "build exit status: $build_exit" 1>&2
697 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100698 if ! ulimit -S "$run_file_size_limit"; then
699 echo "ulimit file size setting failed"
700 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800701 echo "${test_dir}: running..." 1>&2
702 "./${run}" $run_args "$@" 2>&1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700703 run_exit="$?"
Calin Juravle3cf48772015-01-26 16:47:33 +0000704
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800705 if [ "$run_exit" = "0" ]; then
Calin Juravle3cf48772015-01-26 16:47:33 +0000706 if [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100707 if [ "$target_mode" = "yes" ]; then
708 adb pull $cfg_output_dir/$cfg_output &> /dev/null
709 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100710 "$checker" $checker_args "$cfg_output" "$tmp_dir" 2>&1
Calin Juravle3cf48772015-01-26 16:47:33 +0000711 checker_exit="$?"
712 if [ "$checker_exit" = "0" ]; then
713 good="yes"
714 fi
715 echo "checker exit status: $checker_exit" 1>&2
716 else
717 good="yes"
718 fi
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800719 fi
Calin Juravle3cf48772015-01-26 16:47:33 +0000720 echo "run exit status: $run_exit" 1>&2
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700721 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700722elif [ "$update_mode" = "yes" ]; then
David Brazdil4846d132015-01-15 19:07:08 +0000723 "./${build}" $build_args >"$build_output" 2>&1
jeffhao5d1ac922011-09-29 17:41:15 -0700724 build_exit="$?"
725 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100726 if ! ulimit -S "$run_file_size_limit"; then
727 echo "ulimit file size setting failed"
728 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800729 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700730 "./${run}" $run_args "$@" >"$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000731 if [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100732 if [ "$target_mode" = "yes" ]; then
733 adb pull $cfg_output_dir/$cfg_output &> /dev/null
734 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100735 "$checker" -q $checker_args "$cfg_output" "$tmp_dir" >> "$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000736 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700737 sed -e 's/[[:cntrl:]]$//g' < "$output" >"${td_expected}"
738 good="yes"
739 else
740 cat "$build_output" 1>&2
741 echo "build exit status: $build_exit" 1>&2
742 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700743elif [ "$build_only" = "yes" ]; then
744 good="yes"
David Brazdil4846d132015-01-15 19:07:08 +0000745 "./${build}" $build_args >"$build_output" 2>&1
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700746 build_exit="$?"
747 if [ "$build_exit" '!=' '0' ]; then
748 cp "$build_output" "$output"
749 echo "build exit status: $build_exit" >>"$output"
750 diff --strip-trailing-cr -q "$expected" "$output" >/dev/null
751 if [ "$?" '!=' "0" ]; then
752 good="no"
753 echo "BUILD FAILED For ${TEST_NAME}"
754 fi
755 fi
Tsu Chiang Chuang379e2f52013-08-20 12:24:52 -0700756 # Clean up extraneous files that are not used by tests.
Tsu Chiang Chuang0160d992013-09-13 14:17:42 -0700757 find $tmp_dir -mindepth 1 ! -regex ".*/\(.*jar\|$output\|$expected\)" | xargs rm -rf
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700758 exit 0
jeffhao5d1ac922011-09-29 17:41:15 -0700759else
David Brazdil4846d132015-01-15 19:07:08 +0000760 "./${build}" $build_args >"$build_output" 2>&1
jeffhao5d1ac922011-09-29 17:41:15 -0700761 build_exit="$?"
762 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100763 if ! ulimit -S "$run_file_size_limit"; then
764 echo "ulimit file size setting failed"
765 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800766 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700767 "./${run}" $run_args "$@" >"$output" 2>&1
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000768 run_exit="$?"
769 if [ "$run_exit" != "0" ]; then
770 echo "run exit status: $run_exit" 1>&2
771 good_run="no"
David Brazdil4846d132015-01-15 19:07:08 +0000772 elif [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100773 if [ "$target_mode" = "yes" ]; then
774 adb pull $cfg_output_dir/$cfg_output &> /dev/null
775 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100776 "$checker" -q $checker_args "$cfg_output" "$tmp_dir" >> "$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000777 checker_exit="$?"
778 if [ "$checker_exit" != "0" ]; then
779 echo "checker exit status: $checker_exit" 1>&2
780 good_run="no"
781 else
782 good_run="yes"
783 fi
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000784 else
785 good_run="yes"
786 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700787 else
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000788 good_build="no"
jeffhao5d1ac922011-09-29 17:41:15 -0700789 cp "$build_output" "$output"
Andreas Gampef6930a82014-10-21 09:33:08 -0700790 echo "Failed to build in tmpdir=${tmp_dir} from oldwd=${oldwd} and cwd=`pwd`" >> "$output"
791 echo "Non-canonical tmpdir was ${noncanonical_tmp_dir}" >> "$output"
Ian Rogersd9ad27d2014-10-27 13:48:21 -0700792 echo "Args: ${args}" >> "$output"
Andreas Gampef6930a82014-10-21 09:33:08 -0700793 echo "build exit status: $build_exit" >> "$output"
Andreas Gampe5c114902014-10-27 17:03:58 -0700794 max_name_length=$(getconf NAME_MAX ${tmp_dir})
795 echo "Max filename (NAME_MAX): ${max_name_length}" >> "$output"
796 max_path_length=$(getconf PATH_MAX ${tmp_dir})
Andreas Gampe602fbcd2014-10-27 17:06:29 -0700797 echo "Max pathlength (PATH_MAX): ${max_path_length}" >> "$output"
jeffhao5d1ac922011-09-29 17:41:15 -0700798 fi
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700799 ./$check_cmd "$expected" "$output"
jeffhao5d1ac922011-09-29 17:41:15 -0700800 if [ "$?" = "0" ]; then
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000801 if [ "$good_build" = "no" -o "$good_run" = "yes" ]; then
802 # output == expected
803 good="yes"
804 echo "${test_dir}: succeeded!" 1>&2
805 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700806 fi
807fi
808
jeffhao5d1ac922011-09-29 17:41:15 -0700809(
Alex Lightbfac14a2014-07-30 09:41:21 -0700810 if [ "$good" != "yes" -a "$update_mode" != "yes" ]; then
jeffhao5d1ac922011-09-29 17:41:15 -0700811 echo "${test_dir}: FAILED!"
812 echo ' '
813 echo '#################### info'
814 cat "${td_info}" | sed 's/^/# /g'
815 echo '#################### diffs'
Hiroshi Yamauchid630fd62015-09-04 12:52:03 -0700816 diff --strip-trailing-cr -u "$expected" "$output" | tail -n 3000
jeffhao5d1ac922011-09-29 17:41:15 -0700817 echo '####################'
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700818 if [ "$strace" = "yes" ]; then
819 echo '#################### strace output'
Hiroshi Yamauchid630fd62015-09-04 12:52:03 -0700820 tail -n 3000 "$tmp_dir/$strace_output"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700821 echo '####################'
822 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700823 echo ' '
824 fi
Alex Lightbfac14a2014-07-30 09:41:21 -0700825
826) 1>&2
827
828# Clean up test files.
Igor Murashkin05f30e12015-06-10 15:57:17 -0700829if [ "$always_clean" = "yes" -o "$good" = "yes" ] && [ "$never_clean" = "no" ]; then
Alex Lightbfac14a2014-07-30 09:41:21 -0700830 cd "$oldwd"
831 rm -rf "$tmp_dir"
832 if [ "$target_mode" = "yes" -a "$build_exit" = "0" ]; then
833 adb shell rm -rf $DEX_LOCATION
834 fi
835 if [ "$good" = "yes" ]; then
836 exit 0
837 fi
838fi
839
840
841(
842 if [ "$always_clean" = "yes" ]; then
843 echo "${TEST_NAME} files deleted from host "
844 if [ "$target_mode" == "yes" ]; then
845 echo "and from target"
846 fi
847 else
848 echo "${TEST_NAME} files left in ${tmp_dir} on host"
849 if [ "$target_mode" == "yes" ]; then
850 echo "and in ${DEX_LOCATION} on target"
851 fi
Brian Carlstrom105215d2012-06-14 12:50:44 -0700852 fi
853
jeffhao5d1ac922011-09-29 17:41:15 -0700854) 1>&2
855
856exit 1