blob: 3a991e9146bb28652ef8fde180e058e465f0571e [file] [log] [blame]
jeffhao5d1ac922011-09-29 17:41:15 -07001#!/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"
Dmitry Petrochenko81c56e72014-03-05 15:05:46 +070038sequental="no"
jeffhao5d1ac922011-09-29 17:41:15 -070039
40while true; do
41 if [ "x$1" = "x--host" ]; then
42 run_args="${run_args} --host"
43 shift
Elliott Hughes58bcc402012-02-14 14:10:10 -080044 elif [ "x$1" = "x--jvm" ]; then
45 run_args="${run_args} --jvm"
jeffhao5d1ac922011-09-29 17:41:15 -070046 shift
jeffhao5d1ac922011-09-29 17:41:15 -070047 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
jeffhao0dff3f42012-11-20 15:13:43 -080053 elif [ "x$1" = "x--interpreter" ]; then
54 run_args="${run_args} --interpreter"
55 shift
jeffhao5d1ac922011-09-29 17:41:15 -070056 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 Petrochenko81c56e72014-03-05 15:05:46 +070074 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
jeffhao5d1ac922011-09-29 17:41:15 -070080 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -070081 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -070082 usage="yes"
83 break
84 else
85 break
86 fi
87done
88
89if [ "$usage" = "yes" ]; then
90 prog=`basename $prog`
91 (
92 echo "usage:"
93 echo " $prog --help Print this message."
94 echo " $prog [options] Run all tests with the given options."
95 echo " Options are all passed to run-test; refer to that for " \
96 "further documentation:"
jeffhao0dff3f42012-11-20 15:13:43 -080097 echo " --debug --dev --host --interpreter --jvm --no-optimize"
98 echo " --no-verify -O --update --valgrind --zygote"
Dmitry Petrochenko81c56e72014-03-05 15:05:46 +070099 echo " Specific Runtime Options:"
100 echo " --seq Run tests one-by-one, avoiding failures caused by busy CPU"
jeffhao5d1ac922011-09-29 17:41:15 -0700101 ) 1>&2
102 exit 1
103fi
104
Dmitry Petrochenko81c56e72014-03-05 15:05:46 +0700105if [ "$sequental" == "yes" ]; then
106 i=0
107 for test_name in *; do
108 if [ -d "$test_name" -a -r "$test_name" -a -r "$test_name/info.txt" ]; then
109 ./run-test ${run_args} "$test_name"
110 RES=$?
111 test_pids[i]=i
112 test_names[test_pids[i]]="$test_name"
113 if [ "$RES" != "0" ]; then
114 let failure_count+=1
115 failed_test_names="$failed_test_names ${test_names[i]}"
116 else
117 let succeeded_count+=1
118 fi
119 let i+=1
120 fi
121 done
122else
123 # start all the tests
124 i=0
125 for test_name in *; do
126 if [ -d "$test_name" -a -r "$test_name" -a -r "$test_name/info.txt" ]; then
127 ./run-test ${run_args} "$test_name" &
128 test_pids[i]=$!
129 test_names[test_pids[i]]="$test_name"
130 let i+=1
131 fi
132 done
jeffhao5d1ac922011-09-29 17:41:15 -0700133
Dmitry Petrochenko81c56e72014-03-05 15:05:46 +0700134 # wait for all the tests, collecting the failures
135 failure_count=0
136 succeeded_count=0
137 failed_test_names=""
138 for pid in ${test_pids[@]}; do
139 wait $pid
140 if [ "$?" != "0" ]; then
141 let failure_count+=1
142 failed_test_names="$failed_test_names ${test_names[$pid]}[pid=$pid]"
143 else
144 let succeeded_count+=1
145 fi
146 done
147fi
jeffhao5d1ac922011-09-29 17:41:15 -0700148
TDYa127b92bcab2012-04-08 00:09:51 -0700149echo "succeeded tests: $succeeded_count"
Elliott Hughes8cbc8bc2011-10-04 11:19:45 -0700150echo "failed tests: $failure_count"
151
152for i in $failed_test_names; do
153 echo "failed: $i"
jeffhao5d1ac922011-09-29 17:41:15 -0700154done