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