blob: 1910100a7f5d3c6b2a8ba547ac6803eb958f6c2c [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=""
36while getopts "sx:f:d" 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 ;;
54 '?')
55 exit 1
56 ;;
57esac
58done
59shift $(($OPTIND - 1))
Makoto Onuki450f9f32024-01-30 14:51:48 -080060
Makoto Onuki00c2baf2024-10-23 15:40:21 -070061all_tests=(hoststubgentest tiny-framework-dump-test hoststubgen-invoke-test ravenwood-stats-checker)
62all_tests+=( $(${0%/*}/list-ravenwood-tests.sh) )
63
Makoto Onuki54a90002024-11-01 16:31:07 -070064filter() {
65 local re="$1"
66 local grep_arg="$2"
67 if [[ "$re" == "" ]] ; then
68 cat # No filtering
69 else
Makoto Onuki62e28dc2024-11-05 11:55:24 -080070 grep $grep_arg -iP "$re"
Makoto Onuki54a90002024-11-01 16:31:07 -070071 fi
Makoto Onuki847ba782024-02-20 10:45:14 -080072}
73
Makoto Onuki54a90002024-11-01 16:31:07 -070074filter_in() {
75 filter "$1"
76}
77
78filter_out() {
79 filter "$1" -v
80}
81
82
83# Remove the slow tests.
84targets=( $(
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
92echo "Target tests:"
93for t in "${targets[@]}"; do
94 echo " $t"
95done
96
97# Calculate the removed tests.
98
99diff="$(diff <(echo "${all_tests[@]}" | tr ' ' '\n') <(echo "${targets[@]}" | tr ' ' '\n') )"
100
101if [[ "$diff" != "" ]]; then
102 echo "Excluded tests:"
103 echo "$diff"
104fi
105
106$dry_run ${ATEST:-atest} "${targets[@]}"