Skip to content
Snippets Groups Projects
Commit 5bb15ef8 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

#8763 Add static code analysis during Hudson build

parent fb3fb8c1
Branches
Tags
No related merge requests found
...@@ -4,10 +4,26 @@ ...@@ -4,10 +4,26 @@
# #
# Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> # Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
XML_RESULTS="cppunitresults.xml"
TEST=0
BUILD=
CODE_ANALYSIS=0
function run_code_analysis {
# Check if cppcheck is installed on the system
if [ `which cppcheck &>/dev/null ; echo $?` -ne 1 ] ; then
cppcheck . --enable=all --xml 2> cppcheck-report.xml
fi
}
function build_daemon { function build_daemon {
# Compile the daemon # Compile the daemon
pushd daemon pushd daemon
# Run static analysis code tool
if [ $CODE_ANALYSIS == 1 ]; then
run_code_analysis
fi
make distclean make distclean
./autogen.sh ./autogen.sh
# Compile pjproject first # Compile pjproject first
...@@ -18,12 +34,15 @@ function build_daemon { ...@@ -18,12 +34,15 @@ function build_daemon {
popd popd
./configure --prefix=/usr ./configure --prefix=/usr
make clean make clean
# Compile src code
make -j make -j
# Generate documentation
make doc make doc
# Compile unit tests
make check make check
popd popd
if [ $1 == 1 ]; then if [ $TEST == 1 ]; then
# Run the unit tests for the daemon # Run the unit tests for the daemon
pushd daemon/test pushd daemon/test
# Remove the previous XML test file # Remove the previous XML test file
...@@ -63,11 +82,8 @@ fi ...@@ -63,11 +82,8 @@ fi
git clean -f -d -x git clean -f -d -x
XML_RESULTS="cppunitresults.xml"
TEST=0
BUILD=
while getopts ":b: t" opt; do while getopts ":b: t a" opt; do
case $opt in case $opt in
b) b)
echo "-b was triggered. Parameter: $OPTARG" >&2 echo "-b was triggered. Parameter: $OPTARG" >&2
...@@ -77,6 +93,10 @@ while getopts ":b: t" opt; do ...@@ -77,6 +93,10 @@ while getopts ":b: t" opt; do
echo "-t was triggered. Tests will be run" >&2 echo "-t was triggered. Tests will be run" >&2
TEST=1 TEST=1
;; ;;
a)
echo "-a was triggered. Static code analysis will be run" >&2
CODE_ANALYSIS=1
;;
\?) \?)
echo "Invalid option: -$OPTARG" >&2 echo "Invalid option: -$OPTARG" >&2
exit 1 exit 1
...@@ -89,7 +109,7 @@ while getopts ":b: t" opt; do ...@@ -89,7 +109,7 @@ while getopts ":b: t" opt; do
done done
# Call appropriate build function, with parameters if needed # Call appropriate build function, with parameters if needed
build_$BUILD $TEST build_$BUILD
# SUCCESS # SUCCESS
exit 0 exit 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment