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