| 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 | 2c27f2c | 2015-05-12 18:06:38 +0100 | [diff] [blame] | 42 | checker="${progdir}/../tools/checker/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 | 
| Andreas Gampe | 3f1dc56 | 2015-05-18 15:52:22 -0700 | [diff] [blame^] | 371 | elif [ "$runtime" = "jvm" ]; then | 
 | 372 |     # TODO: Detect whether the host is 32-bit or 64-bit. | 
 | 373 |     run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib64" | 
| Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 374 | fi | 
 | 375 |  | 
| Alex Light | 03a112d | 2014-08-25 13:25:56 -0700 | [diff] [blame] | 376 | if [ "$have_image" = "no" ]; then | 
| Alex Light | 1ef4ce8 | 2014-08-27 11:13:47 -0700 | [diff] [blame] | 377 |     if [ "$runtime" != "art" ]; then | 
 | 378 |         echo "--no-image is only supported on the art runtime" | 
 | 379 |         exit 1 | 
 | 380 |     fi | 
 | 381 |     if [ "$target_mode" = "no" ]; then | 
 | 382 |         framework="${ANDROID_HOST_OUT}/framework" | 
 | 383 |         bpath_suffix="-hostdex" | 
 | 384 |     else | 
| Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 385 |         framework="${android_root}/framework" | 
| Alex Light | 1ef4ce8 | 2014-08-27 11:13:47 -0700 | [diff] [blame] | 386 |         bpath_suffix="" | 
 | 387 |     fi | 
 | 388 |     # TODO If the target was compiled WITH_DEXPREOPT=true then these tests will | 
 | 389 |     # fail since these jar files will be stripped. | 
 | 390 |     bpath="${framework}/core-libart${bpath_suffix}.jar" | 
 | 391 |     bpath="${bpath}:${framework}/conscrypt${bpath_suffix}.jar" | 
 | 392 |     bpath="${bpath}:${framework}/okhttp${bpath_suffix}.jar" | 
 | 393 |     bpath="${bpath}:${framework}/core-junit${bpath_suffix}.jar" | 
 | 394 |     bpath="${bpath}:${framework}/bouncycastle${bpath_suffix}.jar" | 
 | 395 |     # Pass down the bootclasspath | 
 | 396 |     run_args="${run_args} --runtime-option -Xbootclasspath:${bpath}" | 
