2 # SPDX-License-Identifier: LGPL-2.1-or-later
5 if [ "$NO_BUILD" ]; then
7 elif BUILD_DIR
="$("$
(dirname "$0")/..
/tools
/find-build-dir.sh
")"; then
10 echo "No build found, please set BUILD_DIR or NO_BUILD" >&2
17 args
="setup run clean-again"
20 VALID_TARGETS
="all setup run clean clean-again"
23 for target
in $VALID_TARGETS; do
24 [ "$1" = "$target" ] && return 0
29 # reject invalid make targets in $args
31 if ! is_valid_target
"$arg"; then
32 echo "Invalid target: $arg" >&2
40 # separate 'clean' and 'clean-again' operations
41 [[ "$args" =~
"clean-again" ]] && CLEANAGAIN
=1
42 args
=${args/clean-again}
43 [[ "$args" =~
"clean" ]] && CLEAN
=1
55 for marker
in $DENY_LIST_MARKERS $BLACKLIST_MARKERS; do
56 if [ -f "$1/$marker" ]; then
57 echo "========== DENY-LISTED: $1 ($marker) =========="
64 SELECTED_TESTS
="${SELECTED_TESTS:-TEST-??-*}"
66 # Let's always do the cleaning operation first, because it destroys the image
68 if [ $CLEAN = 1 ]; then
69 for TEST
in $SELECTED_TESTS; do
70 ( set -x ; make -C "$TEST" clean
)
74 # Run actual tests (if requested)
75 if [[ $args =~
[a-z
] ]]; then
76 for TEST
in $SELECTED_TESTS; do
79 pass_deny_list
"$TEST" ||
continue
82 echo -e "\n[$(date +%R:%S)] --x-- Running $TEST --x--"
84 # shellcheck disable=SC2086
85 ( set -x ; make -C "$TEST" $args )
88 echo "[$(date +%R:%S)] --x-- Result of $TEST: $RESULT --x--"
90 results
["$TEST"]="$RESULT"
91 times["$TEST"]=$
(( $
(date +%s
) - start
))
93 [ "$RESULT" -ne "0" ] && FAILURES
=$
((FAILURES
+1))
97 # Run clean-again, if requested, and if no tests failed
98 if [[ $FAILURES -eq 0 && $CLEANAGAIN -eq 1 ]]; then
99 for TEST
in "${!results[@]}"; do
100 ( set -x ; make -C "$TEST" clean-again
)
106 for TEST
in "${!results[@]}"; do
107 RESULT
="${results[$TEST]}"
108 time="${times[$TEST]}"
109 string
=$
([ "$RESULT" = "0" ] && echo "SUCCESS" ||
echo "FAIL")
110 printf "%-35s %-8s (%3s s)\n" "${TEST}:" "${string}" "$time"
113 if [ "$FAILURES" -eq 0 ] ; then
114 echo -e "\nALL $COUNT TESTS PASSED"
116 echo -e "\nTOTAL FAILURES: $FAILURES OF $COUNT"
119 # If we have coverage files, merge them into a single report for upload
120 if [ -n "${ARTIFACT_DIRECTORY}" ]; then
123 while read -r info_file
; do
124 lcov_args
+=(--add-tracefile "${info_file}")
125 done < <(find "${ARTIFACT_DIRECTORY}" -maxdepth 1 -name "*.coverage-info")
127 if [ ${#lcov_args[@]} -gt 1 ]; then
128 lcov
"${lcov_args[@]}" --output-file "${ARTIFACT_DIRECTORY}/merged.coverage-info"