jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 1 | #!/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. |
| 19 | prog="$0" |
| 20 | while [ -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 |
| 29 | done |
| 30 | oldwd=`pwd` |
| 31 | progdir=`dirname "${prog}"` |
| 32 | cd "${progdir}" |
| 33 | progdir=`pwd` |
| 34 | prog="${progdir}"/`basename "${prog}"` |
Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 35 | test_dir="test-$$" |
Andreas Gampe | 5a79fde | 2014-08-06 13:12:26 -0700 | [diff] [blame] | 36 | if [ -z "$TMPDIR" ]; then |
| 37 | tmp_dir="/tmp/$USER/${test_dir}" |
| 38 | else |
| 39 | tmp_dir="${TMPDIR}/$USER/${test_dir}" |
| 40 | fi |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 41 | |
| 42 | export JAVA="java" |
Brian Carlstrom | 5103ce6 | 2014-03-30 16:17:42 -0700 | [diff] [blame] | 43 | export JAVAC="javac -g" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 44 | export RUN="${progdir}/etc/push-and-run-test-jar" |
Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 45 | export DEX_LOCATION=/data/run-test/${test_dir} |
Elliott Hughes | c717eef | 2012-06-15 16:01:26 -0700 | [diff] [blame] | 46 | export NEED_DEX="true" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 47 | |
Tsu Chiang Chuang | 4407e61 | 2012-07-19 16:13:43 -0700 | [diff] [blame] | 48 | # If dx was not set by the environment variable, assume it is in the path. |
| 49 | if [ -z "$DX" ]; then |
| 50 | export DX="dx" |
| 51 | fi |
| 52 | |
Tsu Chiang Chuang | 6674f8a | 2013-01-16 15:41:21 -0800 | [diff] [blame] | 53 | # If jasmin was not set by the environment variable, assume it is in the path. |
| 54 | if [ -z "$JASMIN" ]; then |
| 55 | export JASMIN="jasmin" |
| 56 | fi |
| 57 | |
| 58 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 59 | info="info.txt" |
| 60 | build="build" |
| 61 | run="run" |
| 62 | expected="expected.txt" |
Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 63 | check_cmd="check" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 64 | output="output.txt" |
| 65 | build_output="build-output.txt" |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 66 | lib="libartd.so" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 67 | run_args="--quiet" |
| 68 | |
Alex Light | 9d72253 | 2014-07-22 18:07:12 -0700 | [diff] [blame] | 69 | prebuild_mode="yes" |
Brian Carlstrom | 2613de4 | 2012-06-15 17:37:16 -0700 | [diff] [blame] | 70 | target_mode="yes" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 71 | dev_mode="no" |
| 72 | update_mode="no" |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 73 | debug_mode="no" |
| 74 | relocate="yes" |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 75 | runtime="art" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 76 | usage="no" |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 77 | build_only="no" |
Andreas Gampe | 2fe0792 | 2014-04-21 07:50:39 -0700 | [diff] [blame] | 78 | suffix64="" |
Jeff Hao | 85139a3 | 2014-07-23 11:52:52 -0700 | [diff] [blame] | 79 | trace="false" |
Alex Light | e7873ec | 2014-08-12 09:53:50 -0700 | [diff] [blame] | 80 | basic_verify="false" |
| 81 | gc_verify="false" |
| 82 | gc_stress="false" |
Alex Light | bfac14a | 2014-07-30 09:41:21 -0700 | [diff] [blame] | 83 | always_clean="no" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 84 | |
| 85 | while true; do |
| 86 | if [ "x$1" = "x--host" ]; then |
Brian Carlstrom | 2613de4 | 2012-06-15 17:37:16 -0700 | [diff] [blame] | 87 | target_mode="no" |
TDYa127 | b92bcab | 2012-04-08 00:09:51 -0700 | [diff] [blame] | 88 | DEX_LOCATION=$tmp_dir |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 89 | shift |
Elliott Hughes | 58bcc40 | 2012-02-14 14:10:10 -0800 | [diff] [blame] | 90 | elif [ "x$1" = "x--jvm" ]; then |
Brian Carlstrom | 2613de4 | 2012-06-15 17:37:16 -0700 | [diff] [blame] | 91 | target_mode="no" |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 92 | runtime="jvm" |
Elliott Hughes | c717eef | 2012-06-15 16:01:26 -0700 | [diff] [blame] | 93 | NEED_DEX="false" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 94 | shift |
Elliott Hughes | 58bcc40 | 2012-02-14 14:10:10 -0800 | [diff] [blame] | 95 | elif [ "x$1" = "x-O" ]; then |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 96 | lib="libart.so" |
| 97 | shift |
| 98 | elif [ "x$1" = "x--dalvik" ]; then |
| 99 | lib="libdvm.so" |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 100 | runtime="dalvik" |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 101 | shift |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 102 | elif [ "x$1" = "x--relocate" ]; then |
| 103 | relocate="yes" |
| 104 | shift |
| 105 | elif [ "x$1" = "x--no-relocate" ]; then |
| 106 | relocate="no" |
| 107 | shift |
| 108 | elif [ "x$1" = "x--prebuild" ]; then |
| 109 | prebuild_mode="yes" |
| 110 | shift; |
| 111 | elif [ "x$1" = "x--no-prebuild" ]; then |
| 112 | prebuild_mode="no" |
| 113 | shift; |
Alex Light | e7873ec | 2014-08-12 09:53:50 -0700 | [diff] [blame] | 114 | elif [ "x$1" = "x--gcverify" ]; then |
| 115 | basic_verify="true" |
| 116 | gc_verify="true" |
| 117 | shift |
| 118 | elif [ "x$1" = "x--gcstress" ]; then |
| 119 | basic_verify="true" |
| 120 | gc_stress="true" |
| 121 | shift |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 122 | elif [ "x$1" = "x--image" ]; then |
| 123 | shift |
| 124 | image="$1" |
| 125 | run_args="${run_args} --image $image" |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 126 | shift |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 127 | elif [ "x$1" = "x-Xcompiler-option" ]; then |
| 128 | shift |
| 129 | option="$1" |
| 130 | run_args="${run_args} -Xcompiler-option $option" |
| 131 | shift |
Mathieu Chartier | 769a5ad | 2014-05-18 15:30:10 -0700 | [diff] [blame] | 132 | elif [ "x$1" = "x--runtime-option" ]; then |
| 133 | shift |
| 134 | option="$1" |
| 135 | run_args="${run_args} --runtime-option $option" |
| 136 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 137 | elif [ "x$1" = "x--debug" ]; then |
| 138 | run_args="${run_args} --debug" |
| 139 | shift |
| 140 | elif [ "x$1" = "x--gdb" ]; then |
| 141 | run_args="${run_args} --gdb" |
| 142 | dev_mode="yes" |
| 143 | shift |
| 144 | elif [ "x$1" = "x--zygote" ]; then |
| 145 | run_args="${run_args} --zygote" |
| 146 | shift |
jeffhao | 0dff3f4 | 2012-11-20 15:13:43 -0800 | [diff] [blame] | 147 | elif [ "x$1" = "x--interpreter" ]; then |
| 148 | run_args="${run_args} --interpreter" |
| 149 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 150 | elif [ "x$1" = "x--no-verify" ]; then |
| 151 | run_args="${run_args} --no-verify" |
| 152 | shift |
| 153 | elif [ "x$1" = "x--no-optimize" ]; then |
| 154 | run_args="${run_args} --no-optimize" |
| 155 | shift |
| 156 | elif [ "x$1" = "x--no-precise" ]; then |
| 157 | run_args="${run_args} --no-precise" |
| 158 | shift |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 159 | elif [ "x$1" = "x--invoke-with" ]; then |
| 160 | shift |
| 161 | what="$1" |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 162 | if [ "x$what" = "x" ]; then |
| 163 | echo "$0 missing argument to --invoke-with" 1>&2 |
| 164 | usage="yes" |
| 165 | break |
| 166 | fi |
Ian Rogers | 0e03367 | 2013-04-19 10:22:46 -0700 | [diff] [blame] | 167 | run_args="${run_args} --invoke-with ${what}" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 168 | shift |
| 169 | elif [ "x$1" = "x--dev" ]; then |
| 170 | run_args="${run_args} --dev" |
| 171 | dev_mode="yes" |
| 172 | shift |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 173 | elif [ "x$1" = "x--build-only" ]; then |
| 174 | build_only="yes" |
| 175 | shift |
| 176 | elif [ "x$1" = "x--output-path" ]; then |
| 177 | shift |
| 178 | tmp_dir=$1 |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 179 | if [ "x$tmp_dir" = "x" ]; then |
| 180 | echo "$0 missing argument to --output-path" 1>&2 |
| 181 | usage="yes" |
| 182 | break |
| 183 | fi |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 184 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 185 | elif [ "x$1" = "x--update" ]; then |
| 186 | update_mode="yes" |
| 187 | shift |
| 188 | elif [ "x$1" = "x--help" ]; then |
| 189 | usage="yes" |
| 190 | shift |
Andreas Gampe | afbaa1a | 2014-03-25 18:09:32 -0700 | [diff] [blame] | 191 | elif [ "x$1" = "x--64" ]; then |
| 192 | run_args="${run_args} --64" |
Andreas Gampe | 2fe0792 | 2014-04-21 07:50:39 -0700 | [diff] [blame] | 193 | suffix64="64" |
Andreas Gampe | afbaa1a | 2014-03-25 18:09:32 -0700 | [diff] [blame] | 194 | shift |
Sebastien Hertz | 07aaac8 | 2014-07-09 15:59:05 +0200 | [diff] [blame] | 195 | elif [ "x$1" = "x--trace" ]; then |
Jeff Hao | 85139a3 | 2014-07-23 11:52:52 -0700 | [diff] [blame] | 196 | trace="true" |
Sebastien Hertz | 07aaac8 | 2014-07-09 15:59:05 +0200 | [diff] [blame] | 197 | shift |
Alex Light | bfac14a | 2014-07-30 09:41:21 -0700 | [diff] [blame] | 198 | elif [ "x$1" = "x--always-clean" ]; then |
| 199 | always_clean="yes" |
| 200 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 201 | elif expr "x$1" : "x--" >/dev/null 2>&1; then |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 202 | echo "unknown $0 option: $1" 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 203 | usage="yes" |
| 204 | break |
| 205 | else |
| 206 | break |
| 207 | fi |
| 208 | done |
Andreas Gampe | 3a12cfe | 2014-08-13 15:40:22 -0700 | [diff] [blame] | 209 | |
| 210 | # tmp_dir may be relative, resolve. |
| 211 | # |
| 212 | # Cannot use realpath, as it does not exist on Mac. |
| 213 | # Cannot us a simple "cd", as the path might not be created yet. |
| 214 | # Use -m option of readlink: canonicalizes, but allows non-existing components. |
Andreas Gampe | 907b699 | 2014-08-18 22:26:49 -0700 | [diff] [blame^] | 215 | noncanonical_tmp_dir=$tmp_dir |
Andreas Gampe | 3a12cfe | 2014-08-13 15:40:22 -0700 | [diff] [blame] | 216 | tmp_dir="`cd $oldwd ; readlink -m $tmp_dir`" |
| 217 | |
Dmitry Petrochenko | 81c56e7 | 2014-03-05 15:05:46 +0700 | [diff] [blame] | 218 | mkdir -p $tmp_dir |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 219 | |
Alex Light | e7873ec | 2014-08-12 09:53:50 -0700 | [diff] [blame] | 220 | if [ "$basic_verify" = "true" ]; then |
| 221 | run_args="${run_args} --runtime-option -Xgc:preverify --runtime-option -Xgc:postverify" |
| 222 | fi |
| 223 | if [ "$gc_verify" = "true" ]; then |
| 224 | run_args="${run_args} --runtime-option -Xgc:preverify_rosalloc --runtime-option -Xgc:postverify_rosalloc" |
| 225 | fi |
| 226 | if [ "$gc_stress" = "true" ]; then |
| 227 | run_args="${run_args} --runtime-option -Xgc:SS --runtime-option -Xms2m --runtime-option -Xmx2m" |
| 228 | fi |
Jeff Hao | 85139a3 | 2014-07-23 11:52:52 -0700 | [diff] [blame] | 229 | if [ "$trace" = "true" ]; then |
| 230 | run_args="${run_args} --runtime-option -Xmethod-trace --runtime-option -Xmethod-trace-file:${DEX_LOCATION}/trace.bin --runtime-option -Xmethod-trace-file-size:2000000" |
| 231 | fi |
| 232 | |
Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 233 | # Most interesting target architecture variables are Makefile variables, not environment variables. |
Nicolas Geoffray | 6fbcc12 | 2014-07-24 00:36:48 +0100 | [diff] [blame] | 234 | # Try to map the suffix64 flag and what we find in ${ANDROID_PRODUCT_OUT}/data/art-test to an architecture name. |
Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 235 | function guess_arch_name() { |
Nicolas Geoffray | 6fbcc12 | 2014-07-24 00:36:48 +0100 | [diff] [blame] | 236 | grep32bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm|x86|mips)$'` |
| 237 | grep64bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm64|x86_64)$'` |
Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 238 | if [ "x${suffix64}" = "x64" ]; then |
| 239 | target_arch_name=${grep64bit} |
| 240 | else |
| 241 | target_arch_name=${grep32bit} |
| 242 | fi |
| 243 | } |
| 244 | |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 245 | if [ "$target_mode" = "no" ]; then |
| 246 | if [ "$runtime" = "jvm" ]; then |
| 247 | RUN="${progdir}/etc/reference-run-test-classes" |
| 248 | if [ "$prebuild_mode" = "yes" ]; then |
| 249 | echo "--prebuild with --jvm is unsupported"; |
| 250 | exit 1; |
| 251 | fi |
| 252 | else |
| 253 | RUN="${progdir}/etc/host-run-test-jar" |
| 254 | if [ "$prebuild_mode" = "yes" ]; then |
| 255 | run_args="${run_args} --prebuild" |
| 256 | fi |
| 257 | fi |
| 258 | else |
| 259 | if [ "$prebuild_mode" = "yes" ]; then |
| 260 | RUN="${progdir}/etc/push-and-run-prebuilt-test-jar" |
| 261 | fi |
| 262 | fi |
| 263 | |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 264 | if [ ! "$runtime" = "jvm" ]; then |
| 265 | run_args="${run_args} --lib $lib" |
| 266 | fi |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 267 | |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 268 | if [ "$runtime" = "dalvik" ]; then |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 269 | if [ "$target_mode" = "no" ]; then |
Nicolas Geoffray | 6fbcc12 | 2014-07-24 00:36:48 +0100 | [diff] [blame] | 270 | framework="${ANDROID_PRODUCT_OUT}/system/framework" |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 271 | bpath="${framework}/core.jar:${framework}/conscrypt.jar:${framework}/okhttp.jar:${framework}/core-junit.jar:${framework}/bouncycastle.jar:${framework}/ext.jar" |
| 272 | run_args="${run_args} --boot -Xbootclasspath:${bpath}" |
| 273 | else |
| 274 | true # defaults to using target BOOTCLASSPATH |
| 275 | fi |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 276 | elif [ "$runtime" = "art" ]; then |
| 277 | if [ "$target_mode" = "no" ]; then |
Brian Carlstrom | 4353486 | 2014-02-19 01:13:52 -0800 | [diff] [blame] | 278 | # ANDROID_BUILD_TOP and ANDROID_HOST_OUT are not set in a build environment. |
| 279 | if [ -z "$ANDROID_BUILD_TOP" ]; then |
| 280 | export ANDROID_BUILD_TOP=$oldwd |
| 281 | fi |
| 282 | if [ -z "$ANDROID_HOST_OUT" ]; then |
| 283 | export ANDROID_HOST_OUT=$ANDROID_BUILD_TOP/out/host/linux-x86 |
| 284 | fi |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 285 | run_args="${run_args} --boot -Ximage:${ANDROID_HOST_OUT}/framework/core.art" |
Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 286 | run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib${suffix64}" |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 287 | else |
Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 288 | guess_arch_name |
| 289 | run_args="${run_args} --runtime-option -Djava.library.path=/data/art-test/${target_arch_name}" |
Brian Carlstrom | 0e12bdc | 2014-05-14 17:44:28 -0700 | [diff] [blame] | 290 | run_args="${run_args} --boot -Ximage:/data/art-test/core.art" |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 291 | fi |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 292 | if [ "$relocate" = "yes" ]; then |
| 293 | run_args="${run_args} --relocate" |
| 294 | else |
| 295 | run_args="${run_args} --no-relocate" |
| 296 | fi |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 297 | fi |
| 298 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 299 | if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then |
| 300 | echo "--dev and --update are mutually exclusive" 1>&2 |
| 301 | usage="yes" |
| 302 | fi |
| 303 | |
| 304 | if [ "$usage" = "no" ]; then |
| 305 | if [ "x$1" = "x" -o "x$1" = "x-" ]; then |
| 306 | test_dir=`basename "$oldwd"` |
| 307 | else |
| 308 | test_dir="$1" |
| 309 | fi |
| 310 | |
| 311 | if [ '!' -d "$test_dir" ]; then |
| 312 | td2=`echo ${test_dir}-*` |
| 313 | if [ '!' -d "$td2" ]; then |
| 314 | echo "${test_dir}: no such test directory" 1>&2 |
| 315 | usage="yes" |
| 316 | fi |
| 317 | test_dir="$td2" |
| 318 | fi |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 319 | # Shift to get rid of the test name argument. The rest of the arguments |
| 320 | # will get passed to the test run. |
| 321 | shift |
| 322 | fi |
| 323 | |
| 324 | if [ "$usage" = "yes" ]; then |
| 325 | prog=`basename $prog` |
| 326 | ( |
| 327 | echo "usage:" |
| 328 | echo " $prog --help Print this message." |
| 329 | echo " $prog [options] [test-name] Run test normally." |
| 330 | echo " $prog --dev [options] [test-name] Development mode" \ |
| 331 | "(dumps to stdout)." |
| 332 | echo " $prog --update [options] [test-name] Update mode" \ |
| 333 | "(replaces expected.txt)." |
| 334 | echo ' Omitting the test name or specifying "-" will use the' \ |
| 335 | "current directory." |
| 336 | echo " Runtime Options:" |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 337 | echo " -O Run non-debug rather than debug build (off by default)." |
| 338 | echo " -Xcompiler-option Pass an option to the compiler." |
Ian Rogers | 701aa64 | 2014-07-18 11:38:13 -0700 | [diff] [blame] | 339 | echo " --runtime-option Pass an option to the runtime." |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 340 | echo " --debug Wait for a debugger to attach." |
| 341 | echo " --gdb Run under gdb; incompatible with some tests." |
| 342 | echo " --build-only Build test files only (off by default)." |
| 343 | echo " --interpreter Enable interpreter only mode (off by default)." |
| 344 | echo " --no-verify Turn off verification (on by default)." |
| 345 | echo " --no-optimize Turn off optimization (on by default)." |
| 346 | echo " --no-precise Turn off precise GC (on by default)." |
| 347 | echo " --zygote Spawn the process from the Zygote." \ |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 348 | "If used, then the" |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 349 | echo " other runtime options are ignored." |
Alex Light | 9d72253 | 2014-07-22 18:07:12 -0700 | [diff] [blame] | 350 | echo " --prebuild Run dex2oat on the files before starting test. (default)" |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 351 | echo " --no-prebuild Do not run dex2oat on the files before starting" |
Alex Light | 9d72253 | 2014-07-22 18:07:12 -0700 | [diff] [blame] | 352 | echo " the test." |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 353 | echo " --relocate Force the use of relocating in the test, making" |
| 354 | echo " the image and oat files be relocated to a random" |
| 355 | echo " address before running. (default)" |
| 356 | echo " --no-relocate Force the use of no relocating in the test" |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 357 | echo " --host Use the host-mode virtual machine." |
| 358 | echo " --invoke-with Pass --invoke-with option to runtime." |
| 359 | echo " --dalvik Use Dalvik (off by default)." |
| 360 | echo " --jvm Use a host-local RI virtual machine." |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 361 | echo " --output-path [path] Location where to store the build" \ |
| 362 | "files." |
Andreas Gampe | afbaa1a | 2014-03-25 18:09:32 -0700 | [diff] [blame] | 363 | echo " --64 Run the test in 64-bit mode" |
Sebastien Hertz | 07aaac8 | 2014-07-09 15:59:05 +0200 | [diff] [blame] | 364 | echo " --trace Run with method tracing" |
Alex Light | e7873ec | 2014-08-12 09:53:50 -0700 | [diff] [blame] | 365 | echo " --gcstress Run with gc stress testing" |
| 366 | echo " --gcverify Run with gc verification" |
Alex Light | bfac14a | 2014-07-30 09:41:21 -0700 | [diff] [blame] | 367 | echo " --always-clean Delete the test files even if the test fails." |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 368 | ) 1>&2 |
| 369 | exit 1 |
| 370 | fi |
| 371 | |
| 372 | cd "$test_dir" |
| 373 | test_dir=`pwd` |
| 374 | |
| 375 | td_info="${test_dir}/${info}" |
| 376 | td_expected="${test_dir}/${expected}" |
| 377 | |
Brian Carlstrom | 22469aa | 2012-09-07 10:34:57 -0700 | [diff] [blame] | 378 | if [ ! -r $td_info ]; then |
| 379 | echo "${test_dir}: missing file $td_info" 1>&2 |
| 380 | exit 1 |
| 381 | fi |
| 382 | |
| 383 | if [ ! -r $td_expected ]; then |
| 384 | echo "${test_dir}: missing file $td_expected" 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 385 | exit 1 |
| 386 | fi |
| 387 | |
| 388 | # copy the test to a temp dir and run it |
| 389 | |
Elliott Hughes | 510c878 | 2011-10-06 10:57:34 -0700 | [diff] [blame] | 390 | echo "${test_dir}: building..." 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 391 | |
| 392 | rm -rf "$tmp_dir" |
| 393 | cp -Rp "$test_dir" "$tmp_dir" |
| 394 | cd "$tmp_dir" |
| 395 | |
| 396 | if [ '!' -r "$build" ]; then |
| 397 | cp "${progdir}/etc/default-build" build |
| 398 | fi |
| 399 | |
| 400 | if [ '!' -r "$run" ]; then |
| 401 | cp "${progdir}/etc/default-run" run |
| 402 | fi |
| 403 | |
Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 404 | if [ '!' -r "$check_cmd" ]; then |
| 405 | cp "${progdir}/etc/default-check" check |
| 406 | fi |
| 407 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 408 | chmod 755 "$build" |
| 409 | chmod 755 "$run" |
Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 410 | chmod 755 "$check_cmd" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 411 | |
Elliott Hughes | 8cbc8bc | 2011-10-04 11:19:45 -0700 | [diff] [blame] | 412 | export TEST_NAME=`basename ${test_dir}` |
| 413 | |
Ian Rogers | 997f0f9 | 2014-06-21 22:58:05 -0700 | [diff] [blame] | 414 | # To cause tests to fail fast, limit the file sizes created by dx, dex2oat and ART output to 2MB. |
| 415 | file_size_limit=2048 |
| 416 | if echo "$test_dir" | grep 089; then |
| 417 | file_size_limit=5120 |
| 418 | elif echo "$test_dir" | grep 083; then |
| 419 | file_size_limit=5120 |
Andreas Gampe | 855564b | 2014-07-25 02:32:19 -0700 | [diff] [blame] | 420 | elif echo "$test_dir" | grep 115; then |
| 421 | # Native bridge test copies libarttest.so into its directory, which needs 2MB already. |
| 422 | file_size_limit=5120 |
Ian Rogers | 997f0f9 | 2014-06-21 22:58:05 -0700 | [diff] [blame] | 423 | fi |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 424 | if ! ulimit -S "$file_size_limit"; then |
Ian Rogers | 997f0f9 | 2014-06-21 22:58:05 -0700 | [diff] [blame] | 425 | echo "ulimit file size setting failed" |
| 426 | fi |
| 427 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 428 | good="no" |
| 429 | if [ "$dev_mode" = "yes" ]; then |
| 430 | "./${build}" 2>&1 |
Elliott Hughes | 7ab3a2a | 2012-06-18 16:34:20 -0700 | [diff] [blame] | 431 | build_exit="$?" |
| 432 | echo "build exit status: $build_exit" 1>&2 |
| 433 | if [ "$build_exit" = '0' ]; then |
Elliott Hughes | 2bfc673 | 2012-11-27 20:40:51 -0800 | [diff] [blame] | 434 | echo "${test_dir}: running..." 1>&2 |
| 435 | "./${run}" $run_args "$@" 2>&1 |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 436 | run_exit="$?" |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 437 | echo "run exit status: $run_exit" 1>&2 |
| 438 | if [ "$run_exit" = "0" ]; then |
| 439 | good="yes" |
| 440 | fi |
Elliott Hughes | 7ab3a2a | 2012-06-18 16:34:20 -0700 | [diff] [blame] | 441 | fi |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 442 | elif [ "$update_mode" = "yes" ]; then |
| 443 | "./${build}" >"$build_output" 2>&1 |
| 444 | build_exit="$?" |
| 445 | if [ "$build_exit" = '0' ]; then |
Elliott Hughes | 2bfc673 | 2012-11-27 20:40:51 -0800 | [diff] [blame] | 446 | echo "${test_dir}: running..." 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 447 | "./${run}" $run_args "$@" >"$output" 2>&1 |
| 448 | sed -e 's/[[:cntrl:]]$//g' < "$output" >"${td_expected}" |
| 449 | good="yes" |
| 450 | else |
| 451 | cat "$build_output" 1>&2 |
| 452 | echo "build exit status: $build_exit" 1>&2 |
| 453 | fi |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 454 | elif [ "$build_only" = "yes" ]; then |
| 455 | good="yes" |
| 456 | "./${build}" >"$build_output" 2>&1 |
| 457 | build_exit="$?" |
| 458 | if [ "$build_exit" '!=' '0' ]; then |
| 459 | cp "$build_output" "$output" |
| 460 | echo "build exit status: $build_exit" >>"$output" |
| 461 | diff --strip-trailing-cr -q "$expected" "$output" >/dev/null |
| 462 | if [ "$?" '!=' "0" ]; then |
| 463 | good="no" |
| 464 | echo "BUILD FAILED For ${TEST_NAME}" |
| 465 | fi |
| 466 | fi |
Tsu Chiang Chuang | 379e2f5 | 2013-08-20 12:24:52 -0700 | [diff] [blame] | 467 | # Clean up extraneous files that are not used by tests. |
Tsu Chiang Chuang | 0160d99 | 2013-09-13 14:17:42 -0700 | [diff] [blame] | 468 | find $tmp_dir -mindepth 1 ! -regex ".*/\(.*jar\|$output\|$expected\)" | xargs rm -rf |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 469 | exit 0 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 470 | else |
| 471 | "./${build}" >"$build_output" 2>&1 |
| 472 | build_exit="$?" |
| 473 | if [ "$build_exit" = '0' ]; then |
Elliott Hughes | 2bfc673 | 2012-11-27 20:40:51 -0800 | [diff] [blame] | 474 | echo "${test_dir}: running..." 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 475 | "./${run}" $run_args "$@" >"$output" 2>&1 |
| 476 | else |
| 477 | cp "$build_output" "$output" |
Andreas Gampe | 907b699 | 2014-08-18 22:26:49 -0700 | [diff] [blame^] | 478 | echo "Failed to build in tmpdir=${tmp_dir} from oldwd=${oldwd} and cwd=`pwd`" |
| 479 | echo "Non-canonical tmpdir was ${noncanonical_tmp_dir}" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 480 | echo "build exit status: $build_exit" >>"$output" |
| 481 | fi |
Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 482 | ./$check_cmd "$expected" "$output" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 483 | if [ "$?" = "0" ]; then |
| 484 | # output == expected |
| 485 | good="yes" |
| 486 | echo "${test_dir}: succeeded!" 1>&2 |
| 487 | fi |
| 488 | fi |
| 489 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 490 | ( |
Alex Light | bfac14a | 2014-07-30 09:41:21 -0700 | [diff] [blame] | 491 | if [ "$good" != "yes" -a "$update_mode" != "yes" ]; then |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 492 | echo "${test_dir}: FAILED!" |
| 493 | echo ' ' |
| 494 | echo '#################### info' |
| 495 | cat "${td_info}" | sed 's/^/# /g' |
| 496 | echo '#################### diffs' |
Ian Rogers | 997f0f9 | 2014-06-21 22:58:05 -0700 | [diff] [blame] | 497 | diff --strip-trailing-cr -u "$expected" "$output" | tail -n 500 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 498 | echo '####################' |
| 499 | echo ' ' |
| 500 | fi |
Alex Light | bfac14a | 2014-07-30 09:41:21 -0700 | [diff] [blame] | 501 | |
| 502 | ) 1>&2 |
| 503 | |
| 504 | # Clean up test files. |
| 505 | if [ "$always_clean" = "yes" -o "$good" = "yes" ]; then |
| 506 | cd "$oldwd" |
| 507 | rm -rf "$tmp_dir" |
| 508 | if [ "$target_mode" = "yes" -a "$build_exit" = "0" ]; then |
| 509 | adb shell rm -rf $DEX_LOCATION |
| 510 | fi |
| 511 | if [ "$good" = "yes" ]; then |
| 512 | exit 0 |
| 513 | fi |
| 514 | fi |
| 515 | |
| 516 | |
| 517 | ( |
| 518 | if [ "$always_clean" = "yes" ]; then |
| 519 | echo "${TEST_NAME} files deleted from host " |
| 520 | if [ "$target_mode" == "yes" ]; then |
| 521 | echo "and from target" |
| 522 | fi |
| 523 | else |
| 524 | echo "${TEST_NAME} files left in ${tmp_dir} on host" |
| 525 | if [ "$target_mode" == "yes" ]; then |
| 526 | echo "and in ${DEX_LOCATION} on target" |
| 527 | fi |
Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 528 | fi |
| 529 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 530 | ) 1>&2 |
| 531 | |
| 532 | exit 1 |