| Alex Light | 03a112d | 2014-08-25 13:25:56 -0700 | [diff] [blame] | 397 |     run_args="${run_args} --no-image" | 
 | 398 | fi | 
 | 399 |  | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 400 | if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then | 
 | 401 |     echo "--dev and --update are mutually exclusive" 1>&2 | 
 | 402 |     usage="yes" | 
 | 403 | fi | 
 | 404 |  | 
 | 405 | if [ "$usage" = "no" ]; then | 
 | 406 |     if [ "x$1" = "x" -o "x$1" = "x-" ]; then | 
 | 407 |         test_dir=`basename "$oldwd"` | 
 | 408 |     else | 
 | 409 |         test_dir="$1" | 
 | 410 |     fi | 
 | 411 |  | 
 | 412 |     if [ '!' -d "$test_dir" ]; then | 
 | 413 |         td2=`echo ${test_dir}-*` | 
 | 414 |         if [ '!' -d "$td2" ]; then | 
 | 415 |             echo "${test_dir}: no such test directory" 1>&2 | 
 | 416 |             usage="yes" | 
 | 417 |         fi | 
 | 418 |         test_dir="$td2" | 
 | 419 |     fi | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 420 |     # Shift to get rid of the test name argument. The rest of the arguments | 
 | 421 |     # will get passed to the test run. | 
 | 422 |     shift | 
 | 423 | fi | 
 | 424 |  | 
 | 425 | if [ "$usage" = "yes" ]; then | 
 | 426 |     prog=`basename $prog` | 
 | 427 |     ( | 
 | 428 |         echo "usage:" | 
 | 429 |         echo "  $prog --help                          Print this message." | 
 | 430 |         echo "  $prog [options] [test-name]           Run test normally." | 
 | 431 |         echo "  $prog --dev [options] [test-name]     Development mode" \ | 
 | 432 |              "(dumps to stdout)." | 
 | 433 |         echo "  $prog --update [options] [test-name]  Update mode" \ | 
 | 434 |              "(replaces expected.txt)." | 
 | 435 |         echo '  Omitting the test name or specifying "-" will use the' \ | 
 | 436 |              "current directory." | 
 | 437 |         echo "  Runtime Options:" | 
| Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 438 |         echo "    -O                    Run non-debug rather than debug build (off by default)." | 
 | 439 |         echo "    -Xcompiler-option     Pass an option to the compiler." | 
 | 440 |         echo "    --runtime-option      Pass an option to the runtime." | 
 | 441 |         echo "    --debug               Wait for a debugger to attach." | 
| Nicolas Geoffray | 43c162f | 2015-03-09 12:21:26 +0000 | [diff] [blame] | 442 |         echo "    --debuggable          Whether to compile Java code for a debugger." | 
| Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 443 |         echo "    --gdb                 Run under gdb; incompatible with some tests." | 
 | 444 |         echo "    --build-only          Build test files only (off by default)." | 
 | 445 |         echo "    --interpreter         Enable interpreter only mode (off by default)." | 
| Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 446 |         echo "    --jit                 Enable jit (off by default)." | 
| Nicolas Geoffray | 0e07125 | 2015-03-21 13:43:15 +0000 | [diff] [blame] | 447 |         echo "    --optimizing          Enable optimizing compiler (default)." | 
 | 448 |         echo "    --quick               Use Quick compiler (off by default)." | 
| Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 449 |         echo "    --no-verify           Turn off verification (on by default)." | 
 | 450 |         echo "    --no-optimize         Turn off optimization (on by default)." | 
 | 451 |         echo "    --no-precise          Turn off precise GC (on by default)." | 
 | 452 |         echo "    --zygote              Spawn the process from the Zygote." \ | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 453 |              "If used, then the" | 
| Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 454 |         echo "                          other runtime options are ignored." | 
 | 455 |         echo "    --no-dex2oat          Run as though dex2oat was failing." | 
 | 456 |         echo "    --no-patchoat         Run as though patchoat was failing." | 
 | 457 |         echo "    --prebuild            Run dex2oat on the files before starting test. (default)" | 
 | 458 |         echo "    --no-prebuild         Do not run dex2oat on the files before starting" | 
 | 459 |         echo "                          the test." | 
 | 460 |         echo "    --relocate            Force the use of relocating in the test, making" | 
 | 461 |         echo "                          the image and oat files be relocated to a random" | 
 | 462 |         echo "                          address before running. (default)" | 
 | 463 |         echo "    --no-relocate         Force the use of no relocating in the test" | 
 | 464 |         echo "    --host                Use the host-mode virtual machine." | 
 | 465 |         echo "    --invoke-with         Pass --invoke-with option to runtime." | 
 | 466 |         echo "    --dalvik              Use Dalvik (off by default)." | 
 | 467 |         echo "    --jvm                 Use a host-local RI virtual machine." | 
 | 468 |         echo "    --output-path [path]  Location where to store the build" \ | 
| Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 469 |              "files." | 
| Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 470 |         echo "    --64                  Run the test in 64-bit mode" | 
 | 471 |         echo "    --trace               Run with method tracing" | 
 | 472 |         echo "    --gcstress            Run with gc stress testing" | 
 | 473 |         echo "    --gcverify            Run with gc verification" | 
 | 474 |         echo "    --always-clean        Delete the test files even if the test fails." | 
 | 475 |         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] | 476 |         echo "    --dex2oat-swap        Use a dex2oat swap file." | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 477 |     ) 1>&2 | 
 | 478 |     exit 1 | 
 | 479 | fi | 
 | 480 |  | 
 | 481 | cd "$test_dir" | 
 | 482 | test_dir=`pwd` | 
 | 483 |  | 
 | 484 | td_info="${test_dir}/${info}" | 
 | 485 | td_expected="${test_dir}/${expected}" | 
 | 486 |  | 
