blob: 2892ce9f18d2b5d6fd5ad444e9f3979b3da8217a [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 -070043
44export JAVA="java"
Brian Carlstrom5103ce62014-03-30 16:17:42 -070045export JAVAC="javac -g"
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +010046export RUN="${progdir}/etc/run-test-jar"
Brian Carlstrom105215d2012-06-14 12:50:44 -070047export DEX_LOCATION=/data/run-test/${test_dir}
Elliott Hughesc717eef2012-06-15 16:01:26 -070048export NEED_DEX="true"
Sebastien Hertz19ac0272015-02-24 17:39:50 +010049export USE_JACK="false"
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
76# If the tree is compiled with Jack, build test with Jack by default.
77if [ "$ANDROID_COMPILE_WITH_JACK" = "true" ]; then
78 USE_JACK="true"
79fi
80
81# ANDROID_BUILD_TOP is not set in a build environment.
82if [ -z "$ANDROID_BUILD_TOP" ]; then
83 export ANDROID_BUILD_TOP=$oldwd
84fi
85
86# If JACK_VM_COMMAND is not set, assume it launches the prebuilt jack-launcher.
87if [ -z "$JACK_VM_COMMAND" ]; then
88 if [ ! -z "$TMPDIR" ]; then
89 jack_temp_dir="-Djava.io.tmpdir=$TMPDIR"
90 fi
91 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"
92fi
93
94# If JACK_CLASSPATH is not set, assume it only contains core-libart.
95if [ -z "$JACK_CLASSPATH" ]; then
96 export JACK_CLASSPATH="$ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/core-libart-hostdex_intermediates/classes.jack"
97fi
98
99# If JACK_JAR is not set, assume it is located in the prebuilts directory.
100if [ -z "$JACK_JAR" ]; then
101 export JACK_JAR="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/jack.jar"
102fi
103
104# If JILL_JAR is not set, assume it is located in the prebuilts directory.
105if [ -z "$JILL_JAR" ]; then
106 export JILL_JAR="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/jill.jar"
107fi
108
109export JACK="$JACK -g -cp $JACK_CLASSPATH"
110export JILL="java -jar $JILL_JAR"
Tsu Chiang Chuang6674f8a2013-01-16 15:41:21 -0800111
jeffhao5d1ac922011-09-29 17:41:15 -0700112info="info.txt"
113build="build"
114run="run"
115expected="expected.txt"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700116check_cmd="check"
jeffhao5d1ac922011-09-29 17:41:15 -0700117output="output.txt"
118build_output="build-output.txt"
David Brazdil24128c62015-05-21 12:06:13 +0100119cfg_output="graph.cfg"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700120strace_output="strace-output.txt"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700121lib="libartd.so"
Mathieu Chartier031768a2015-08-27 10:25:02 -0700122testlib="arttestd"
jeffhao5d1ac922011-09-29 17:41:15 -0700123run_args="--quiet"
David Brazdil4846d132015-01-15 19:07:08 +0000124build_args=""
jeffhao5d1ac922011-09-29 17:41:15 -0700125
Nicolas Geoffraya3d90fb2015-03-16 13:55:40 +0000126debuggable="no"
Alex Light9d722532014-07-22 18:07:12 -0700127prebuild_mode="yes"
Brian Carlstrom2613de42012-06-15 17:37:16 -0700128target_mode="yes"
jeffhao5d1ac922011-09-29 17:41:15 -0700129dev_mode="no"
130update_mode="no"
Alex Lighta59dd802014-07-02 16:28:08 -0700131debug_mode="no"
132relocate="yes"
Jeff Hao201803f2013-11-20 18:11:39 -0800133runtime="art"
jeffhao5d1ac922011-09-29 17:41:15 -0700134usage="no"
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700135build_only="no"
Andreas Gampe2fe07922014-04-21 07:50:39 -0700136suffix64=""
Jeff Hao85139a32014-07-23 11:52:52 -0700137trace="false"
Andreas Gampe7526d782015-06-22 22:53:45 -0700138trace_stream="false"
Alex Lighte7873ec2014-08-12 09:53:50 -0700139basic_verify="false"
140gc_verify="false"
141gc_stress="false"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700142strace="false"
Alex Lightbfac14a2014-07-30 09:41:21 -0700143always_clean="no"
Igor Murashkin05f30e12015-06-10 15:57:17 -0700144never_clean="no"
Alex Light03a112d2014-08-25 13:25:56 -0700145have_dex2oat="yes"
146have_patchoat="yes"
147have_image="yes"
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700148image_suffix=""
Andreas Gampec23c9c92014-10-28 14:47:25 -0700149pic_image_suffix=""
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000150android_root="/system"
jeffhao5d1ac922011-09-29 17:41:15 -0700151
152while true; do
153 if [ "x$1" = "x--host" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -0700154 target_mode="no"
TDYa127b92bcab2012-04-08 00:09:51 -0700155 DEX_LOCATION=$tmp_dir
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100156 run_args="${run_args} --host"
jeffhao5d1ac922011-09-29 17:41:15 -0700157 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -0800158 elif [ "x$1" = "x--jvm" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -0700159 target_mode="no"
Jeff Hao201803f2013-11-20 18:11:39 -0800160 runtime="jvm"
Brian Carlstrom01afdba2014-10-03 10:28:47 -0700161 prebuild_mode="no"
Elliott Hughesc717eef2012-06-15 16:01:26 -0700162 NEED_DEX="false"
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100163 USE_JACK="false"
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100164 run_args="${run_args} --jvm"
jeffhao5d1ac922011-09-29 17:41:15 -0700165 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -0800166 elif [ "x$1" = "x-O" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700167 lib="libart.so"
Mathieu Chartier031768a2015-08-27 10:25:02 -0700168 testlib="arttest"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700169 shift
170 elif [ "x$1" = "x--dalvik" ]; then
171 lib="libdvm.so"
Jeff Hao201803f2013-11-20 18:11:39 -0800172 runtime="dalvik"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700173 shift
Alex Light03a112d2014-08-25 13:25:56 -0700174 elif [ "x$1" = "x--no-dex2oat" ]; then
175 have_dex2oat="no"
176 shift
177 elif [ "x$1" = "x--no-patchoat" ]; then
178 have_patchoat="no"
179 shift
180 elif [ "x$1" = "x--no-image" ]; then
181 have_image="no"
182 shift
Andreas Gampec23c9c92014-10-28 14:47:25 -0700183 elif [ "x$1" = "x--pic-image" ]; then
184 pic_image_suffix="-pic"
185 shift
186 elif [ "x$1" = "x--pic-test" ]; then
187 run_args="${run_args} --pic-test"
188 shift
Alex Lighta59dd802014-07-02 16:28:08 -0700189 elif [ "x$1" = "x--relocate" ]; then
190 relocate="yes"
191 shift
192 elif [ "x$1" = "x--no-relocate" ]; then
193 relocate="no"
194 shift
195 elif [ "x$1" = "x--prebuild" ]; then
Nicolas Geoffray5fd18ba2014-10-03 12:08:38 +0100196 run_args="${run_args} --prebuild"
Alex Lighta59dd802014-07-02 16:28:08 -0700197 prebuild_mode="yes"
198 shift;
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000199 elif [ "x$1" = "x--debuggable" ]; then
200 run_args="${run_args} -Xcompiler-option --debuggable"
Nicolas Geoffraya3d90fb2015-03-16 13:55:40 +0000201 debuggable="yes"
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000202 shift;
Alex Lighta59dd802014-07-02 16:28:08 -0700203 elif [ "x$1" = "x--no-prebuild" ]; then
Nicolas Geoffray5fd18ba2014-10-03 12:08:38 +0100204 run_args="${run_args} --no-prebuild"
Alex Lighta59dd802014-07-02 16:28:08 -0700205 prebuild_mode="no"
206 shift;
Alex Lighte7873ec2014-08-12 09:53:50 -0700207 elif [ "x$1" = "x--gcverify" ]; then
208 basic_verify="true"
209 gc_verify="true"
210 shift
211 elif [ "x$1" = "x--gcstress" ]; then
212 basic_verify="true"
213 gc_stress="true"
214 shift
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700215 elif [ "x$1" = "x--image" ]; then
216 shift
217 image="$1"
218 run_args="${run_args} --image $image"
Elliott Hughes7c046102011-10-19 18:16:03 -0700219 shift
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000220 elif [ "x$1" = "x-Xcompiler-option" ]; then
221 shift
222 option="$1"
223 run_args="${run_args} -Xcompiler-option $option"
224 shift
Mathieu Chartier769a5ad2014-05-18 15:30:10 -0700225 elif [ "x$1" = "x--runtime-option" ]; then
226 shift
227 option="$1"
228 run_args="${run_args} --runtime-option $option"
229 shift
Mathieu Chartierc0a8a802014-10-17 15:58:01 -0700230 elif [ "x$1" = "x--gdb-arg" ]; then
231 shift
232 gdb_arg="$1"
233 run_args="${run_args} --gdb-arg $gdb_arg"
234 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700235 elif [ "x$1" = "x--debug" ]; then
236 run_args="${run_args} --debug"
237 shift
238 elif [ "x$1" = "x--gdb" ]; then
239 run_args="${run_args} --gdb"
240 dev_mode="yes"
241 shift
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700242 elif [ "x$1" = "x--strace" ]; then
243 strace="yes"
244 run_args="${run_args} --invoke-with strace --invoke-with -o --invoke-with $tmp_dir/$strace_output"
245 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700246 elif [ "x$1" = "x--zygote" ]; then
247 run_args="${run_args} --zygote"
248 shift
jeffhao0dff3f42012-11-20 15:13:43 -0800249 elif [ "x$1" = "x--interpreter" ]; then
250 run_args="${run_args} --interpreter"
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700251 image_suffix="-interpreter"
252 shift
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800253 elif [ "x$1" = "x--jit" ]; then
254 run_args="${run_args} --jit"
Andreas Gampe8a159fd2015-09-21 15:14:38 -0700255 image_suffix="-jit"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800256 shift
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700257 elif [ "x$1" = "x--optimizing" ]; then
258 run_args="${run_args} -Xcompiler-option --compiler-backend=Optimizing"
259 image_suffix="-optimizing"
jeffhao0dff3f42012-11-20 15:13:43 -0800260 shift
Nicolas Geoffrayc9338b92014-12-03 13:36:10 +0000261 elif [ "x$1" = "x--quick" ]; then
262 run_args="${run_args} -Xcompiler-option --compiler-backend=Quick"
263 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700264 elif [ "x$1" = "x--no-verify" ]; then
265 run_args="${run_args} --no-verify"
266 shift
Igor Murashkin7617abd2015-07-10 18:27:47 -0700267 elif [ "x$1" = "x--verify-soft-fail" ]; then
268 run_args="${run_args} --verify-soft-fail"
Andreas Gampe825570c2015-07-26 10:26:03 -0700269 image_suffix="-interp-ac"
Igor Murashkin7617abd2015-07-10 18:27:47 -0700270 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700271 elif [ "x$1" = "x--no-optimize" ]; then
272 run_args="${run_args} --no-optimize"
273 shift
274 elif [ "x$1" = "x--no-precise" ]; then
275 run_args="${run_args} --no-precise"
276 shift
Elliott Hughes7c046102011-10-19 18:16:03 -0700277 elif [ "x$1" = "x--invoke-with" ]; then
278 shift
279 what="$1"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700280 if [ "x$what" = "x" ]; then
281 echo "$0 missing argument to --invoke-with" 1>&2
282 usage="yes"
283 break
284 fi
Ian Rogers0e033672013-04-19 10:22:46 -0700285 run_args="${run_args} --invoke-with ${what}"
jeffhao5d1ac922011-09-29 17:41:15 -0700286 shift
287 elif [ "x$1" = "x--dev" ]; then
288 run_args="${run_args} --dev"
289 dev_mode="yes"
290 shift
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700291 elif [ "x$1" = "x--build-only" ]; then
292 build_only="yes"
293 shift
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100294 elif [ "x$1" = "x--build-with-javac-dx" ]; then
295 USE_JACK="false"
296 shift
297 elif [ "x$1" = "x--build-with-jack" ]; then
298 USE_JACK="true"
299 shift
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700300 elif [ "x$1" = "x--output-path" ]; then
301 shift
302 tmp_dir=$1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700303 if [ "x$tmp_dir" = "x" ]; then
304 echo "$0 missing argument to --output-path" 1>&2
305 usage="yes"
306 break
307 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700308 shift
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000309 elif [ "x$1" = "x--android-root" ]; then
310 shift
311 if [ "x$1" = "x" ]; then
312 echo "$0 missing argument to --android-root" 1>&2
313 usage="yes"
314 break
315 fi
316 android_root="$1"
317 run_args="${run_args} --android-root $1"
318 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700319 elif [ "x$1" = "x--update" ]; then
320 update_mode="yes"
321 shift
322 elif [ "x$1" = "x--help" ]; then
323 usage="yes"
324 shift
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700325 elif [ "x$1" = "x--64" ]; then
326 run_args="${run_args} --64"
Andreas Gampe2fe07922014-04-21 07:50:39 -0700327 suffix64="64"
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700328 shift
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200329 elif [ "x$1" = "x--trace" ]; then
Jeff Hao85139a32014-07-23 11:52:52 -0700330 trace="true"
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200331 shift
Andreas Gampe7526d782015-06-22 22:53:45 -0700332 elif [ "x$1" = "x--stream" ]; then
333 trace_stream="true"
334 shift
Alex Lightbfac14a2014-07-30 09:41:21 -0700335 elif [ "x$1" = "x--always-clean" ]; then
336 always_clean="yes"
337 shift
Igor Murashkin05f30e12015-06-10 15:57:17 -0700338 elif [ "x$1" = "x--never-clean" ]; then
339 never_clean="yes"
340 shift
Andreas Gampee21dc3d2014-12-08 16:59:43 -0800341 elif [ "x$1" = "x--dex2oat-swap" ]; then
342 run_args="${run_args} --dex2oat-swap"
343 shift
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700344 elif [ "x$1" = "x--instruction-set-features" ]; then
345 shift
346 run_args="${run_args} --instruction-set-features $1"
347 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700348 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -0700349 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700350 usage="yes"
351 break
352 else
353 break
354 fi
355done
Andreas Gampe3a12cfe2014-08-13 15:40:22 -0700356
357# tmp_dir may be relative, resolve.
358#
359# Cannot use realpath, as it does not exist on Mac.
360# Cannot us a simple "cd", as the path might not be created yet.
Brian Carlstromc580e042014-09-08 21:37:39 -0700361# Cannot use readlink -m, as it does not exist on Mac.
362# Fallback to nuclear option:
Andreas Gampe907b6992014-08-18 22:26:49 -0700363noncanonical_tmp_dir=$tmp_dir
Brian Carlstromc580e042014-09-08 21:37:39 -0700364tmp_dir="`cd $oldwd ; python -c "import os; print os.path.realpath('$tmp_dir')"`"
Dmitry Petrochenko81c56e72014-03-05 15:05:46 +0700365mkdir -p $tmp_dir
jeffhao5d1ac922011-09-29 17:41:15 -0700366
Alex Lighte7873ec2014-08-12 09:53:50 -0700367if [ "$basic_verify" = "true" ]; then
Hiroshi Yamauchi312baf12015-01-12 12:11:05 -0800368 # Set HspaceCompactForOOMMinIntervalMs to zero to run hspace compaction for OOM more frequently in tests.
369 run_args="${run_args} --runtime-option -Xgc:preverify --runtime-option -Xgc:postverify --runtime-option -XX:HspaceCompactForOOMMinIntervalMs=0"
Alex Lighte7873ec2014-08-12 09:53:50 -0700370fi
371if [ "$gc_verify" = "true" ]; then
372 run_args="${run_args} --runtime-option -Xgc:preverify_rosalloc --runtime-option -Xgc:postverify_rosalloc"
373fi
374if [ "$gc_stress" = "true" ]; then
Mathieu Chartiereb193622015-06-27 15:42:27 -0700375 run_args="${run_args} --runtime-option -Xgc:SS,gcstress --runtime-option -Xms2m --runtime-option -Xmx16m"
Alex Lighte7873ec2014-08-12 09:53:50 -0700376fi
Jeff Hao85139a32014-07-23 11:52:52 -0700377if [ "$trace" = "true" ]; then
Andreas Gampe7526d782015-06-22 22:53:45 -0700378 run_args="${run_args} --runtime-option -Xmethod-trace --runtime-option -Xmethod-trace-file-size:2000000"
379 if [ "$trace_stream" = "true" ]; then
380 # Streaming mode uses the file size as the buffer size. So output gets really large. Drop
381 # the ability to analyze the file and just write to /dev/null.
382 run_args="${run_args} --runtime-option -Xmethod-trace-file:/dev/null"
383 # Enable streaming mode.
384 run_args="${run_args} --runtime-option -Xmethod-trace-stream"
385 else
386 run_args="${run_args} --runtime-option -Xmethod-trace-file:${DEX_LOCATION}/trace.bin"
387 fi
388elif [ "$trace_stream" = "true" ]; then
389 echo "Cannot use --stream without --trace."
390 exit 1
Jeff Hao85139a32014-07-23 11:52:52 -0700391fi
392
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700393# Most interesting target architecture variables are Makefile variables, not environment variables.
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100394# 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 +0100395function guess_target_arch_name() {
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100396 grep32bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm|x86|mips)$'`
Andreas Gampe1a5c4062015-01-15 12:10:47 -0800397 grep64bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm64|x86_64|mips64)$'`
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700398 if [ "x${suffix64}" = "x64" ]; then
399 target_arch_name=${grep64bit}
400 else
401 target_arch_name=${grep32bit}
402 fi
403}
404
David Brazdil853a4c32015-09-28 16:15:50 +0100405function guess_host_arch_name() {
406 if [ "x${suffix64}" = "x64" ]; then
407 host_arch_name="x86_64"
408 else
409 host_arch_name="x86"
410 fi
411}
412
Alex Lighta59dd802014-07-02 16:28:08 -0700413if [ "$target_mode" = "no" ]; then
414 if [ "$runtime" = "jvm" ]; then
Alex Lighta59dd802014-07-02 16:28:08 -0700415 if [ "$prebuild_mode" = "yes" ]; then
416 echo "--prebuild with --jvm is unsupported";
417 exit 1;
418 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700419 fi
420fi
421
Alex Light03a112d2014-08-25 13:25:56 -0700422if [ "$have_patchoat" = "no" ]; then
423 run_args="${run_args} --no-patchoat"
424fi
425
426if [ "$have_dex2oat" = "no" ]; then
427 run_args="${run_args} --no-dex2oat"
428fi
429
Jeff Hao201803f2013-11-20 18:11:39 -0800430if [ ! "$runtime" = "jvm" ]; then
431 run_args="${run_args} --lib $lib"
432fi
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700433
Jeff Hao201803f2013-11-20 18:11:39 -0800434if [ "$runtime" = "dalvik" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700435 if [ "$target_mode" = "no" ]; then
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100436 framework="${ANDROID_PRODUCT_OUT}/system/framework"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700437 bpath="${framework}/core.jar:${framework}/conscrypt.jar:${framework}/okhttp.jar:${framework}/core-junit.jar:${framework}/bouncycastle.jar:${framework}/ext.jar"
438 run_args="${run_args} --boot -Xbootclasspath:${bpath}"
439 else
440 true # defaults to using target BOOTCLASSPATH
441 fi
Jeff Hao201803f2013-11-20 18:11:39 -0800442elif [ "$runtime" = "art" ]; then
443 if [ "$target_mode" = "no" ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100444 # ANDROID_HOST_OUT is not set in a build environment.
Brian Carlstrom43534862014-02-19 01:13:52 -0800445 if [ -z "$ANDROID_HOST_OUT" ]; then
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100446 export ANDROID_HOST_OUT=$ANDROID_BUILD_TOP/out/host/linux-x86
Brian Carlstrom43534862014-02-19 01:13:52 -0800447 fi
David Brazdil853a4c32015-09-28 16:15:50 +0100448 guess_host_arch_name
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000449 run_args="${run_args} --boot ${ANDROID_HOST_OUT}/framework/core${image_suffix}${pic_image_suffix}.art"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700450 run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib${suffix64}"
Jeff Hao201803f2013-11-20 18:11:39 -0800451 else
David Brazdil853a4c32015-09-28 16:15:50 +0100452 guess_target_arch_name
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700453 run_args="${run_args} --runtime-option -Djava.library.path=/data/art-test/${target_arch_name}"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000454 run_args="${run_args} --boot /data/art-test/core${image_suffix}${pic_image_suffix}.art"
Jeff Hao201803f2013-11-20 18:11:39 -0800455 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700456 if [ "$relocate" = "yes" ]; then
457 run_args="${run_args} --relocate"
458 else
459 run_args="${run_args} --no-relocate"
460 fi
Andreas Gampe3f1dc562015-05-18 15:52:22 -0700461elif [ "$runtime" = "jvm" ]; then
462 # TODO: Detect whether the host is 32-bit or 64-bit.
463 run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib64"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700464fi
465
Alex Light03a112d2014-08-25 13:25:56 -0700466if [ "$have_image" = "no" ]; then
Alex Light1ef4ce82014-08-27 11:13:47 -0700467 if [ "$runtime" != "art" ]; then
468 echo "--no-image is only supported on the art runtime"
469 exit 1
470 fi
471 if [ "$target_mode" = "no" ]; then
472 framework="${ANDROID_HOST_OUT}/framework"
473 bpath_suffix="-hostdex"
474 else
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000475 framework="${android_root}/framework"
Alex Light1ef4ce82014-08-27 11:13:47 -0700476 bpath_suffix=""
477 fi
478 # TODO If the target was compiled WITH_DEXPREOPT=true then these tests will
479 # fail since these jar files will be stripped.
480 bpath="${framework}/core-libart${bpath_suffix}.jar"
481 bpath="${bpath}:${framework}/conscrypt${bpath_suffix}.jar"
482 bpath="${bpath}:${framework}/okhttp${bpath_suffix}.jar"
483 bpath="${bpath}:${framework}/core-junit${bpath_suffix}.jar"
484 bpath="${bpath}:${framework}/bouncycastle${bpath_suffix}.jar"
485 # Pass down the bootclasspath
486 run_args="${run_args} --runtime-option -Xbootclasspath:${bpath}"
Alex Light03a112d2014-08-25 13:25:56 -0700487 run_args="${run_args} --no-image"
488fi
489
jeffhao5d1ac922011-09-29 17:41:15 -0700490if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then
491 echo "--dev and --update are mutually exclusive" 1>&2
492 usage="yes"
493fi
494
495if [ "$usage" = "no" ]; then
496 if [ "x$1" = "x" -o "x$1" = "x-" ]; then
497 test_dir=`basename "$oldwd"`
498 else
499 test_dir="$1"
500 fi
501
502 if [ '!' -d "$test_dir" ]; then
503 td2=`echo ${test_dir}-*`
504 if [ '!' -d "$td2" ]; then
505 echo "${test_dir}: no such test directory" 1>&2
506 usage="yes"
507 fi
508 test_dir="$td2"
509 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700510 # Shift to get rid of the test name argument. The rest of the arguments
511 # will get passed to the test run.
512 shift
513fi
514
515if [ "$usage" = "yes" ]; then
516 prog=`basename $prog`
517 (
518 echo "usage:"
519 echo " $prog --help Print this message."
520 echo " $prog [options] [test-name] Run test normally."
521 echo " $prog --dev [options] [test-name] Development mode" \
522 "(dumps to stdout)."
523 echo " $prog --update [options] [test-name] Update mode" \
524 "(replaces expected.txt)."
525 echo ' Omitting the test name or specifying "-" will use the' \
526 "current directory."
527 echo " Runtime Options:"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000528 echo " -O Run non-debug rather than debug build (off by default)."
529 echo " -Xcompiler-option Pass an option to the compiler."
530 echo " --runtime-option Pass an option to the runtime."
531 echo " --debug Wait for a debugger to attach."
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000532 echo " --debuggable Whether to compile Java code for a debugger."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000533 echo " --gdb Run under gdb; incompatible with some tests."
534 echo " --build-only Build test files only (off by default)."
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100535 echo " --build-with-javac-dx Build test files with javac and dx (on by default)."
536 echo " --build-with-jack Build test files with jack and jill (off by default)."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000537 echo " --interpreter Enable interpreter only mode (off by default)."
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800538 echo " --jit Enable jit (off by default)."
Nicolas Geoffray0e071252015-03-21 13:43:15 +0000539 echo " --optimizing Enable optimizing compiler (default)."
540 echo " --quick Use Quick compiler (off by default)."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000541 echo " --no-verify Turn off verification (on by default)."
Igor Murashkin7617abd2015-07-10 18:27:47 -0700542 echo " --verify-soft-fail Force soft fail verification (off by default)."
543 echo " Verification is enabled if neither --no-verify"
544 echo " nor --verify-soft-fail is specified."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000545 echo " --no-optimize Turn off optimization (on by default)."
546 echo " --no-precise Turn off precise GC (on by default)."
547 echo " --zygote Spawn the process from the Zygote." \
jeffhao5d1ac922011-09-29 17:41:15 -0700548 "If used, then the"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000549 echo " other runtime options are ignored."
550 echo " --no-dex2oat Run as though dex2oat was failing."
551 echo " --no-patchoat Run as though patchoat was failing."
552 echo " --prebuild Run dex2oat on the files before starting test. (default)"
553 echo " --no-prebuild Do not run dex2oat on the files before starting"
554 echo " the test."
555 echo " --relocate Force the use of relocating in the test, making"
556 echo " the image and oat files be relocated to a random"
557 echo " address before running. (default)"
558 echo " --no-relocate Force the use of no relocating in the test"
559 echo " --host Use the host-mode virtual machine."
560 echo " --invoke-with Pass --invoke-with option to runtime."
561 echo " --dalvik Use Dalvik (off by default)."
562 echo " --jvm Use a host-local RI virtual machine."
563 echo " --output-path [path] Location where to store the build" \
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700564 "files."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000565 echo " --64 Run the test in 64-bit mode"
566 echo " --trace Run with method tracing"
Andreas Gampe7526d782015-06-22 22:53:45 -0700567 echo " --stream Run method tracing in streaming mode (requires --trace)"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000568 echo " --gcstress Run with gc stress testing"
569 echo " --gcverify Run with gc verification"
570 echo " --always-clean Delete the test files even if the test fails."
Igor Murashkin05f30e12015-06-10 15:57:17 -0700571 echo " --never-clean Keep the test files even if the test succeeds."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000572 echo " --android-root [path] The path on target for the android root. (/system by default)."
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000573 echo " --dex2oat-swap Use a dex2oat swap file."
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700574 echo " --instruction-set-features [string]"
575 echo " Set instruction-set-features for compilation."
jeffhao5d1ac922011-09-29 17:41:15 -0700576 ) 1>&2
577 exit 1
578fi
579
580cd "$test_dir"
581test_dir=`pwd`
582
583td_info="${test_dir}/${info}"
584td_expected="${test_dir}/${expected}"
585
Brian Carlstrom22469aa2012-09-07 10:34:57 -0700586if [ ! -r $td_info ]; then
587 echo "${test_dir}: missing file $td_info" 1>&2
588 exit 1
589fi
590
591if [ ! -r $td_expected ]; then
592 echo "${test_dir}: missing file $td_expected" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700593 exit 1
594fi
595
596# copy the test to a temp dir and run it
597
Elliott Hughes510c8782011-10-06 10:57:34 -0700598echo "${test_dir}: building..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700599
600rm -rf "$tmp_dir"
601cp -Rp "$test_dir" "$tmp_dir"
602cd "$tmp_dir"
603
604if [ '!' -r "$build" ]; then
605 cp "${progdir}/etc/default-build" build
Zheng Xuc6667102015-05-15 16:08:45 +0800606else
607 cp "${progdir}/etc/default-build" .
jeffhao5d1ac922011-09-29 17:41:15 -0700608fi
609
610if [ '!' -r "$run" ]; then
611 cp "${progdir}/etc/default-run" run
Zheng Xuc6667102015-05-15 16:08:45 +0800612else
613 cp "${progdir}/etc/default-run" .
jeffhao5d1ac922011-09-29 17:41:15 -0700614fi
615
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700616if [ '!' -r "$check_cmd" ]; then
617 cp "${progdir}/etc/default-check" check
Zheng Xuc6667102015-05-15 16:08:45 +0800618else
619 cp "${progdir}/etc/default-check" .
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700620fi
621
jeffhao5d1ac922011-09-29 17:41:15 -0700622chmod 755 "$build"
623chmod 755 "$run"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700624chmod 755 "$check_cmd"
jeffhao5d1ac922011-09-29 17:41:15 -0700625
Elliott Hughes8cbc8bc2011-10-04 11:19:45 -0700626export TEST_NAME=`basename ${test_dir}`
627
David Brazdil4846d132015-01-15 19:07:08 +0000628# Tests named '<number>-checker-*' will also have their CFGs verified with
629# Checker when compiled with Optimizing on host.
630if [[ "$TEST_NAME" =~ ^[0-9]+-checker- ]]; then
631 # Build Checker DEX files without dx's optimizations so the input to dex2oat
632 # better resembles the Java source. We always build the DEX the same way, even
633 # if Checker is not invoked and the test only runs the program.
634 build_args="${build_args} --dx-option --no-optimize"
635
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100636 # Jack does not necessarily generate the same DEX output than dx. Because these tests depend
637 # on a particular DEX output, keep building them with dx for now (b/19467889).
638 USE_JACK="false"
639
David Brazdil5cc343d2015-10-08 11:35:32 +0100640 if [ "$runtime" = "art" -a "$image_suffix" = "-optimizing" ]; then
David Brazdil80fb3942015-07-23 11:53:42 +0100641 # In no-prebuild mode, the compiler is only invoked if both dex2oat and
642 # patchoat are available. Disable Checker otherwise (b/22552692).
643 if [ "$prebuild_mode" = "yes" ] || [ "$have_patchoat" = "yes" -a "$have_dex2oat" = "yes" ]; then
644 run_checker="yes"
David Brazdil5cc343d2015-10-08 11:35:32 +0100645
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100646 if [ "$target_mode" = "no" ]; then
647 cfg_output_dir="$tmp_dir"
David Brazdil5cc343d2015-10-08 11:35:32 +0100648 checker_args="--arch=${host_arch_name^^}"
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100649 else
650 cfg_output_dir="$DEX_LOCATION"
David Brazdil5cc343d2015-10-08 11:35:32 +0100651 checker_args="--arch=${target_arch_name^^}"
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100652 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100653
654 if [ "$debuggable" = "yes" ]; then
655 checker_args="$checker_args --debuggable"
656 fi
657
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100658 run_args="${run_args} -Xcompiler-option --dump-cfg=$cfg_output_dir/$cfg_output \
David Brazdil80fb3942015-07-23 11:53:42 +0100659 -Xcompiler-option -j1"
660 fi
David Brazdil4846d132015-01-15 19:07:08 +0000661 fi
662fi
663
Mathieu Chartier031768a2015-08-27 10:25:02 -0700664if [ "$runtime" != "jvm" ]; then
665 run_args="${run_args} --testlib ${testlib}"
666fi
667
Ian Rogers997f0f92014-06-21 22:58:05 -0700668# 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 +0100669build_file_size_limit=2048
670run_file_size_limit=2048
Ian Rogers997f0f92014-06-21 22:58:05 -0700671if echo "$test_dir" | grep 089; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100672 build_file_size_limit=5120
673 run_file_size_limit=5120
Ian Rogers997f0f92014-06-21 22:58:05 -0700674elif echo "$test_dir" | grep 083; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100675 build_file_size_limit=5120
676 run_file_size_limit=5120
Ian Rogers997f0f92014-06-21 22:58:05 -0700677fi
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100678if [ "$run_checker" = "yes" -a "$target_mode" = "yes" ]; then
679 # We will need to `adb pull` the .cfg output from the target onto the host to
680 # run checker on it. This file can be big.
681 build_file_size_limit=16384
682 run_file_size_limit=16384
683fi
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100684if [ ${USE_JACK} = "false" ]; then
685 # Set ulimit if we build with dx only, Jack can generate big temp files.
686 if ! ulimit -S "$build_file_size_limit"; then
687 echo "ulimit file size setting failed"
688 fi
Ian Rogers997f0f92014-06-21 22:58:05 -0700689fi
690
jeffhao5d1ac922011-09-29 17:41:15 -0700691good="no"
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000692good_build="yes"
693good_run="yes"
jeffhao5d1ac922011-09-29 17:41:15 -0700694if [ "$dev_mode" = "yes" ]; then
David Brazdil4846d132015-01-15 19:07:08 +0000695 "./${build}" $build_args 2>&1
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700696 build_exit="$?"
697 echo "build exit status: $build_exit" 1>&2
698 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100699 if ! ulimit -S "$run_file_size_limit"; then
700 echo "ulimit file size setting failed"
701 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800702 echo "${test_dir}: running..." 1>&2
703 "./${run}" $run_args "$@" 2>&1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700704 run_exit="$?"
Calin Juravle3cf48772015-01-26 16:47:33 +0000705
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800706 if [ "$run_exit" = "0" ]; then
Calin Juravle3cf48772015-01-26 16:47:33 +0000707 if [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100708 if [ "$target_mode" = "yes" ]; then
709 adb pull $cfg_output_dir/$cfg_output &> /dev/null
710 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100711 "$checker" $checker_args "$cfg_output" "$tmp_dir" 2>&1
Calin Juravle3cf48772015-01-26 16:47:33 +0000712 checker_exit="$?"
713 if [ "$checker_exit" = "0" ]; then
714 good="yes"
715 fi
716 echo "checker exit status: $checker_exit" 1>&2
717 else
718 good="yes"
719 fi
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800720 fi
Calin Juravle3cf48772015-01-26 16:47:33 +0000721 echo "run exit status: $run_exit" 1>&2
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700722 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700723elif [ "$update_mode" = "yes" ]; then
David Brazdil4846d132015-01-15 19:07:08 +0000724 "./${build}" $build_args >"$build_output" 2>&1
jeffhao5d1ac922011-09-29 17:41:15 -0700725 build_exit="$?"
726 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100727 if ! ulimit -S "$run_file_size_limit"; then
728 echo "ulimit file size setting failed"
729 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800730 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700731 "./${run}" $run_args "$@" >"$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000732 if [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100733 if [ "$target_mode" = "yes" ]; then
734 adb pull $cfg_output_dir/$cfg_output &> /dev/null
735 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100736 "$checker" -q $checker_args "$cfg_output" "$tmp_dir" >> "$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000737 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700738 sed -e 's/[[:cntrl:]]$//g' < "$output" >"${td_expected}"
739 good="yes"
740 else
741 cat "$build_output" 1>&2
742 echo "build exit status: $build_exit" 1>&2
743 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700744elif [ "$build_only" = "yes" ]; then
745 good="yes"
David Brazdil4846d132015-01-15 19:07:08 +0000746 "./${build}" $build_args >"$build_output" 2>&1
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700747 build_exit="$?"
748 if [ "$build_exit" '!=' '0' ]; then
749 cp "$build_output" "$output"
750 echo "build exit status: $build_exit" >>"$output"
751 diff --strip-trailing-cr -q "$expected" "$output" >/dev/null
752 if [ "$?" '!=' "0" ]; then
753 good="no"
754 echo "BUILD FAILED For ${TEST_NAME}"
755 fi
756 fi
Tsu Chiang Chuang379e2f52013-08-20 12:24:52 -0700757 # Clean up extraneous files that are not used by tests.
Tsu Chiang Chuang0160d992013-09-13 14:17:42 -0700758 find $tmp_dir -mindepth 1 ! -regex ".*/\(.*jar\|$output\|$expected\)" | xargs rm -rf
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700759 exit 0
jeffhao5d1ac922011-09-29 17:41:15 -0700760else
David Brazdil4846d132015-01-15 19:07:08 +0000761 "./${build}" $build_args >"$build_output" 2>&1
jeffhao5d1ac922011-09-29 17:41:15 -0700762 build_exit="$?"
763 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100764 if ! ulimit -S "$run_file_size_limit"; then
765 echo "ulimit file size setting failed"
766 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800767 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700768 "./${run}" $run_args "$@" >"$output" 2>&1
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000769 run_exit="$?"
770 if [ "$run_exit" != "0" ]; then
771 echo "run exit status: $run_exit" 1>&2
772 good_run="no"
David Brazdil4846d132015-01-15 19:07:08 +0000773 elif [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100774 if [ "$target_mode" = "yes" ]; then
775 adb pull $cfg_output_dir/$cfg_output &> /dev/null
776 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100777 "$checker" -q $checker_args "$cfg_output" "$tmp_dir" >> "$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000778 checker_exit="$?"
779 if [ "$checker_exit" != "0" ]; then
780 echo "checker exit status: $checker_exit" 1>&2
781 good_run="no"
782 else
783 good_run="yes"
784 fi
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000785 else
786 good_run="yes"
787 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700788 else
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000789 good_build="no"
jeffhao5d1ac922011-09-29 17:41:15 -0700790 cp "$build_output" "$output"
Andreas Gampef6930a82014-10-21 09:33:08 -0700791 echo "Failed to build in tmpdir=${tmp_dir} from oldwd=${oldwd} and cwd=`pwd`" >> "$output"
792 echo "Non-canonical tmpdir was ${noncanonical_tmp_dir}" >> "$output"
Ian Rogersd9ad27d2014-10-27 13:48:21 -0700793 echo "Args: ${args}" >> "$output"
Andreas Gampef6930a82014-10-21 09:33:08 -0700794 echo "build exit status: $build_exit" >> "$output"
Andreas Gampe5c114902014-10-27 17:03:58 -0700795 max_name_length=$(getconf NAME_MAX ${tmp_dir})
796 echo "Max filename (NAME_MAX): ${max_name_length}" >> "$output"
797 max_path_length=$(getconf PATH_MAX ${tmp_dir})
Andreas Gampe602fbcd2014-10-27 17:06:29 -0700798 echo "Max pathlength (PATH_MAX): ${max_path_length}" >> "$output"
jeffhao5d1ac922011-09-29 17:41:15 -0700799 fi
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700800 ./$check_cmd "$expected" "$output"
jeffhao5d1ac922011-09-29 17:41:15 -0700801 if [ "$?" = "0" ]; then
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000802 if [ "$good_build" = "no" -o "$good_run" = "yes" ]; then
803 # output == expected
804 good="yes"
805 echo "${test_dir}: succeeded!" 1>&2
806 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700807 fi
808fi
809
jeffhao5d1ac922011-09-29 17:41:15 -0700810(
Alex Lightbfac14a2014-07-30 09:41:21 -0700811 if [ "$good" != "yes" -a "$update_mode" != "yes" ]; then
jeffhao5d1ac922011-09-29 17:41:15 -0700812 echo "${test_dir}: FAILED!"
813 echo ' '
814 echo '#################### info'
815 cat "${td_info}" | sed 's/^/# /g'
816 echo '#################### diffs'
Hiroshi Yamauchid630fd62015-09-04 12:52:03 -0700817 diff --strip-trailing-cr -u "$expected" "$output" | tail -n 3000
jeffhao5d1ac922011-09-29 17:41:15 -0700818 echo '####################'
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700819 if [ "$strace" = "yes" ]; then
820 echo '#################### strace output'
Hiroshi Yamauchid630fd62015-09-04 12:52:03 -0700821 tail -n 3000 "$tmp_dir/$strace_output"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700822 echo '####################'
823 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700824 echo ' '
825 fi
Alex Lightbfac14a2014-07-30 09:41:21 -0700826
827) 1>&2
828
829# Clean up test files.
Igor Murashkin05f30e12015-06-10 15:57:17 -0700830if [ "$always_clean" = "yes" -o "$good" = "yes" ] && [ "$never_clean" = "no" ]; then
Alex Lightbfac14a2014-07-30 09:41:21 -0700831 cd "$oldwd"
832 rm -rf "$tmp_dir"
833 if [ "$target_mode" = "yes" -a "$build_exit" = "0" ]; then
834 adb shell rm -rf $DEX_LOCATION
835 fi
836 if [ "$good" = "yes" ]; then
837 exit 0
838 fi
839fi
840
841
842(
843 if [ "$always_clean" = "yes" ]; then
844 echo "${TEST_NAME} files deleted from host "
845 if [ "$target_mode" == "yes" ]; then
846 echo "and from target"
847 fi
848 else
849 echo "${TEST_NAME} files left in ${tmp_dir} on host"
850 if [ "$target_mode" == "yes" ]; then
851 echo "and in ${DEX_LOCATION} on target"
852 fi
Brian Carlstrom105215d2012-06-14 12:50:44 -0700853 fi
854
jeffhao5d1ac922011-09-29 17:41:15 -0700855) 1>&2
856
857exit 1