2020-03-04 12:35:06 +03:00
#!/usr/bin/env bash
2021-10-01 14:04:32 +03:00
# SPDX-License-Identifier: LGPL-2.1-or-later
2020-03-04 12:35:06 +03:00
set -e
2017-11-28 21:42:15 +03:00
2020-11-17 23:55:47 +03:00
if [ " $NO_BUILD " ] ; then
BUILD_DIR = ""
2021-09-29 21:30:08 +03:00
elif BUILD_DIR = " $( " $( dirname " $0 " ) /../tools/find-build-dir.sh " ) " ; then
2020-11-17 23:55:47 +03:00
ninja -C " $BUILD_DIR "
else
echo "No build found, please set BUILD_DIR or NO_BUILD" >& 2
exit 1
fi
2017-12-06 17:13:02 +03:00
if [ $# -gt 0 ] ; then
2020-11-18 15:30:11 +03:00
args = " $* "
2017-12-06 17:13:02 +03:00
else
2020-03-20 21:09:35 +03:00
args = "setup run clean-again"
2017-12-06 17:13:02 +03:00
fi
2020-11-18 15:30:11 +03:00
VALID_TARGETS = "all setup run clean clean-again"
is_valid_target( ) {
for target in $VALID_TARGETS ; do
[ " $1 " = " $target " ] && return 0
done
return 1
}
# reject invalid make targets in $args
for arg in $args ; do
if ! is_valid_target " $arg " ; then
echo " Invalid target: $arg " >& 2
exit 1
fi
done
CLEAN = 0
CLEANAGAIN = 0
# separate 'clean' and 'clean-again' operations
[ [ " $args " = ~ "clean-again" ] ] && CLEANAGAIN = 1
args = ${ args /clean-again }
[ [ " $args " = ~ "clean" ] ] && CLEAN = 1
args = ${ args /clean }
2017-11-28 21:42:15 +03:00
declare -A results
2020-03-31 12:44:09 +03:00
declare -A times
2017-11-28 21:42:15 +03:00
2018-03-23 12:02:22 +03:00
COUNT = 0
2017-11-28 21:42:15 +03:00
FAILURES = 0
2017-12-06 17:09:54 +03:00
cd " $( dirname " $0 " ) "
2019-12-12 11:37:19 +03:00
2020-12-19 21:41:03 +03:00
pass_deny_list( ) {
for marker in $DENY_LIST_MARKERS $BLACKLIST_MARKERS ; do
2020-03-25 15:46:44 +03:00
if [ -f " $1 / $marker " ] ; then
2020-12-19 21:41:03 +03:00
echo " ========== DENY-LISTED: $1 ( $marker ) ========== "
2020-03-25 15:46:44 +03:00
return 1
fi
done
return 0
}
2021-05-10 21:46:37 +03:00
SELECTED_TESTS = " ${ SELECTED_TESTS :- TEST -??-* } "
2020-11-18 15:30:11 +03:00
# Let's always do the cleaning operation first, because it destroys the image
# cache.
if [ $CLEAN = 1 ] ; then
2021-05-10 21:46:37 +03:00
for TEST in $SELECTED_TESTS ; do
2020-11-18 15:30:11 +03:00
( set -x ; make -C " $TEST " clean )
done
fi
2018-03-23 12:02:22 +03:00
2020-11-18 15:30:11 +03:00
# Run actual tests (if requested)
if [ [ $args = ~ [ a-z] ] ] ; then
2021-05-10 21:46:37 +03:00
for TEST in $SELECTED_TESTS ; do
2021-09-29 21:30:08 +03:00
COUNT = $(( COUNT+1))
2020-03-25 15:46:44 +03:00
2021-09-29 21:30:08 +03:00
pass_deny_list " $TEST " || continue
2020-11-18 15:30:11 +03:00
start = $( date +%s)
2017-11-28 21:42:15 +03:00
2021-11-20 03:44:13 +03:00
echo -e " \n[ $( date +%R:%S) ] --x-- Running $TEST --x-- "
2020-11-18 15:30:11 +03:00
set +e
2021-09-29 21:30:08 +03:00
# shellcheck disable=SC2086
2020-11-18 15:30:11 +03:00
( set -x ; make -C " $TEST " $args )
RESULT = $?
set -e
2021-11-20 03:44:13 +03:00
echo " [ $( date +%R:%S) ] --x-- Result of $TEST : $RESULT --x-- "
2017-11-28 21:42:15 +03:00
2020-11-18 15:30:11 +03:00
results[ " $TEST " ] = " $RESULT "
2021-09-29 21:30:08 +03:00
times[ " $TEST " ] = $(( $( date +%s) - start ))
2020-11-18 15:30:11 +03:00
2021-09-29 21:30:08 +03:00
[ " $RESULT " -ne "0" ] && FAILURES = $(( FAILURES+1))
2020-11-18 15:30:11 +03:00
done
fi
2017-11-28 21:42:15 +03:00
2020-11-18 15:30:11 +03:00
# Run clean-again, if requested, and if no tests failed
2021-09-29 21:30:08 +03:00
if [ [ $FAILURES -eq 0 && $CLEANAGAIN -eq 1 ] ] ; then
for TEST in " ${ !results[@] } " ; do
2020-11-17 23:39:37 +03:00
( set -x ; make -C " $TEST " clean-again )
2019-12-12 11:37:19 +03:00
done
fi
2017-11-28 21:42:15 +03:00
echo ""
2021-09-29 21:30:08 +03:00
for TEST in " ${ !results[@] } " ; do
scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)
Also remove the few vim config lines that were left. We should either have them
on all files, or none.
Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-04 15:10:42 +03:00
RESULT = " ${ results [ $TEST ] } "
2020-03-31 12:44:09 +03:00
time = " ${ times [ $TEST ] } "
string = $( [ " $RESULT " = "0" ] && echo "SUCCESS" || echo "FAIL" )
printf "%-35s %-8s (%3s s)\n" " ${ TEST } : " " ${ string } " " $time "
2017-11-28 21:42:15 +03:00
done | sort
if [ " $FAILURES " -eq 0 ] ; then
scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)
Also remove the few vim config lines that were left. We should either have them
on all files, or none.
Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-04 15:10:42 +03:00
echo -e " \nALL $COUNT TESTS PASSED "
2017-11-28 21:42:15 +03:00
else
scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)
Also remove the few vim config lines that were left. We should either have them
on all files, or none.
Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-04 15:10:42 +03:00
echo -e " \nTOTAL FAILURES: $FAILURES OF $COUNT "
2017-11-28 21:42:15 +03:00
fi
2021-10-03 18:50:38 +03:00
# If we have coverage files, merge them into a single report for upload
if [ -n " ${ ARTIFACT_DIRECTORY } " ] ; then
lcov_args = ( )
while read -r info_file; do
lcov_args += ( --add-tracefile " ${ info_file } " )
done < <( find " ${ ARTIFACT_DIRECTORY } " -maxdepth 1 -name "*.coverage-info" )
if [ ${# lcov_args [@] } -gt 1 ] ; then
lcov " ${ lcov_args [@] } " --output-file " ${ ARTIFACT_DIRECTORY } /merged.coverage-info "
fi
fi
2017-11-28 21:42:15 +03:00
exit " $FAILURES "