| Brian Carlstrom | 22469aa | 2012-09-07 10:34:57 -0700 | [diff] [blame] | 487 | if [ ! -r $td_info ]; then | 
 | 488 |     echo "${test_dir}: missing file $td_info" 1>&2 | 
 | 489 |     exit 1 | 
 | 490 | fi | 
 | 491 |  | 
 | 492 | if [ ! -r $td_expected ]; then | 
 | 493 |     echo "${test_dir}: missing file $td_expected" 1>&2 | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 494 |     exit 1 | 
 | 495 | fi | 
 | 496 |  | 
 | 497 | # copy the test to a temp dir and run it | 
 | 498 |  | 
| Elliott Hughes | 510c878 | 2011-10-06 10:57:34 -0700 | [diff] [blame] | 499 | echo "${test_dir}: building..." 1>&2 | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 500 |  | 
 | 501 | rm -rf "$tmp_dir" | 
 | 502 | cp -Rp "$test_dir" "$tmp_dir" | 
 | 503 | cd "$tmp_dir" | 
 | 504 |  | 
 | 505 | if [ '!' -r "$build" ]; then | 
 | 506 |     cp "${progdir}/etc/default-build" build | 
| Zheng Xu | c666710 | 2015-05-15 16:08:45 +0800 | [diff] [blame] | 507 | else | 
 | 508 |     cp "${progdir}/etc/default-build" . | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 509 | fi | 
 | 510 |  | 
 | 511 | if [ '!' -r "$run" ]; then | 
 | 512 |     cp "${progdir}/etc/default-run" run | 
| Zheng Xu | c666710 | 2015-05-15 16:08:45 +0800 | [diff] [blame] | 513 | else | 
 | 514 |     cp "${progdir}/etc/default-run" . | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 515 | fi | 
 | 516 |  | 
| Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 517 | if [ '!' -r "$check_cmd" ]; then | 
 | 518 |     cp "${progdir}/etc/default-check" check | 
| Zheng Xu | c666710 | 2015-05-15 16:08:45 +0800 | [diff] [blame] | 519 | else | 
 | 520 |     cp "${progdir}/etc/default-check" . | 
| Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 521 | fi | 
 | 522 |  | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 523 | chmod 755 "$build" | 
 | 524 | chmod 755 "$run" | 
| Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 525 | chmod 755 "$check_cmd" | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 526 |  | 
| Elliott Hughes | 8cbc8bc | 2011-10-04 11:19:45 -0700 | [diff] [blame] | 527 | export TEST_NAME=`basename ${test_dir}` | 
 | 528 |  | 
| David Brazdil | 4846d13 | 2015-01-15 19:07:08 +0000 | [diff] [blame] | 529 | # Tests named '<number>-checker-*' will also have their CFGs verified with | 
 | 530 | # Checker when compiled with Optimizing on host. | 
 | 531 | if [[ "$TEST_NAME" =~ ^[0-9]+-checker- ]]; then | 
 | 532 |   # Build Checker DEX files without dx's optimizations so the input to dex2oat | 
 | 533 |   # better resembles the Java source. We always build the DEX the same way, even | 
 | 534 |   # if Checker is not invoked and the test only runs the program. | 
 | 535 |   build_args="${build_args} --dx-option --no-optimize" | 
 | 536 |  | 
| Nicolas Geoffray | e730729 | 2015-03-17 18:12:06 +0000 | [diff] [blame] | 537 |   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] | 538 |     run_checker="yes" | 
 | 539 |     run_args="${run_args} -Xcompiler-option --dump-cfg=$tmp_dir/$cfg_output \ | 
 | 540 |                           -Xcompiler-option -j1" | 
 | 541 |   fi | 
 | 542 | fi | 
 | 543 |  | 
