blob: ca7e68c2630f55db4eae1e6cb440686d0480c116 [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"
20while [ -h "${prog}" ]; do
21 newProg=`/bin/ls -ld "${prog}"`
22 newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
23 if expr "x${newProg}" : 'x/' >/dev/null; then
24 prog="${newProg}"
25 else
26 progdir=`dirname "${prog}"`
27 prog="${progdir}/${newProg}"
28 fi
29done
30oldwd=`pwd`
31progdir=`dirname "${prog}"`
32cd "${progdir}"
33progdir=`pwd`
34prog="${progdir}"/`basename "${prog}"`
Brian Carlstrom105215d2012-06-14 12:50:44 -070035test_dir="test-$$"
Andreas Gampe5a79fde2014-08-06 13:12:26 -070036if [ -z "$TMPDIR" ]; then
37 tmp_dir="/tmp/$USER/${test_dir}"
38else
39 tmp_dir="${TMPDIR}/$USER/${test_dir}"
40fi
jeffhao5d1ac922011-09-29 17:41:15 -070041
42export JAVA="java"
Brian Carlstrom5103ce62014-03-30 16:17:42 -070043export JAVAC="javac -g"
jeffhao5d1ac922011-09-29 17:41:15 -070044export RUN="${progdir}/etc/push-and-run-test-jar"
Brian Carlstrom105215d2012-06-14 12:50:44 -070045export DEX_LOCATION=/data/run-test/${test_dir}
Elliott Hughesc717eef2012-06-15 16:01:26 -070046export NEED_DEX="true"
jeffhao5d1ac922011-09-29 17:41:15 -070047
Tsu Chiang Chuang4407e612012-07-19 16:13:43 -070048# If dx was not set by the environment variable, assume it is in the path.
49if [ -z "$DX" ]; then
50 export DX="dx"
51fi
52
Tsu Chiang Chuang6674f8a2013-01-16 15:41:21 -080053# If jasmin was not set by the environment variable, assume it is in the path.
54if [ -z "$JASMIN" ]; then
55 export JASMIN="jasmin"
56fi
57
58
jeffhao5d1ac922011-09-29 17:41:15 -070059info="info.txt"
60build="build"
61run="run"
62expected="expected.txt"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -070063check_cmd="check"
jeffhao5d1ac922011-09-29 17:41:15 -070064output="output.txt"
65build_output="build-output.txt"
Brian Carlstromdc959ea2013-10-28 00:44:49 -070066lib="libartd.so"
jeffhao5d1ac922011-09-29 17:41:15 -070067run_args="--quiet"
68
Alex Light9d722532014-07-22 18:07:12 -070069prebuild_mode="yes"
Brian Carlstrom2613de42012-06-15 17:37:16 -070070target_mode="yes"
jeffhao5d1ac922011-09-29 17:41:15 -070071dev_mode="no"
72update_mode="no"
Alex Lighta59dd802014-07-02 16:28:08 -070073debug_mode="no"
74relocate="yes"
Jeff Hao201803f2013-11-20 18:11:39 -080075runtime="art"
jeffhao5d1ac922011-09-29 17:41:15 -070076usage="no"
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -070077build_only="no"
Andreas Gampe2fe07922014-04-21 07:50:39 -070078suffix64=""
Jeff Hao85139a32014-07-23 11:52:52 -070079trace="false"
Alex Lightbfac14a2014-07-30 09:41:21 -070080always_clean="no"
jeffhao5d1ac922011-09-29 17:41:15 -070081
82while true; do
83 if [ "x$1" = "x--host" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -070084 target_mode="no"
TDYa127b92bcab2012-04-08 00:09:51 -070085 DEX_LOCATION=$tmp_dir
jeffhao5d1ac922011-09-29 17:41:15 -070086 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -080087 elif [ "x$1" = "x--jvm" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -070088 target_mode="no"
Jeff Hao201803f2013-11-20 18:11:39 -080089 runtime="jvm"
Elliott Hughesc717eef2012-06-15 16:01:26 -070090 NEED_DEX="false"
jeffhao5d1ac922011-09-29 17:41:15 -070091 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -080092 elif [ "x$1" = "x-O" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -070093 lib="libart.so"
94 shift
95 elif [ "x$1" = "x--dalvik" ]; then
96 lib="libdvm.so"
Jeff Hao201803f2013-11-20 18:11:39 -080097 runtime="dalvik"
Brian Carlstromdc959ea2013-10-28 00:44:49 -070098 shift
Alex Lighta59dd802014-07-02 16:28:08 -070099 elif [ "x$1" = "x--relocate" ]; then
100 relocate="yes"
101 shift
102 elif [ "x$1" = "x--no-relocate" ]; then
103 relocate="no"
104 shift
105 elif [ "x$1" = "x--prebuild" ]; then
106 prebuild_mode="yes"
107 shift;
108 elif [ "x$1" = "x--no-prebuild" ]; then
109 prebuild_mode="no"
110 shift;
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700111 elif [ "x$1" = "x--image" ]; then
112 shift
113 image="$1"
114 run_args="${run_args} --image $image"
Elliott Hughes7c046102011-10-19 18:16:03 -0700115 shift
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000116 elif [ "x$1" = "x-Xcompiler-option" ]; then
117 shift
118 option="$1"
119 run_args="${run_args} -Xcompiler-option $option"
120 shift
Mathieu Chartier769a5ad2014-05-18 15:30:10 -0700121 elif [ "x$1" = "x--runtime-option" ]; then
122 shift
123 option="$1"
124 run_args="${run_args} --runtime-option $option"
125 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700126 elif [ "x$1" = "x--debug" ]; then
127 run_args="${run_args} --debug"
128 shift
129 elif [ "x$1" = "x--gdb" ]; then
130 run_args="${run_args} --gdb"
131 dev_mode="yes"
132 shift
133 elif [ "x$1" = "x--zygote" ]; then
134 run_args="${run_args} --zygote"
135 shift
jeffhao0dff3f42012-11-20 15:13:43 -0800136 elif [ "x$1" = "x--interpreter" ]; then
137 run_args="${run_args} --interpreter"
138 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700139 elif [ "x$1" = "x--no-verify" ]; then
140 run_args="${run_args} --no-verify"
141 shift
142 elif [ "x$1" = "x--no-optimize" ]; then
143 run_args="${run_args} --no-optimize"
144 shift
145 elif [ "x$1" = "x--no-precise" ]; then
146 run_args="${run_args} --no-precise"
147 shift
Elliott Hughes7c046102011-10-19 18:16:03 -0700148 elif [ "x$1" = "x--invoke-with" ]; then
149 shift
150 what="$1"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700151 if [ "x$what" = "x" ]; then
152 echo "$0 missing argument to --invoke-with" 1>&2
153 usage="yes"
154 break
155 fi
Ian Rogers0e033672013-04-19 10:22:46 -0700156 run_args="${run_args} --invoke-with ${what}"
jeffhao5d1ac922011-09-29 17:41:15 -0700157 shift
158 elif [ "x$1" = "x--dev" ]; then
159 run_args="${run_args} --dev"
160 dev_mode="yes"
161 shift
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700162 elif [ "x$1" = "x--build-only" ]; then
163 build_only="yes"
164 shift
165 elif [ "x$1" = "x--output-path" ]; then
166 shift
167 tmp_dir=$1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700168 if [ "x$tmp_dir" = "x" ]; then
169 echo "$0 missing argument to --output-path" 1>&2
170 usage="yes"
171 break
172 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700173 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700174 elif [ "x$1" = "x--update" ]; then
175 update_mode="yes"
176 shift
177 elif [ "x$1" = "x--help" ]; then
178 usage="yes"
179 shift
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700180 elif [ "x$1" = "x--64" ]; then
181 run_args="${run_args} --64"
Andreas Gampe2fe07922014-04-21 07:50:39 -0700182 suffix64="64"
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700183 shift
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200184 elif [ "x$1" = "x--trace" ]; then
Jeff Hao85139a32014-07-23 11:52:52 -0700185 trace="true"
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200186 shift
Alex Lightbfac14a2014-07-30 09:41:21 -0700187 elif [ "x$1" = "x--always-clean" ]; then
188 always_clean="yes"
189 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700190 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -0700191 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700192 usage="yes"
193 break
194 else
195 break
196 fi
197done
Dmitry Petrochenko81c56e72014-03-05 15:05:46 +0700198mkdir -p $tmp_dir
jeffhao5d1ac922011-09-29 17:41:15 -0700199
Jeff Hao85139a32014-07-23 11:52:52 -0700200if [ "$trace" = "true" ]; then
201 run_args="${run_args} --runtime-option -Xmethod-trace --runtime-option -Xmethod-trace-file:${DEX_LOCATION}/trace.bin --runtime-option -Xmethod-trace-file-size:2000000"
202fi
203
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700204# Most interesting target architecture variables are Makefile variables, not environment variables.
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100205# Try to map the suffix64 flag and what we find in ${ANDROID_PRODUCT_OUT}/data/art-test to an architecture name.
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700206function guess_arch_name() {
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100207 grep32bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm|x86|mips)$'`
208 grep64bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm64|x86_64)$'`
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700209 if [ "x${suffix64}" = "x64" ]; then
210 target_arch_name=${grep64bit}
211 else
212 target_arch_name=${grep32bit}
213 fi
214}
215
Alex Lighta59dd802014-07-02 16:28:08 -0700216if [ "$target_mode" = "no" ]; then
217 if [ "$runtime" = "jvm" ]; then
218 RUN="${progdir}/etc/reference-run-test-classes"
219 if [ "$prebuild_mode" = "yes" ]; then
220 echo "--prebuild with --jvm is unsupported";
221 exit 1;
222 fi
223 else
224 RUN="${progdir}/etc/host-run-test-jar"
225 if [ "$prebuild_mode" = "yes" ]; then
226 run_args="${run_args} --prebuild"
227 fi
228 fi
229else
230 if [ "$prebuild_mode" = "yes" ]; then
231 RUN="${progdir}/etc/push-and-run-prebuilt-test-jar"
232 fi
233fi
234
Jeff Hao201803f2013-11-20 18:11:39 -0800235if [ ! "$runtime" = "jvm" ]; then
236 run_args="${run_args} --lib $lib"
237fi
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700238
Jeff Hao201803f2013-11-20 18:11:39 -0800239if [ "$runtime" = "dalvik" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700240 if [ "$target_mode" = "no" ]; then
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100241 framework="${ANDROID_PRODUCT_OUT}/system/framework"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700242 bpath="${framework}/core.jar:${framework}/conscrypt.jar:${framework}/okhttp.jar:${framework}/core-junit.jar:${framework}/bouncycastle.jar:${framework}/ext.jar"
243 run_args="${run_args} --boot -Xbootclasspath:${bpath}"
244 else
245 true # defaults to using target BOOTCLASSPATH
246 fi
Jeff Hao201803f2013-11-20 18:11:39 -0800247elif [ "$runtime" = "art" ]; then
248 if [ "$target_mode" = "no" ]; then
Brian Carlstrom43534862014-02-19 01:13:52 -0800249 # ANDROID_BUILD_TOP and ANDROID_HOST_OUT are not set in a build environment.
250 if [ -z "$ANDROID_BUILD_TOP" ]; then
251 export ANDROID_BUILD_TOP=$oldwd
252 fi
253 if [ -z "$ANDROID_HOST_OUT" ]; then
254 export ANDROID_HOST_OUT=$ANDROID_BUILD_TOP/out/host/linux-x86
255 fi
Jeff Hao201803f2013-11-20 18:11:39 -0800256 run_args="${run_args} --boot -Ximage:${ANDROID_HOST_OUT}/framework/core.art"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700257 run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib${suffix64}"
Jeff Hao201803f2013-11-20 18:11:39 -0800258 else
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700259 guess_arch_name
260 run_args="${run_args} --runtime-option -Djava.library.path=/data/art-test/${target_arch_name}"
Brian Carlstrom0e12bdc2014-05-14 17:44:28 -0700261 run_args="${run_args} --boot -Ximage:/data/art-test/core.art"
Jeff Hao201803f2013-11-20 18:11:39 -0800262 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700263 if [ "$relocate" = "yes" ]; then
264 run_args="${run_args} --relocate"
265 else
266 run_args="${run_args} --no-relocate"
267 fi
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700268fi
269
jeffhao5d1ac922011-09-29 17:41:15 -0700270if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then
271 echo "--dev and --update are mutually exclusive" 1>&2
272 usage="yes"
273fi
274
275if [ "$usage" = "no" ]; then
276 if [ "x$1" = "x" -o "x$1" = "x-" ]; then
277 test_dir=`basename "$oldwd"`
278 else
279 test_dir="$1"
280 fi
281
282 if [ '!' -d "$test_dir" ]; then
283 td2=`echo ${test_dir}-*`
284 if [ '!' -d "$td2" ]; then
285 echo "${test_dir}: no such test directory" 1>&2
286 usage="yes"
287 fi
288 test_dir="$td2"
289 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700290 # Shift to get rid of the test name argument. The rest of the arguments
291 # will get passed to the test run.
292 shift
293fi
294
295if [ "$usage" = "yes" ]; then
296 prog=`basename $prog`
297 (
298 echo "usage:"
299 echo " $prog --help Print this message."
300 echo " $prog [options] [test-name] Run test normally."
301 echo " $prog --dev [options] [test-name] Development mode" \
302 "(dumps to stdout)."
303 echo " $prog --update [options] [test-name] Update mode" \
304 "(replaces expected.txt)."
305 echo ' Omitting the test name or specifying "-" will use the' \
306 "current directory."
307 echo " Runtime Options:"
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000308 echo " -O Run non-debug rather than debug build (off by default)."
309 echo " -Xcompiler-option Pass an option to the compiler."
Ian Rogers701aa642014-07-18 11:38:13 -0700310 echo " --runtime-option Pass an option to the runtime."
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000311 echo " --debug Wait for a debugger to attach."
312 echo " --gdb Run under gdb; incompatible with some tests."
313 echo " --build-only Build test files only (off by default)."
314 echo " --interpreter Enable interpreter only mode (off by default)."
315 echo " --no-verify Turn off verification (on by default)."
316 echo " --no-optimize Turn off optimization (on by default)."
317 echo " --no-precise Turn off precise GC (on by default)."
318 echo " --zygote Spawn the process from the Zygote." \
jeffhao5d1ac922011-09-29 17:41:15 -0700319 "If used, then the"
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000320 echo " other runtime options are ignored."
Alex Light9d722532014-07-22 18:07:12 -0700321 echo " --prebuild Run dex2oat on the files before starting test. (default)"
Alex Lighta59dd802014-07-02 16:28:08 -0700322 echo " --no-prebuild Do not run dex2oat on the files before starting"
Alex Light9d722532014-07-22 18:07:12 -0700323 echo " the test."
Alex Lighta59dd802014-07-02 16:28:08 -0700324 echo " --relocate Force the use of relocating in the test, making"
325 echo " the image and oat files be relocated to a random"
326 echo " address before running. (default)"
327 echo " --no-relocate Force the use of no relocating in the test"
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000328 echo " --host Use the host-mode virtual machine."
329 echo " --invoke-with Pass --invoke-with option to runtime."
330 echo " --dalvik Use Dalvik (off by default)."
331 echo " --jvm Use a host-local RI virtual machine."
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700332 echo " --output-path [path] Location where to store the build" \
333 "files."
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700334 echo " --64 Run the test in 64-bit mode"
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200335 echo " --trace Run with method tracing"
Alex Lightbfac14a2014-07-30 09:41:21 -0700336 echo " --always-clean Delete the test files even if the test fails."
jeffhao5d1ac922011-09-29 17:41:15 -0700337 ) 1>&2
338 exit 1
339fi
340
341cd "$test_dir"
342test_dir=`pwd`
343
344td_info="${test_dir}/${info}"
345td_expected="${test_dir}/${expected}"
346
Brian Carlstrom22469aa2012-09-07 10:34:57 -0700347if [ ! -r $td_info ]; then
348 echo "${test_dir}: missing file $td_info" 1>&2
349 exit 1
350fi
351
352if [ ! -r $td_expected ]; then
353 echo "${test_dir}: missing file $td_expected" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700354 exit 1
355fi
356
357# copy the test to a temp dir and run it
358
Elliott Hughes510c8782011-10-06 10:57:34 -0700359echo "${test_dir}: building..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700360
361rm -rf "$tmp_dir"
362cp -Rp "$test_dir" "$tmp_dir"
363cd "$tmp_dir"
364
365if [ '!' -r "$build" ]; then
366 cp "${progdir}/etc/default-build" build
367fi
368
369if [ '!' -r "$run" ]; then
370 cp "${progdir}/etc/default-run" run
371fi
372
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700373if [ '!' -r "$check_cmd" ]; then
374 cp "${progdir}/etc/default-check" check
375fi
376
jeffhao5d1ac922011-09-29 17:41:15 -0700377chmod 755 "$build"
378chmod 755 "$run"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700379chmod 755 "$check_cmd"
jeffhao5d1ac922011-09-29 17:41:15 -0700380
Elliott Hughes8cbc8bc2011-10-04 11:19:45 -0700381export TEST_NAME=`basename ${test_dir}`
382
Ian Rogers997f0f92014-06-21 22:58:05 -0700383# To cause tests to fail fast, limit the file sizes created by dx, dex2oat and ART output to 2MB.
384file_size_limit=2048
385if echo "$test_dir" | grep 089; then
386 file_size_limit=5120
387elif echo "$test_dir" | grep 083; then
388 file_size_limit=5120
Andreas Gampe855564b2014-07-25 02:32:19 -0700389elif echo "$test_dir" | grep 115; then
390# Native bridge test copies libarttest.so into its directory, which needs 2MB already.
391 file_size_limit=5120
Ian Rogers997f0f92014-06-21 22:58:05 -0700392fi
Alex Lighta59dd802014-07-02 16:28:08 -0700393if ! ulimit -S "$file_size_limit"; then
Ian Rogers997f0f92014-06-21 22:58:05 -0700394 echo "ulimit file size setting failed"
395fi
396
jeffhao5d1ac922011-09-29 17:41:15 -0700397good="no"
398if [ "$dev_mode" = "yes" ]; then
399 "./${build}" 2>&1
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700400 build_exit="$?"
401 echo "build exit status: $build_exit" 1>&2
402 if [ "$build_exit" = '0' ]; then
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800403 echo "${test_dir}: running..." 1>&2
404 "./${run}" $run_args "$@" 2>&1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700405 run_exit="$?"
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800406 echo "run exit status: $run_exit" 1>&2
407 if [ "$run_exit" = "0" ]; then
408 good="yes"
409 fi
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700410 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700411elif [ "$update_mode" = "yes" ]; then
412 "./${build}" >"$build_output" 2>&1
413 build_exit="$?"
414 if [ "$build_exit" = '0' ]; then
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800415 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700416 "./${run}" $run_args "$@" >"$output" 2>&1
417 sed -e 's/[[:cntrl:]]$//g' < "$output" >"${td_expected}"
418 good="yes"
419 else
420 cat "$build_output" 1>&2
421 echo "build exit status: $build_exit" 1>&2
422 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700423elif [ "$build_only" = "yes" ]; then
424 good="yes"
425 "./${build}" >"$build_output" 2>&1
426 build_exit="$?"
427 if [ "$build_exit" '!=' '0' ]; then
428 cp "$build_output" "$output"
429 echo "build exit status: $build_exit" >>"$output"
430 diff --strip-trailing-cr -q "$expected" "$output" >/dev/null
431 if [ "$?" '!=' "0" ]; then
432 good="no"
433 echo "BUILD FAILED For ${TEST_NAME}"
434 fi
435 fi
Tsu Chiang Chuang379e2f52013-08-20 12:24:52 -0700436 # Clean up extraneous files that are not used by tests.
Tsu Chiang Chuang0160d992013-09-13 14:17:42 -0700437 find $tmp_dir -mindepth 1 ! -regex ".*/\(.*jar\|$output\|$expected\)" | xargs rm -rf
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700438 exit 0
jeffhao5d1ac922011-09-29 17:41:15 -0700439else
440 "./${build}" >"$build_output" 2>&1
441 build_exit="$?"
442 if [ "$build_exit" = '0' ]; then
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800443 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700444 "./${run}" $run_args "$@" >"$output" 2>&1
445 else
446 cp "$build_output" "$output"
447 echo "build exit status: $build_exit" >>"$output"
448 fi
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700449 ./$check_cmd "$expected" "$output"
jeffhao5d1ac922011-09-29 17:41:15 -0700450 if [ "$?" = "0" ]; then
451 # output == expected
452 good="yes"
453 echo "${test_dir}: succeeded!" 1>&2
454 fi
455fi
456
jeffhao5d1ac922011-09-29 17:41:15 -0700457(
Alex Lightbfac14a2014-07-30 09:41:21 -0700458 if [ "$good" != "yes" -a "$update_mode" != "yes" ]; then
jeffhao5d1ac922011-09-29 17:41:15 -0700459 echo "${test_dir}: FAILED!"
460 echo ' '
461 echo '#################### info'
462 cat "${td_info}" | sed 's/^/# /g'
463 echo '#################### diffs'
Ian Rogers997f0f92014-06-21 22:58:05 -0700464 diff --strip-trailing-cr -u "$expected" "$output" | tail -n 500
jeffhao5d1ac922011-09-29 17:41:15 -0700465 echo '####################'
466 echo ' '
467 fi
Alex Lightbfac14a2014-07-30 09:41:21 -0700468
469) 1>&2
470
471# Clean up test files.
472if [ "$always_clean" = "yes" -o "$good" = "yes" ]; then
473 cd "$oldwd"
474 rm -rf "$tmp_dir"
475 if [ "$target_mode" = "yes" -a "$build_exit" = "0" ]; then
476 adb shell rm -rf $DEX_LOCATION
477 fi
478 if [ "$good" = "yes" ]; then
479 exit 0
480 fi
481fi
482
483
484(
485 if [ "$always_clean" = "yes" ]; then
486 echo "${TEST_NAME} files deleted from host "
487 if [ "$target_mode" == "yes" ]; then
488 echo "and from target"
489 fi
490 else
491 echo "${TEST_NAME} files left in ${tmp_dir} on host"
492 if [ "$target_mode" == "yes" ]; then
493 echo "and in ${DEX_LOCATION} on target"
494 fi
Brian Carlstrom105215d2012-06-14 12:50:44 -0700495 fi
496
jeffhao5d1ac922011-09-29 17:41:15 -0700497) 1>&2
498
499exit 1