Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9fd0c6a7 authored by Makoto Onuki's avatar Makoto Onuki Committed by Gerrit Code Review
Browse files

Merge "Add exclusion / inclusion filter options to..." into main

parents 0d2989e3 54a90000
Loading
Loading
Loading
Loading
+68 −17
Original line number Diff line number Diff line
@@ -18,12 +18,38 @@
# Options:
#
#   -s: "Smoke" test -- skip slow tests (SysUI, ICU)
#
#   -x PCRE: Specify exclusion filter in PCRE
#            Example: -x '^(Cts|hoststub)' # Exclude CTS and hoststubgen tests.
#
#   -f PCRE: Specify inclusion filter in PCRE


# Regex to identify slow tests, in PCRE
SLOW_TEST_RE='^(SystemUiRavenTests|CtsIcuTestCasesRavenwood)$'

smoke=0
while getopts "s" opt; do
include_re=""
exclude_re=""
smoke_exclude_re=""
dry_run=""
while getopts "sx:f:d" opt; do
case "$opt" in
    s)
        smoke=1
        # Remove slow tests.
        smoke_exclude_re="$SLOW_TEST_RE"
        ;;
    x)
        # Take a PCRE from the arg, and use it as an exclusion filter.
        exclude_re="$OPTARG"
        ;;
    f)
        # Take a PCRE from the arg, and use it as an inclusion filter.
        include_re="$OPTARG"
        ;;
    d)
        # Dry run
        dry_run="echo"
        ;;
    '?')
        exit 1
@@ -35,21 +61,46 @@ shift $(($OPTIND - 1))
all_tests=(hoststubgentest tiny-framework-dump-test hoststubgen-invoke-test ravenwood-stats-checker)
all_tests+=( $(${0%/*}/list-ravenwood-tests.sh) )

# Regex to identify slow tests, in PCRE
slow_tests_re='^(SystemUiRavenTests|CtsIcuTestCasesRavenwood)$'
filter() {
    local re="$1"
    local grep_arg="$2"
    if [[ "$re" == "" ]] ; then
        cat # No filtering
    else
        grep $grep_arg -P "$re"
    fi
}

filter_in() {
    filter "$1"
}

filter_out() {
    filter "$1" -v
}


if (( $smoke )) ; then
# Remove the slow tests.
    all_tests=( $(
targets=( $(
    for t in "${all_tests[@]}"; do
            echo $t | grep -vP "$slow_tests_re"
        echo $t | filter_in "$include_re" | filter_out "$smoke_exclude_re" | filter_out "$exclude_re"
    done
) )
fi

run() {
    echo "Running: $*"
    "${@}"
}
# Show the target tests

echo "Target tests:"
for t in "${targets[@]}"; do
    echo "  $t"
done

# Calculate the removed tests.

diff="$(diff  <(echo "${all_tests[@]}" | tr ' ' '\n') <(echo "${targets[@]}" | tr ' ' '\n') )"

if [[ "$diff" != "" ]]; then
    echo "Excluded tests:"
    echo "$diff"
fi

run ${ATEST:-atest} "${all_tests[@]}"
$dry_run ${ATEST:-atest} "${targets[@]}"