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. 19prog="$0" 20while [ -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 29done 30oldwd=`pwd` 31progdir=`dirname "${prog}"` 32cd "${progdir}" 33progdir=`pwd` 34prog="${progdir}"/`basename "${prog}"` 35 36run_args="" 37usage="no" 38sequental="no" 39 40while true; do 41 if [ "x$1" = "x--host" ]; then 42 run_args="${run_args} --host" 43 shift 44 elif [ "x$1" = "x--jvm" ]; then 45 run_args="${run_args} --jvm" 46 shift 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 53 elif [ "x$1" = "x--interpreter" ]; then 54 run_args="${run_args} --interpreter" 55 shift 56 elif [ "x$1" = "x--jit" ]; then 57 run_args="${run_args} --jit" 58 shift 59 elif [ "x$1" = "x--no-verify" ]; then 60 run_args="${run_args} --no-verify" 61 shift 62 elif [ "x$1" = "x--no-optimize" ]; then 63 run_args="${run_args} --no-optimize" 64 shift 65 elif [ "x$1" = "x--valgrind" ]; then 66 run_args="${run_args} --valgrind" 67 shift 68 elif [ "x$1" = "x--dev" ]; then 69 run_args="${run_args} --dev" 70 shift 71 elif [ "x$1" = "x--update" ]; then 72 run_args="${run_args} --update" 73 shift 74 elif [ "x$1" = "x--help" ]; then 75 usage="yes" 76 shift 77 elif [ "x$1" = "x--seq" ]; then 78 sequental="yes" 79 shift 80 elif [ "x$1" = "x-O" ]; then 81 run_args="${run_args} -O" 82 shift 83 elif [ "x$1" = "x--64" ]; then 84 run_args="${run_args} --64" 85 shift 86 elif [ "x$1" = "x--gcstress" ]; then 87 run_args="${run_args} --gcstress" 88 shift 89 elif [ "x$1" = "x--gcverify" ]; then 90 run_args="${run_args} --gcverify" 91 shift 92 elif [ "x$1" = "x--trace" ]; then 93 run_args="${run_args} --trace" 94 shift 95 elif [ "x$1" = "x--relocate" ]; then 96 run_args="${run_args} --relocate" 97 shift 98 elif [ "x$1" = "x--no-relocate" ]; then 99 run_args="${run_args} --no-relocate" 100 shift 101 elif [ "x$1" = "x--no-prebuild" ]; then 102 run_args="${run_args} --no-prebuild" 103 shift; 104 elif [ "x$1" = "x--prebuild" ]; then 105 run_args="${run_args} --prebuild" 106 shift; 107 elif [ "x$1" = "x--no-dex2oat" ]; then 108 run_args="${run_args} --no-dex2oat" 109 shift; 110 elif [ "x$1" = "x--no-patchoat" ]; then 111 run_args="${run_args} --no-patchoat" 112 shift; 113 elif [ "x$1" = "x--always-clean" ]; then 114 run_args="${run_args} --always-clean" 115 shift 116 elif expr "x$1" : "x--" >/dev/null 2>&1; then 117 echo "unknown $0 option: $1" 1>&2 118 usage="yes" 119 break 120 else 121 break 122 fi 123done 124 125if [ "$usage" = "yes" ]; then 126 prog=`basename $prog` 127 ( 128 echo "usage:" 129 echo " $prog --help Print this message." 130 echo " $prog [options] Run all tests with the given options." 131 echo " Options are all passed to run-test; refer to that for " \ 132 "further documentation:" 133 echo " --debug --dev --host --interpreter --jit --jvm --no-optimize" 134 echo " --no-verify -O --update --valgrind --zygote --64 --relocate" 135 echo " --prebuild --always-clean --gcstress --gcverify --trace" 136 echo " --no-patchoat --no-dex2oat" 137 echo " Specific Runtime Options:" 138 echo " --seq Run tests one-by-one, avoiding failures caused by busy CPU" 139 ) 1>&2 140 exit 1 141fi 142 143if [ "$sequental" == "yes" ]; then 144 i=0 145 for test_name in *; do 146 if [ -d "$test_name" -a -r "$test_name" -a -r "$test_name/info.txt" ]; then 147 ./run-test ${run_args} "$test_name" 148 RES=$? 149 test_pids[i]=i 150 test_names[test_pids[i]]="$test_name" 151 if [ "$RES" != "0" ]; then 152 let failure_count+=1 153 failed_test_names="$failed_test_names ${test_names[i]}" 154 else 155 let succeeded_count+=1 156 fi 157 let i+=1 158 fi 159 done 160else 161 # start all the tests 162 i=0 163 for test_name in *; do 164 if [ -d "$test_name" -a -r "$test_name" -a -r "$test_name/info.txt" ]; then 165 ./run-test ${run_args} "$test_name" & 166 test_pids[i]=$! 167 test_names[test_pids[i]]="$test_name" 168 let i+=1 169 fi 170 done 171 172 # wait for all the tests, collecting the failures 173 failure_count=0 174 succeeded_count=0 175 failed_test_names="" 176 for pid in ${test_pids[@]}; do 177 wait $pid 178 if [ "$?" != "0" ]; then 179 let failure_count+=1 180 failed_test_names="$failed_test_names ${test_names[$pid]}[pid=$pid]" 181 else 182 let succeeded_count+=1 183 fi 184 done 185fi 186 187echo "succeeded tests: $succeeded_count" 188echo "failed tests: $failure_count" 189 190for i in $failed_test_names; do 191 echo "failed: $i" 192done 193