Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1 | #! /bin/bash |
Nicolas Geoffray | 5b93aef | 2019-01-21 13:44:58 +0000 | [diff] [blame] | 2 | # |
| 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 | |
Roland Levillain | de54ddd | 2021-07-28 20:02:04 +0100 | [diff] [blame] | 17 | set -e |
| 18 | |
Martin Stjernholm | 05b0086 | 2019-08-14 17:47:23 +0100 | [diff] [blame] | 19 | if [[ $1 = -h ]]; then |
| 20 | cat <<EOF |
Roland Levillain | de54ddd | 2021-07-28 20:02:04 +0100 | [diff] [blame] | 21 | Usage: $0 [<gtest>...] [--] [<gtest-option>...] |
| 22 | |
Martin Stjernholm | 05b0086 | 2019-08-14 17:47:23 +0100 | [diff] [blame] | 23 | Script to run gtests located in the ART (Testing) APEX. |
| 24 | |
| 25 | If called with arguments, only those tests are run, as specified by their |
| 26 | absolute paths (starting with /apex). All gtests are run otherwise. |
Roland Levillain | de54ddd | 2021-07-28 20:02:04 +0100 | [diff] [blame] | 27 | |
| 28 | Options after \`--\` are passed verbatim to each gtest binary. |
Martin Stjernholm | 05b0086 | 2019-08-14 17:47:23 +0100 | [diff] [blame] | 29 | EOF |
| 30 | exit |
| 31 | fi |
Nicolas Geoffray | 5b93aef | 2019-01-21 13:44:58 +0000 | [diff] [blame] | 32 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 33 | if [[ -z "$ART_TEST_CHROOT" ]]; then |
| 34 | echo 'ART_TEST_CHROOT environment variable is empty; please set it before running this script.' |
| 35 | exit 1 |
| 36 | fi |
| 37 | |
Roland Levillain | 70b93ff | 2019-07-02 19:48:50 +0100 | [diff] [blame] | 38 | adb="${ADB:-adb}" |
| 39 | |
Victor Chang | 6461124 | 2019-07-05 16:32:41 +0100 | [diff] [blame] | 40 | android_i18n_root=/apex/com.android.i18n |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 41 | android_art_root=/apex/com.android.art |
Roland Levillain | 70b93ff | 2019-07-02 19:48:50 +0100 | [diff] [blame] | 42 | android_tzdata_root=/apex/com.android.tzdata |
| 43 | |
Martin Stjernholm | 05b0086 | 2019-08-14 17:47:23 +0100 | [diff] [blame] | 44 | if [[ $1 = -j* ]]; then |
| 45 | # TODO(b/129930445): Implement support for parallel execution. |
| 46 | shift |
| 47 | fi |
| 48 | |
Roland Levillain | de54ddd | 2021-07-28 20:02:04 +0100 | [diff] [blame] | 49 | tests=() |
| 50 | |
| 51 | while [[ $# -gt 0 ]]; do |
| 52 | if [[ "$1" == "--" ]]; then |
| 53 | shift |
| 54 | break |
| 55 | fi |
| 56 | tests+=("$1") |
| 57 | shift |
| 58 | done |
| 59 | |
| 60 | options="$@" |
| 61 | |
| 62 | if [[ ${#tests[@]} -eq 0 ]]; then |
Martin Stjernholm | 05b0086 | 2019-08-14 17:47:23 +0100 | [diff] [blame] | 63 | # Search for executables under the `bin/art` directory of the ART APEX. |
Roland Levillain | de54ddd | 2021-07-28 20:02:04 +0100 | [diff] [blame] | 64 | readarray -t tests <<<$("$adb" shell chroot "$ART_TEST_CHROOT" \ |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 65 | find "$android_art_root/bin/art" -type f -perm /ugo+x | sort) |
Martin Stjernholm | 05b0086 | 2019-08-14 17:47:23 +0100 | [diff] [blame] | 66 | fi |
Roland Levillain | 70b93ff | 2019-07-02 19:48:50 +0100 | [diff] [blame] | 67 | |
Nicolas Geoffray | 5b93aef | 2019-01-21 13:44:58 +0000 | [diff] [blame] | 68 | failing_tests=() |
| 69 | |
Roland Levillain | de54ddd | 2021-07-28 20:02:04 +0100 | [diff] [blame] | 70 | for t in ${tests[@]}; do |
Roland Levillain | 70b93ff | 2019-07-02 19:48:50 +0100 | [diff] [blame] | 71 | echo "$t" |
| 72 | "$adb" shell chroot "$ART_TEST_CHROOT" \ |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 73 | env ANDROID_ART_ROOT="$android_art_root" \ |
| 74 | ANDROID_I18N_ROOT="$android_i18n_root" \ |
| 75 | ANDROID_TZDATA_ROOT="$android_tzdata_root" \ |
Roland Levillain | de54ddd | 2021-07-28 20:02:04 +0100 | [diff] [blame] | 76 | $t $options \ |
Roland Levillain | 70b93ff | 2019-07-02 19:48:50 +0100 | [diff] [blame] | 77 | || failing_tests+=("$t") |
Nicolas Geoffray | 5b93aef | 2019-01-21 13:44:58 +0000 | [diff] [blame] | 78 | done |
| 79 | |
Roland Levillain | de54ddd | 2021-07-28 20:02:04 +0100 | [diff] [blame] | 80 | if [[ -n "$failing_tests" ]]; then |
Roland Levillain | 70b93ff | 2019-07-02 19:48:50 +0100 | [diff] [blame] | 81 | for t in "${failing_tests[@]}"; do |
| 82 | echo "Failed test: $t" |
Nicolas Geoffray | 5b93aef | 2019-01-21 13:44:58 +0000 | [diff] [blame] | 83 | done |
| 84 | exit 1 |
| 85 | fi |