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