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