mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 04:52:59 +01:00
Improve execution of static-tests
Allow execution of static tests with the `make static-tests` command and improve its output for the human reader
This commit is contained in:
parent
523e6975dd
commit
f7c28ccecd
2
Makefile
2
Makefile
@ -36,3 +36,5 @@ welcome:
|
|||||||
@echo " https://github.com/RIOT-OS/RIOT/wiki/Quick-Start-Guide"
|
@echo " https://github.com/RIOT-OS/RIOT/wiki/Quick-Start-Guide"
|
||||||
@echo "Or ask questions on our mailing list:"
|
@echo "Or ask questions on our mailing list:"
|
||||||
@echo " users@riot-os.org (http://lists.riot-os.org/mailman/listinfo/users)"
|
@echo " users@riot-os.org (http://lists.riot-os.org/mailman/listinfo/users)"
|
||||||
|
|
||||||
|
-include Makefile.tests
|
||||||
|
3
Makefile.tests
Normal file
3
Makefile.tests
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
static-test:
|
||||||
|
./dist/tools/static-tests.sh
|
45
dist/tools/static-tests.sh
vendored
Executable file
45
dist/tools/static-tests.sh
vendored
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (C) 2015 Lucas Jenß <lucas@x3ro.de>
|
||||||
|
#
|
||||||
|
# This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
# General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
# directory for more details.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Change to RIOT root
|
||||||
|
cd "$(dirname "$0")/../../"
|
||||||
|
|
||||||
|
function dep {
|
||||||
|
which $1 2>&1 1>/dev/null
|
||||||
|
if (( $? != 0 )); then
|
||||||
|
echo "Dependency not met: $1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function abort {
|
||||||
|
echo "$(tput setaf 1)$1$(tput sgr0)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function request_confirmation {
|
||||||
|
read -p "$(tput setaf 4)$1 (y/n) $(tput sgr0)"
|
||||||
|
[ "$REPLY" == "y" ] || abort "Aborted!"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Make sure all required commands are available
|
||||||
|
dep cppcheck
|
||||||
|
dep pcregrep
|
||||||
|
|
||||||
|
RIOT_REMOTE_COUNT="$(git remote | grep "^riot$" | wc -l)"
|
||||||
|
if (( "$RIOT_REMOTE_COUNT" != 1 )); then
|
||||||
|
echo "The static test setup expect a remote called 'riot', pointing to the"
|
||||||
|
echo "central repository. This remote currently does not exist."
|
||||||
|
request_confirmation "Do you wish to create it?"
|
||||||
|
|
||||||
|
git remote add riot https://github.com/RIOT-OS/RIOT.git
|
||||||
|
git fetch riot
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUILDTEST_MCU_GROUP=static-tests ./dist/tools/travis-scripts/build_and_test.sh
|
75
dist/tools/travis-scripts/build_and_test.sh
vendored
75
dist/tools/travis-scripts/build_and_test.sh
vendored
@ -9,6 +9,45 @@
|
|||||||
|
|
||||||
CI_BASE_BRANCH=${CI_BASE_BRANCH:-master}
|
CI_BASE_BRANCH=${CI_BASE_BRANCH:-master}
|
||||||
|
|
||||||
|
function print_result {
|
||||||
|
local RED="\033[0;31m"
|
||||||
|
local GREEN="\033[0;32m"
|
||||||
|
local NO_COLOUR="\033[0m"
|
||||||
|
|
||||||
|
if (( "$1" == 0 )); then
|
||||||
|
echo -e "${GREEN}✓$NO_COLOUR"
|
||||||
|
else
|
||||||
|
echo -e "${RED}x$NO_COLOUR"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
RESULT=0
|
||||||
|
set_result() {
|
||||||
|
NEW_RESULT=$1
|
||||||
|
|
||||||
|
if (( $NEW_RESULT != 0))
|
||||||
|
then
|
||||||
|
RESULT=$NEW_RESULT
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function run {
|
||||||
|
echo -n "Running '$@' "
|
||||||
|
OUT=$($@ 2>&1)
|
||||||
|
NEW_RESULT=$?
|
||||||
|
|
||||||
|
print_result $NEW_RESULT
|
||||||
|
set_result $NEW_RESULT
|
||||||
|
|
||||||
|
# Indent command output so that its easily discernable from the rest
|
||||||
|
OUT_LENGTH="$(echo -n $OUT | wc -c)"
|
||||||
|
if (( "$OUT_LENGTH" > 0 )); then
|
||||||
|
echo -e "Command output:\n"
|
||||||
|
(echo $OUT | while read -r line; do echo -ne "\t"; echo $line; done)
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [[ $BUILDTEST_MCU_GROUP ]]
|
if [[ $BUILDTEST_MCU_GROUP ]]
|
||||||
then
|
then
|
||||||
|
|
||||||
@ -43,31 +82,30 @@ then
|
|||||||
|
|
||||||
trap "RESULT=1" ERR
|
trap "RESULT=1" ERR
|
||||||
|
|
||||||
git rebase ${CI_BASE_BRANCH} || git rebase --abort
|
git rebase ${CI_BASE_BRANCH}
|
||||||
|
if (( $? != 0 )); then
|
||||||
|
git rebase --abort > /dev/null 2>&1
|
||||||
|
echo "Rebase failed, aborting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $RESULT -ne 0 ]; then
|
if [ $RESULT -ne 0 ]; then
|
||||||
exit $RESULT
|
exit $RESULT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
./dist/tools/whitespacecheck/check.sh ${CI_BASE_BRANCH}
|
run ./dist/tools/whitespacecheck/check.sh ${CI_BASE_BRANCH}
|
||||||
|
run ./dist/tools/licenses/check.sh ${CI_BASE_BRANCH} --diff-filter=MR --error-exitcode=0
|
||||||
./dist/tools/licenses/check.sh ${CI_BASE_BRANCH} --diff-filter=MR --error-exitcode=0
|
run ./dist/tools/licenses/check.sh ${CI_BASE_BRANCH} --diff-filter=AC
|
||||||
|
run ./dist/tools/doccheck/check.sh ${CI_BASE_BRANCH}
|
||||||
./dist/tools/licenses/check.sh ${CI_BASE_BRANCH} --diff-filter=AC
|
run ./dist/tools/externc/check.sh ${CI_BASE_BRANCH}
|
||||||
|
|
||||||
./dist/tools/doccheck/check.sh ${CI_BASE_BRANCH}
|
|
||||||
|
|
||||||
./dist/tools/externc/check.sh ${CI_BASE_BRANCH}
|
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
# Remove all but `${CI_BASE_BRANCH}` parameters to cppcheck (and remove second
|
# Remove all but `${CI_BASE_BRANCH}` parameters to cppcheck (and remove second
|
||||||
# invocation) once all warnings of cppcheck have been taken care of
|
# invocation) once all warnings of cppcheck have been taken care of
|
||||||
# in ${CI_BASE_BRANCH}.
|
# in ${CI_BASE_BRANCH}.
|
||||||
./dist/tools/cppcheck/check.sh ${CI_BASE_BRANCH} --diff-filter=MR --error-exitcode=0
|
run ./dist/tools/cppcheck/check.sh ${CI_BASE_BRANCH} --diff-filter=MR --error-exitcode=0
|
||||||
|
run ./dist/tools/cppcheck/check.sh ${CI_BASE_BRANCH} --diff-filter=AC
|
||||||
./dist/tools/cppcheck/check.sh ${CI_BASE_BRANCH} --diff-filter=AC
|
run ./dist/tools/pr_check/pr_check.sh ${CI_BASE_BRANCH}
|
||||||
|
|
||||||
./dist/tools/pr_check/pr_check.sh ${CI_BASE_BRANCH}
|
|
||||||
|
|
||||||
exit $RESULT
|
exit $RESULT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -79,11 +117,16 @@ then
|
|||||||
if [ "$BUILDTEST_MCU_GROUP" == "x86" ]
|
if [ "$BUILDTEST_MCU_GROUP" == "x86" ]
|
||||||
then
|
then
|
||||||
make -C ./tests/unittests all-debug test BOARD=native TERMPROG='gdb -batch -ex r -ex bt $(ELF)' || exit
|
make -C ./tests/unittests all-debug test BOARD=native TERMPROG='gdb -batch -ex r -ex bt $(ELF)' || exit
|
||||||
|
set_result $?
|
||||||
# TODO:
|
# TODO:
|
||||||
# Reenable once https://github.com/RIOT-OS/RIOT/issues/2300 is
|
# Reenable once https://github.com/RIOT-OS/RIOT/issues/2300 is
|
||||||
# resolved:
|
# resolved:
|
||||||
# - make -C ./tests/unittests all test BOARD=qemu-i386 || exit
|
# - make -C ./tests/unittests all test BOARD=qemu-i386 || exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BASE_BRANCH="${TRAVIS_BRANCH:-${CI_BASE_BRANCH}}"
|
BASE_BRANCH="${TRAVIS_BRANCH:-${CI_BASE_BRANCH}}"
|
||||||
./dist/tools/compile_test/compile_test.py $BASE_BRANCH
|
./dist/tools/compile_test/compile_test.py $BASE_BRANCH
|
||||||
|
set_result $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
exit $RESULT
|
||||||
|
Loading…
Reference in New Issue
Block a user