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