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 |
Elliott Hughes | 58bcc40 | 2012-02-14 14:10:10 -0800 | [diff] [blame] | 44 | elif [ "x$1" = "x--jvm" ]; then |
| 45 | run_args="${run_args} --jvm" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 46 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 47 | elif [ "x$1" = "x--debug" ]; then |
| 48 | run_args="${run_args} --debug" |
| 49 | shift |
| 50 | elif [ "x$1" = "x--zygote" ]; then |
| 51 | run_args="${run_args} --zygote" |
| 52 | shift |
jeffhao | 0dff3f4 | 2012-11-20 15:13:43 -0800 | [diff] [blame] | 53 | elif [ "x$1" = "x--interpreter" ]; then |
| 54 | run_args="${run_args} --interpreter" |
| 55 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 56 | elif [ "x$1" = "x--no-verify" ]; then |
| 57 | run_args="${run_args} --no-verify" |
| 58 | shift |
| 59 | elif [ "x$1" = "x--no-optimize" ]; then |
| 60 | run_args="${run_args} --no-optimize" |
| 61 | shift |
| 62 | elif [ "x$1" = "x--valgrind" ]; then |
| 63 | run_args="${run_args} --valgrind" |
| 64 | shift |
| 65 | elif [ "x$1" = "x--dev" ]; then |
| 66 | run_args="${run_args} --dev" |
| 67 | shift |
| 68 | elif [ "x$1" = "x--update" ]; then |
| 69 | run_args="${run_args} --update" |
| 70 | shift |
| 71 | elif [ "x$1" = "x--help" ]; then |
| 72 | usage="yes" |
| 73 | shift |
Dmitry Petrochenko | 81c56e7 | 2014-03-05 15:05:46 +0700 | [diff] [blame] | 74 | elif [ "x$1" = "x--seq" ]; then |
| 75 | sequental="yes" |
| 76 | shift |
| 77 | elif [ "x$1" = "x-O" ]; then |
| 78 | run_args="${run_args} -O" |
| 79 | shift |
Zheng Xu | dc8e732 | 2014-05-07 17:07:20 +0100 | [diff] [blame] | 80 | elif [ "x$1" = "x--64" ]; then |
| 81 | run_args="${run_args} --64" |
| 82 | shift |
Sebastien Hertz | 07aaac8 | 2014-07-09 15:59:05 +0200 | [diff] [blame^] | 83 | elif [ "x$1" = "x--trace" ]; then |
| 84 | run_args="${run_args} --trace" |
| 85 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 86 | elif expr "x$1" : "x--" >/dev/null 2>&1; then |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 87 | echo "unknown $0 option: $1" 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 88 | usage="yes" |
| 89 | break |
| 90 | else |
| 91 | break |
| 92 | fi |
| 93 | done |
| 94 | |
| 95 | if [ "$usage" = "yes" ]; then |
| 96 | prog=`basename $prog` |
| 97 | ( |
| 98 | echo "usage:" |
| 99 | echo " $prog --help Print this message." |
| 100 | echo " $prog [options] Run all tests with the given options." |
| 101 | echo " Options are all passed to run-test; refer to that for " \ |
| 102 | "further documentation:" |
jeffhao | 0dff3f4 | 2012-11-20 15:13:43 -0800 | [diff] [blame] | 103 | echo " --debug --dev --host --interpreter --jvm --no-optimize" |
Zheng Xu | dc8e732 | 2014-05-07 17:07:20 +0100 | [diff] [blame] | 104 | echo " --no-verify -O --update --valgrind --zygote --64" |
Dmitry Petrochenko | 81c56e7 | 2014-03-05 15:05:46 +0700 | [diff] [blame] | 105 | echo " Specific Runtime Options:" |
| 106 | echo " --seq Run tests one-by-one, avoiding failures caused by busy CPU" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 107 | ) 1>&2 |
| 108 | exit 1 |
| 109 | fi |
| 110 | |
Dmitry Petrochenko | 81c56e7 | 2014-03-05 15:05:46 +0700 | [diff] [blame] | 111 | if [ "$sequental" == "yes" ]; then |
| 112 | i=0 |
| 113 | for test_name in *; do |
| 114 | if [ -d "$test_name" -a -r "$test_name" -a -r "$test_name/info.txt" ]; then |
| 115 | ./run-test ${run_args} "$test_name" |
| 116 | RES=$? |
| 117 | test_pids[i]=i |
| 118 | test_names[test_pids[i]]="$test_name" |
| 119 | if [ "$RES" != "0" ]; then |
| 120 | let failure_count+=1 |
| 121 | failed_test_names="$failed_test_names ${test_names[i]}" |
| 122 | else |
| 123 | let succeeded_count+=1 |
| 124 | fi |
| 125 | let i+=1 |
| 126 | fi |
| 127 | done |
| 128 | else |
| 129 | # start all the tests |
| 130 | i=0 |
| 131 | for test_name in *; do |
| 132 | if [ -d "$test_name" -a -r "$test_name" -a -r "$test_name/info.txt" ]; then |
| 133 | ./run-test ${run_args} "$test_name" & |
| 134 | test_pids[i]=$! |
| 135 | test_names[test_pids[i]]="$test_name" |
| 136 | let i+=1 |
| 137 | fi |
| 138 | done |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 139 | |
Dmitry Petrochenko | 81c56e7 | 2014-03-05 15:05:46 +0700 | [diff] [blame] | 140 | # wait for all the tests, collecting the failures |
| 141 | failure_count=0 |
| 142 | succeeded_count=0 |
| 143 | failed_test_names="" |
| 144 | for pid in ${test_pids[@]}; do |
| 145 | wait $pid |
| 146 | if [ "$?" != "0" ]; then |
| 147 | let failure_count+=1 |
| 148 | failed_test_names="$failed_test_names ${test_names[$pid]}[pid=$pid]" |
| 149 | else |
| 150 | let succeeded_count+=1 |
| 151 | fi |
| 152 | done |
| 153 | fi |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 154 | |
TDYa127 | b92bcab | 2012-04-08 00:09:51 -0700 | [diff] [blame] | 155 | echo "succeeded tests: $succeeded_count" |
Elliott Hughes | 8cbc8bc | 2011-10-04 11:19:45 -0700 | [diff] [blame] | 156 | echo "failed tests: $failure_count" |
| 157 | |
| 158 | for i in $failed_test_names; do |
| 159 | echo "failed: $i" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 160 | done |