From fec0340c02b4c2b23362aed5dcd79e4e11859e9d Mon Sep 17 00:00:00 2001 From: Grigoris Pavlakis <gregory.pavlakis@gmail.com> Date: Wed, 20 Mar 2019 09:58:48 +0000 Subject: [PATCH] Split MISRA checking into its own job to avoid clutter --- .gitlab-ci.yml | 12 ++++++++++++ ci/cppcheck-misra.sh | 28 ++++++++++++++++++++++++++++ ci/cppcheck.sh | 20 +------------------- 3 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 ci/cppcheck-misra.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9623a648..ab7cfd9f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,6 +46,18 @@ cppcheck: tags: - helit +cppcheck-misra: + stage: build + before_script: + # install cppcheck from the sid repos in order to get the latest version + - echo deb http://deb.debian.org/debian sid main > /etc/apt/sources.list + - apt-get update -qq && apt-get -t sid install -y -qq cppcheck + - cppcheck --version + script: + - ci/cppcheck-misra.sh + tags: + - helit + .vera: stage: build before_script: diff --git a/ci/cppcheck-misra.sh b/ci/cppcheck-misra.sh new file mode 100644 index 00000000..a1d14f95 --- /dev/null +++ b/ci/cppcheck-misra.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# +# Static code analysis for MISRA C-2012 compliance using cppcheck +# +# Usage: +# $ ci/cppcheck-misra.sh +# + +echo -e "\033[0;34mStarting cppcheck...\033[0m" + +echo -e "\033[0;34mRunning cppcheck with MISRA C(2012) rule compliance tests...\033[0m" + +# grab the MISRA addon and the cppcheck addon interface from github +curl https://raw.githubusercontent.com/danmar/cppcheck/f4b5b156d720c712f6ce99f6e01d8c1b3f800d52/addons/misra.py > misra.py +curl https://raw.githubusercontent.com/danmar/cppcheck/f4b5b156d720c712f6ce99f6e01d8c1b3f800d52/addons/cppcheckdata.py > cppcheckdata.py + +# generate dump files (XML representations of AST etc.) for all headers, source files etc. +for file in $(find inc/ src/ -type f) +do + cppcheck --dump $file +done + +# run the MISRA checks against the dumps +for file in $(find inc/ src/ -type f -name "*.dump") +do + python misra.py $file +done \ No newline at end of file diff --git a/ci/cppcheck.sh b/ci/cppcheck.sh index cb8f5466..83812104 100755 --- a/ci/cppcheck.sh +++ b/ci/cppcheck.sh @@ -13,22 +13,4 @@ echo -e "\033[0;34mRunning cppcheck with default checklist...\033[0m" cd "$(dirname "$0")/.." cppcheck --enable=all --inline-suppr --suppress=unusedFunction --suppress=missingIncludeSystem \ - --suppress=noExplicitConstructor --error-exitcode=1 -I inc src test - -echo -e "\033[33mRunning cppcheck with MISRA rule compliance tests...\033[0m" - -# grab the MISRA addon and the cppcheck addon interface from github -curl https://raw.githubusercontent.com/danmar/cppcheck/f4b5b156d720c712f6ce99f6e01d8c1b3f800d52/addons/misra.py > misra.py -curl https://raw.githubusercontent.com/danmar/cppcheck/f4b5b156d720c712f6ce99f6e01d8c1b3f800d52/addons/cppcheckdata.py > cppcheckdata.py - -# generate dump files (XML representations of AST etc.) for all headers, source files etc. -for file in $(find inc/ src/ -type f) -do - cppcheck --dump $file -done - -# run the MISRA checks against the dumps -for file in $(find inc/ src/ -type f -name "*.dump") -do - python misra.py $file -done \ No newline at end of file + --suppress=noExplicitConstructor --error-exitcode=1 -I inc src test \ No newline at end of file -- GitLab