jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2007 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Set up prog to be the path of this script, including following symlinks, |
| 18 | # and set up progdir to be the fully-qualified pathname of its directory. |
| 19 | prog="$0" |
| 20 | while [ -h "${prog}" ]; do |
| 21 | newProg=`/bin/ls -ld "${prog}"` |
| 22 | newProg=`expr "${newProg}" : ".* -> \(.*\)$"` |
| 23 | if expr "x${newProg}" : 'x/' >/dev/null; then |
| 24 | prog="${newProg}" |
| 25 | else |
| 26 | progdir=`dirname "${prog}"` |
| 27 | prog="${progdir}/${newProg}" |
| 28 | fi |
| 29 | done |
| 30 | oldwd=`pwd` |
| 31 | progdir=`dirname "${prog}"` |
| 32 | cd "${progdir}" |
| 33 | progdir=`pwd` |
| 34 | prog="${progdir}"/`basename "${prog}"` |
Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 35 | test_dir="test-$$" |
| 36 | tmp_dir="/tmp/${test_dir}" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 37 | |
| 38 | export JAVA="java" |
Brian Carlstrom | 5103ce6 | 2014-03-30 16:17:42 -0700 | [diff] [blame] | 39 | export JAVAC="javac -g" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 40 | export RUN="${progdir}/etc/push-and-run-test-jar" |
Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 41 | export DEX_LOCATION=/data/run-test/${test_dir} |
Elliott Hughes | c717eef | 2012-06-15 16:01:26 -0700 | [diff] [blame] | 42 | export NEED_DEX="true" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 43 | |
Tsu Chiang Chuang | 4407e61 | 2012-07-19 16:13:43 -0700 | [diff] [blame] | 44 | # If dx was not set by the environment variable, assume it is in the path. |
| 45 | if [ -z "$DX" ]; then |
| 46 | export DX="dx" |
| 47 | fi |
| 48 | |
Tsu Chiang Chuang | 6674f8a | 2013-01-16 15:41:21 -0800 | [diff] [blame] | 49 | # If jasmin was not set by the environment variable, assume it is in the path. |
| 50 | if [ -z "$JASMIN" ]; then |
| 51 | export JASMIN="jasmin" |
| 52 | fi |
| 53 | |
| 54 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 55 | info="info.txt" |
| 56 | build="build" |
| 57 | run="run" |
| 58 | expected="expected.txt" |
| 59 | output="output.txt" |
| 60 | build_output="build-output.txt" |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 61 | lib="libartd.so" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 62 | run_args="--quiet" |
| 63 | |
Brian Carlstrom | 2613de4 | 2012-06-15 17:37:16 -0700 | [diff] [blame] | 64 | target_mode="yes" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 65 | dev_mode="no" |
| 66 | update_mode="no" |
| 67 | debug_mode="no" |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 68 | runtime="art" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 69 | usage="no" |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 70 | build_only="no" |
Andreas Gampe | 2fe0792 | 2014-04-21 07:50:39 -0700 | [diff] [blame^] | 71 | suffix64="" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 72 | |
| 73 | while true; do |
| 74 | if [ "x$1" = "x--host" ]; then |
Brian Carlstrom | 2613de4 | 2012-06-15 17:37:16 -0700 | [diff] [blame] | 75 | target_mode="no" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 76 | RUN="${progdir}/etc/host-run-test-jar" |
TDYa127 | b92bcab | 2012-04-08 00:09:51 -0700 | [diff] [blame] | 77 | DEX_LOCATION=$tmp_dir |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 78 | shift |
Elliott Hughes | 58bcc40 | 2012-02-14 14:10:10 -0800 | [diff] [blame] | 79 | elif [ "x$1" = "x--jvm" ]; then |
Brian Carlstrom | 2613de4 | 2012-06-15 17:37:16 -0700 | [diff] [blame] | 80 | target_mode="no" |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 81 | runtime="jvm" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 82 | RUN="${progdir}/etc/reference-run-test-classes" |
Elliott Hughes | c717eef | 2012-06-15 16:01:26 -0700 | [diff] [blame] | 83 | NEED_DEX="false" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 84 | shift |
Elliott Hughes | 58bcc40 | 2012-02-14 14:10:10 -0800 | [diff] [blame] | 85 | elif [ "x$1" = "x-O" ]; then |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 86 | lib="libart.so" |
| 87 | shift |
| 88 | elif [ "x$1" = "x--dalvik" ]; then |
| 89 | lib="libdvm.so" |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 90 | runtime="dalvik" |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 91 | shift |
| 92 | elif [ "x$1" = "x--image" ]; then |
| 93 | shift |
| 94 | image="$1" |
| 95 | run_args="${run_args} --image $image" |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 96 | shift |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 97 | elif [ "x$1" = "x-Xcompiler-option" ]; then |
| 98 | shift |
| 99 | option="$1" |
| 100 | run_args="${run_args} -Xcompiler-option $option" |
| 101 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 102 | elif [ "x$1" = "x--debug" ]; then |
| 103 | run_args="${run_args} --debug" |
| 104 | shift |
| 105 | elif [ "x$1" = "x--gdb" ]; then |
| 106 | run_args="${run_args} --gdb" |
| 107 | dev_mode="yes" |
| 108 | shift |
| 109 | elif [ "x$1" = "x--zygote" ]; then |
| 110 | run_args="${run_args} --zygote" |
| 111 | shift |
jeffhao | 0dff3f4 | 2012-11-20 15:13:43 -0800 | [diff] [blame] | 112 | elif [ "x$1" = "x--interpreter" ]; then |
| 113 | run_args="${run_args} --interpreter" |
| 114 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 115 | elif [ "x$1" = "x--no-verify" ]; then |
| 116 | run_args="${run_args} --no-verify" |
| 117 | shift |
| 118 | elif [ "x$1" = "x--no-optimize" ]; then |
| 119 | run_args="${run_args} --no-optimize" |
| 120 | shift |
| 121 | elif [ "x$1" = "x--no-precise" ]; then |
| 122 | run_args="${run_args} --no-precise" |
| 123 | shift |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 124 | elif [ "x$1" = "x--invoke-with" ]; then |
| 125 | shift |
| 126 | what="$1" |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 127 | if [ "x$what" = "x" ]; then |
| 128 | echo "$0 missing argument to --invoke-with" 1>&2 |
| 129 | usage="yes" |
| 130 | break |
| 131 | fi |
Ian Rogers | 0e03367 | 2013-04-19 10:22:46 -0700 | [diff] [blame] | 132 | run_args="${run_args} --invoke-with ${what}" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 133 | shift |
| 134 | elif [ "x$1" = "x--dev" ]; then |
| 135 | run_args="${run_args} --dev" |
| 136 | dev_mode="yes" |
| 137 | shift |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 138 | elif [ "x$1" = "x--build-only" ]; then |
| 139 | build_only="yes" |
| 140 | shift |
| 141 | elif [ "x$1" = "x--output-path" ]; then |
| 142 | shift |
| 143 | tmp_dir=$1 |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 144 | if [ "x$tmp_dir" = "x" ]; then |
| 145 | echo "$0 missing argument to --output-path" 1>&2 |
| 146 | usage="yes" |
| 147 | break |
| 148 | fi |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 149 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 150 | elif [ "x$1" = "x--update" ]; then |
| 151 | update_mode="yes" |
| 152 | shift |
| 153 | elif [ "x$1" = "x--help" ]; then |
| 154 | usage="yes" |
| 155 | shift |
Andreas Gampe | afbaa1a | 2014-03-25 18:09:32 -0700 | [diff] [blame] | 156 | elif [ "x$1" = "x--64" ]; then |
| 157 | run_args="${run_args} --64" |
Andreas Gampe | 2fe0792 | 2014-04-21 07:50:39 -0700 | [diff] [blame^] | 158 | suffix64="64" |
Andreas Gampe | afbaa1a | 2014-03-25 18:09:32 -0700 | [diff] [blame] | 159 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 160 | elif expr "x$1" : "x--" >/dev/null 2>&1; then |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 161 | echo "unknown $0 option: $1" 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 162 | usage="yes" |
| 163 | break |
| 164 | else |
| 165 | break |
| 166 | fi |
| 167 | done |
| 168 | |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 169 | if [ ! "$runtime" = "jvm" ]; then |
| 170 | run_args="${run_args} --lib $lib" |
| 171 | fi |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 172 | |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 173 | if [ "$runtime" = "dalvik" ]; then |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 174 | if [ "$target_mode" = "no" ]; then |
| 175 | framework="${OUT}/system/framework" |
| 176 | bpath="${framework}/core.jar:${framework}/conscrypt.jar:${framework}/okhttp.jar:${framework}/core-junit.jar:${framework}/bouncycastle.jar:${framework}/ext.jar" |
| 177 | run_args="${run_args} --boot -Xbootclasspath:${bpath}" |
| 178 | else |
| 179 | true # defaults to using target BOOTCLASSPATH |
| 180 | fi |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 181 | elif [ "$runtime" = "art" ]; then |
| 182 | if [ "$target_mode" = "no" ]; then |
Brian Carlstrom | 4353486 | 2014-02-19 01:13:52 -0800 | [diff] [blame] | 183 | # ANDROID_BUILD_TOP and ANDROID_HOST_OUT are not set in a build environment. |
| 184 | if [ -z "$ANDROID_BUILD_TOP" ]; then |
| 185 | export ANDROID_BUILD_TOP=$oldwd |
| 186 | fi |
| 187 | if [ -z "$ANDROID_HOST_OUT" ]; then |
| 188 | export ANDROID_HOST_OUT=$ANDROID_BUILD_TOP/out/host/linux-x86 |
| 189 | fi |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 190 | run_args="${run_args} --boot -Ximage:${ANDROID_HOST_OUT}/framework/core.art" |
| 191 | else |
Andreas Gampe | 2fe0792 | 2014-04-21 07:50:39 -0700 | [diff] [blame^] | 192 | run_args="${run_args} --boot -Ximage:/data/art-test${suffix64}/core.art" |
Jeff Hao | 201803f | 2013-11-20 18:11:39 -0800 | [diff] [blame] | 193 | fi |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 194 | fi |
| 195 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 196 | if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then |
| 197 | echo "--dev and --update are mutually exclusive" 1>&2 |
| 198 | usage="yes" |
| 199 | fi |
| 200 | |
| 201 | if [ "$usage" = "no" ]; then |
| 202 | if [ "x$1" = "x" -o "x$1" = "x-" ]; then |
| 203 | test_dir=`basename "$oldwd"` |
| 204 | else |
| 205 | test_dir="$1" |
| 206 | fi |
| 207 | |
| 208 | if [ '!' -d "$test_dir" ]; then |
| 209 | td2=`echo ${test_dir}-*` |
| 210 | if [ '!' -d "$td2" ]; then |
| 211 | echo "${test_dir}: no such test directory" 1>&2 |
| 212 | usage="yes" |
| 213 | fi |
| 214 | test_dir="$td2" |
| 215 | fi |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 216 | # Shift to get rid of the test name argument. The rest of the arguments |
| 217 | # will get passed to the test run. |
| 218 | shift |
| 219 | fi |
| 220 | |
| 221 | if [ "$usage" = "yes" ]; then |
| 222 | prog=`basename $prog` |
| 223 | ( |
| 224 | echo "usage:" |
| 225 | echo " $prog --help Print this message." |
| 226 | echo " $prog [options] [test-name] Run test normally." |
| 227 | echo " $prog --dev [options] [test-name] Development mode" \ |
| 228 | "(dumps to stdout)." |
| 229 | echo " $prog --update [options] [test-name] Update mode" \ |
| 230 | "(replaces expected.txt)." |
| 231 | echo ' Omitting the test name or specifying "-" will use the' \ |
| 232 | "current directory." |
| 233 | echo " Runtime Options:" |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 234 | echo " -O Run non-debug rather than debug build (off by default)." |
| 235 | echo " -Xcompiler-option Pass an option to the compiler." |
| 236 | echo " --debug Wait for a debugger to attach." |
| 237 | echo " --gdb Run under gdb; incompatible with some tests." |
| 238 | echo " --build-only Build test files only (off by default)." |
| 239 | echo " --interpreter Enable interpreter only mode (off by default)." |
| 240 | echo " --no-verify Turn off verification (on by default)." |
| 241 | echo " --no-optimize Turn off optimization (on by default)." |
| 242 | echo " --no-precise Turn off precise GC (on by default)." |
| 243 | echo " --zygote Spawn the process from the Zygote." \ |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 244 | "If used, then the" |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 245 | echo " other runtime options are ignored." |
| 246 | echo " --host Use the host-mode virtual machine." |
| 247 | echo " --invoke-with Pass --invoke-with option to runtime." |
| 248 | echo " --dalvik Use Dalvik (off by default)." |
| 249 | echo " --jvm Use a host-local RI virtual machine." |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 250 | echo " --output-path [path] Location where to store the build" \ |
| 251 | "files." |
Andreas Gampe | afbaa1a | 2014-03-25 18:09:32 -0700 | [diff] [blame] | 252 | echo " --64 Run the test in 64-bit mode" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 253 | ) 1>&2 |
| 254 | exit 1 |
| 255 | fi |
| 256 | |
| 257 | cd "$test_dir" |
| 258 | test_dir=`pwd` |
| 259 | |
| 260 | td_info="${test_dir}/${info}" |
| 261 | td_expected="${test_dir}/${expected}" |
| 262 | |
Brian Carlstrom | 22469aa | 2012-09-07 10:34:57 -0700 | [diff] [blame] | 263 | if [ ! -r $td_info ]; then |
| 264 | echo "${test_dir}: missing file $td_info" 1>&2 |
| 265 | exit 1 |
| 266 | fi |
| 267 | |
| 268 | if [ ! -r $td_expected ]; then |
| 269 | echo "${test_dir}: missing file $td_expected" 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 270 | exit 1 |
| 271 | fi |
| 272 | |
| 273 | # copy the test to a temp dir and run it |
| 274 | |
Elliott Hughes | 510c878 | 2011-10-06 10:57:34 -0700 | [diff] [blame] | 275 | echo "${test_dir}: building..." 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 276 | |
| 277 | rm -rf "$tmp_dir" |
| 278 | cp -Rp "$test_dir" "$tmp_dir" |
| 279 | cd "$tmp_dir" |
| 280 | |
| 281 | if [ '!' -r "$build" ]; then |
| 282 | cp "${progdir}/etc/default-build" build |
| 283 | fi |
| 284 | |
| 285 | if [ '!' -r "$run" ]; then |
| 286 | cp "${progdir}/etc/default-run" run |
| 287 | fi |
| 288 | |
| 289 | chmod 755 "$build" |
| 290 | chmod 755 "$run" |
| 291 | |
Elliott Hughes | 8cbc8bc | 2011-10-04 11:19:45 -0700 | [diff] [blame] | 292 | export TEST_NAME=`basename ${test_dir}` |
| 293 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 294 | good="no" |
| 295 | if [ "$dev_mode" = "yes" ]; then |
| 296 | "./${build}" 2>&1 |
Elliott Hughes | 7ab3a2a | 2012-06-18 16:34:20 -0700 | [diff] [blame] | 297 | build_exit="$?" |
| 298 | echo "build exit status: $build_exit" 1>&2 |
| 299 | if [ "$build_exit" = '0' ]; then |
Elliott Hughes | 2bfc673 | 2012-11-27 20:40:51 -0800 | [diff] [blame] | 300 | echo "${test_dir}: running..." 1>&2 |
| 301 | "./${run}" $run_args "$@" 2>&1 |
Brian Carlstrom | dc959ea | 2013-10-28 00:44:49 -0700 | [diff] [blame] | 302 | run_exit="$?" |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 303 | echo "run exit status: $run_exit" 1>&2 |
| 304 | if [ "$run_exit" = "0" ]; then |
| 305 | good="yes" |
| 306 | fi |
Elliott Hughes | 7ab3a2a | 2012-06-18 16:34:20 -0700 | [diff] [blame] | 307 | fi |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 308 | elif [ "$update_mode" = "yes" ]; then |
| 309 | "./${build}" >"$build_output" 2>&1 |
| 310 | build_exit="$?" |
| 311 | if [ "$build_exit" = '0' ]; then |
Elliott Hughes | 2bfc673 | 2012-11-27 20:40:51 -0800 | [diff] [blame] | 312 | echo "${test_dir}: running..." 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 313 | "./${run}" $run_args "$@" >"$output" 2>&1 |
| 314 | sed -e 's/[[:cntrl:]]$//g' < "$output" >"${td_expected}" |
| 315 | good="yes" |
| 316 | else |
| 317 | cat "$build_output" 1>&2 |
| 318 | echo "build exit status: $build_exit" 1>&2 |
| 319 | fi |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 320 | elif [ "$build_only" = "yes" ]; then |
| 321 | good="yes" |
| 322 | "./${build}" >"$build_output" 2>&1 |
| 323 | build_exit="$?" |
| 324 | if [ "$build_exit" '!=' '0' ]; then |
| 325 | cp "$build_output" "$output" |
| 326 | echo "build exit status: $build_exit" >>"$output" |
| 327 | diff --strip-trailing-cr -q "$expected" "$output" >/dev/null |
| 328 | if [ "$?" '!=' "0" ]; then |
| 329 | good="no" |
| 330 | echo "BUILD FAILED For ${TEST_NAME}" |
| 331 | fi |
| 332 | fi |
Tsu Chiang Chuang | 379e2f5 | 2013-08-20 12:24:52 -0700 | [diff] [blame] | 333 | # Clean up extraneous files that are not used by tests. |
Tsu Chiang Chuang | 0160d99 | 2013-09-13 14:17:42 -0700 | [diff] [blame] | 334 | 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] | 335 | exit 0 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 336 | else |
| 337 | "./${build}" >"$build_output" 2>&1 |
| 338 | build_exit="$?" |
| 339 | if [ "$build_exit" = '0' ]; then |
Elliott Hughes | 2bfc673 | 2012-11-27 20:40:51 -0800 | [diff] [blame] | 340 | echo "${test_dir}: running..." 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 341 | "./${run}" $run_args "$@" >"$output" 2>&1 |
| 342 | else |
| 343 | cp "$build_output" "$output" |
| 344 | echo "build exit status: $build_exit" >>"$output" |
| 345 | fi |
| 346 | diff --strip-trailing-cr -q "$expected" "$output" >/dev/null |
| 347 | if [ "$?" = "0" ]; then |
| 348 | # output == expected |
| 349 | good="yes" |
| 350 | echo "${test_dir}: succeeded!" 1>&2 |
| 351 | fi |
| 352 | fi |
| 353 | |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 354 | # Clean up test files. |
| 355 | if [ "$good" == "yes" ]; then |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 356 | cd "$oldwd" |
| 357 | rm -rf "$tmp_dir" |
Elliott Hughes | 7ab3a2a | 2012-06-18 16:34:20 -0700 | [diff] [blame] | 358 | if [ "$target_mode" = "yes" -a "$build_exit" = "0" ]; then |
Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 359 | adb shell rm -r $DEX_LOCATION |
| 360 | fi |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 361 | exit 0 |
| 362 | fi |
| 363 | |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 364 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 365 | ( |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 366 | if [ "$update_mode" != "yes" ]; then |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 367 | echo "${test_dir}: FAILED!" |
| 368 | echo ' ' |
| 369 | echo '#################### info' |
| 370 | cat "${td_info}" | sed 's/^/# /g' |
| 371 | echo '#################### diffs' |
| 372 | diff --strip-trailing-cr -u "$expected" "$output" |
| 373 | echo '####################' |
| 374 | echo ' ' |
| 375 | fi |
Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 376 | echo "${TEST_NAME} files left in ${tmp_dir} on host" |
Tsu Chiang Chuang | 011fade | 2012-07-09 18:34:47 -0700 | [diff] [blame] | 377 | if [ "$target_mode" == "yes" ]; then |
Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 378 | echo "and in ${DEX_LOCATION} on target" |
| 379 | fi |
| 380 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 381 | ) 1>&2 |
| 382 | |
| 383 | exit 1 |