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 16# Run all the ravenwood tests + hoststubgen unit tests. 17# 18# Options: 19# 20# -s: "Smoke" test -- skip slow tests (SysUI, ICU) 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 29SLOW_TEST_RE='^(SystemUiRavenTests|CtsIcuTestCasesRavenwood|CarSystemUIRavenTests)$' 30 31smoke=0 32include_re="" 33exclude_re="" 34smoke_exclude_re="" 35dry_run="" 36while getopts "sx:f:dtb" opt; do 37case "$opt" in 38 s) 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" 53 ;; 54 t) 55 # Redirect log to terminal 56 export RAVENWOOD_LOG_OUT=$(tty) 57 ;; 58 b) 59 # Build only 60 ATEST=m 61 ;; 62 '?') 63 exit 1 64 ;; 65esac 66done 67shift $(($OPTIND - 1)) 68 69all_tests=(hoststubgentest tiny-framework-dump-test hoststubgen-invoke-test ravenwood-stats-checker) 70all_tests+=( $(${0%/*}/list-ravenwood-tests.sh) ) 71 72filter() { 73 local re="$1" 74 local grep_arg="$2" 75 if [[ "$re" == "" ]] ; then 76 cat # No filtering 77 else 78 grep $grep_arg -iP "$re" 79 fi 80} 81 82filter_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 107diff="$(diff <(echo "${all_tests[@]}" | tr ' ' '\n') <(echo "${targets[@]}" | tr ' ' '\n') | grep -v [0-9] )" 108 109if [[ "$diff" != "" ]]; then 110 echo "Excluded tests:" 111 echo "$diff" 112fi 113 114run() { 115 echo "Running: ${@}" 116 "${@}" 117} 118 119run $dry_run ${ATEST:-atest} "${targets[@]}" 120