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}"` |
| 35 | |
| 36 | run_args="" |
| 37 | usage="no" |
Dmitry Petrochenko | 81c56e7 | 2014-03-05 15:05:46 +0700 | [diff] [blame] | 38 | sequental="no" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 39 | |
| 40 | while true; do |
| 41 | if [ "x$1" = "x--host" ]; then |
| 42 | run_args="${run_args} --host" |
| 43 | shift |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 44 | elif [ "x$1" = "x--use-java-home" ]; then |
| 45 | run_args="${run_args} --use-java-home" |
| 46 | shift |
Alex Light | fadfee9 | 2015-10-28 09:40:10 -0700 | [diff] [blame] | 47 | elif [ "x$1" = "x--no-image" ]; then |
| 48 | run_args="${run_args} --no-image" |
| 49 | shift |
| 50 | elif [ "x$1" = "x--quick" ]; then |
| 51 | run_args="${run_args} --quick" |
| 52 | shift |
| 53 | elif [ "x$1" = "x--optimizing" ]; then |
| 54 | run_args="${run_args} --optimizing" |
| 55 | shift |
| 56 | elif [ "x$1" = "x--image" ]; then |
| 57 | run_args="${run_args} --image" |
| 58 | shift |
| 59 | elif [ "x$1" = "x--never-clean" ]; then |
| 60 | run_args="${run_args} --never-clean" |
| 61 | shift |
Elliott Hughes | 58bcc40 | 2012-02-14 14:10:10 -0800 | [diff] [blame] | 62 | elif [ "x$1" = "x--jvm" ]; then |
| 63 | run_args="${run_args} --jvm" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 64 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 65 | elif [ "x$1" = "x--debug" ]; then |
| 66 | run_args="${run_args} --debug" |
| 67 | shift |
Alex Light | fadfee9 | 2015-10-28 09:40:10 -0700 | [diff] [blame] | 68 | elif [ "x$1" = "x--build-only" ]; then |
| 69 | run_args="${run_args} --build-only" |
| 70 | shift |
| 71 | elif [ "x$1" = "x--build-with-jack" ]; then |
| 72 | run_args="${run_args} --build-with-jack" |
| 73 | shift |
| 74 | elif [ "x$1" = "x--build-with-javac-dx" ]; then |
| 75 | run_args="${run_args} --build-with-javac-dx" |
| 76 | shift |
| 77 | elif [ "x$1" = "x--dex2oat-swap" ]; then |
| 78 | run_args="${run_args} --dex2oat-swap" |
| 79 | shift |
| 80 | elif [ "x$1" = "x--dalvik" ]; then |
| 81 | run_args="${run_args} --dalvik" |
| 82 | shift |
| 83 | elif [ "x$1" = "x--debuggable" ]; then |
| 84 | run_args="${run_args} --debuggable" |
| 85 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 86 | elif [ "x$1" = "x--zygote" ]; then |
| 87 | run_args="${run_args} --zygote" |
| 88 | shift |
jeffhao | 0dff3f4 | 2012-11-20 15:13:43 -0800 | [diff] [blame] | 89 | elif [ "x$1" = "x--interpreter" ]; then |
| 90 | run_args="${run_args} --interpreter" |
| 91 | shift |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 92 | elif [ "x$1" = "x--jit" ]; then |
| 93 | run_args="${run_args} --jit" |
| 94 | shift |
Alex Light | fadfee9 | 2015-10-28 09:40:10 -0700 | [diff] [blame] | 95 | elif [ "x$1" = "x--verify-soft-fail" ]; then |
| 96 | run_args="${run_args} --verify-soft-fail" |
| 97 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 98 | elif [ "x$1" = "x--no-verify" ]; then |
| 99 | run_args="${run_args} --no-verify" |
| 100 | shift |
| 101 | elif [ "x$1" = "x--no-optimize" ]; then |
| 102 | run_args="${run_args} --no-optimize" |
| 103 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 104 | elif [ "x$1" = "x--dev" ]; then |
| 105 | run_args="${run_args} --dev" |
| 106 | shift |
| 107 | elif [ "x$1" = "x--update" ]; then |
| 108 | run_args="${run_args} --update" |
| 109 | shift |
| 110 | elif [ "x$1" = "x--help" ]; then |
| 111 | usage="yes" |
| 112 | shift |
Dmitry Petrochenko | 81c56e7 | 2014-03-05 15:05:46 +0700 | [diff] [blame] | 113 | elif [ "x$1" = "x--seq" ]; then |
| 114 | sequental="yes" |
| 115 | shift |
| 116 | elif [ "x$1" = "x-O" ]; then |
| 117 | run_args="${run_args} -O" |
| 118 | shift |
Zheng Xu | dc8e732 | 2014-05-07 17:07:20 +0100 | [diff] [blame] | 119 | elif [ "x$1" = "x--64" ]; then |
| 120 | run_args="${run_args} --64" |
| 121 | shift |
Alex Light | e7873ec | 2014-08-12 09:53:50 -0700 | [diff] [blame] | 122 | elif [ "x$1" = "x--gcstress" ]; then |
| 123 | run_args="${run_args} --gcstress" |
| 124 | shift |
| 125 | elif [ "x$1" = "x--gcverify" ]; then |
| 126 | run_args="${run_args} --gcverify" |
| 127 | shift |
Sebastien Hertz | 07aaac8 | 2014-07-09 15:59:05 +0200 | [diff] [blame] | 128 | elif [ "x$1" = "x--trace" ]; then |
| 129 | run_args="${run_args} --trace" |
| 130 | shift |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 131 | elif [ "x$1" = "x--relocate" ]; then |
| 132 | run_args="${run_args} --relocate" |
| 133 | shift |
| 134 | elif [ "x$1" = "x--no-relocate" ]; then |
| 135 | run_args="${run_args} --no-relocate" |
| 136 | shift |
Alex Light | 9d72253 | 2014-07-22 18:07:12 -0700 | [diff] [blame] | 137 | elif [ "x$1" = "x--no-prebuild" ]; then |
| 138 | run_args="${run_args} --no-prebuild" |
| 139 | shift; |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 140 | elif [ "x$1" = "x--prebuild" ]; then |
| 141 | run_args="${run_args} --prebuild" |
| 142 | shift; |
Alex Light | 03a112d | 2014-08-25 13:25:56 -0700 | [diff] [blame] | 143 | elif [ "x$1" = "x--no-dex2oat" ]; then |
| 144 | run_args="${run_args} --no-dex2oat" |
| 145 | shift; |
| 146 | elif [ "x$1" = "x--no-patchoat" ]; then |
| 147 | run_args="${run_args} --no-patchoat" |
| 148 | shift; |
Alex Light | bfac14a | 2014-07-30 09:41:21 -0700 | [diff] [blame] | 149 | elif [ "x$1" = "x--always-clean" ]; then |
| 150 | run_args="${run_args} --always-clean" |
Goran Jakovljevic | 79829cb | 2015-03-27 11:48:25 +0100 | [diff] [blame] | 151 | shift |
Alex Light | fadfee9 | 2015-10-28 09:40:10 -0700 | [diff] [blame] | 152 | elif [ "x$1" = "x--pic-test" ]; then |
| 153 | run_args="${run_args} --pic-test" |
| 154 | shift |
| 155 | elif [ "x$1" = "x--pic-image" ]; then |
| 156 | run_args="${run_args} --pic-image" |
| 157 | shift |
| 158 | elif [ "x$1" = "x--strace" ]; then |
| 159 | run_args="${run_args} --strace" |
| 160 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 161 | elif expr "x$1" : "x--" >/dev/null 2>&1; then |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 162 | echo "unknown $0 option: $1" 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 163 | usage="yes" |
| 164 | break |
| 165 | else |
| 166 | break |
| 167 | fi |
| 168 | done |
| 169 | |
| 170 | if [ "$usage" = "yes" ]; then |
| 171 | prog=`basename $prog` |
| 172 | ( |
| 173 | echo "usage:" |
| 174 | echo " $prog --help Print this message." |
| 175 | echo " $prog [options] Run all tests with the given options." |
| 176 | echo " Options are all passed to run-test; refer to that for " \ |
| 177 | "further documentation:" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 178 | echo " --debug --dev --host --interpreter --jit --jvm --no-optimize" |
Alex Light | fadfee9 | 2015-10-28 09:40:10 -0700 | [diff] [blame] | 179 | echo " --no-verify --verify-soft-fail -O --update --zygote --64" |
| 180 | echo " --relocate --prebuild --always-clean --gcstress --gcverify" |
| 181 | echo " --trace --no-patchoat --no-dex2oat --use-java-home --pic-image" |
| 182 | echo " --pic-test --strace --debuggable --dalvik --dex2oat-swap" |
| 183 | echo " --build-only --build-with-jack --build-with-javac-dx" |
| 184 | echo " --never-clean --image --no-image --quick --optimizing" |
| 185 | echo " --no-relocate --no-prebuild" |
Dmitry Petrochenko | 81c56e7 | 2014-03-05 15:05:46 +0700 | [diff] [blame] | 186 | echo " Specific Runtime Options:" |
| 187 | echo " --seq Run tests one-by-one, avoiding failures caused by busy CPU" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 188 | ) 1>&2 |
| 189 | exit 1 |
| 190 | fi |
| 191 | |
Dmitry Petrochenko | 81c56e7 | 2014-03-05 15:05:46 +0700 | [diff] [blame] | 192 | if [ "$sequental" == "yes" ]; then |
| 193 | i=0 |
| 194 | for test_name in *; do |
| 195 | if [ -d "$test_name" -a -r "$test_name" -a -r "$test_name/info.txt" ]; then |
| 196 | ./run-test ${run_args} "$test_name" |
| 197 | RES=$? |
| 198 | test_pids[i]=i |
| 199 | test_names[test_pids[i]]="$test_name" |
| 200 | if [ "$RES" != "0" ]; then |
| 201 | let failure_count+=1 |
| 202 | failed_test_names="$failed_test_names ${test_names[i]}" |
| 203 | else |
| 204 | let succeeded_count+=1 |
| 205 | fi |
| 206 | let i+=1 |
| 207 | fi |
| 208 | done |
| 209 | else |
| 210 | # start all the tests |
| 211 | i=0 |
| 212 | for test_name in *; do |
| 213 | if [ -d "$test_name" -a -r "$test_name" -a -r "$test_name/info.txt" ]; then |
| 214 | ./run-test ${run_args} "$test_name" & |
| 215 | test_pids[i]=$! |
| 216 | test_names[test_pids[i]]="$test_name" |
| 217 | let i+=1 |
| 218 | fi |
| 219 | done |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 220 | |
Dmitry Petrochenko | 81c56e7 | 2014-03-05 15:05:46 +0700 | [diff] [blame] | 221 | # wait for all the tests, collecting the failures |
| 222 | failure_count=0 |
| 223 | succeeded_count=0 |
| 224 | failed_test_names="" |
| 225 | for pid in ${test_pids[@]}; do |
| 226 | wait $pid |
| 227 | if [ "$?" != "0" ]; then |
| 228 | let failure_count+=1 |
| 229 | failed_test_names="$failed_test_names ${test_names[$pid]}[pid=$pid]" |
| 230 | else |
| 231 | let succeeded_count+=1 |
| 232 | fi |
| 233 | done |
| 234 | fi |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 235 | |
TDYa127 | b92bcab | 2012-04-08 00:09:51 -0700 | [diff] [blame] | 236 | echo "succeeded tests: $succeeded_count" |
Elliott Hughes | 8cbc8bc | 2011-10-04 11:19:45 -0700 | [diff] [blame] | 237 | echo "failed tests: $failure_count" |
| 238 | |
| 239 | for i in $failed_test_names; do |
| 240 | echo "failed: $i" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 241 | done |