| Ian Rogers | 997f0f9 | 2014-06-21 22:58:05 -0700 | [diff] [blame] | 544 | # To cause tests to fail fast, limit the file sizes created by dx, dex2oat and ART output to 2MB. | 
 | 545 | file_size_limit=2048 | 
 | 546 | if echo "$test_dir" | grep 089; then | 
 | 547 |   file_size_limit=5120 | 
 | 548 | elif echo "$test_dir" | grep 083; then | 
 | 549 |   file_size_limit=5120 | 
 | 550 | fi | 
| Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 551 | if ! ulimit -S "$file_size_limit"; then | 
| Ian Rogers | 997f0f9 | 2014-06-21 22:58:05 -0700 | [diff] [blame] | 552 |    echo "ulimit file size setting failed" | 
 | 553 | fi | 
 | 554 |  | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 555 | good="no" | 
| Nicolas Geoffray | 1ed097d | 2014-11-13 15:15:39 +0000 | [diff] [blame] | 556 | good_build="yes" | 
 | 557 | good_run="yes" | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 558 | if [ "$dev_mode" = "yes" ]; then | 
| David Brazdil | 4846d13 | 2015-01-15 19:07:08 +0000 | [diff] [blame] | 559 |     "./${build}" $build_args 2>&1 | 
| Elliott Hughes | 7ab3a2a | 2012-06-18 16:34:20 -0700 | [diff] [blame] | 560 |     build_exit="$?" | 
 | 561 |     echo "build exit status: $build_exit" 1>&2 | 
 | 562 |     if [ "$build_exit" = '0' ]; then | 
| Elliott Hughes | 2bfc673 | 2012-11-27 20:40:51 -0800 | [diff] [blame] | 563 |         echo "${test_dir}: running..." 1>&2 | 
 | 564 |         "./${run}" $run_args "$@" 2>&1 | 
| Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 565 |         run_exit="$?" | 
| Calin Juravle | 3cf4877 | 2015-01-26 16:47:33 +0000 | [diff] [blame] | 566 |  | 
| Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 567 |         if [ "$run_exit" = "0" ]; then | 
| Calin Juravle | 3cf4877 | 2015-01-26 16:47:33 +0000 | [diff] [blame] | 568 |             if [ "$run_checker" = "yes" ]; then | 
 | 569 |                 "$checker" "$cfg_output" "$tmp_dir" 2>&1 | 
 | 570 |                 checker_exit="$?" | 
 | 571 |                 if [ "$checker_exit" = "0" ]; then | 
 | 572 |                     good="yes" | 
 | 573 |                 fi | 
 | 574 |                 echo "checker exit status: $checker_exit" 1>&2 | 
 | 575 |             else | 
 | 576 |                 good="yes" | 
 | 577 |             fi | 
| Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 578 |         fi | 
| Calin Juravle | 3cf4877 | 2015-01-26 16:47:33 +0000 | [diff] [blame] | 579 |         echo "run exit status: $run_exit" 1>&2 | 
| Elliott Hughes | 7ab3a2a | 2012-06-18 16:34:20 -0700 | [diff] [blame] | 580 |     fi | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 581 | elif [ "$update_mode" = "yes" ]; then | 
| David Brazdil | 4846d13 | 2015-01-15 19:07:08 +0000 | [diff] [blame] | 582 |     "./${build}" $build_args >"$build_output" 2>&1 | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 583 |     build_exit="$?" | 
 | 584 |     if [ "$build_exit" = '0' ]; then | 
| Elliott Hughes | 2bfc673 | 2012-11-27 20:40:51 -0800 | [diff] [blame] | 585 |         echo "${test_dir}: running..." 1>&2 | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 586 |         "./${run}" $run_args "$@" >"$output" 2>&1 | 
| David Brazdil | 4846d13 | 2015-01-15 19:07:08 +0000 | [diff] [blame] | 587 |         if [ "$run_checker" = "yes" ]; then | 
 | 588 |           "$checker" -q "$cfg_output" "$tmp_dir" >> "$output" 2>&1 | 
 | 589 |         fi | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 590 |         sed -e 's/[[:cntrl:]]$//g' < "$output" >"${td_expected}" | 
 | 591 |         good="yes" | 
 | 592 |     else | 
 | 593 |         cat "$build_output" 1>&2 | 
 | 594 |         echo "build exit status: $build_exit" 1>&2 | 
 | 595 |     fi | 
| Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 596 | elif [ "$build_only" = "yes" ]; then | 
 | 597 |     good="yes" | 
| David Brazdil | 4846d13 | 2015-01-15 19:07:08 +0000 | [diff] [blame] | 598 |     "./${build}" $build_args >"$build_output" 2>&1 | 
| Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 599 |     build_exit="$?" | 
 | 600 |     if [ "$build_exit" '!=' '0' ]; then | 
 | 601 |         cp "$build_output" "$output" | 
 | 602 |         echo "build exit status: $build_exit" >>"$output" | 
 | 603 |         diff --strip-trailing-cr -q "$expected" "$output" >/dev/null | 
 | 604 |         if [ "$?" '!=' "0" ]; then | 
 | 605 |             good="no" | 
 | 606 |             echo "BUILD FAILED For ${TEST_NAME}" | 
 | 607 |         fi | 
 | 608 |     fi | 
| Tsu Chiang Chuang | 379e2f5 | 2013-08-20 12:24:52 -0700 | [diff] [blame] | 609 |     # Clean up extraneous files that are not used by tests. | 
| Tsu Chiang Chuang | 0160d99 | 2013-09-13 14:17:42 -0700 | [diff] [blame] | 610 |     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] | 611 |     exit 0 | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 612 | else | 
| David Brazdil | 4846d13 | 2015-01-15 19:07:08 +0000 | [diff] [blame] | 613 |     "./${build}" $build_args >"$build_output" 2>&1 | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 614 |     build_exit="$?" | 
 | 615 |     if [ "$build_exit" = '0' ]; then | 
| Elliott Hughes | 2bfc673 | 2012-11-27 20:40:51 -0800 | [diff] [blame] | 616 |         echo "${test_dir}: running..." 1>&2 | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 617 |         "./${run}" $run_args "$@" >"$output" 2>&1 | 
| Nicolas Geoffray | 1ed097d | 2014-11-13 15:15:39 +0000 | [diff] [blame] | 618 |         run_exit="$?" | 
 | 619 |         if [ "$run_exit" != "0" ]; then | 
 | 620 |             echo "run exit status: $run_exit" 1>&2 | 
 | 621 |             good_run="no" | 
| David Brazdil | 4846d13 | 2015-01-15 19:07:08 +0000 | [diff] [blame] | 622 |         elif [ "$run_checker" = "yes" ]; then | 
 | 623 |             "$checker" -q "$cfg_output" "$tmp_dir" >> "$output" 2>&1 | 
 | 624 |             checker_exit="$?" | 
 | 625 |             if [ "$checker_exit" != "0" ]; then | 
 | 626 |                 echo "checker exit status: $checker_exit" 1>&2 | 
 | 627 |                 good_run="no" | 
 | 628 |             else | 
 | 629 |                 good_run="yes" | 
 | 630 |             fi | 
| Nicolas Geoffray | 1ed097d | 2014-11-13 15:15:39 +0000 | [diff] [blame] | 631 |         else | 
 | 632 |             good_run="yes" | 
 | 633 |         fi | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 634 |     else | 
| Nicolas Geoffray | 1ed097d | 2014-11-13 15:15:39 +0000 | [diff] [blame] | 635 |         good_build="no" | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 636 |         cp "$build_output" "$output" | 
| Andreas Gampe | f6930a8 | 2014-10-21 09:33:08 -0700 | [diff] [blame] | 637 |         echo "Failed to build in tmpdir=${tmp_dir} from oldwd=${oldwd} and cwd=`pwd`" >> "$output" | 
 | 638 |         echo "Non-canonical tmpdir was ${noncanonical_tmp_dir}" >> "$output" | 
