blob: 3442fcf67d6237c6e043f2fe27e98eb0eea6e2e4 [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"
Alex Light8a0e0332015-10-26 10:11:58 -070049export SMALI_ARGS="--experimental --api-level 23"
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
Sebastien Hertz19ac0272015-02-24 17:39:50 +010086# If JACK_CLASSPATH is not set, assume it only contains core-libart.
87if [ -z "$JACK_CLASSPATH" ]; then
88 export JACK_CLASSPATH="$ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/core-libart-hostdex_intermediates/classes.jack"
89fi
90
Sebastien Hertz19ac0272015-02-24 17:39:50 +010091# If JILL_JAR is not set, assume it is located in the prebuilts directory.
92if [ -z "$JILL_JAR" ]; then
93 export JILL_JAR="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/jill.jar"
94fi
95
96export JACK="$JACK -g -cp $JACK_CLASSPATH"
97export JILL="java -jar $JILL_JAR"
Tsu Chiang Chuang6674f8a2013-01-16 15:41:21 -080098
jeffhao5d1ac922011-09-29 17:41:15 -070099info="info.txt"
100build="build"
101run="run"
102expected="expected.txt"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700103check_cmd="check"
jeffhao5d1ac922011-09-29 17:41:15 -0700104output="output.txt"
105build_output="build-output.txt"
David Brazdil24128c62015-05-21 12:06:13 +0100106cfg_output="graph.cfg"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700107strace_output="strace-output.txt"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700108lib="libartd.so"
Mathieu Chartier031768a2015-08-27 10:25:02 -0700109testlib="arttestd"
jeffhao5d1ac922011-09-29 17:41:15 -0700110run_args="--quiet"
David Brazdil4846d132015-01-15 19:07:08 +0000111build_args=""
jeffhao5d1ac922011-09-29 17:41:15 -0700112
Nicolas Geoffraya3d90fb2015-03-16 13:55:40 +0000113debuggable="no"
Alex Light9d722532014-07-22 18:07:12 -0700114prebuild_mode="yes"
Brian Carlstrom2613de42012-06-15 17:37:16 -0700115target_mode="yes"
jeffhao5d1ac922011-09-29 17:41:15 -0700116dev_mode="no"
117update_mode="no"
Alex Lighta59dd802014-07-02 16:28:08 -0700118debug_mode="no"
119relocate="yes"
Jeff Hao201803f2013-11-20 18:11:39 -0800120runtime="art"
jeffhao5d1ac922011-09-29 17:41:15 -0700121usage="no"
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700122build_only="no"
Andreas Gampe2fe07922014-04-21 07:50:39 -0700123suffix64=""
Jeff Hao85139a32014-07-23 11:52:52 -0700124trace="false"
Andreas Gampe7526d782015-06-22 22:53:45 -0700125trace_stream="false"
Alex Lighte7873ec2014-08-12 09:53:50 -0700126basic_verify="false"
127gc_verify="false"
128gc_stress="false"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700129strace="false"
Alex Lightbfac14a2014-07-30 09:41:21 -0700130always_clean="no"
Igor Murashkin05f30e12015-06-10 15:57:17 -0700131never_clean="no"
Alex Light03a112d2014-08-25 13:25:56 -0700132have_dex2oat="yes"
133have_patchoat="yes"
134have_image="yes"
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700135image_suffix=""
Andreas Gampec23c9c92014-10-28 14:47:25 -0700136pic_image_suffix=""
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000137android_root="/system"
jeffhao5d1ac922011-09-29 17:41:15 -0700138
139while true; do
140 if [ "x$1" = "x--host" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -0700141 target_mode="no"
TDYa127b92bcab2012-04-08 00:09:51 -0700142 DEX_LOCATION=$tmp_dir
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100143 run_args="${run_args} --host"
jeffhao5d1ac922011-09-29 17:41:15 -0700144 shift
Alex Lighteb7c1442015-08-31 13:17:42 -0700145 elif [ "x$1" = "x--use-java-home" ]; then
146 if [ -n "${JAVA_HOME}" ]; then
147 export JAVA="${JAVA_HOME}/bin/java"
148 export JAVAC="${JAVA_HOME}/bin/javac -g"
149 else
150 echo "Passed --use-java-home without JAVA_HOME variable set!"
151 usage="yes"
152 fi
153 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -0800154 elif [ "x$1" = "x--jvm" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -0700155 target_mode="no"
Jeff Hao201803f2013-11-20 18:11:39 -0800156 runtime="jvm"
Brian Carlstrom01afdba2014-10-03 10:28:47 -0700157 prebuild_mode="no"
Elliott Hughesc717eef2012-06-15 16:01:26 -0700158 NEED_DEX="false"
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100159 USE_JACK="false"
Nicolas Geoffray288a4a22014-10-07 11:02:40 +0100160 run_args="${run_args} --jvm"
Alex Lighteb7c1442015-08-31 13:17:42 -0700161 build_args="${build_args} --jvm"
jeffhao5d1ac922011-09-29 17:41:15 -0700162 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -0800163 elif [ "x$1" = "x-O" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700164 lib="libart.so"
Mathieu Chartier031768a2015-08-27 10:25:02 -0700165 testlib="arttest"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700166 shift
167 elif [ "x$1" = "x--dalvik" ]; then
168 lib="libdvm.so"
Jeff Hao201803f2013-11-20 18:11:39 -0800169 runtime="dalvik"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700170 shift
Alex Light03a112d2014-08-25 13:25:56 -0700171 elif [ "x$1" = "x--no-dex2oat" ]; then
172 have_dex2oat="no"
173 shift
174 elif [ "x$1" = "x--no-patchoat" ]; then
175 have_patchoat="no"
176 shift
177 elif [ "x$1" = "x--no-image" ]; then
178 have_image="no"
179 shift
Andreas Gampec23c9c92014-10-28 14:47:25 -0700180 elif [ "x$1" = "x--pic-image" ]; then
181 pic_image_suffix="-pic"
182 shift
183 elif [ "x$1" = "x--pic-test" ]; then
184 run_args="${run_args} --pic-test"
185 shift
Alex Lighta59dd802014-07-02 16:28:08 -0700186 elif [ "x$1" = "x--relocate" ]; then
187 relocate="yes"
188 shift
189 elif [ "x$1" = "x--no-relocate" ]; then
190 relocate="no"
191 shift
192 elif [ "x$1" = "x--prebuild" ]; then
Nicolas Geoffray5fd18ba2014-10-03 12:08:38 +0100193 run_args="${run_args} --prebuild"
Alex Lighta59dd802014-07-02 16:28:08 -0700194 prebuild_mode="yes"
195 shift;
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000196 elif [ "x$1" = "x--debuggable" ]; then
197 run_args="${run_args} -Xcompiler-option --debuggable"
Nicolas Geoffraya3d90fb2015-03-16 13:55:40 +0000198 debuggable="yes"
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000199 shift;
Alex Lighta59dd802014-07-02 16:28:08 -0700200 elif [ "x$1" = "x--no-prebuild" ]; then
Nicolas Geoffray5fd18ba2014-10-03 12:08:38 +0100201 run_args="${run_args} --no-prebuild"
Alex Lighta59dd802014-07-02 16:28:08 -0700202 prebuild_mode="no"
203 shift;
Alex Lighte7873ec2014-08-12 09:53:50 -0700204 elif [ "x$1" = "x--gcverify" ]; then
205 basic_verify="true"
206 gc_verify="true"
207 shift
208 elif [ "x$1" = "x--gcstress" ]; then
209 basic_verify="true"
210 gc_stress="true"
211 shift
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700212 elif [ "x$1" = "x--image" ]; then
213 shift
214 image="$1"
215 run_args="${run_args} --image $image"
Elliott Hughes7c046102011-10-19 18:16:03 -0700216 shift
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000217 elif [ "x$1" = "x-Xcompiler-option" ]; then
218 shift
219 option="$1"
220 run_args="${run_args} -Xcompiler-option $option"
221 shift
Mathieu Chartier769a5ad2014-05-18 15:30:10 -0700222 elif [ "x$1" = "x--runtime-option" ]; then
223 shift
224 option="$1"
225 run_args="${run_args} --runtime-option $option"
226 shift
Mathieu Chartierc0a8a802014-10-17 15:58:01 -0700227 elif [ "x$1" = "x--gdb-arg" ]; then
228 shift
229 gdb_arg="$1"
230 run_args="${run_args} --gdb-arg $gdb_arg"
231 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700232 elif [ "x$1" = "x--debug" ]; then
233 run_args="${run_args} --debug"
234 shift
235 elif [ "x$1" = "x--gdb" ]; then
236 run_args="${run_args} --gdb"
237 dev_mode="yes"
238 shift
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700239 elif [ "x$1" = "x--strace" ]; then
240 strace="yes"
241 run_args="${run_args} --invoke-with strace --invoke-with -o --invoke-with $tmp_dir/$strace_output"
242 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700243 elif [ "x$1" = "x--zygote" ]; then
244 run_args="${run_args} --zygote"
245 shift
jeffhao0dff3f42012-11-20 15:13:43 -0800246 elif [ "x$1" = "x--interpreter" ]; then
247 run_args="${run_args} --interpreter"
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700248 image_suffix="-interpreter"
249 shift
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800250 elif [ "x$1" = "x--jit" ]; then
251 run_args="${run_args} --jit"
Andreas Gampe8a159fd2015-09-21 15:14:38 -0700252 image_suffix="-jit"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800253 shift
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700254 elif [ "x$1" = "x--optimizing" ]; then
255 run_args="${run_args} -Xcompiler-option --compiler-backend=Optimizing"
256 image_suffix="-optimizing"
jeffhao0dff3f42012-11-20 15:13:43 -0800257 shift
Nicolas Geoffrayc9338b92014-12-03 13:36:10 +0000258 elif [ "x$1" = "x--quick" ]; then
259 run_args="${run_args} -Xcompiler-option --compiler-backend=Quick"
260 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700261 elif [ "x$1" = "x--no-verify" ]; then
262 run_args="${run_args} --no-verify"
263 shift
Igor Murashkin7617abd2015-07-10 18:27:47 -0700264 elif [ "x$1" = "x--verify-soft-fail" ]; then
265 run_args="${run_args} --verify-soft-fail"
Andreas Gampe825570c2015-07-26 10:26:03 -0700266 image_suffix="-interp-ac"
Igor Murashkin7617abd2015-07-10 18:27:47 -0700267 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700268 elif [ "x$1" = "x--no-optimize" ]; then
269 run_args="${run_args} --no-optimize"
270 shift
271 elif [ "x$1" = "x--no-precise" ]; then
272 run_args="${run_args} --no-precise"
273 shift
Elliott Hughes7c046102011-10-19 18:16:03 -0700274 elif [ "x$1" = "x--invoke-with" ]; then
275 shift
276 what="$1"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700277 if [ "x$what" = "x" ]; then
278 echo "$0 missing argument to --invoke-with" 1>&2
279 usage="yes"
280 break
281 fi
Ian Rogers0e033672013-04-19 10:22:46 -0700282 run_args="${run_args} --invoke-with ${what}"
jeffhao5d1ac922011-09-29 17:41:15 -0700283 shift
284 elif [ "x$1" = "x--dev" ]; then
285 run_args="${run_args} --dev"
286 dev_mode="yes"
287 shift
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700288 elif [ "x$1" = "x--build-only" ]; then
289 build_only="yes"
290 shift
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100291 elif [ "x$1" = "x--build-with-javac-dx" ]; then
292 USE_JACK="false"
293 shift
294 elif [ "x$1" = "x--build-with-jack" ]; then
295 USE_JACK="true"
296 shift
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700297 elif [ "x$1" = "x--output-path" ]; then
298 shift
299 tmp_dir=$1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700300 if [ "x$tmp_dir" = "x" ]; then
301 echo "$0 missing argument to --output-path" 1>&2
302 usage="yes"
303 break
304 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700305 shift
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000306 elif [ "x$1" = "x--android-root" ]; then
307 shift
308 if [ "x$1" = "x" ]; then
309 echo "$0 missing argument to --android-root" 1>&2
310 usage="yes"
311 break
312 fi
313 android_root="$1"
314 run_args="${run_args} --android-root $1"
315 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700316 elif [ "x$1" = "x--update" ]; then
317 update_mode="yes"
318 shift
319 elif [ "x$1" = "x--help" ]; then
320 usage="yes"
321 shift
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700322 elif [ "x$1" = "x--64" ]; then
323 run_args="${run_args} --64"
Andreas Gampe2fe07922014-04-21 07:50:39 -0700324 suffix64="64"
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700325 shift
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200326 elif [ "x$1" = "x--trace" ]; then
Jeff Hao85139a32014-07-23 11:52:52 -0700327 trace="true"
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200328 shift
Andreas Gampe7526d782015-06-22 22:53:45 -0700329 elif [ "x$1" = "x--stream" ]; then
330 trace_stream="true"
331 shift
Alex Lightbfac14a2014-07-30 09:41:21 -0700332 elif [ "x$1" = "x--always-clean" ]; then
333 always_clean="yes"
334 shift
Igor Murashkin05f30e12015-06-10 15:57:17 -0700335 elif [ "x$1" = "x--never-clean" ]; then
336 never_clean="yes"
337 shift
Andreas Gampee21dc3d2014-12-08 16:59:43 -0800338 elif [ "x$1" = "x--dex2oat-swap" ]; then
339 run_args="${run_args} --dex2oat-swap"
340 shift
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700341 elif [ "x$1" = "x--instruction-set-features" ]; then
342 shift
343 run_args="${run_args} --instruction-set-features $1"
344 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700345 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -0700346 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700347 usage="yes"
348 break
349 else
350 break
351 fi
352done
Andreas Gampe3a12cfe2014-08-13 15:40:22 -0700353
354# tmp_dir may be relative, resolve.
355#
356# Cannot use realpath, as it does not exist on Mac.
357# Cannot us a simple "cd", as the path might not be created yet.
Brian Carlstromc580e042014-09-08 21:37:39 -0700358# Cannot use readlink -m, as it does not exist on Mac.
359# Fallback to nuclear option:
Andreas Gampe907b6992014-08-18 22:26:49 -0700360noncanonical_tmp_dir=$tmp_dir
Brian Carlstromc580e042014-09-08 21:37:39 -0700361tmp_dir="`cd $oldwd ; python -c "import os; print os.path.realpath('$tmp_dir')"`"
Dmitry Petrochenko81c56e72014-03-05 15:05:46 +0700362mkdir -p $tmp_dir
jeffhao5d1ac922011-09-29 17:41:15 -0700363
Alex Lighte7873ec2014-08-12 09:53:50 -0700364if [ "$basic_verify" = "true" ]; then
Hiroshi Yamauchi312baf12015-01-12 12:11:05 -0800365 # Set HspaceCompactForOOMMinIntervalMs to zero to run hspace compaction for OOM more frequently in tests.
366 run_args="${run_args} --runtime-option -Xgc:preverify --runtime-option -Xgc:postverify --runtime-option -XX:HspaceCompactForOOMMinIntervalMs=0"
Alex Lighte7873ec2014-08-12 09:53:50 -0700367fi
368if [ "$gc_verify" = "true" ]; then
369 run_args="${run_args} --runtime-option -Xgc:preverify_rosalloc --runtime-option -Xgc:postverify_rosalloc"
370fi
371if [ "$gc_stress" = "true" ]; then
Mathieu Chartiereb193622015-06-27 15:42:27 -0700372 run_args="${run_args} --runtime-option -Xgc:SS,gcstress --runtime-option -Xms2m --runtime-option -Xmx16m"
Alex Lighte7873ec2014-08-12 09:53:50 -0700373fi
Jeff Hao85139a32014-07-23 11:52:52 -0700374if [ "$trace" = "true" ]; then
Andreas Gampe7526d782015-06-22 22:53:45 -0700375 run_args="${run_args} --runtime-option -Xmethod-trace --runtime-option -Xmethod-trace-file-size:2000000"
376 if [ "$trace_stream" = "true" ]; then
377 # Streaming mode uses the file size as the buffer size. So output gets really large. Drop
378 # the ability to analyze the file and just write to /dev/null.
379 run_args="${run_args} --runtime-option -Xmethod-trace-file:/dev/null"
380 # Enable streaming mode.
381 run_args="${run_args} --runtime-option -Xmethod-trace-stream"
382 else
383 run_args="${run_args} --runtime-option -Xmethod-trace-file:${DEX_LOCATION}/trace.bin"
384 fi
385elif [ "$trace_stream" = "true" ]; then
386 echo "Cannot use --stream without --trace."
387 exit 1
Jeff Hao85139a32014-07-23 11:52:52 -0700388fi
389
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700390# Most interesting target architecture variables are Makefile variables, not environment variables.
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100391# 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 +0100392function guess_target_arch_name() {
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100393 grep32bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm|x86|mips)$'`
Andreas Gampe1a5c4062015-01-15 12:10:47 -0800394 grep64bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm64|x86_64|mips64)$'`
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700395 if [ "x${suffix64}" = "x64" ]; then
396 target_arch_name=${grep64bit}
397 else
398 target_arch_name=${grep32bit}
399 fi
400}
401
David Brazdil853a4c32015-09-28 16:15:50 +0100402function guess_host_arch_name() {
403 if [ "x${suffix64}" = "x64" ]; then
404 host_arch_name="x86_64"
405 else
406 host_arch_name="x86"
407 fi
408}
409
Alex Lighta59dd802014-07-02 16:28:08 -0700410if [ "$target_mode" = "no" ]; then
411 if [ "$runtime" = "jvm" ]; then
Alex Lighta59dd802014-07-02 16:28:08 -0700412 if [ "$prebuild_mode" = "yes" ]; then
413 echo "--prebuild with --jvm is unsupported";
414 exit 1;
415 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700416 fi
417fi
418
Alex Light03a112d2014-08-25 13:25:56 -0700419if [ "$have_patchoat" = "no" ]; then
420 run_args="${run_args} --no-patchoat"
421fi
422
423if [ "$have_dex2oat" = "no" ]; then
424 run_args="${run_args} --no-dex2oat"
425fi
426
Jeff Hao201803f2013-11-20 18:11:39 -0800427if [ ! "$runtime" = "jvm" ]; then
428 run_args="${run_args} --lib $lib"
429fi
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700430
Jeff Hao201803f2013-11-20 18:11:39 -0800431if [ "$runtime" = "dalvik" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700432 if [ "$target_mode" = "no" ]; then
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100433 framework="${ANDROID_PRODUCT_OUT}/system/framework"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700434 bpath="${framework}/core.jar:${framework}/conscrypt.jar:${framework}/okhttp.jar:${framework}/core-junit.jar:${framework}/bouncycastle.jar:${framework}/ext.jar"
435 run_args="${run_args} --boot -Xbootclasspath:${bpath}"
436 else
437 true # defaults to using target BOOTCLASSPATH
438 fi
Jeff Hao201803f2013-11-20 18:11:39 -0800439elif [ "$runtime" = "art" ]; then
440 if [ "$target_mode" = "no" ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100441 # ANDROID_HOST_OUT is not set in a build environment.
Brian Carlstrom43534862014-02-19 01:13:52 -0800442 if [ -z "$ANDROID_HOST_OUT" ]; then
Nicolas Geoffray1a58b7f2014-10-06 12:23:04 +0100443 export ANDROID_HOST_OUT=$ANDROID_BUILD_TOP/out/host/linux-x86
Brian Carlstrom43534862014-02-19 01:13:52 -0800444 fi
David Brazdil853a4c32015-09-28 16:15:50 +0100445 guess_host_arch_name
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000446 run_args="${run_args} --boot ${ANDROID_HOST_OUT}/framework/core${image_suffix}${pic_image_suffix}.art"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700447 run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib${suffix64}"
Jeff Hao201803f2013-11-20 18:11:39 -0800448 else
David Brazdil853a4c32015-09-28 16:15:50 +0100449 guess_target_arch_name
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700450 run_args="${run_args} --runtime-option -Djava.library.path=/data/art-test/${target_arch_name}"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000451 run_args="${run_args} --boot /data/art-test/core${image_suffix}${pic_image_suffix}.art"
Jeff Hao201803f2013-11-20 18:11:39 -0800452 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700453 if [ "$relocate" = "yes" ]; then
454 run_args="${run_args} --relocate"
455 else
456 run_args="${run_args} --no-relocate"
457 fi
Andreas Gampe3f1dc562015-05-18 15:52:22 -0700458elif [ "$runtime" = "jvm" ]; then
459 # TODO: Detect whether the host is 32-bit or 64-bit.
460 run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib64"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700461fi
462
Alex Light03a112d2014-08-25 13:25:56 -0700463if [ "$have_image" = "no" ]; then
Alex Light1ef4ce82014-08-27 11:13:47 -0700464 if [ "$runtime" != "art" ]; then
465 echo "--no-image is only supported on the art runtime"
466 exit 1
467 fi
468 if [ "$target_mode" = "no" ]; then
469 framework="${ANDROID_HOST_OUT}/framework"
470 bpath_suffix="-hostdex"
471 else
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000472 framework="${android_root}/framework"
Alex Light1ef4ce82014-08-27 11:13:47 -0700473 bpath_suffix=""
474 fi
475 # TODO If the target was compiled WITH_DEXPREOPT=true then these tests will
476 # fail since these jar files will be stripped.
477 bpath="${framework}/core-libart${bpath_suffix}.jar"
478 bpath="${bpath}:${framework}/conscrypt${bpath_suffix}.jar"
479 bpath="${bpath}:${framework}/okhttp${bpath_suffix}.jar"
480 bpath="${bpath}:${framework}/core-junit${bpath_suffix}.jar"
481 bpath="${bpath}:${framework}/bouncycastle${bpath_suffix}.jar"
482 # Pass down the bootclasspath
483 run_args="${run_args} --runtime-option -Xbootclasspath:${bpath}"
Alex Light03a112d2014-08-25 13:25:56 -0700484 run_args="${run_args} --no-image"
485fi
486
jeffhao5d1ac922011-09-29 17:41:15 -0700487if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then
488 echo "--dev and --update are mutually exclusive" 1>&2
489 usage="yes"
490fi
491
492if [ "$usage" = "no" ]; then
493 if [ "x$1" = "x" -o "x$1" = "x-" ]; then
494 test_dir=`basename "$oldwd"`
495 else
496 test_dir="$1"
497 fi
498
499 if [ '!' -d "$test_dir" ]; then
500 td2=`echo ${test_dir}-*`
501 if [ '!' -d "$td2" ]; then
502 echo "${test_dir}: no such test directory" 1>&2
503 usage="yes"
504 fi
505 test_dir="$td2"
506 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700507 # Shift to get rid of the test name argument. The rest of the arguments
508 # will get passed to the test run.
509 shift
510fi
511
512if [ "$usage" = "yes" ]; then
513 prog=`basename $prog`
514 (
515 echo "usage:"
516 echo " $prog --help Print this message."
517 echo " $prog [options] [test-name] Run test normally."
518 echo " $prog --dev [options] [test-name] Development mode" \
519 "(dumps to stdout)."
520 echo " $prog --update [options] [test-name] Update mode" \
521 "(replaces expected.txt)."
522 echo ' Omitting the test name or specifying "-" will use the' \
523 "current directory."
524 echo " Runtime Options:"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000525 echo " -O Run non-debug rather than debug build (off by default)."
526 echo " -Xcompiler-option Pass an option to the compiler."
527 echo " --runtime-option Pass an option to the runtime."
528 echo " --debug Wait for a debugger to attach."
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000529 echo " --debuggable Whether to compile Java code for a debugger."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000530 echo " --gdb Run under gdb; incompatible with some tests."
Alex Lightfadfee92015-10-28 09:40:10 -0700531 echo " --gdb-arg Pass an option to gdb."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000532 echo " --build-only Build test files only (off by default)."
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100533 echo " --build-with-javac-dx Build test files with javac and dx (on by default)."
534 echo " --build-with-jack Build test files with jack and jill (off by default)."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000535 echo " --interpreter Enable interpreter only mode (off by default)."
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800536 echo " --jit Enable jit (off by default)."
Nicolas Geoffray0e071252015-03-21 13:43:15 +0000537 echo " --optimizing Enable optimizing compiler (default)."
538 echo " --quick Use Quick compiler (off by default)."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000539 echo " --no-verify Turn off verification (on by default)."
Igor Murashkin7617abd2015-07-10 18:27:47 -0700540 echo " --verify-soft-fail Force soft fail verification (off by default)."
541 echo " Verification is enabled if neither --no-verify"
542 echo " nor --verify-soft-fail is specified."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000543 echo " --no-optimize Turn off optimization (on by default)."
544 echo " --no-precise Turn off precise GC (on by default)."
545 echo " --zygote Spawn the process from the Zygote." \
jeffhao5d1ac922011-09-29 17:41:15 -0700546 "If used, then the"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000547 echo " other runtime options are ignored."
548 echo " --no-dex2oat Run as though dex2oat was failing."
549 echo " --no-patchoat Run as though patchoat was failing."
550 echo " --prebuild Run dex2oat on the files before starting test. (default)"
551 echo " --no-prebuild Do not run dex2oat on the files before starting"
552 echo " the test."
553 echo " --relocate Force the use of relocating in the test, making"
554 echo " the image and oat files be relocated to a random"
555 echo " address before running. (default)"
556 echo " --no-relocate Force the use of no relocating in the test"
Alex Lightfadfee92015-10-28 09:40:10 -0700557 echo " --image Run the test using a precompiled boot image. (default)"
558 echo " --no-image Run the test without a precompiled boot image."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000559 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."
Alex Lighteb7c1442015-08-31 13:17:42 -0700563 echo " --use-java-home Use the JAVA_HOME environment variable"
564 echo " to find the java compiler and runtime"
565 echo " (if applicable) to run the test with."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000566 echo " --output-path [path] Location where to store the build" \
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700567 "files."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000568 echo " --64 Run the test in 64-bit mode"
569 echo " --trace Run with method tracing"
Alex Lightfadfee92015-10-28 09:40:10 -0700570 echo " --strace Run with syscall tracing from strace."
Andreas Gampe7526d782015-06-22 22:53:45 -0700571 echo " --stream Run method tracing in streaming mode (requires --trace)"
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000572 echo " --gcstress Run with gc stress testing"
573 echo " --gcverify Run with gc verification"
574 echo " --always-clean Delete the test files even if the test fails."
Igor Murashkin05f30e12015-06-10 15:57:17 -0700575 echo " --never-clean Keep the test files even if the test succeeds."
Nicolas Geoffrayc8f23fc2014-10-28 17:59:47 +0000576 echo " --android-root [path] The path on target for the android root. (/system by default)."
Nicolas Geoffray43c162f2015-03-09 12:21:26 +0000577 echo " --dex2oat-swap Use a dex2oat swap file."
Andreas Gampe4d2ef332015-08-05 09:24:45 -0700578 echo " --instruction-set-features [string]"
579 echo " Set instruction-set-features for compilation."
Alex Lightfadfee92015-10-28 09:40:10 -0700580 echo " --pic-image Use an image compiled with position independent code for the"
581 echo " boot class path."
582 echo " --pic-test Compile the test code position independent."
jeffhao5d1ac922011-09-29 17:41:15 -0700583 ) 1>&2
584 exit 1
585fi
586
587cd "$test_dir"
588test_dir=`pwd`
589
590td_info="${test_dir}/${info}"
591td_expected="${test_dir}/${expected}"
592
Brian Carlstrom22469aa2012-09-07 10:34:57 -0700593if [ ! -r $td_info ]; then
594 echo "${test_dir}: missing file $td_info" 1>&2
595 exit 1
596fi
597
598if [ ! -r $td_expected ]; then
599 echo "${test_dir}: missing file $td_expected" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700600 exit 1
601fi
602
603# copy the test to a temp dir and run it
604
Elliott Hughes510c8782011-10-06 10:57:34 -0700605echo "${test_dir}: building..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700606
607rm -rf "$tmp_dir"
608cp -Rp "$test_dir" "$tmp_dir"
609cd "$tmp_dir"
610
611if [ '!' -r "$build" ]; then
612 cp "${progdir}/etc/default-build" build
Zheng Xuc6667102015-05-15 16:08:45 +0800613else
614 cp "${progdir}/etc/default-build" .
jeffhao5d1ac922011-09-29 17:41:15 -0700615fi
616
617if [ '!' -r "$run" ]; then
618 cp "${progdir}/etc/default-run" run
Zheng Xuc6667102015-05-15 16:08:45 +0800619else
620 cp "${progdir}/etc/default-run" .
jeffhao5d1ac922011-09-29 17:41:15 -0700621fi
622
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700623if [ '!' -r "$check_cmd" ]; then
624 cp "${progdir}/etc/default-check" check
Zheng Xuc6667102015-05-15 16:08:45 +0800625else
626 cp "${progdir}/etc/default-check" .
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700627fi
628
jeffhao5d1ac922011-09-29 17:41:15 -0700629chmod 755 "$build"
630chmod 755 "$run"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700631chmod 755 "$check_cmd"
jeffhao5d1ac922011-09-29 17:41:15 -0700632
Elliott Hughes8cbc8bc2011-10-04 11:19:45 -0700633export TEST_NAME=`basename ${test_dir}`
634
David Brazdil4846d132015-01-15 19:07:08 +0000635# Tests named '<number>-checker-*' will also have their CFGs verified with
636# Checker when compiled with Optimizing on host.
637if [[ "$TEST_NAME" =~ ^[0-9]+-checker- ]]; then
638 # Build Checker DEX files without dx's optimizations so the input to dex2oat
639 # better resembles the Java source. We always build the DEX the same way, even
640 # if Checker is not invoked and the test only runs the program.
641 build_args="${build_args} --dx-option --no-optimize"
642
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100643 # Jack does not necessarily generate the same DEX output than dx. Because these tests depend
644 # on a particular DEX output, keep building them with dx for now (b/19467889).
645 USE_JACK="false"
646
David Brazdil5cc343d2015-10-08 11:35:32 +0100647 if [ "$runtime" = "art" -a "$image_suffix" = "-optimizing" ]; then
David Brazdil80fb3942015-07-23 11:53:42 +0100648 # In no-prebuild mode, the compiler is only invoked if both dex2oat and
649 # patchoat are available. Disable Checker otherwise (b/22552692).
650 if [ "$prebuild_mode" = "yes" ] || [ "$have_patchoat" = "yes" -a "$have_dex2oat" = "yes" ]; then
651 run_checker="yes"
David Brazdil5cc343d2015-10-08 11:35:32 +0100652
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100653 if [ "$target_mode" = "no" ]; then
654 cfg_output_dir="$tmp_dir"
David Brazdil5cc343d2015-10-08 11:35:32 +0100655 checker_args="--arch=${host_arch_name^^}"
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100656 else
657 cfg_output_dir="$DEX_LOCATION"
David Brazdil5cc343d2015-10-08 11:35:32 +0100658 checker_args="--arch=${target_arch_name^^}"
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100659 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100660
661 if [ "$debuggable" = "yes" ]; then
662 checker_args="$checker_args --debuggable"
663 fi
664
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100665 run_args="${run_args} -Xcompiler-option --dump-cfg=$cfg_output_dir/$cfg_output \
David Brazdil80fb3942015-07-23 11:53:42 +0100666 -Xcompiler-option -j1"
667 fi
David Brazdil4846d132015-01-15 19:07:08 +0000668 fi
669fi
670
Mathieu Chartier031768a2015-08-27 10:25:02 -0700671if [ "$runtime" != "jvm" ]; then
672 run_args="${run_args} --testlib ${testlib}"
673fi
674
Ian Rogers997f0f92014-06-21 22:58:05 -0700675# 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 +0100676build_file_size_limit=2048
677run_file_size_limit=2048
Ian Rogers997f0f92014-06-21 22:58:05 -0700678if echo "$test_dir" | grep 089; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100679 build_file_size_limit=5120
680 run_file_size_limit=5120
Ian Rogers997f0f92014-06-21 22:58:05 -0700681elif echo "$test_dir" | grep 083; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100682 build_file_size_limit=5120
683 run_file_size_limit=5120
Ian Rogers997f0f92014-06-21 22:58:05 -0700684fi
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100685if [ "$run_checker" = "yes" -a "$target_mode" = "yes" ]; then
686 # We will need to `adb pull` the .cfg output from the target onto the host to
687 # run checker on it. This file can be big.
688 build_file_size_limit=16384
689 run_file_size_limit=16384
690fi
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100691if [ ${USE_JACK} = "false" ]; then
692 # Set ulimit if we build with dx only, Jack can generate big temp files.
693 if ! ulimit -S "$build_file_size_limit"; then
694 echo "ulimit file size setting failed"
695 fi
Ian Rogers997f0f92014-06-21 22:58:05 -0700696fi
697
jeffhao5d1ac922011-09-29 17:41:15 -0700698good="no"
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000699good_build="yes"
700good_run="yes"
jeffhao5d1ac922011-09-29 17:41:15 -0700701if [ "$dev_mode" = "yes" ]; then
David Brazdil4846d132015-01-15 19:07:08 +0000702 "./${build}" $build_args 2>&1
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700703 build_exit="$?"
704 echo "build exit status: $build_exit" 1>&2
705 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100706 if ! ulimit -S "$run_file_size_limit"; then
707 echo "ulimit file size setting failed"
708 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800709 echo "${test_dir}: running..." 1>&2
710 "./${run}" $run_args "$@" 2>&1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700711 run_exit="$?"
Calin Juravle3cf48772015-01-26 16:47:33 +0000712
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800713 if [ "$run_exit" = "0" ]; then
Calin Juravle3cf48772015-01-26 16:47:33 +0000714 if [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100715 if [ "$target_mode" = "yes" ]; then
716 adb pull $cfg_output_dir/$cfg_output &> /dev/null
717 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100718 "$checker" $checker_args "$cfg_output" "$tmp_dir" 2>&1
Calin Juravle3cf48772015-01-26 16:47:33 +0000719 checker_exit="$?"
720 if [ "$checker_exit" = "0" ]; then
721 good="yes"
722 fi
723 echo "checker exit status: $checker_exit" 1>&2
724 else
725 good="yes"
726 fi
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800727 fi
Calin Juravle3cf48772015-01-26 16:47:33 +0000728 echo "run exit status: $run_exit" 1>&2
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700729 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700730elif [ "$update_mode" = "yes" ]; then
David Brazdil4846d132015-01-15 19:07:08 +0000731 "./${build}" $build_args >"$build_output" 2>&1
jeffhao5d1ac922011-09-29 17:41:15 -0700732 build_exit="$?"
733 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100734 if ! ulimit -S "$run_file_size_limit"; then
735 echo "ulimit file size setting failed"
736 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800737 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700738 "./${run}" $run_args "$@" >"$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000739 if [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100740 if [ "$target_mode" = "yes" ]; then
741 adb pull $cfg_output_dir/$cfg_output &> /dev/null
742 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100743 "$checker" -q $checker_args "$cfg_output" "$tmp_dir" >> "$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000744 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700745 sed -e 's/[[:cntrl:]]$//g' < "$output" >"${td_expected}"
746 good="yes"
747 else
748 cat "$build_output" 1>&2
749 echo "build exit status: $build_exit" 1>&2
750 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700751elif [ "$build_only" = "yes" ]; then
752 good="yes"
David Brazdil4846d132015-01-15 19:07:08 +0000753 "./${build}" $build_args >"$build_output" 2>&1
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700754 build_exit="$?"
755 if [ "$build_exit" '!=' '0' ]; then
756 cp "$build_output" "$output"
757 echo "build exit status: $build_exit" >>"$output"
758 diff --strip-trailing-cr -q "$expected" "$output" >/dev/null
759 if [ "$?" '!=' "0" ]; then
760 good="no"
761 echo "BUILD FAILED For ${TEST_NAME}"
762 fi
763 fi
Tsu Chiang Chuang379e2f52013-08-20 12:24:52 -0700764 # Clean up extraneous files that are not used by tests.
Tsu Chiang Chuang0160d992013-09-13 14:17:42 -0700765 find $tmp_dir -mindepth 1 ! -regex ".*/\(.*jar\|$output\|$expected\)" | xargs rm -rf
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700766 exit 0
jeffhao5d1ac922011-09-29 17:41:15 -0700767else
David Brazdil4846d132015-01-15 19:07:08 +0000768 "./${build}" $build_args >"$build_output" 2>&1
jeffhao5d1ac922011-09-29 17:41:15 -0700769 build_exit="$?"
770 if [ "$build_exit" = '0' ]; then
Sebastien Hertz19ac0272015-02-24 17:39:50 +0100771 if ! ulimit -S "$run_file_size_limit"; then
772 echo "ulimit file size setting failed"
773 fi
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800774 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700775 "./${run}" $run_args "$@" >"$output" 2>&1
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000776 run_exit="$?"
777 if [ "$run_exit" != "0" ]; then
778 echo "run exit status: $run_exit" 1>&2
779 good_run="no"
David Brazdil4846d132015-01-15 19:07:08 +0000780 elif [ "$run_checker" = "yes" ]; then
Alexandre Rames5e2c8d32015-08-06 14:49:28 +0100781 if [ "$target_mode" = "yes" ]; then
782 adb pull $cfg_output_dir/$cfg_output &> /dev/null
783 fi
David Brazdil5cc343d2015-10-08 11:35:32 +0100784 "$checker" -q $checker_args "$cfg_output" "$tmp_dir" >> "$output" 2>&1
David Brazdil4846d132015-01-15 19:07:08 +0000785 checker_exit="$?"
786 if [ "$checker_exit" != "0" ]; then
787 echo "checker exit status: $checker_exit" 1>&2
788 good_run="no"
789 else
790 good_run="yes"
791 fi
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000792 else
793 good_run="yes"
794 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700795 else
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000796 good_build="no"
jeffhao5d1ac922011-09-29 17:41:15 -0700797 cp "$build_output" "$output"
Andreas Gampef6930a82014-10-21 09:33:08 -0700798 echo "Failed to build in tmpdir=${tmp_dir} from oldwd=${oldwd} and cwd=`pwd`" >> "$output"
799 echo "Non-canonical tmpdir was ${noncanonical_tmp_dir}" >> "$output"
Ian Rogersd9ad27d2014-10-27 13:48:21 -0700800 echo "Args: ${args}" >> "$output"
Andreas Gampef6930a82014-10-21 09:33:08 -0700801 echo "build exit status: $build_exit" >> "$output"
Andreas Gampe5c114902014-10-27 17:03:58 -0700802 max_name_length=$(getconf NAME_MAX ${tmp_dir})
803 echo "Max filename (NAME_MAX): ${max_name_length}" >> "$output"
804 max_path_length=$(getconf PATH_MAX ${tmp_dir})
Andreas Gampe602fbcd2014-10-27 17:06:29 -0700805 echo "Max pathlength (PATH_MAX): ${max_path_length}" >> "$output"
jeffhao5d1ac922011-09-29 17:41:15 -0700806 fi
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700807 ./$check_cmd "$expected" "$output"
jeffhao5d1ac922011-09-29 17:41:15 -0700808 if [ "$?" = "0" ]; then
Nicolas Geoffray1ed097d2014-11-13 15:15:39 +0000809 if [ "$good_build" = "no" -o "$good_run" = "yes" ]; then
810 # output == expected
811 good="yes"
812 echo "${test_dir}: succeeded!" 1>&2
813 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700814 fi
815fi
816
jeffhao5d1ac922011-09-29 17:41:15 -0700817(
Alex Lightbfac14a2014-07-30 09:41:21 -0700818 if [ "$good" != "yes" -a "$update_mode" != "yes" ]; then
jeffhao5d1ac922011-09-29 17:41:15 -0700819 echo "${test_dir}: FAILED!"
820 echo ' '
821 echo '#################### info'
822 cat "${td_info}" | sed 's/^/# /g'
823 echo '#################### diffs'
Hiroshi Yamauchid630fd62015-09-04 12:52:03 -0700824 diff --strip-trailing-cr -u "$expected" "$output" | tail -n 3000
jeffhao5d1ac922011-09-29 17:41:15 -0700825 echo '####################'
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700826 if [ "$strace" = "yes" ]; then
827 echo '#################### strace output'
Hiroshi Yamauchid630fd62015-09-04 12:52:03 -0700828 tail -n 3000 "$tmp_dir/$strace_output"
Hiroshi Yamauchi1d4184d2015-07-13 17:11:22 -0700829 echo '####################'
830 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700831 echo ' '
832 fi
Alex Lightbfac14a2014-07-30 09:41:21 -0700833
834) 1>&2
835
836# Clean up test files.
Igor Murashkin05f30e12015-06-10 15:57:17 -0700837if [ "$always_clean" = "yes" -o "$good" = "yes" ] && [ "$never_clean" = "no" ]; then
Alex Lightbfac14a2014-07-30 09:41:21 -0700838 cd "$oldwd"
839 rm -rf "$tmp_dir"
840 if [ "$target_mode" = "yes" -a "$build_exit" = "0" ]; then
841 adb shell rm -rf $DEX_LOCATION
842 fi
843 if [ "$good" = "yes" ]; then
844 exit 0
845 fi
846fi
847
848
849(
850 if [ "$always_clean" = "yes" ]; then
851 echo "${TEST_NAME} files deleted from host "
852 if [ "$target_mode" == "yes" ]; then
853 echo "and from target"
854 fi
855 else
856 echo "${TEST_NAME} files left in ${tmp_dir} on host"
857 if [ "$target_mode" == "yes" ]; then
858 echo "and in ${DEX_LOCATION} on target"
859 fi
Brian Carlstrom105215d2012-06-14 12:50:44 -0700860 fi
861
jeffhao5d1ac922011-09-29 17:41:15 -0700862) 1>&2
863
864exit 1