blob: fe2269a8dc38f4d535b5fcfe8dacd4a0e528fe2a [file] [log] [blame]
Makoto Onuki450f9f32024-01-30 14:51:48 -08001#!/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 Onukid347a612024-02-14 10:10:12 -080016# Run all the ravenwood tests + hoststubgen unit tests.
Makoto Onuki00c2baf2024-10-23 15:40:21 -070017#
18# Options:
19#
20# -s: "Smoke" test -- skip slow tests (SysUI, ICU)
Makoto Onuki54a90002024-11-01 16:31:07 -070021#
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 Onuki62e28dc2024-11-05 11:55:24 -080029SLOW_TEST_RE='^(SystemUiRavenTests|CtsIcuTestCasesRavenwood|CarSystemUIRavenTests)$'
Makoto Onukid347a612024-02-14 10:10:12 -080030
Makoto Onuki00c2baf2024-10-23 15:40:21 -070031smoke=0
Makoto Onuki54a90002024-11-01 16:31:07 -070032include_re=""
33exclude_re=""
34smoke_exclude_re=""
35dry_run=""
Makoto Onuki0c737dc2024-11-06 16:27:22 -080036while getopts "sx:f:dt" opt; do
Makoto Onuki00c2baf2024-10-23 15:40:21 -070037case "$opt" in
38 s)
Makoto Onuki54a90002024-11-01 16:31:07 -070039 # 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 Onuki00c2baf2024-10-23 15:40:21 -070053 ;;
Makoto Onuki0c737dc2024-11-06 16:27:22 -080054 t)
55 export RAVENWOOD_LOG_OUT=$(tty)
56 ;;
Makoto Onuki00c2baf2024-10-23 15:40:21 -070057 '?')
58 exit 1
59 ;;
60esac
61done
62shift $(($OPTIND - 1))
Makoto Onuki450f9f32024-01-30 14:51:48 -080063
Makoto Onuki00c2baf2024-10-23 15:40:21 -070064all_tests=(hoststubgentest tiny-framework-dump-test hoststubgen-invoke-test ravenwood-stats-checker)
65all_tests+=( $(${0%/*}/list-ravenwood-tests.sh) )
66
Makoto Onuki54a90002024-11-01 16:31:07 -070067filter() {
68 local re="$1"
69 local grep_arg="$2"
70 if [[ "$re" == "" ]] ; then
71 cat # No filtering
72 else
Makoto Onuki62e28dc2024-11-05 11:55:24 -080073 grep $grep_arg -iP "$re"
Makoto Onuki54a90002024-11-01 16:31:07 -070074 fi
Makoto Onuki847ba782024-02-20 10:45:14 -080075}
76
Makoto Onuki54a90002024-11-01 16:31:07 -070077filter_in() {
78 filter "$1"
79}
80
81filter_out() {
82 filter "$1" -v
83}
84
85
86# Remove the slow tests.
87targets=( $(
88 for t in "${all_tests[@]}"; do
89 echo $t | filter_in "$include_re" | filter_out "$smoke_exclude_re" | filter_out "$exclude_re"
90 done
91) )
92
93# Show the target tests
94
95echo "Target tests:"
96for t in "${targets[@]}"; do
97 echo " $t"
98done
99
100# Calculate the removed tests.
101
102diff="$(diff <(echo "${all_tests[@]}" | tr ' ' '\n') <(echo "${targets[@]}" | tr ' ' '\n') )"
103
104if [[ "$diff" != "" ]]; then
105 echo "Excluded tests:"
106 echo "$diff"
107fi
108
109$dry_run ${ATEST:-atest} "${targets[@]}"