| Ian Rogers | d9ad27d | 2014-10-27 13:48:21 -0700 | [diff] [blame] | 639 |         echo "Args: ${args}" >> "$output" | 
| Andreas Gampe | f6930a8 | 2014-10-21 09:33:08 -0700 | [diff] [blame] | 640 |         echo "build exit status: $build_exit" >> "$output" | 
| Andreas Gampe | 5c11490 | 2014-10-27 17:03:58 -0700 | [diff] [blame] | 641 |         max_name_length=$(getconf NAME_MAX ${tmp_dir}) | 
 | 642 |         echo "Max filename (NAME_MAX): ${max_name_length}" >> "$output" | 
 | 643 |         max_path_length=$(getconf PATH_MAX ${tmp_dir}) | 
| Andreas Gampe | 602fbcd | 2014-10-27 17:06:29 -0700 | [diff] [blame] | 644 |         echo "Max pathlength (PATH_MAX): ${max_path_length}" >> "$output" | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 645 |     fi | 
| Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 646 |     ./$check_cmd "$expected" "$output" | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 647 |     if [ "$?" = "0" ]; then | 
| Nicolas Geoffray | 1ed097d | 2014-11-13 15:15:39 +0000 | [diff] [blame] | 648 |         if [ "$good_build" = "no" -o "$good_run" = "yes" ]; then | 
 | 649 |           # output == expected | 
 | 650 |           good="yes" | 
 | 651 |           echo "${test_dir}: succeeded!" 1>&2 | 
 | 652 |         fi | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 653 |     fi | 
 | 654 | fi | 
 | 655 |  | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 656 | ( | 
| Alex Light | bfac14a | 2014-07-30 09:41:21 -0700 | [diff] [blame] | 657 |     if [ "$good" != "yes" -a "$update_mode" != "yes" ]; then | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 658 |         echo "${test_dir}: FAILED!" | 
 | 659 |         echo ' ' | 
 | 660 |         echo '#################### info' | 
 | 661 |         cat "${td_info}" | sed 's/^/# /g' | 
 | 662 |         echo '#################### diffs' | 
| Ian Rogers | 75deec0 | 2014-11-23 20:07:39 -0800 | [diff] [blame] | 663 |         diff --strip-trailing-cr -u "$expected" "$output" | tail -n 2000 | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 664 |         echo '####################' | 
 | 665 |         echo ' ' | 
 | 666 |     fi | 
| Alex Light | bfac14a | 2014-07-30 09:41:21 -0700 | [diff] [blame] | 667 |  | 
 | 668 | ) 1>&2 | 
 | 669 |  | 
 | 670 | # Clean up test files. | 
 | 671 | if [ "$always_clean" = "yes" -o "$good" = "yes" ]; then | 
 | 672 |     cd "$oldwd" | 
 | 673 |     rm -rf "$tmp_dir" | 
 | 674 |     if [ "$target_mode" = "yes" -a "$build_exit" = "0" ]; then | 
 | 675 |         adb shell rm -rf $DEX_LOCATION | 
 | 676 |     fi | 
 | 677 |     if [ "$good" = "yes" ]; then | 
 | 678 |         exit 0 | 
 | 679 |     fi | 
 | 680 | fi | 
 | 681 |  | 
 | 682 |  | 
 | 683 | ( | 
 | 684 |     if [ "$always_clean" = "yes" ]; then | 
 | 685 |         echo "${TEST_NAME} files deleted from host " | 
 | 686 |         if [ "$target_mode" == "yes" ]; then | 
 | 687 |             echo "and from target" | 
 | 688 |         fi | 
 | 689 |     else | 
 | 690 |         echo "${TEST_NAME} files left in ${tmp_dir} on host" | 
 | 691 |         if [ "$target_mode" == "yes" ]; then | 
 | 692 |             echo "and in ${DEX_LOCATION} on target" | 
 | 693 |         fi | 
| Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 694 |     fi | 
 | 695 |  | 
| jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 696 | ) 1>&2 | 
 | 697 |  | 
 | 698 | exit 1 |