2020-03-04 12:35:06 +03:00
#!/usr/bin/env bash
set -e
2017-11-28 21:42:15 +03:00
2020-11-17 23:55:47 +03:00
if [ " $NO_BUILD " ] ; then
BUILD_DIR = ""
elif BUILD_DIR = " $( $( dirname " $0 " ) /../tools/find-build-dir.sh) " ; then
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
}
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
for TEST in TEST-??-* ; do
( 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
for TEST in TEST-??-* ; do
COUNT = $(( $COUNT + 1 ))
2020-03-25 15:46:44 +03:00
2020-11-18 15:30:11 +03:00
pass_deny_list $TEST || continue
start = $( date +%s)
2017-11-28 21:42:15 +03:00
2020-11-18 15:30:11 +03:00
echo -e " \n--x-- Running $TEST --x-- "
set +e
( set -x ; make -C " $TEST " $args )
RESULT = $?
set -e
echo " --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 "
times[ " $TEST " ] = $(( $( date +%s) - $start ))
[ " $RESULT " -ne "0" ] && FAILURES = $(( $FAILURES + 1 ))
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
if [ $FAILURES -eq 0 -a $CLEANAGAIN = 1 ] ; then
2020-03-25 15:46:44 +03:00
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 ""
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
exit " $FAILURES "