2 # SPDX-License-Identifier: LGPL-2.1-or-later
9 for t
in all setup run clean clean-again
; do
10 [[ "$target" == "$t" ]] && return 0
20 for marker
in $DENY_LIST_MARKERS $BLACKLIST_MARKERS; do
21 if [[ -f "$test/$marker" ]]; then
22 echo "========== DENY-LISTED: $test ($marker) =========="
31 local test_name
="${1:?}"
34 if [[ $# -eq 0 ]]; then
35 echo >&2 "test_run: missing arguments"
39 # Note: let's be very explicit in reporting the return code of the test command here, i.e don't rely on
40 # `set -e` or the return code of the last statement in the function, since reporting false positive
41 # would be very bad in this case.
42 if [[ "${SPLIT_TEST_LOGS:-0}" -ne 0 && -n "${ARTIFACT_DIRECTORY:-}" ]]; then
43 (set -x; "$@") &>>"$ARTIFACT_DIRECTORY/$test_name.log" ||
return $?
45 (set -x; "$@") ||
return $?
49 ARGS
=(setup run clean-again
)
57 if [[ "${NO_BUILD:-0}" =~ ^
(1|
yes|true
)$
]]; then
59 elif BUILD_DIR
="$("$
(dirname "$0")/..
/tools
/find-build-dir.sh
")"; then
62 echo >&2 "No build found, please set BUILD_DIR or NO_BUILD"
66 if [[ $# -gt 0 ]]; then
70 # Reject invalid make targets
71 for arg
in "${ARGS[@]}"; do
72 if ! is_valid_target
"$arg"; then
73 echo >&2 "Invalid target: $arg"
78 # Separate 'clean' and 'clean-again' operations
80 for arg
in "${ARGS[@]}"; do
81 if [[ "$arg" == "clean-again" ]]; then
83 elif [[ "$arg" == "clean" ]]; then
86 args_filtered
+=("$arg")
89 ARGS
=("${args_filtered[@]}")
93 SELECTED_TESTS
="${SELECTED_TESTS:-TEST-??-*}"
95 # Let's always do the cleaning operation first, because it destroys the image
97 if [[ $CLEAN -eq 1 ]]; then
98 for test in $SELECTED_TESTS; do
99 test_run
"$test" make -C "$test" clean
103 # Run actual tests (if requested)
104 if [[ ${#ARGS[@]} -ne 0 ]]; then
105 for test in $SELECTED_TESTS; do
108 pass_deny_list
"$test" ||
continue
111 echo -e "\n[$(date +%R:%S)] --x-- Running $test --x--"
113 test_run
"$test" make -C "$test" "${ARGS[@]}"
116 echo "[$(date +%R:%S)] --x-- Result of $test: $result --x--"
118 RESULTS
["$test"]="$result"
119 TIMES
["$test"]="$SECONDS"
121 # Run clean-again here to free up space, if requested, and if the test succeeded
122 if [[ "$result" -ne 0 ]]; then
123 FAILURES
=$
((FAILURES
+ 1))
124 elif [[ $CLEAN_AGAIN -eq 1 ]]; then
125 test_run
"$test" make -C "$test" clean-again
132 for test in "${!RESULTS[@]}"; do
133 result
="${RESULTS[$test]}"
134 time="${TIMES[$test]}"
135 [[ "$result" -eq 0 ]] && string
="SUCCESS" || string
="FAIL"
136 printf "%-35s %-8s (%3s s)\n" "$test:" "$string" "$time"
139 if [[ "$FAILURES" -eq 0 ]]; then
140 echo -e "\nALL $COUNT TESTS PASSED"
142 echo -e "\nTOTAL FAILURES: $FAILURES OF $COUNT"
145 # If we have coverage files, merge them into a single report for upload
146 if [[ -n "$ARTIFACT_DIRECTORY" ]]; then
149 while read -r info_file
; do
150 lcov_args
+=(--add-tracefile "$info_file")
151 done < <(find "$ARTIFACT_DIRECTORY" -maxdepth 1 -name "*.coverage-info")
153 if [[ ${#lcov_args[@]} -gt 1 ]]; then
154 lcov
"${lcov_args[@]}" --output-file "$ARTIFACT_DIRECTORY/merged.coverage-info"