summaryrefslogtreecommitdiffstats
path: root/test/run-all-tests
blob: 318a0de17e73da1f720cbb3737a0b7e73f492263 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/bin/bash
#
# Copyright (C) 2007 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Set up prog to be the path of this script, including following symlinks,
# and set up progdir to be the fully-qualified pathname of its directory.
prog="$0"
while [ -h "${prog}" ]; do
    newProg=`/bin/ls -ld "${prog}"`
    newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
    if expr "x${newProg}" : 'x/' >/dev/null; then
        prog="${newProg}"
    else
        progdir=`dirname "${prog}"`
        prog="${progdir}/${newProg}"
    fi
done
oldwd=`pwd`
progdir=`dirname "${prog}"`
cd "${progdir}"
progdir=`pwd`
prog="${progdir}"/`basename "${prog}"`

run_args=""
usage="no"
sequental="no"

while true; do
    if [ "x$1" = "x--host" ]; then
        run_args="${run_args} --host"
        shift
    elif [ "x$1" = "x--jvm" ]; then
        run_args="${run_args} --jvm"
        shift
    elif [ "x$1" = "x--debug" ]; then
        run_args="${run_args} --debug"
        shift
    elif [ "x$1" = "x--zygote" ]; then
        run_args="${run_args} --zygote"
        shift
    elif [ "x$1" = "x--interpreter" ]; then
        run_args="${run_args} --interpreter"
        shift
    elif [ "x$1" = "x--no-verify" ]; then
        run_args="${run_args} --no-verify"
        shift
    elif [ "x$1" = "x--no-optimize" ]; then
        run_args="${run_args} --no-optimize"
        shift
    elif [ "x$1" = "x--valgrind" ]; then
        run_args="${run_args} --valgrind"
        shift
    elif [ "x$1" = "x--dev" ]; then
        run_args="${run_args} --dev"
        shift
    elif [ "x$1" = "x--update" ]; then
        run_args="${run_args} --update"
        shift
    elif [ "x$1" = "x--help" ]; then
        usage="yes"
        shift
    elif [ "x$1" = "x--seq" ]; then
        sequental="yes"
        shift
    elif [ "x$1" = "x-O" ]; then
        run_args="${run_args} -O"
        shift
    elif [ "x$1" = "x--64" ]; then
        run_args="${run_args} --64"
        shift
    elif [ "x$1" = "x--gcstress" ]; then
        run_args="${run_args} --gcstress"
        shift
    elif [ "x$1" = "x--gcverify" ]; then
        run_args="${run_args} --gcverify"
        shift
    elif [ "x$1" = "x--trace" ]; then
        run_args="${run_args} --trace"
        shift
    elif [ "x$1" = "x--relocate" ]; then
        run_args="${run_args} --relocate"
        shift
    elif [ "x$1" = "x--no-relocate" ]; then
        run_args="${run_args} --no-relocate"
        shift
    elif [ "x$1" = "x--no-prebuild" ]; then
        run_args="${run_args} --no-prebuild"
        shift;
    elif [ "x$1" = "x--prebuild" ]; then
        run_args="${run_args} --prebuild"
        shift;
    elif [ "x$1" = "x--no-dex2oat" ]; then
        run_args="${run_args} --no-dex2oat"
        shift;
    elif [ "x$1" = "x--no-patchoat" ]; then
        run_args="${run_args} --no-patchoat"
        shift;
    elif [ "x$1" = "x--always-clean" ]; then
        run_args="${run_args} --always-clean"
    elif expr "x$1" : "x--" >/dev/null 2>&1; then
        echo "unknown $0 option: $1" 1>&2
        usage="yes"
        break
    else
        break
    fi
done

if [ "$usage" = "yes" ]; then
    prog=`basename $prog`
    (
        echo "usage:"
        echo "  $prog --help     Print this message."
        echo "  $prog [options]  Run all tests with the given options."
        echo "  Options are all passed to run-test; refer to that for " \
             "further documentation:"
        echo "    --debug --dev --host --interpreter --jvm --no-optimize"
        echo "    --no-verify -O --update --valgrind --zygote --64 --relocate"
        echo "    --prebuild --always-clean --gcstress --gcverify --trace"
        echo "    --no-patchoat --no-dex2oat"
        echo "  Specific Runtime Options:"
        echo "    --seq                Run tests one-by-one, avoiding failures caused by busy CPU"
    ) 1>&2
    exit 1
fi

if [ "$sequental" == "yes" ]; then
  i=0
  for test_name in *; do
    if [ -d "$test_name" -a -r "$test_name" -a -r "$test_name/info.txt" ]; then
      ./run-test ${run_args} "$test_name"
      RES=$?
      test_pids[i]=i
      test_names[test_pids[i]]="$test_name"
      if [ "$RES" != "0" ]; then
        let failure_count+=1
        failed_test_names="$failed_test_names ${test_names[i]}"
      else
        let succeeded_count+=1
      fi
      let i+=1
    fi
  done
else
  # start all the tests
  i=0
  for test_name in *; do
    if [ -d "$test_name" -a -r "$test_name" -a -r "$test_name/info.txt" ]; then
      ./run-test ${run_args} "$test_name" &
      test_pids[i]=$!
      test_names[test_pids[i]]="$test_name"
      let i+=1
    fi
  done

  # wait for all the tests, collecting the failures
  failure_count=0
  succeeded_count=0
  failed_test_names=""
  for pid in ${test_pids[@]}; do
    wait $pid
    if [ "$?" != "0" ]; then
      let failure_count+=1
      failed_test_names="$failed_test_names ${test_names[$pid]}[pid=$pid]"
    else
      let succeeded_count+=1
    fi
  done
fi

echo "succeeded tests: $succeeded_count"
echo "failed tests: $failure_count"

for i in $failed_test_names; do
  echo "failed: $i"
done