blob: aef7c52120c20b7e3eef92c46fcf46ad162424b8 [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-$$"
Dmitry Petrochenko81c56e72014-03-05 15:05:46 +070036tmp_dir="/tmp/$USER/${test_dir}"
jeffhao5d1ac922011-09-29 17:41:15 -070037
38export JAVA="java"
Brian Carlstrom5103ce62014-03-30 16:17:42 -070039export JAVAC="javac -g"
jeffhao5d1ac922011-09-29 17:41:15 -070040export RUN="${progdir}/etc/push-and-run-test-jar"
Brian Carlstrom105215d2012-06-14 12:50:44 -070041export DEX_LOCATION=/data/run-test/${test_dir}
Elliott Hughesc717eef2012-06-15 16:01:26 -070042export NEED_DEX="true"
jeffhao5d1ac922011-09-29 17:41:15 -070043
Tsu Chiang Chuang4407e612012-07-19 16:13:43 -070044# If dx was not set by the environment variable, assume it is in the path.
45if [ -z "$DX" ]; then
46 export DX="dx"
47fi
48
Tsu Chiang Chuang6674f8a2013-01-16 15:41:21 -080049# If jasmin was not set by the environment variable, assume it is in the path.
50if [ -z "$JASMIN" ]; then
51 export JASMIN="jasmin"
52fi
53
54
jeffhao5d1ac922011-09-29 17:41:15 -070055info="info.txt"
56build="build"
57run="run"
58expected="expected.txt"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -070059check_cmd="check"
jeffhao5d1ac922011-09-29 17:41:15 -070060output="output.txt"
61build_output="build-output.txt"
Brian Carlstromdc959ea2013-10-28 00:44:49 -070062lib="libartd.so"
jeffhao5d1ac922011-09-29 17:41:15 -070063run_args="--quiet"
64
Alex Light9d722532014-07-22 18:07:12 -070065prebuild_mode="yes"
Brian Carlstrom2613de42012-06-15 17:37:16 -070066target_mode="yes"
jeffhao5d1ac922011-09-29 17:41:15 -070067dev_mode="no"
68update_mode="no"
Alex Lighta59dd802014-07-02 16:28:08 -070069debug_mode="no"
70relocate="yes"
Jeff Hao201803f2013-11-20 18:11:39 -080071runtime="art"
jeffhao5d1ac922011-09-29 17:41:15 -070072usage="no"
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -070073build_only="no"
Andreas Gampe2fe07922014-04-21 07:50:39 -070074suffix64=""
Jeff Hao85139a32014-07-23 11:52:52 -070075trace="false"
Alex Lightbfac14a2014-07-30 09:41:21 -070076always_clean="no"
jeffhao5d1ac922011-09-29 17:41:15 -070077
78while true; do
79 if [ "x$1" = "x--host" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -070080 target_mode="no"
TDYa127b92bcab2012-04-08 00:09:51 -070081 DEX_LOCATION=$tmp_dir
jeffhao5d1ac922011-09-29 17:41:15 -070082 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -080083 elif [ "x$1" = "x--jvm" ]; then
Brian Carlstrom2613de42012-06-15 17:37:16 -070084 target_mode="no"
Jeff Hao201803f2013-11-20 18:11:39 -080085 runtime="jvm"
Elliott Hughesc717eef2012-06-15 16:01:26 -070086 NEED_DEX="false"
jeffhao5d1ac922011-09-29 17:41:15 -070087 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -080088 elif [ "x$1" = "x-O" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -070089 lib="libart.so"
90 shift
91 elif [ "x$1" = "x--dalvik" ]; then
92 lib="libdvm.so"
Jeff Hao201803f2013-11-20 18:11:39 -080093 runtime="dalvik"
Brian Carlstromdc959ea2013-10-28 00:44:49 -070094 shift
Alex Lighta59dd802014-07-02 16:28:08 -070095 elif [ "x$1" = "x--relocate" ]; then
96 relocate="yes"
97 shift
98 elif [ "x$1" = "x--no-relocate" ]; then
99 relocate="no"
100 shift
101 elif [ "x$1" = "x--prebuild" ]; then
102 prebuild_mode="yes"
103 shift;
104 elif [ "x$1" = "x--no-prebuild" ]; then
105 prebuild_mode="no"
106 shift;
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700107 elif [ "x$1" = "x--image" ]; then
108 shift
109 image="$1"
110 run_args="${run_args} --image $image"
Elliott Hughes7c046102011-10-19 18:16:03 -0700111 shift
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000112 elif [ "x$1" = "x-Xcompiler-option" ]; then
113 shift
114 option="$1"
115 run_args="${run_args} -Xcompiler-option $option"
116 shift
Mathieu Chartier769a5ad2014-05-18 15:30:10 -0700117 elif [ "x$1" = "x--runtime-option" ]; then
118 shift
119 option="$1"
120 run_args="${run_args} --runtime-option $option"
121 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700122 elif [ "x$1" = "x--debug" ]; then
123 run_args="${run_args} --debug"
124 shift
125 elif [ "x$1" = "x--gdb" ]; then
126 run_args="${run_args} --gdb"
127 dev_mode="yes"
128 shift
129 elif [ "x$1" = "x--zygote" ]; then
130 run_args="${run_args} --zygote"
131 shift
jeffhao0dff3f42012-11-20 15:13:43 -0800132 elif [ "x$1" = "x--interpreter" ]; then
133 run_args="${run_args} --interpreter"
134 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700135 elif [ "x$1" = "x--no-verify" ]; then
136 run_args="${run_args} --no-verify"
137 shift
138 elif [ "x$1" = "x--no-optimize" ]; then
139 run_args="${run_args} --no-optimize"
140 shift
141 elif [ "x$1" = "x--no-precise" ]; then
142 run_args="${run_args} --no-precise"
143 shift
Elliott Hughes7c046102011-10-19 18:16:03 -0700144 elif [ "x$1" = "x--invoke-with" ]; then
145 shift
146 what="$1"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700147 if [ "x$what" = "x" ]; then
148 echo "$0 missing argument to --invoke-with" 1>&2
149 usage="yes"
150 break
151 fi
Ian Rogers0e033672013-04-19 10:22:46 -0700152 run_args="${run_args} --invoke-with ${what}"
jeffhao5d1ac922011-09-29 17:41:15 -0700153 shift
154 elif [ "x$1" = "x--dev" ]; then
155 run_args="${run_args} --dev"
156 dev_mode="yes"
157 shift
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700158 elif [ "x$1" = "x--build-only" ]; then
159 build_only="yes"
160 shift
161 elif [ "x$1" = "x--output-path" ]; then
162 shift
163 tmp_dir=$1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700164 if [ "x$tmp_dir" = "x" ]; then
165 echo "$0 missing argument to --output-path" 1>&2
166 usage="yes"
167 break
168 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700169 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700170 elif [ "x$1" = "x--update" ]; then
171 update_mode="yes"
172 shift
173 elif [ "x$1" = "x--help" ]; then
174 usage="yes"
175 shift
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700176 elif [ "x$1" = "x--64" ]; then
177 run_args="${run_args} --64"
Andreas Gampe2fe07922014-04-21 07:50:39 -0700178 suffix64="64"
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700179 shift
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200180 elif [ "x$1" = "x--trace" ]; then
Jeff Hao85139a32014-07-23 11:52:52 -0700181 trace="true"
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200182 shift
Alex Lightbfac14a2014-07-30 09:41:21 -0700183 elif [ "x$1" = "x--always-clean" ]; then
184 always_clean="yes"
185 shift
jeffhao5d1ac922011-09-29 17:41:15 -0700186 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -0700187 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700188 usage="yes"
189 break
190 else
191 break
192 fi
193done
Dmitry Petrochenko81c56e72014-03-05 15:05:46 +0700194mkdir -p $tmp_dir
jeffhao5d1ac922011-09-29 17:41:15 -0700195
Jeff Hao85139a32014-07-23 11:52:52 -0700196if [ "$trace" = "true" ]; then
197 run_args="${run_args} --runtime-option -Xmethod-trace --runtime-option -Xmethod-trace-file:${DEX_LOCATION}/trace.bin --runtime-option -Xmethod-trace-file-size:2000000"
198fi
199
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700200# Most interesting target architecture variables are Makefile variables, not environment variables.
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100201# 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 -0700202function guess_arch_name() {
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100203 grep32bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm|x86|mips)$'`
204 grep64bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm64|x86_64)$'`
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700205 if [ "x${suffix64}" = "x64" ]; then
206 target_arch_name=${grep64bit}
207 else
208 target_arch_name=${grep32bit}
209 fi
210}
211
Alex Lighta59dd802014-07-02 16:28:08 -0700212if [ "$target_mode" = "no" ]; then
213 if [ "$runtime" = "jvm" ]; then
214 RUN="${progdir}/etc/reference-run-test-classes"
215 if [ "$prebuild_mode" = "yes" ]; then
216 echo "--prebuild with --jvm is unsupported";
217 exit 1;
218 fi
219 else
220 RUN="${progdir}/etc/host-run-test-jar"
221 if [ "$prebuild_mode" = "yes" ]; then
222 run_args="${run_args} --prebuild"
223 fi
224 fi
225else
226 if [ "$prebuild_mode" = "yes" ]; then
227 RUN="${progdir}/etc/push-and-run-prebuilt-test-jar"
228 fi
229fi
230
Jeff Hao201803f2013-11-20 18:11:39 -0800231if [ ! "$runtime" = "jvm" ]; then
232 run_args="${run_args} --lib $lib"
233fi
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700234
Jeff Hao201803f2013-11-20 18:11:39 -0800235if [ "$runtime" = "dalvik" ]; then
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700236 if [ "$target_mode" = "no" ]; then
Nicolas Geoffray6fbcc122014-07-24 00:36:48 +0100237 framework="${ANDROID_PRODUCT_OUT}/system/framework"
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700238 bpath="${framework}/core.jar:${framework}/conscrypt.jar:${framework}/okhttp.jar:${framework}/core-junit.jar:${framework}/bouncycastle.jar:${framework}/ext.jar"
239 run_args="${run_args} --boot -Xbootclasspath:${bpath}"
240 else
241 true # defaults to using target BOOTCLASSPATH
242 fi
Jeff Hao201803f2013-11-20 18:11:39 -0800243elif [ "$runtime" = "art" ]; then
244 if [ "$target_mode" = "no" ]; then
Brian Carlstrom43534862014-02-19 01:13:52 -0800245 # ANDROID_BUILD_TOP and ANDROID_HOST_OUT are not set in a build environment.
246 if [ -z "$ANDROID_BUILD_TOP" ]; then
247 export ANDROID_BUILD_TOP=$oldwd
248 fi
249 if [ -z "$ANDROID_HOST_OUT" ]; then
250 export ANDROID_HOST_OUT=$ANDROID_BUILD_TOP/out/host/linux-x86
251 fi
Jeff Hao201803f2013-11-20 18:11:39 -0800252 run_args="${run_args} --boot -Ximage:${ANDROID_HOST_OUT}/framework/core.art"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700253 run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib${suffix64}"
Jeff Hao201803f2013-11-20 18:11:39 -0800254 else
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700255 guess_arch_name
256 run_args="${run_args} --runtime-option -Djava.library.path=/data/art-test/${target_arch_name}"
Brian Carlstrom0e12bdc2014-05-14 17:44:28 -0700257 run_args="${run_args} --boot -Ximage:/data/art-test/core.art"
Jeff Hao201803f2013-11-20 18:11:39 -0800258 fi
Alex Lighta59dd802014-07-02 16:28:08 -0700259 if [ "$relocate" = "yes" ]; then
260 run_args="${run_args} --relocate"
261 else
262 run_args="${run_args} --no-relocate"
263 fi
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700264fi
265
jeffhao5d1ac922011-09-29 17:41:15 -0700266if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then
267 echo "--dev and --update are mutually exclusive" 1>&2
268 usage="yes"
269fi
270
271if [ "$usage" = "no" ]; then
272 if [ "x$1" = "x" -o "x$1" = "x-" ]; then
273 test_dir=`basename "$oldwd"`
274 else
275 test_dir="$1"
276 fi
277
278 if [ '!' -d "$test_dir" ]; then
279 td2=`echo ${test_dir}-*`
280 if [ '!' -d "$td2" ]; then
281 echo "${test_dir}: no such test directory" 1>&2
282 usage="yes"
283 fi
284 test_dir="$td2"
285 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700286 # Shift to get rid of the test name argument. The rest of the arguments
287 # will get passed to the test run.
288 shift
289fi
290
291if [ "$usage" = "yes" ]; then
292 prog=`basename $prog`
293 (
294 echo "usage:"
295 echo " $prog --help Print this message."
296 echo " $prog [options] [test-name] Run test normally."
297 echo " $prog --dev [options] [test-name] Development mode" \
298 "(dumps to stdout)."
299 echo " $prog --update [options] [test-name] Update mode" \
300 "(replaces expected.txt)."
301 echo ' Omitting the test name or specifying "-" will use the' \
302 "current directory."
303 echo " Runtime Options:"
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000304 echo " -O Run non-debug rather than debug build (off by default)."
305 echo " -Xcompiler-option Pass an option to the compiler."
Ian Rogers701aa642014-07-18 11:38:13 -0700306 echo " --runtime-option Pass an option to the runtime."
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000307 echo " --debug Wait for a debugger to attach."
308 echo " --gdb Run under gdb; incompatible with some tests."
309 echo " --build-only Build test files only (off by default)."
310 echo " --interpreter Enable interpreter only mode (off by default)."
311 echo " --no-verify Turn off verification (on by default)."
312 echo " --no-optimize Turn off optimization (on by default)."
313 echo " --no-precise Turn off precise GC (on by default)."
314 echo " --zygote Spawn the process from the Zygote." \
jeffhao5d1ac922011-09-29 17:41:15 -0700315 "If used, then the"
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000316 echo " other runtime options are ignored."
Alex Light9d722532014-07-22 18:07:12 -0700317 echo " --prebuild Run dex2oat on the files before starting test. (default)"
Alex Lighta59dd802014-07-02 16:28:08 -0700318 echo " --no-prebuild Do not run dex2oat on the files before starting"
Alex Light9d722532014-07-22 18:07:12 -0700319 echo " the test."
Alex Lighta59dd802014-07-02 16:28:08 -0700320 echo " --relocate Force the use of relocating in the test, making"
321 echo " the image and oat files be relocated to a random"
322 echo " address before running. (default)"
323 echo " --no-relocate Force the use of no relocating in the test"
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000324 echo " --host Use the host-mode virtual machine."
325 echo " --invoke-with Pass --invoke-with option to runtime."
326 echo " --dalvik Use Dalvik (off by default)."
327 echo " --jvm Use a host-local RI virtual machine."
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700328 echo " --output-path [path] Location where to store the build" \
329 "files."
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700330 echo " --64 Run the test in 64-bit mode"
Sebastien Hertz07aaac82014-07-09 15:59:05 +0200331 echo " --trace Run with method tracing"
Alex Lightbfac14a2014-07-30 09:41:21 -0700332 echo " --always-clean Delete the test files even if the test fails."
jeffhao5d1ac922011-09-29 17:41:15 -0700333 ) 1>&2
334 exit 1
335fi
336
337cd "$test_dir"
338test_dir=`pwd`
339
340td_info="${test_dir}/${info}"
341td_expected="${test_dir}/${expected}"
342
Brian Carlstrom22469aa2012-09-07 10:34:57 -0700343if [ ! -r $td_info ]; then
344 echo "${test_dir}: missing file $td_info" 1>&2
345 exit 1
346fi
347
348if [ ! -r $td_expected ]; then
349 echo "${test_dir}: missing file $td_expected" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700350 exit 1
351fi
352
353# copy the test to a temp dir and run it
354
Elliott Hughes510c8782011-10-06 10:57:34 -0700355echo "${test_dir}: building..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700356
357rm -rf "$tmp_dir"
358cp -Rp "$test_dir" "$tmp_dir"
359cd "$tmp_dir"
360
361if [ '!' -r "$build" ]; then
362 cp "${progdir}/etc/default-build" build
363fi
364
365if [ '!' -r "$run" ]; then
366 cp "${progdir}/etc/default-run" run
367fi
368
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700369if [ '!' -r "$check_cmd" ]; then
370 cp "${progdir}/etc/default-check" check
371fi
372
jeffhao5d1ac922011-09-29 17:41:15 -0700373chmod 755 "$build"
374chmod 755 "$run"
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700375chmod 755 "$check_cmd"
jeffhao5d1ac922011-09-29 17:41:15 -0700376
Elliott Hughes8cbc8bc2011-10-04 11:19:45 -0700377export TEST_NAME=`basename ${test_dir}`
378
Ian Rogers997f0f92014-06-21 22:58:05 -0700379# To cause tests to fail fast, limit the file sizes created by dx, dex2oat and ART output to 2MB.
380file_size_limit=2048
381if echo "$test_dir" | grep 089; then
382 file_size_limit=5120
383elif echo "$test_dir" | grep 083; then
384 file_size_limit=5120
Andreas Gampe855564b2014-07-25 02:32:19 -0700385elif echo "$test_dir" | grep 115; then
386# Native bridge test copies libarttest.so into its directory, which needs 2MB already.
387 file_size_limit=5120
Ian Rogers997f0f92014-06-21 22:58:05 -0700388fi
Alex Lighta59dd802014-07-02 16:28:08 -0700389if ! ulimit -S "$file_size_limit"; then
Ian Rogers997f0f92014-06-21 22:58:05 -0700390 echo "ulimit file size setting failed"
391fi
392
jeffhao5d1ac922011-09-29 17:41:15 -0700393good="no"
394if [ "$dev_mode" = "yes" ]; then
395 "./${build}" 2>&1
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700396 build_exit="$?"
397 echo "build exit status: $build_exit" 1>&2
398 if [ "$build_exit" = '0' ]; then
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800399 echo "${test_dir}: running..." 1>&2
400 "./${run}" $run_args "$@" 2>&1
Brian Carlstromdc959ea2013-10-28 00:44:49 -0700401 run_exit="$?"
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800402 echo "run exit status: $run_exit" 1>&2
403 if [ "$run_exit" = "0" ]; then
404 good="yes"
405 fi
Elliott Hughes7ab3a2a2012-06-18 16:34:20 -0700406 fi
jeffhao5d1ac922011-09-29 17:41:15 -0700407elif [ "$update_mode" = "yes" ]; then
408 "./${build}" >"$build_output" 2>&1
409 build_exit="$?"
410 if [ "$build_exit" = '0' ]; then
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800411 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700412 "./${run}" $run_args "$@" >"$output" 2>&1
413 sed -e 's/[[:cntrl:]]$//g' < "$output" >"${td_expected}"
414 good="yes"
415 else
416 cat "$build_output" 1>&2
417 echo "build exit status: $build_exit" 1>&2
418 fi
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700419elif [ "$build_only" = "yes" ]; then
420 good="yes"
421 "./${build}" >"$build_output" 2>&1
422 build_exit="$?"
423 if [ "$build_exit" '!=' '0' ]; then
424 cp "$build_output" "$output"
425 echo "build exit status: $build_exit" >>"$output"
426 diff --strip-trailing-cr -q "$expected" "$output" >/dev/null
427 if [ "$?" '!=' "0" ]; then
428 good="no"
429 echo "BUILD FAILED For ${TEST_NAME}"
430 fi
431 fi
Tsu Chiang Chuang379e2f52013-08-20 12:24:52 -0700432 # Clean up extraneous files that are not used by tests.
Tsu Chiang Chuang0160d992013-09-13 14:17:42 -0700433 find $tmp_dir -mindepth 1 ! -regex ".*/\(.*jar\|$output\|$expected\)" | xargs rm -rf
Tsu Chiang Chuang011fade2012-07-09 18:34:47 -0700434 exit 0
jeffhao5d1ac922011-09-29 17:41:15 -0700435else
436 "./${build}" >"$build_output" 2>&1
437 build_exit="$?"
438 if [ "$build_exit" = '0' ]; then
Elliott Hughes2bfc6732012-11-27 20:40:51 -0800439 echo "${test_dir}: running..." 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -0700440 "./${run}" $run_args "$@" >"$output" 2>&1
441 else
442 cp "$build_output" "$output"
443 echo "build exit status: $build_exit" >>"$output"
444 fi
Andreas Gampe1c83cbc2014-07-22 18:52:29 -0700445 ./$check_cmd "$expected" "$output"
jeffhao5d1ac922011-09-29 17:41:15 -0700446 if [ "$?" = "0" ]; then
447 # output == expected
448 good="yes"
449 echo "${test_dir}: succeeded!" 1>&2
450 fi
451fi
452
jeffhao5d1ac922011-09-29 17:41:15 -0700453(
Alex Lightbfac14a2014-07-30 09:41:21 -0700454 if [ "$good" != "yes" -a "$update_mode" != "yes" ]; then
jeffhao5d1ac922011-09-29 17:41:15 -0700455 echo "${test_dir}: FAILED!"
456 echo ' '
457 echo '#################### info'
458 cat "${td_info}" | sed 's/^/# /g'
459 echo '#################### diffs'
Ian Rogers997f0f92014-06-21 22:58:05 -0700460 diff --strip-trailing-cr -u "$expected" "$output" | tail -n 500
jeffhao5d1ac922011-09-29 17:41:15 -0700461 echo '####################'
462 echo ' '
463 fi
Alex Lightbfac14a2014-07-30 09:41:21 -0700464
465) 1>&2
466
467# Clean up test files.
468if [ "$always_clean" = "yes" -o "$good" = "yes" ]; then
469 cd "$oldwd"
470 rm -rf "$tmp_dir"
471 if [ "$target_mode" = "yes" -a "$build_exit" = "0" ]; then
472 adb shell rm -rf $DEX_LOCATION
473 fi
474 if [ "$good" = "yes" ]; then
475 exit 0
476 fi
477fi
478
479
480(
481 if [ "$always_clean" = "yes" ]; then
482 echo "${TEST_NAME} files deleted from host "
483 if [ "$target_mode" == "yes" ]; then
484 echo "and from target"
485 fi
486 else
487 echo "${TEST_NAME} files left in ${tmp_dir} on host"
488 if [ "$target_mode" == "yes" ]; then
489 echo "and in ${DEX_LOCATION} on target"
490 fi
Brian Carlstrom105215d2012-06-14 12:50:44 -0700491 fi
492
jeffhao5d1ac922011-09-29 17:41:15 -0700493) 1>&2
494
495exit 1