Makoto Onuki | 450f9f3 | 2024-01-30 14:51:48 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright (C) 2024 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
Makoto Onuki | d347a61 | 2024-02-14 10:10:12 -0800 | [diff] [blame] | 16 | # Run all the ravenwood tests + hoststubgen unit tests. |
Makoto Onuki | 00c2baf | 2024-10-23 15:40:21 -0700 | [diff] [blame] | 17 | # |
| 18 | # Options: |
| 19 | # |
| 20 | # -s: "Smoke" test -- skip slow tests (SysUI, ICU) |
Makoto Onuki | 54a9000 | 2024-11-01 16:31:07 -0700 | [diff] [blame] | 21 | # |
| 22 | # -x PCRE: Specify exclusion filter in PCRE |
| 23 | # Example: -x '^(Cts|hoststub)' # Exclude CTS and hoststubgen tests. |
| 24 | # |
| 25 | # -f PCRE: Specify inclusion filter in PCRE |
| 26 | |
| 27 | |
| 28 | # Regex to identify slow tests, in PCRE |
Makoto Onuki | 62e28dc | 2024-11-05 11:55:24 -0800 | [diff] [blame^] | 29 | SLOW_TEST_RE='^(SystemUiRavenTests|CtsIcuTestCasesRavenwood|CarSystemUIRavenTests)$' |
Makoto Onuki | d347a61 | 2024-02-14 10:10:12 -0800 | [diff] [blame] | 30 | |
Makoto Onuki | 00c2baf | 2024-10-23 15:40:21 -0700 | [diff] [blame] | 31 | smoke=0 |
Makoto Onuki | 54a9000 | 2024-11-01 16:31:07 -0700 | [diff] [blame] | 32 | include_re="" |
| 33 | exclude_re="" |
| 34 | smoke_exclude_re="" |
| 35 | dry_run="" |
| 36 | while getopts "sx:f:d" opt; do |
Makoto Onuki | 00c2baf | 2024-10-23 15:40:21 -0700 | [diff] [blame] | 37 | case "$opt" in |
| 38 | s) |
Makoto Onuki | 54a9000 | 2024-11-01 16:31:07 -0700 | [diff] [blame] | 39 | # Remove slow tests. |
| 40 | smoke_exclude_re="$SLOW_TEST_RE" |
| 41 | ;; |
| 42 | x) |
| 43 | # Take a PCRE from the arg, and use it as an exclusion filter. |
| 44 | exclude_re="$OPTARG" |
| 45 | ;; |
| 46 | f) |
| 47 | # Take a PCRE from the arg, and use it as an inclusion filter. |
| 48 | include_re="$OPTARG" |
| 49 | ;; |
| 50 | d) |
| 51 | # Dry run |
| 52 | dry_run="echo" |
Makoto Onuki | 00c2baf | 2024-10-23 15:40:21 -0700 | [diff] [blame] | 53 | ;; |
| 54 | '?') |
| 55 | exit 1 |
| 56 | ;; |
| 57 | esac |
| 58 | done |
| 59 | shift $(($OPTIND - 1)) |
Makoto Onuki | 450f9f3 | 2024-01-30 14:51:48 -0800 | [diff] [blame] | 60 | |
Makoto Onuki | 00c2baf | 2024-10-23 15:40:21 -0700 | [diff] [blame] | 61 | all_tests=(hoststubgentest tiny-framework-dump-test hoststubgen-invoke-test ravenwood-stats-checker) |
| 62 | all_tests+=( $(${0%/*}/list-ravenwood-tests.sh) ) |
| 63 | |
Makoto Onuki | 54a9000 | 2024-11-01 16:31:07 -0700 | [diff] [blame] | 64 | filter() { |
| 65 | local re="$1" |
| 66 | local grep_arg="$2" |
| 67 | if [[ "$re" == "" ]] ; then |
| 68 | cat # No filtering |
| 69 | else |
Makoto Onuki | 62e28dc | 2024-11-05 11:55:24 -0800 | [diff] [blame^] | 70 | grep $grep_arg -iP "$re" |
Makoto Onuki | 54a9000 | 2024-11-01 16:31:07 -0700 | [diff] [blame] | 71 | fi |
Makoto Onuki | 847ba78 | 2024-02-20 10:45:14 -0800 | [diff] [blame] | 72 | } |
| 73 | |
Makoto Onuki | 54a9000 | 2024-11-01 16:31:07 -0700 | [diff] [blame] | 74 | filter_in() { |
| 75 | filter "$1" |
| 76 | } |
| 77 | |
| 78 | filter_out() { |
| 79 | filter "$1" -v |
| 80 | } |
| 81 | |
| 82 | |
| 83 | # Remove the slow tests. |
| 84 | targets=( $( |
| 85 | for t in "${all_tests[@]}"; do |
| 86 | echo $t | filter_in "$include_re" | filter_out "$smoke_exclude_re" | filter_out "$exclude_re" |
| 87 | done |
| 88 | ) ) |
| 89 | |
| 90 | # Show the target tests |
| 91 | |
| 92 | echo "Target tests:" |
| 93 | for t in "${targets[@]}"; do |
| 94 | echo " $t" |
| 95 | done |
| 96 | |
| 97 | # Calculate the removed tests. |
| 98 | |
| 99 | diff="$(diff <(echo "${all_tests[@]}" | tr ' ' '\n') <(echo "${targets[@]}" | tr ' ' '\n') )" |
| 100 | |
| 101 | if [[ "$diff" != "" ]]; then |
| 102 | echo "Excluded tests:" |
| 103 | echo "$diff" |
| 104 | fi |
| 105 | |
| 106 | $dry_run ${ATEST:-atest} "${targets[@]}" |