blob: 27c5ea1bd0d73b06fdc00d5508b26838ffeb335e [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 Onuki7a315602024-11-12 14:33:25 -080036while getopts "sx:f:dtb" 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)
Makoto Onuki7a315602024-11-12 14:33:25 -080055 # Redirect log to terminal
Makoto Onuki0c737dc2024-11-06 16:27:22 -080056 export RAVENWOOD_LOG_OUT=$(tty)
57 ;;
Makoto Onuki7a315602024-11-12 14:33:25 -080058 b)
59 # Build only
60 ATEST=m
61 ;;
Makoto Onuki00c2baf2024-10-23 15:40:21 -070062 '?')
63 exit 1
64 ;;
65esac
66done
67shift $(($OPTIND - 1))
Makoto Onuki450f9f32024-01-30 14:51:48 -080068
Makoto Onuki00c2baf2024-10-23 15:40:21 -070069all_tests=(hoststubgentest tiny-framework-dump-test hoststubgen-invoke-test ravenwood-stats-checker)
70all_tests+=( $(${0%/*}/list-ravenwood-tests.sh) )
71
Makoto Onuki54a90002024-11-01 16:31:07 -070072filter() {
73 local re="$1"
74 local grep_arg="$2"
75 if [[ "$re" == "" ]] ; then
76 cat # No filtering
77 else
Makoto Onuki62e28dc2024-11-05 11:55:24 -080078 grep $grep_arg -iP "$re"
Makoto Onuki54a90002024-11-01 16:31:07 -070079 fi
Makoto Onuki847ba782024-02-20 10:45:14 -080080}
81
Makoto Onuki54a90002024-11-01 16:31:07 -070082filter_in() {
83 filter "$1"
84}
85
86filter_out() {
87 filter "$1" -v
88}
89
90
91# Remove the slow tests.
92targets=( $(
93 for t in "${all_tests[@]}"; do
94 echo $t | filter_in "$include_re" | filter_out "$smoke_exclude_re" | filter_out "$exclude_re"
95 done
96) )
97
98# Show the target tests
99
100echo "Target tests:"
101for t in "${targets[@]}"; do
102 echo " $t"
103done
104
105# Calculate the removed tests.
106
Makoto Onuki7a315602024-11-12 14:33:25 -0800107diff="$(diff <(echo "${all_tests[@]}" | tr ' ' '\n') <(echo "${targets[@]}" | tr ' ' '\n') | grep -v [0-9] )"
Makoto Onuki54a90002024-11-01 16:31:07 -0700108
109if [[ "$diff" != "" ]]; then
110 echo "Excluded tests:"
111 echo "$diff"
112fi
113
Makoto Onuki7a315602024-11-12 14:33:25 -0800114run() {
115 echo "Running: ${@}"
116 "${@}"
117}
118
119run $dry_run ${ATEST:-atest} "${targets[@]}"