blob: 1b71f33209422486a4fa64a6dd972cdda8ab1fac [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
85# If JACK_VM_COMMAND is not set, assume it launches the prebuilt jack-launcher.
86if [ -z "$JACK_VM_COMMAND" ]; then
87 if [ ! -z "$TMPDIR" ]; then
88 jack_temp_dir="-Djava.io.tmpdir=$TMPDIR"
89 fi
90 export JACK_VM_COMMAND="java -Dfile.encoding=UTF-8 -Xms2560m -XX:+TieredCompilation $jack_temp_dir -jar $ANDROID_BUILD_TOP/prebuilts/sdk/tools/jack-launcher.jar"
91fi
92
93# If JACK_CLASSPATH is not set, assume it only contains core-libart.
94if [ -z "$JACK_CLASSPATH" ]; then
95 export JACK_CLASSPATH="$ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/core-libart-hostdex_intermediates/classes.jack"
96fi
97
98# If JACK_JAR is not set, assume it is located in the prebuilts directory.
99if [ -z "$JACK_JAR" ]; then
100 export JACK_JAR="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/jack.jar"
101fi
102
103# If JILL_JAR is not set, assume it is located in the prebuilts directory.
104if [ -z "$JILL_JAR" ]; then
105 export JILL_JAR="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/jill.jar"
106fi
107
108export JACK="$JACK -g -cp $JACK_CLASSPATH"
109export JILL="java -jar $JILL_JAR"
Tsu Chiang Chuang6674f8a2013-01-16 15:41:21 -0800110
jeffhao5d1ac922011-09-29 17:41:15 -0700111info="info.txt"
112build="build"
113run="run"
114expected="expected.txt"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700115check_cmd="check"
jeffhao5d1ac922011-09-29 17:41:15 -0700116output="output.txt"
117build_output="build-output.txt"
David Brazdil24128c62015-05-21 12:06:13 +0100118cfg_output="graph.cfg"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700119strace_output="strace-output.txt"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700120lib="libartd.so"
Mathieu Chartier031768a2015-08-27 10:25:02 -0700121testlib="arttestd"
jeffhao5d1ac922011-09-29 17:41:15 -0700122run_args="--quiet"
David Brazdil4846d132015-01-15 19:07:08 +0000123build_args=""
jeffhao5d1ac922011-09-29 17:41:15 -0700124
Nicolas Geoffraya3d90fb2015-03-16 13:55:40 +0000125debuggable="no"
Alex Light9d722532014-07-22 18:07:12 -0700126prebuild_mode="yes"
Brian Carlstrom2613de42012-06-15 17:37:16 -0700127target_mode="yes"
jeffhao5d1ac922011-09-29 17:41:15 -0700128dev_mode="no"
129update_mode="no"
Alex Lighta59dd802014-07-02 16:28:08 -0700130debug_mode="no"
131relocate="yes"
Jeff Hao201803f2013-11-20 18:11:39 -0800132runtime="art"
jeffhao5d1ac922011-09-29 17:41:15 -0700133usage="no"
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700134build_only="no"
Andreas Gampe2fe07922014-04-21 07:50:39 -0700135suffix64=""
Jeff Hao85139a32014-07-23 11:52:52 -0700136trace="false"
Andreas Gampe7526d782015-06-22 22:53:45 -0700137trace_stream="false"
Alex Lighte7873ec2014-08-12 09:53:50 -0700138basic_verify="false"
139gc_verify="false"
140gc_stress="false"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700141strace="false"
Alex Lightbfac14a2014-07-30 09:41:21 -0700142always_clean="no"
Igor Murashkin05f30e12015-06-10 15:57:17 -0700143never_clean="no"
Alex Light03a112d2014-08-25 13:25:56 -0700144have_dex2oat="yes"
145have_patchoat="yes"
146have_image="yes"
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700147image_suffix=""
Andreas Gampec23c9c92014-10-28 14:47:25 -0700148pic_image_suffix=""
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000149android_root="/system"
jeffhao5d1ac922011-09-29 17:41:15 -0700150
151while true; do
152 if [ "x$1" = "x--host" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -0700153 target_mode="no"
TDYa127b92bcab2012-04-08 00:09:51 -0700154 DEX_LOCATION=$tmp_dir
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100155 run_args="${run_args} --host"
jeffhao5d1ac922011-09-29 17:41:15 -0700156 shift
Alex Lighteb7c1442015-08-31 13:17:42 -0700157 elif [ "x$1" = "x--use-java-home" ]; then
158 if [ -n "${JAVA_HOME}" ]; then
159 export JAVA="${JAVA_HOME}/bin/java"
160 export JAVAC="${JAVA_HOME}/bin/javac -g"
161 else
162 echo "Passed --use-java-home without JAVA_HOME variable set!"
163 usage="yes"
164 fi
165 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -0800166 elif [ "x$1" = "x--jvm" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -0700167 target_mode="no"
Jeff Hao201803f2013-11-20 18:11:39 -0800168 runtime="jvm"
Brian Carlstrom01afdba2014-10-03 10:28:47 -0700169 prebuild_mode="no"
Elliott Hughesc717eef2012-06-15 16:01:26 -0700170 NEED_DEX="false"
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100171 USE_JACK="false"
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100172 run_args="${run_args} --jvm"
Alex Lighteb7c1442015-08-31 13:17:42 -0700173 build_args="${build_args} --jvm"
jeffhao5d1ac922011-09-29 17:41:15 -0700174 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -0800175 elif [ "x$1" = "x-O" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700176 lib="libart.so"
Mathieu Chartier031768a2015-08-27 10:25:02 -0700177 testlib="arttest"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700178 shift
179 elif [ "x$1" = "x--dalvik" ]; then
180 lib="libdvm.so"
Jeff Hao201803f2013-11-20 18:11:39 -0800181 runtime="dalvik"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700182 shift
Alex Light03a112d2014-08-25 13:25:56 -0700183 elif [ "x$1" = "x--no-dex2oat" ]; then
184 have_dex2oat="no"
185 shift
186 elif [ "x$1" = "x--no-patchoat" ]; then
187 have_patchoat="no"
188 shift
189 elif [ "x$1" = "x--no-image" ]; then
190 have_image="no"
191 shift
Andreas Gampec23c9c92014-10-28 14:47:25 -0700192 elif [ "x$1" = "x--pic-image" ]; then
193 pic_image_suffix="-pic"
194 shift
195 elif [ "x$1" = "x--pic-test" ]; then
196 run_args="${run_args} --pic-test"
197 shift
Alex Lighta59dd802014-07-02 16:28:08 -0700198 elif [ "x$1" = "x--relocate" ]; then
199 relocate="yes"
200 shift
201 elif [ "x$1" = "x--no-relocate" ]; then
202 relocate="no"
203 shift
204 elif [ "x$1" = "x--prebuild" ]; then
Nicolas Geoffray5fd18ba2014-10-03 12:08:38 +0100205 run_args="${run_args} --prebuild"
Alex Lighta59dd802014-07-02 16:28:08 -0700206 prebuild_mode="yes"
207 shift;
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000208 elif [ "x$1" = "x--debuggable" ]; then
209 run_args="${run_args} -Xcompiler-option --debuggable"
Nicolas Geoffraya3d90fb2015-03-16 13:55:40 +0000210 debuggable="yes"
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000211 shift;
Alex Lighta59dd802014-07-02 16:28:08 -0700212 elif [ "x$1" = "x--no-prebuild" ]; then
Nicolas Geoffray5fd18ba2014-10-03 12:08:38 +0100213 run_args="${run_args} --no-prebuild"
Alex Lighta59dd802014-07-02 16:28:08 -0700214 prebuild_mode="no"
215 shift;
Alex Lighte7873ec2014-08-12 09:53:50 -0700216 elif [ "x$1" = "x--gcverify" ]; then
217 basic_verify="true"
218 gc_verify="true"
219 shift
220 elif [ "x$1" = "x--gcstress" ]; then
221 basic_verify="true"
222 gc_stress="true"
223 shift
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700224 elif [ "x$1" = "x--image" ]; then
225 shift
226 image="$1"
227 run_args="${run_args} --image $image"
Elliott Hughes7c046102011-10-19 18:16:03 -0700228 shift
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000229 elif [ "x$1" = "x-Xcompiler-option" ]; then
230 shift
231 option="$1"
232 run_args="${run_args} -Xcompiler-option $option"
233 shift
Mathieu Chartier769a5ad2014-05-18 15:30:10 -0700234 elif [ "x$1" = "x--runtime-option" ]; then
235 shift
236 option="$1"
237 run_args="${run_args} --runtime-option $option"
238 shift
Mathieu Chartierc0a8a802014-10-17 15:58:01 -0700239 elif [ "x$1" = "x--gdb-arg" ]; then
240 shift
241 gdb_arg="$1"
242 run_args="${run_args} --gdb-arg $gdb_arg"
243 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700244 elif [ "x$1" = "x--debug" ]; then
245 run_args="${run_args} --debug"
246 shift
247 elif [ "x$1" = "x--gdb" ]; then
248 run_args="${run_args} --gdb"
249 dev_mode="yes"
250 shift
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700251 elif [ "x$1" = "x--strace" ]; then
252 strace="yes"
253 run_args="${run_args} --invoke-with strace --invoke-with -o --invoke-with $tmp_dir/$strace_output"
254 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700255 elif [ "x$1" = "x--zygote" ]; then
256 run_args="${run_args} --zygote"
257 shift
jeffhao0dff3f42012-11-20 15:13:43 -0800258 elif [ "x$1" = "x--interpreter" ]; then
259 run_args="${run_args} --interpreter"
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700260 image_suffix="-interpreter"
261 shift
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800262 elif [ "x$1" = "x--jit" ]; then
263 run_args="${run_args} --jit"
Andreas Gampe8a159fd2015-09-21 15:14:38 -0700264 image_suffix="-jit"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800265 shift
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700266 elif [ "x$1" = "x--optimizing" ]; then
267 run_args="${run_args} -Xcompiler-option --compiler-backend=Optimizing"
268 image_suffix="-optimizing"
jeffhao0dff3f42012-11-20 15:13:43 -0800269 shift
Nicolas Geoffrayc9338b92014-12-03 13:36:10 +0000270 elif [ "x$1" = "x--quick" ]; then
271 run_args="${run_args} -Xcompiler-option --compiler-backend=Quick"
272 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700273 elif [ "x$1" = "x--no-verify" ]; then
274 run_args="${run_args} --no-verify"
275 shift
Igor Murashkin7617abd2015-07-10 18:27:47 -0700276 elif [ "x$1" = "x--verify-soft-fail" ]; then
277 run_args="${run_args} --verify-soft-fail"
Andreas Gampe825570c2015-07-26 10:26:03 -0700278 image_suffix="-interp-ac"
Igor Murashkin7617abd2015-07-10 18:27:47 -0700279 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700280 elif [ "x$1" = "x--no-optimize" ]; then
281 run_args="${run_args} --no-optimize"
282 shift
283 elif [ "x$1" = "x--no-precise" ]; then
284 run_args="${run_args} --no-precise"
285 shift
Elliott Hughes7c046102011-10-19 18:16:03 -0700286 elif [ "x$1" = "x--invoke-with" ]; then
287 shift
288 what="$1"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700289 if [ "x$what" = "x" ]; then
290 echo "$0 missing argument to --invoke-with" 1>&2
291 usage="yes"
292 break
293 fi
Ian Rogers0e033672013-04-19 10:22:46 -0700294 run_args="${run_args} --invoke-with ${what}"
jeffhao5d1ac922011-09-29 17:41:15 -0700295 shift
296 elif [ "x$1" = "x--dev" ]; then
297 run_args="${run_args} --dev"
298 dev_mode="yes"
299 shift
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700300 elif [ "x$1" = "x--build-only" ]; then
301 build_only="yes"
302 shift
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100303 elif [ "x$1" = "x--build-with-javac-dx" ]; then
304 USE_JACK="false"
305 shift
306 elif [ "x$1" = "x--build-with-jack" ]; then
307 USE_JACK="true"
308 shift
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700309 elif [ "x$1" = "x--output-path" ]; then
310 shift
311 tmp_dir=$1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700312 if [ "x$tmp_dir" = "x" ]; then
313 echo "$0 missing argument to --output-path" 1>&2
314 usage="yes"
315 break
316 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700317 shift
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000318 elif [ "x$1" = "x--android-root" ]; then
319 shift
320 if [ "x$1" = "x" ]; then
321 echo "$0 missing argument to --android-root" 1>&2
322 usage="yes"
323 break
324 fi
325 android_root="$1"
326 run_args="${run_args} --android-root $1"
327 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700328 elif [ "x$1" = "x--update" ]; then
329 update_mode="yes"
330 shift
331 elif [ "x$1" = "x--help" ]; then
332 usage="yes"
333 shift
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700334 elif [ "x$1" = "x--64" ]; then
335 run_args="${run_args} --64"
Andreas Gampe2fe07922014-04-21 07:50:39 -0700336 suffix64="64"
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700337 shift
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200338 elif [ "x$1" = "x--trace" ]; then
Jeff Hao85139a32014-07-23 11:52:52 -0700339 trace="true"
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200340 shift
Andreas Gampe7526d782015-06-22 22:53:45 -0700341 elif [ "x$1" = "x--stream" ]; then
342 trace_stream="true"
343 shift
Alex Lightbfac14a2014-07-30 09:41:21 -0700344 elif [ "x$1" = "x--always-clean" ]; then
345 always_clean="yes"
346 shift
Igor Murashkin05f30e12015-06-10 15:57:17 -0700347 elif [ "x$1" = "x--never-clean" ]; then
348 never_clean="yes"
349 shift
Andreas Gampee21dc3d2014-12-08 16:59:43 -0800350 elif [ "x$1" = "x--dex2oat-swap" ]; then
351 run_args="${run_args} --dex2oat-swap"
352 shift
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700353 elif [ "x$1" = "x--instruction-set-features" ]; then
354 shift
355 run_args="${run_args} --instruction-set-features $1"
356 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700357 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -0700358 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700359 usage="yes"
360 break
361 else
362 break
363 fi
364done
Andreas Gampe3a12cfe2014-08-13 15:40:22 -0700365
366# tmp_dir may be relative, resolve.
367#
368# Cannot use realpath, as it does not exist on Mac.
369# Cannot us a simple "cd", as the path might not be created yet.
Brian Carlstromc580e042014-09-08 21:37:39 -0700370# Cannot use readlink -m, as it does not exist on Mac.
371# Fallback to nuclear option:
Andreas Gampe907b6992014-08-18 22:26:49 -0700372noncanonical_tmp_dir=$tmp_dir
Brian Carlstromc580e042014-09-08 21:37:39 -0700373tmp_dir="`cd $oldwd ; python -c "import os; print os.path.realpath('$tmp_dir')"`"
Dmitry Petrochenko81c56e72014-03-05 15:05:46 +0700374mkdir -p $tmp_dir
jeffhao5d1ac922011-09-29 17:41:15 -0700375
Alex Lighte7873ec2014-08-12 09:53:50 -0700376if [ "$basic_verify" = "true" ]; then
Hiroshi Yamauchi312baf12015-01-12 12:11:05 -0800377 # Set HspaceCompactForOOMMinIntervalMs to zero to run hspace compaction for OOM more frequently in tests.
378 run_args="${run_args} --runtime-option -Xgc:preverify --runtime-option -Xgc:postverify --runtime-option -XX:HspaceCompactForOOMMinIntervalMs=0"
Alex Lighte7873ec2014-08-12 09:53:50 -0700379fi
380if [ "$gc_verify" = "true" ]; then
381 run_args="${run_args} --runtime-option -Xgc:preverify_rosalloc --runtime-option -Xgc:postverify_rosalloc"
382fi
383if [ "$gc_stress" = "true" ]; then
Mathieu Chartiereb193622015-06-27 15:42:27 -0700384 run_args="${run_args} --runtime-option -Xgc:SS,gcstress --runtime-option -Xms2m --runtime-option -Xmx16m"
Alex Lighte7873ec2014-08-12 09:53:50 -0700385fi
Jeff Hao85139a32014-07-23 11:52:52 -0700386if [ "$trace" = "true" ]; then
Andreas Gampe7526d782015-06-22 22:53:45 -0700387 run_args="${run_args} --runtime-option -Xmethod-trace --runtime-option -Xmethod-trace-file-size:2000000"
388 if [ "$trace_stream" = "true" ]; then
389 # Streaming mode uses the file size as the buffer size. So output gets really large. Drop
390 # the ability to analyze the file and just write to /dev/null.
391 run_args="${run_args} --runtime-option -Xmethod-trace-file:/dev/null"
392 # Enable streaming mode.
393 run_args="${run_args} --runtime-option -Xmethod-trace-stream"
394 else
395 run_args="${run_args} --runtime-option -Xmethod-trace-file:${DEX_LOCATION}/trace.bin"
396 fi
397elif [ "$trace_stream" = "true" ]; then
398 echo "Cannot use --stream without --trace."
399 exit 1
Jeff Hao85139a32014-07-23 11:52:52 -0700400fi
401
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700402# Most interesting target architecture variables are Makefile variables, not environment variables.
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100403# 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 +0100404function guess_target_arch_name() {
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100405 grep32bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm|x86|mips)$'`
Andreas Gampe1a5c4062015-01-15 12:10:47 -0800406 grep64bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm64|x86_64|mips64)$'`
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700407 if [ "x${suffix64}" = "x64" ]; then
408 target_arch_name=${grep64bit}
409 else
410 target_arch_name=${grep32bit}
411 fi
412}
413
David Brazdil853a4c32015-09-28 16:15:50 +0100414function guess_host_arch_name() {
415 if [ "x${suffix64}" = "x64" ]; then
416 host_arch_name="x86_64"
417 else
418 host_arch_name="x86"
419 fi
420}
421
Alex Lighta59dd802014-07-02 16:28:08 -0700422if [ "$target_mode" = "no" ]; then
423 if [ "$runtime" = "jvm" ]; then
Alex Lighta59dd802014-07-02 16:28:08 -0700424 if [ "$prebuild_mode" = "yes" ]; then
425 echo "--prebuild with --jvm is unsupported";
426 exit 1;
427 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700428 fi
429fi
430
Alex Light03a112d2014-08-25 13:25:56 -0700431if [ "$have_patchoat" = "no" ]; then
432 run_args="${run_args} --no-patchoat"
433fi
434
435if [ "$have_dex2oat" = "no" ]; then
436 run_args="${run_args} --no-dex2oat"
437fi
438
Jeff Hao201803f2013-11-20 18:11:39 -0800439if [ ! "$runtime" = "jvm" ]; then
440 run_args="${run_args} --lib $lib"
441fi
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700442
Jeff Hao201803f2013-11-20 18:11:39 -0800443if [ "$runtime" = "dalvik" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700444 if [ "$target_mode" = "no" ]; then
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100445 framework="${ANDROID_PRODUCT_OUT}/system/framework"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700446 bpath="${framework}/core.jar:${framework}/conscrypt.jar:${framework}/okhttp.jar:${framework}/core-junit.jar:${framework}/bouncycastle.jar:${framework}/ext.jar"
447 run_args="${run_args} --boot -Xbootclasspath:${bpath}"
448 else
449 true # defaults to using target BOOTCLASSPATH
450 fi
Jeff Hao201803f2013-11-20 18:11:39 -0800451elif [ "$runtime" = "art" ]; then
452 if [ "$target_mode" = "no" ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100453 # ANDROID_HOST_OUT is not set in a build environment.
Brian Carlstrom43534862014-02-19 01:13:52 -0800454 if [ -z "$ANDROID_HOST_OUT" ]; then
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100455 export ANDROID_HOST_OUT=$ANDROID_BUILD_TOP/out/host/linux-x86
Brian Carlstrom43534862014-02-19 01:13:52 -0800456 fi
David Brazdil853a4c32015-09-28 16:15:50 +0100457 guess_host_arch_name
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000458 run_args="${run_args} --boot ${ANDROID_HOST_OUT}/framework/core${image_suffix}${pic_image_suffix}.art"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700459 run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib${suffix64}"
Jeff Hao201803f2013-11-20 18:11:39 -0800460 else
David Brazdil853a4c32015-09-28 16:15:50 +0100461 guess_target_arch_name
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700462 run_args="${run_args} --runtime-option -Djava.library.path=/data/art-test/${target_arch_name}"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000463 run_args="${run_args} --boot /data/art-test/core${image_suffix}${pic_image_suffix}.art"
Jeff Hao201803f2013-11-20 18:11:39 -0800464 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700465 if [ "$relocate" = "yes" ]; then
466 run_args="${run_args} --relocate"
467 else
468 run_args="${run_args} --no-relocate"
469 fi
Andreas Gampe3f1dc562015-05-18 15:52:22 -0700470elif [ "$runtime" = "jvm" ]; then
471 # TODO: Detect whether the host is 32-bit or 64-bit.
472 run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib64"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700473fi
474
Alex Light03a112d2014-08-25 13:25:56 -0700475if [ "$have_image" = "no" ]; then
Alex Light1ef4ce82014-08-27 11:13:47 -0700476 if [ "$runtime" != "art" ]; then
477 echo "--no-image is only supported on the art runtime"
478 exit 1
479 fi
480 if [ "$target_mode" = "no" ]; then
481 framework="${ANDROID_HOST_OUT}/framework"
482 bpath_suffix="-hostdex"
483 else
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000484 framework="${android_root}/framework"
Alex Light1ef4ce82014-08-27 11:13:47 -0700485 bpath_suffix=""
486 fi
487 # TODO If the target was compiled WITH_DEXPREOPT=true then these tests will
488 # fail since these jar files will be stripped.
489 bpath="${framework}/core-libart${bpath_suffix}.jar"
490 bpath="${bpath}:${framework}/conscrypt${bpath_suffix}.jar"
491 bpath="${bpath}:${framework}/okhttp${bpath_suffix}.jar"
492 bpath="${bpath}:${framework}/core-junit${bpath_suffix}.jar"
493 bpath="${bpath}:${framework}/bouncycastle${bpath_suffix}.jar"
494 # Pass down the bootclasspath
495 run_args="${run_args} --runtime-option -Xbootclasspath:${bpath}"
Alex Light03a112d2014-08-25 13:25:56 -0700496 run_args="${run_args} --no-image"
497fi
498
jeffhao5d1ac922011-09-29 17:41:15 -0700499if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then
500 echo "--dev and --update are mutually exclusive" 1>&2
501 usage="yes"
502fi
503
504if [ "$usage" = "no" ]; then
505 if [ "x$1" = "x" -o "x$1" = "x-" ]; then
506 test_dir=`basename "$oldwd"`
507 else
508 test_dir="$1"
509 fi
510
511 if [ '!' -d "$test_dir" ]; then
512 td2=`echo ${test_dir}-*`
513 if [ '!' -d "$td2" ]; then
514 echo "${test_dir}: no such test directory" 1>&2
515 usage="yes"
516 fi
517 test_dir="$td2"
518 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700519 # Shift to get rid of the test name argument. The rest of the arguments
520 # will get passed to the test run.
521 shift
522fi
523
524if [ "$usage" = "yes" ]; then
525 prog=`basename $prog`
526 (
527 echo "usage:"
528 echo " $prog --help Print this message."
529 echo " $prog [options] [test-name] Run test normally."
530 echo " $prog --dev [options] [test-name] Development mode" \
531 "(dumps to stdout)."
532 echo " $prog --update [options] [test-name] Update mode" \
533 "(replaces expected.txt)."
534 echo ' Omitting the test name or specifying "-" will use the' \
535 "current directory."
536 echo " Runtime Options:"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000537 echo " -O Run non-debug rather than debug build (off by default)."
538 echo " -Xcompiler-option Pass an option to the compiler."
539 echo " --runtime-option Pass an option to the runtime."
540 echo " --debug Wait for a debugger to attach."
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000541 echo " --debuggable Whether to compile Java code for a debugger."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000542 echo " --gdb Run under gdb; incompatible with some tests."
543 echo " --build-only Build test files only (off by default)."
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100544 echo " --build-with-javac-dx Build test files with javac and dx (on by default)."
545 echo " --build-with-jack Build test files with jack and jill (off by default)."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000546 echo " --interpreter Enable interpreter only mode (off by default)."
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800547 echo " --jit Enable jit (off by default)."
Nicolas Geoffray0e071252015-03-21 13:43:15 +0000548 echo " --optimizing Enable optimizing compiler (default)."
549 echo " --quick Use Quick compiler (off by default)."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000550 echo " --no-verify Turn off verification (on by default)."
Igor Murashkin7617abd2015-07-10 18:27:47 -0700551 echo " --verify-soft-fail Force soft fail verification (off by default)."
552 echo " Verification is enabled if neither --no-verify"
553 echo " nor --verify-soft-fail is specified."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000554 echo " --no-optimize Turn off optimization (on by default)."
555 echo " --no-precise Turn off precise GC (on by default)."
556 echo " --zygote Spawn the process from the Zygote." \
jeffhao5d1ac922011-09-29 17:41:15 -0700557 "If used, then the"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000558 echo " other runtime options are ignored."
559 echo " --no-dex2oat Run as though dex2oat was failing."
560 echo " --no-patchoat Run as though patchoat was failing."
561 echo " --prebuild Run dex2oat on the files before starting test. (default)"
562 echo " --no-prebuild Do not run dex2oat on the files before starting"
563 echo " the test."
564 echo " --relocate Force the use of relocating in the test, making"
565 echo " the image and oat files be relocated to a random"
566 echo " address before running. (default)"
567 echo " --no-relocate Force the use of no relocating in the test"
568 echo " --host Use the host-mode virtual machine."
569 echo " --invoke-with Pass --invoke-with option to runtime."
570 echo " --dalvik Use Dalvik (off by default)."
571 echo " --jvm Use a host-local RI virtual machine."
Alex Lighteb7c1442015-08-31 13:17:42 -0700572 echo " --use-java-home Use the JAVA_HOME environment variable"
573 echo " to find the java compiler and runtime"
574 echo " (if applicable) to run the test with."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000575 echo " --output-path [path] Location where to store the build" \
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700576 "files."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000577 echo " --64 Run the test in 64-bit mode"
578 echo " --trace Run with method tracing"
Andreas Gampe7526d782015-06-22 22:53:45 -0700579 echo " --stream Run method tracing in streaming mode (requires --trace)"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000580 echo " --gcstress Run with gc stress testing"
581 echo " --gcverify Run with gc verification"
582 echo " --always-clean Delete the test files even if the test fails."
Igor Murashkin05f30e12015-06-10 15:57:17 -0700583 echo " --never-clean Keep the test files even if the test succeeds."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000584 echo " --android-root [path] The path on target for the android root. (/system by default)."
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000585 echo " --dex2oat-swap Use a dex2oat swap file."
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700586 echo " --instruction-set-features [string]"
587 echo " Set instruction-set-features for compilation."
jeffhao5d1ac922011-09-29 17:41:15 -0700588 ) 1>&2
589 exit 1
590fi
591
592cd "$test_dir"
593test_dir=`pwd`
594
595td_info="${test_dir}/${info}"
596td_expected="${test_dir}/${expected}"
597
Brian Carlstrom22469aa2012-09-07 10:34:57 -0700598if [ ! -r $td_info ]; then
599 echo "${test_dir}: missing file $td_info" 1>&2
600 exit 1
601fi
602
603if [ ! -r $td_expected ]; then
604 echo "${test_dir}: missing file $td_expected" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700605 exit 1
606fi
607
608# copy the test to a temp dir and run it
609
Elliott Hughes510c8782011-10-06 10:57:34 -0700610echo "${test_dir}: building..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700611
612rm -rf "$tmp_dir"
613cp -Rp "$test_dir" "$tmp_dir"
614cd "$tmp_dir"
615
616if [ '!' -r "$build" ]; then
617 cp "${progdir}/etc/default-build" build
Zheng Xuc6667102015-05-15 16:08:45 +0800618else
619 cp "${progdir}/etc/default-build" .
jeffhao5d1ac922011-09-29 17:41:15 -0700620fi
621
622if [ '!' -r "$run" ]; then
623 cp "${progdir}/etc/default-run" run
Zheng Xuc6667102015-05-15 16:08:45 +0800624else
625 cp "${progdir}/etc/default-run" .
jeffhao5d1ac922011-09-29 17:41:15 -0700626fi
627
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700628if [ '!' -r "$check_cmd" ]; then
629 cp "${progdir}/etc/default-check" check
Zheng Xuc6667102015-05-15 16:08:45 +0800630else
631 cp "${progdir}/etc/default-check" .
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700632fi
633
jeffhao5d1ac922011-09-29 17:41:15 -0700634chmod 755 "$build"
635chmod 755 "$run"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700636chmod 755 "$check_cmd"
jeffhao5d1ac922011-09-29 17:41:15 -0700637
Elliott Hughes8cbc8bc2011-10-04 11:19:45 -0700638export TEST_NAME=`basename ${test_dir}`
639
David Brazdil4846d132015-01-15 19:07:08 +0000640# Tests named '<number>-checker-*' will also have their CFGs verified with
641# Checker when compiled with Optimizing on host.
642if [[ "$TEST_NAME" =~ ^[0-9]+-checker- ]]; then
643 # Build Checker DEX files without dx's optimizations so the input to dex2oat
644 # better resembles the Java source. We always build the DEX the same way, even
645 # if Checker is not invoked and the test only runs the program.
646 build_args="${build_args} --dx-option --no-optimize"
647
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100648 # Jack does not necessarily generate the same DEX output than dx. Because these tests depend
649 # on a particular DEX output, keep building them with dx for now (b/19467889).
650 USE_JACK="false"
651
David Brazdil5cc343d2015-10-08 11:35:32 +0100652 if [ "$runtime" = "art" -a "$image_suffix" = "-optimizing" ]; then
David Brazdil80fb3942015-07-23 11:53:42 +0100653 # In no-prebuild mode, the compiler is only invoked if both dex2oat and
654 # patchoat are available. Disable Checker otherwise (b/22552692).
655 if [ "$prebuild_mode" = "yes" ] || [ "$have_patchoat" = "yes" -a "$have_dex2oat" = "yes" ]; then
656 run_checker="yes"
David Brazdil5cc343d2015-10-08 11:35:32 +0100657
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100658 if [ "$target_mode" = "no" ]; then
659 cfg_output_dir="$tmp_dir"
David Brazdil5cc343d2015-10-08 11:35:32 +0100660 checker_args="--arch=${host_arch_name^^}"
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100661 else
662 cfg_output_dir="$DEX_LOCATION"
David Brazdil5cc343d2015-10-08 11:35:32 +0100663 checker_args="--arch=${target_arch_name^^}"
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100664 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100665
666 if [ "$debuggable" = "yes" ]; then
667 checker_args="$checker_args --debuggable"
668 fi
669
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100670 run_args="${run_args} -Xcompiler-option --dump-cfg=$cfg_output_dir/$cfg_output \
David Brazdil80fb3942015-07-23 11:53:42 +0100671 -Xcompiler-option -j1"
672 fi
David Brazdil4846d132015-01-15 19:07:08 +0000673 fi
674fi
675
Mathieu Chartier031768a2015-08-27 10:25:02 -0700676if [ "$runtime" != "jvm" ]; then
677 run_args="${run_args} --testlib ${testlib}"
678fi
679
Ian Rogers997f0f92014-06-21 22:58:05 -0700680# 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 +0100681build_file_size_limit=2048
682run_file_size_limit=2048
Ian Rogers997f0f92014-06-21 22:58:05 -0700683if echo "$test_dir" | grep 089; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100684 build_file_size_limit=5120
685 run_file_size_limit=5120
Ian Rogers997f0f92014-06-21 22:58:05 -0700686elif echo "$test_dir" | grep 083; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100687 build_file_size_limit=5120
688 run_file_size_limit=5120
Ian Rogers997f0f92014-06-21 22:58:05 -0700689fi
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100690if [ "$run_checker" = "yes" -a "$target_mode" = "yes" ]; then
691 # We will need to `adb pull` the .cfg output from the target onto the host to
692 # run checker on it. This file can be big.
693 build_file_size_limit=16384
694 run_file_size_limit=16384
695fi
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100696if [ ${USE_JACK} = "false" ]; then
697 # Set ulimit if we build with dx only, Jack can generate big temp files.
698 if ! ulimit -S "$build_file_size_limit"; then
699 echo "ulimit file size setting failed"
700 fi
Ian Rogers997f0f92014-06-21 22:58:05 -0700701fi
702
jeffhao5d1ac922011-09-29 17:41:15 -0700703good="no"
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000704good_build="yes"
705good_run="yes"
jeffhao5d1ac922011-09-29 17:41:15 -0700706if [ "$dev_mode" = "yes" ]; then
David Brazdil4846d132015-01-15 19:07:08 +0000707 "./${build}" $build_args 2>&1
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700708 build_exit="$?"
709 echo "build exit status: $build_exit" 1>&2
710 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100711 if ! ulimit -S "$run_file_size_limit"; then
712 echo "ulimit file size setting failed"
713 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800714 echo "${test_dir}: running..." 1>&2
715 "./${run}" $run_args "$@" 2>&1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700716 run_exit="$?"
Calin Juravle3cf48772015-01-26 16:47:33 +0000717
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800718 if [ "$run_exit" = "0" ]; then
Calin Juravle3cf48772015-01-26 16:47:33 +0000719 if [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100720 if [ "$target_mode" = "yes" ]; then
721 adb pull $cfg_output_dir/$cfg_output &> /dev/null
722 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100723 "$checker" $checker_args "$cfg_output" "$tmp_dir" 2>&1
Calin Juravle3cf48772015-01-26 16:47:33 +0000724 checker_exit="$?"
725 if [ "$checker_exit" = "0" ]; then
726 good="yes"
727 fi
728 echo "checker exit status: $checker_exit" 1>&2
729 else
730 good="yes"
731 fi
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800732 fi
Calin Juravle3cf48772015-01-26 16:47:33 +0000733 echo "run exit status: $run_exit" 1>&2
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700734 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700735elif [ "$update_mode" = "yes" ]; then
David Brazdil4846d132015-01-15 19:07:08 +0000736 "./${build}" $build_args >"$build_output" 2>&1
jeffhao5d1ac922011-09-29 17:41:15 -0700737 build_exit="$?"
738 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100739 if ! ulimit -S "$run_file_size_limit"; then
740 echo "ulimit file size setting failed"
741 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800742 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700743 "./${run}" $run_args "$@" >"$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000744 if [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100745 if [ "$target_mode" = "yes" ]; then
746 adb pull $cfg_output_dir/$cfg_output &> /dev/null
747 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100748 "$checker" -q $checker_args "$cfg_output" "$tmp_dir" >> "$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000749 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700750 sed -e 's/[[:cntrl:]]$//g' < "$output" >"${td_expected}"
751 good="yes"
752 else
753 cat "$build_output" 1>&2
754 echo "build exit status: $build_exit" 1>&2
755 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700756elif [ "$build_only" = "yes" ]; then
757 good="yes"
David Brazdil4846d132015-01-15 19:07:08 +0000758 "./${build}" $build_args >"$build_output" 2>&1
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700759 build_exit="$?"
760 if [ "$build_exit" '!=' '0' ]; then
761 cp "$build_output" "$output"
762 echo "build exit status: $build_exit" >>"$output"
763 diff --strip-trailing-cr -q "$expected" "$output" >/dev/null
764 if [ "$?" '!=' "0" ]; then
765 good="no"
766 echo "BUILD FAILED For ${TEST_NAME}"
767 fi
768 fi
Tsu Chiang Chuang379e2f52013-08-20 12:24:52 -0700769 # Clean up extraneous files that are not used by tests.
Tsu Chiang Chuang0160d992013-09-13 14:17:42 -0700770 find $tmp_dir -mindepth 1 ! -regex ".*/\(.*jar\|$output\|$expected\)" | xargs rm -rf
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700771 exit 0
jeffhao5d1ac922011-09-29 17:41:15 -0700772else
David Brazdil4846d132015-01-15 19:07:08 +0000773 "./${build}" $build_args >"$build_output" 2>&1
jeffhao5d1ac922011-09-29 17:41:15 -0700774 build_exit="$?"
775 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100776 if ! ulimit -S "$run_file_size_limit"; then
777 echo "ulimit file size setting failed"
778 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800779 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700780 "./${run}" $run_args "$@" >"$output" 2>&1
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000781 run_exit="$?"
782 if [ "$run_exit" != "0" ]; then
783 echo "run exit status: $run_exit" 1>&2
784 good_run="no"
David Brazdil4846d132015-01-15 19:07:08 +0000785 elif [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100786 if [ "$target_mode" = "yes" ]; then
787 adb pull $cfg_output_dir/$cfg_output &> /dev/null
788 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100789 "$checker" -q $checker_args "$cfg_output" "$tmp_dir" >> "$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000790 checker_exit="$?"
791 if [ "$checker_exit" != "0" ]; then
792 echo "checker exit status: $checker_exit" 1>&2
793 good_run="no"
794 else
795 good_run="yes"
796 fi
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000797 else
798 good_run="yes"
799 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700800 else
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000801 good_build="no"
jeffhao5d1ac922011-09-29 17:41:15 -0700802 cp "$build_output" "$output"
Andreas Gampef6930a82014-10-21 09:33:08 -0700803 echo "Failed to build in tmpdir=${tmp_dir} from oldwd=${oldwd} and cwd=`pwd`" >> "$output"
804 echo "Non-canonical tmpdir was ${noncanonical_tmp_dir}" >> "$output"
Ian Rogersd9ad27d2014-10-27 13:48:21 -0700805 echo "Args: ${args}" >> "$output"
Andreas Gampef6930a82014-10-21 09:33:08 -0700806 echo "build exit status: $build_exit" >> "$output"
Andreas Gampe5c114902014-10-27 17:03:58 -0700807 max_name_length=$(getconf NAME_MAX ${tmp_dir})
808 echo "Max filename (NAME_MAX): ${max_name_length}" >> "$output"
809 max_path_length=$(getconf PATH_MAX ${tmp_dir})
Andreas Gampe602fbcd2014-10-27 17:06:29 -0700810 echo "Max pathlength (PATH_MAX): ${max_path_length}" >> "$output"
jeffhao5d1ac922011-09-29 17:41:15 -0700811 fi
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700812 ./$check_cmd "$expected" "$output"
jeffhao5d1ac922011-09-29 17:41:15 -0700813 if [ "$?" = "0" ]; then
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000814 if [ "$good_build" = "no" -o "$good_run" = "yes" ]; then
815 # output == expected
816 good="yes"
817 echo "${test_dir}: succeeded!" 1>&2
818 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700819 fi
820fi
821
jeffhao5d1ac922011-09-29 17:41:15 -0700822(
Alex Lightbfac14a2014-07-30 09:41:21 -0700823 if [ "$good" != "yes" -a "$update_mode" != "yes" ]; then
jeffhao5d1ac922011-09-29 17:41:15 -0700824 echo "${test_dir}: FAILED!"
825 echo ' '
826 echo '#################### info'
827 cat "${td_info}" | sed 's/^/# /g'
828 echo '#################### diffs'
Hiroshi Yamauchid630fd62015-09-04 12:52:03 -0700829 diff --strip-trailing-cr -u "$expected" "$output" | tail -n 3000
jeffhao5d1ac922011-09-29 17:41:15 -0700830 echo '####################'
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700831 if [ "$strace" = "yes" ]; then
832 echo '#################### strace output'
Hiroshi Yamauchid630fd62015-09-04 12:52:03 -0700833 tail -n 3000 "$tmp_dir/$strace_output"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700834 echo '####################'
835 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700836 echo ' '
837 fi
Alex Lightbfac14a2014-07-30 09:41:21 -0700838
839) 1>&2
840
841# Clean up test files.
Igor Murashkin05f30e12015-06-10 15:57:17 -0700842if [ "$always_clean" = "yes" -o "$good" = "yes" ] && [ "$never_clean" = "no" ]; then
Alex Lightbfac14a2014-07-30 09:41:21 -0700843 cd "$oldwd"
844 rm -rf "$tmp_dir"
845 if [ "$target_mode" = "yes" -a "$build_exit" = "0" ]; then
846 adb shell rm -rf $DEX_LOCATION
847 fi
848 if [ "$good" = "yes" ]; then
849 exit 0
850 fi
851fi
852
853
854(
855 if [ "$always_clean" = "yes" ]; then
856 echo "${TEST_NAME} files deleted from host "
857 if [ "$target_mode" == "yes" ]; then
858 echo "and from target"
859 fi
860 else
861 echo "${TEST_NAME} files left in ${tmp_dir} on host"
862 if [ "$target_mode" == "yes" ]; then
863 echo "and in ${DEX_LOCATION} on target"
864 fi
Brian Carlstrom105215d2012-06-14 12:50:44 -0700865 fi
866
jeffhao5d1ac922011-09-29 17:41:15 -0700867) 1>&2
868
869exit 1