Skip to content
Snippets Groups Projects

Tidy-up workspace and infer option for suppression

Merged Vivek Dutta requested to merge infer_suppress into devel
All threads resolved!
Files
2
@@ -5,60 +5,95 @@ log()
echo "# $* #"
}
log_err()
{
RED='\033[0;31m'
NC='\033[0m'
echo -e "${RED}# $* #${NC}"
}
exec_cmd()
{
log "Running [$@]"
$@
if [ "$?" -ne 0 ]; then
log "Failed to run [$@]..."
log_err "Failed to run [$@]..."
if [ -n "${CI}" ]; then
exit 1
else
# Ignore errors for development environment
log "Ignoring the last error ..."
log_err "Ignoring the last error ..."
fi
fi
}
generate_compilation_db()
{
if [ -f "compile_commands.json" ]; then
if jq -e '. | length == 0' compile_commands.json; then
log_err "Compilation db empty, probably COMPILATION_FIXUP not set"
exit 1
fi
log "Compilation db already exits, skip generation"
return 0
fi
if [ -n "${COMPILATION_FIXUP}" ]; then
COMPILATION_FIXUP="${COMPILATION_FIXUP/cmake /cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON }"
exec_cmd ${COMPILATION_FIXUP}
fi
if [ -f "compile_commands.json" ]; then
if jq -e '. | length == 0' compile_commands.json; then
log_err "Empty compilation db, probably COMPILATION_FIXUP incorrect"
exit 3
fi
log "Compilation db got generated with COMPILATION_FIXUP ..."
return 0
fi
exec_cmd bear -- make -C ${SOURCE_FOLDER}
make -C ${SOURCE_FOLDER} clean
if [ ! -f "compile_commands.json" ]; then
log "Failed to generate compilation db"
log_err "Failed to generate compilation db"
exit 2
fi
if jq -e '. | length == 0' compile_commands.json; then
log_err "Empty compilation db, probably COMPILATION_FIXUP not set"
exit 4
fi
}
run_cppcheck_validation()
{
mkdir -p /tmp/cppcheck
if [ -f "compile_commands.json" ]; then
exec_cmd cppcheck --error-exitcode=1 --addon=threadsafety --addon=cert -i ./test --inline-suppr ${CPPCHECK_OPTIONS} --project=compile_commands.json
else
exec_cmd cppcheck --error-exitcode=1 --addon=threadsafety --addon=cert -i ./test --inline-suppr ${CPPCHECK_OPTIONS} ${SOURCE_FOLDER}
exec_cmd cppcheck --error-exitcode=1 --addon=threadsafety --addon=cert -i ./test --inline-suppr ${CPPCHECK_OPTIONS} --project=compile_commands.json --cppcheck-build-dir=/tmp/cppcheck
fi
}
run_cppcheck_clang_validation()
{
mkdir -p /tmp/cppcheck
if [ -f "compile_commands.json" ]; then
if [ -n "${CI}" ]; then
cppcheck --error-exitcode=1 --clang -i ./test --inline-suppr ${CPPCHECK_OPTIONS} --project=compile_commands.json
cppcheck --error-exitcode=1 --clang -i ./test --inline-suppr ${CPPCHECK_OPTIONS} --project=compile_commands.json --cppcheck-build-dir=/tmp/cppcheck
else
exec_cmd cppcheck --error-exitcode=1 --clang -i ./test --inline-suppr ${CPPCHECK_OPTIONS} --project=compile_commands.json
exec_cmd cppcheck --error-exitcode=1 --clang -i ./test --inline-suppr ${CPPCHECK_OPTIONS} --project=compile_commands.json --cppcheck-build-dir=/tmp/cppcheck
fi
fi
}
run_infer_analysis()
{
exec_cmd infer --fail-on-issue --compilation-database compile_commands.json
cmd="infer --fail-on-issue --compilation-database compile_commands.json -o /tmp/infer ${INFER_OPTIONS}"
if ! ${cmd}; then
log_err "Failed to execute [$cmd]"
cp /tmp/infer/report.txt .
fi
}
run_flawfinder_checks()
@@ -97,6 +132,9 @@ main()
exec_cmd ./gitlab-ci/install-dependencies.sh
fi
# Run CPD checks
run_cpd_check
# Run flawfinder
run_flawfinder_checks
@@ -113,9 +151,6 @@ main()
# Run infer analysis
run_infer_analysis
# Run CPD checks
run_cpd_check
}
main "$@"
Loading