Skip to content
Snippets Groups Projects
Commit ef77d6c2 authored by Vivek Dutta's avatar Vivek Dutta
Browse files

Added more optional tests in static analysis stage

Below are the configuration variables used in static analysis tests
 - COMMON_IMAGE: <Docker image to use for test>
 - SOURCE_FOLDER: <Source directory path, default src>
 - SHELL_SRC: <Shell script path for shellcheck, default disabled>
 - FLAWFINDER_OPTIONS: <Options used with flawfinder,
    default "-m 4 --error-level=4">
 - CPPCHECK_OPTIONS: <Options to use with cppcheck,
    default "--suppress=unusedFunction --suppress=unreadVariable">
 - CPD_OPTIONS: <Options to use with CPD check,
    default "--minimum-tokens 200 --language c --exclude ./test/cmocka --files">
 - SHELLCHECK_OPTIONS: <ShellCheck options,
    default "-s dash -e SC2034,SC1091 -S info">
 - COMPILE: <Option to define how to compile,
    if defined compilation test also triggered as a pipeline job>

Variables can be Overridden by module tests
Optional test includes
 - ShellCheck if SHELL_SRC defined
 - CppCheck with threadsafety addon
 - CppCheck with cert addon
parent 34ca8e3d
Branches more_test
No related tags found
No related merge requests found
......@@ -64,7 +64,9 @@ RUN \
libz-dev \
sqlite3 \
# Dependencies for ieee1905
libpcap-dev
libpcap-dev \
clang \
shellcheck
RUN mkdir /opt/dev && \
mkdir /etc/config
......
variables:
RUN_FLAWFINDER: "flawfinder --falsepositive -m 4"
RUN_CPPCHECK: "cppcheck --enable=all --error-exitcode=1 --suppress=unusedFunction --suppress=unreadVariable --suppress=unmatchedSuppression ."
RUN_CPD: "/home/user/pmd-bin-6.19.0/bin/run.sh cpd --minimum-tokens 200 --language c --exclude ./test/cmocka --files"
COMMON_IMAGE: "dev.iopsys.eu:5050/iopsys/gitlab-ci-pipeline/code-analysis:0.28"
SOURCE_FOLDER: "src"
COMMON_IMAGE: "dev.iopsys.eu:5050/iopsys/gitlab-ci-pipeline/code-analysis:0.27"
SHELL_SRC: ""
FLAWFINDER_OPTIONS: "-m 4 --error-level=4"
CPPCHECK_OPTIONS: " --enable=all --inline-suppr --suppress=unusedFunction --suppress=unreadVariable"
CPD_OPTIONS: "--minimum-tokens 200 --language c --exclude ./test/cmocka --files"
SHELLCHECK_OPTIONS: "-s dash -e SC2034,SC1091 -S info"
DEBUG: "FALSE"
run_static_code_analysis:
......@@ -11,11 +13,34 @@ run_static_code_analysis:
stage: static_code_analysis
allow_failure: false
script:
- echo ${RUN_FLAWFINDER}
- flawfinder --version
- "${RUN_FLAWFINDER} ${SOURCE_FOLDER}"
- echo ${RUN_CPPCHECK}
- cppcheck --version
- "${RUN_CPPCHECK} ${SOURCE_FOLDER}"
- echo ${RUN_CPD}
- "${RUN_CPD} ${SOURCE_FOLDER}"
- echo "flawfinder ${FLAWFINDER_OPTIONS} ${SOURCE_FOLDER}"
- "flawfinder ${FLAWFINDER_OPTIONS} ${SOURCE_FOLDER}"
- echo "cppcheck --error-exitcode=1 ${CPPCHECK_OPTIONS} ${SOURCE_FOLDER}"
- "cppcheck --error-exitcode=1 --inline-suppr ${CPPCHECK_OPTIONS} ${SOURCE_FOLDER}"
- echo "/usr/local/pmd/bin/run.sh cpd ${CPD_OPTIONS}"
- "/usr/local/pmd/bin/run.sh cpd ${CPD_OPTIONS} ${SOURCE_FOLDER}"
run_compilation_test:
image: ${COMMON_IMAGE}
stage: static_code_analysis
allow_failure: false
script:
- "${COMPILE}"
rules:
- if: $COMPILE
when: always
run_optional_checks:
image: ${COMMON_IMAGE}
stage: static_code_analysis
allow_failure: true
script:
- echo "Running optional tests"
- echo "Running shellcheck ${SHELLCHECK_OPTIONS} ${SHELL_SRC}"
- if [ -n "${SHELL_SRC}" ]; then shellcheck ${SHELLCHECK_OPTIONS} ${SHELL_SRC}; fi
- echo "Running CPPCHECK with threadsafety addon"
- "cppcheck --error-exitcode=0 --addon=threadsafety ${SOURCE_FOLDER}"
- echo "Running CPPCHECK with cert addon"
- "cppcheck --error-exitcode=0 --addon=cert ${SOURCE_FOLDER}"
- echo "Running FlawFinder with depth 3"
- "flawfinder -m 3 --error-level=5 ${SOURCE_FOLDER}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment