2014-09-10 05:09:35 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-08-06 19:21:23 +02:00
|
|
|
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2014-09-20 22:14:32 +02:00
|
|
|
TESTS_DIR=examples
|
2020-08-06 19:21:23 +02:00
|
|
|
export ARDMK_DIR="${ARDMK_DIR:-$SCRIPTS_DIR/../..}"
|
2014-09-20 22:14:32 +02:00
|
|
|
|
2014-09-10 05:09:35 +02:00
|
|
|
failures=()
|
|
|
|
|
2020-08-06 19:21:23 +02:00
|
|
|
if [[ "$1" == "-q" ]]; then
|
|
|
|
QUIET=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
runtest() {
|
|
|
|
if [[ $QUIET ]]; then
|
|
|
|
make $* TEST=1 > /dev/null 2>&1
|
|
|
|
else
|
|
|
|
output=`make $* TEST=1`
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
run() {
|
|
|
|
if [[ $QUIET ]]; then
|
|
|
|
"$@" > /dev/null 2>&1
|
|
|
|
else
|
|
|
|
"$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
info() {
|
|
|
|
if [[ $QUIET ]]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
run pushd $SCRIPTS_DIR/../..
|
|
|
|
|
2014-09-20 22:14:32 +02:00
|
|
|
# These examples cannot be tested easily at the moment as they require
|
|
|
|
# alternate cores. The MakefileExample doesn't actually contain any source code
|
|
|
|
# to compile.
|
2020-08-06 09:38:07 +02:00
|
|
|
NON_TESTABLE_EXAMPLES=(ATtinyBlink MakefileExample TinySoftWareSerial BlinkOpenCM BlinkOpenCR BlinkTeensy BlinkNetworkRPi BlinkInAVRC DueBlink)
|
2014-09-20 22:14:32 +02:00
|
|
|
|
|
|
|
for dir in $TESTS_DIR/*/
|
2014-09-10 05:09:35 +02:00
|
|
|
do
|
|
|
|
dir=${dir%*/}
|
|
|
|
example=${dir##*/}
|
2014-09-20 22:14:32 +02:00
|
|
|
example_is_testable=true
|
|
|
|
for non_testable_example in "${NON_TESTABLE_EXAMPLES[@]}"; do
|
|
|
|
if [[ $example == $non_testable_example ]]; then
|
|
|
|
example_is_testable=false
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if ! $example_is_testable; then
|
2020-08-06 19:21:23 +02:00
|
|
|
info "Skipping non-testable example $example..."
|
2014-09-20 22:14:32 +02:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2020-08-06 19:21:23 +02:00
|
|
|
run pushd $dir
|
|
|
|
info "Compiling $example..."
|
|
|
|
runtest clean
|
|
|
|
runtest
|
|
|
|
|
2014-09-10 05:09:35 +02:00
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
|
failures+=("$example")
|
2020-08-06 19:21:23 +02:00
|
|
|
info "Example $example failed"
|
2014-09-10 05:09:35 +02:00
|
|
|
fi
|
2015-05-21 14:31:09 +02:00
|
|
|
|
2020-08-06 19:21:23 +02:00
|
|
|
runtest disasm
|
2015-05-21 14:31:09 +02:00
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
|
failures+=("$example disasm")
|
2020-08-06 19:21:23 +02:00
|
|
|
info "Example $example disasm failed"
|
2015-05-21 14:31:09 +02:00
|
|
|
fi
|
|
|
|
|
2020-08-06 19:21:23 +02:00
|
|
|
runtest generate_assembly
|
2015-05-21 14:31:09 +02:00
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
|
failures+=("$example generate_assembly")
|
2020-08-06 19:21:23 +02:00
|
|
|
info "Example $example generate_assembly failed"
|
2015-05-21 14:31:09 +02:00
|
|
|
fi
|
|
|
|
|
2020-08-06 19:21:23 +02:00
|
|
|
runtest symbol_sizes
|
2015-05-21 14:31:09 +02:00
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
|
failures+=("$example symbol_sizes")
|
2020-08-06 19:21:23 +02:00
|
|
|
info "Example $example symbol_sizes failed"
|
2015-05-21 14:31:09 +02:00
|
|
|
fi
|
|
|
|
|
2020-08-06 19:21:23 +02:00
|
|
|
run popd
|
2014-09-10 05:09:35 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
if [[ ${#failures[@]} -eq 0 ]]; then
|
|
|
|
echo "All tests passed."
|
|
|
|
else
|
2020-08-06 19:21:23 +02:00
|
|
|
for failure in "${failures[@]}"; do
|
|
|
|
echo "Example $failure failed"
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 1
|
2014-09-10 05:09:35 +02:00
|
|
|
fi
|