blob: 5a4ab3a7777cb908369e59a5731710019a606f38 [file] [log] [blame]
Roland Levillain72f67742019-03-06 15:48:08 +00001#! /bin/bash
Nicolas Geoffray5b93aef2019-01-21 13:44:58 +00002#
3# Copyright (C) 2019 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
Martin Stjernholm05b00862019-08-14 17:47:23 +010017if [[ $1 = -h ]]; then
18 cat <<EOF
19Script to run gtests located in the ART (Testing) APEX.
20
21If called with arguments, only those tests are run, as specified by their
22absolute paths (starting with /apex). All gtests are run otherwise.
23EOF
24 exit
25fi
Nicolas Geoffray5b93aef2019-01-21 13:44:58 +000026
Roland Levillain72f67742019-03-06 15:48:08 +000027if [[ -z "$ART_TEST_CHROOT" ]]; then
28 echo 'ART_TEST_CHROOT environment variable is empty; please set it before running this script.'
29 exit 1
30fi
31
Roland Levillain70b93ff2019-07-02 19:48:50 +010032adb="${ADB:-adb}"
33
Victor Chang64611242019-07-05 16:32:41 +010034android_i18n_root=/apex/com.android.i18n
Martin Stjernholme58624f2019-09-20 15:53:40 +010035android_art_root=/apex/com.android.art
Roland Levillain70b93ff2019-07-02 19:48:50 +010036android_tzdata_root=/apex/com.android.tzdata
37
Martin Stjernholm05b00862019-08-14 17:47:23 +010038if [[ $1 = -j* ]]; then
39 # TODO(b/129930445): Implement support for parallel execution.
40 shift
41fi
42
43if [ $# -gt 0 ]; then
44 tests="$@"
45else
46 # Search for executables under the `bin/art` directory of the ART APEX.
47 tests=$("$adb" shell chroot "$ART_TEST_CHROOT" \
Martin Stjernholme58624f2019-09-20 15:53:40 +010048 find "$android_art_root/bin/art" -type f -perm /ugo+x | sort)
Martin Stjernholm05b00862019-08-14 17:47:23 +010049fi
Roland Levillain70b93ff2019-07-02 19:48:50 +010050
Nicolas Geoffray5b93aef2019-01-21 13:44:58 +000051failing_tests=()
52
Roland Levillain70b93ff2019-07-02 19:48:50 +010053for t in $tests; do
54 echo "$t"
55 "$adb" shell chroot "$ART_TEST_CHROOT" \
Martin Stjernholme58624f2019-09-20 15:53:40 +010056 env ANDROID_ART_ROOT="$android_art_root" \
57 ANDROID_I18N_ROOT="$android_i18n_root" \
58 ANDROID_TZDATA_ROOT="$android_tzdata_root" \
59 $t \
Roland Levillain70b93ff2019-07-02 19:48:50 +010060 || failing_tests+=("$t")
Nicolas Geoffray5b93aef2019-01-21 13:44:58 +000061done
62
Nicolas Geoffray13031e52019-01-22 09:05:07 +000063if [ -n "$failing_tests" ]; then
Roland Levillain70b93ff2019-07-02 19:48:50 +010064 for t in "${failing_tests[@]}"; do
65 echo "Failed test: $t"
Nicolas Geoffray5b93aef2019-01-21 13:44:58 +000066 done
67 exit 1
68fi