cppcheck/.travis.yml

254 lines
11 KiB
YAML

language: cpp
dist: xenial
compiler:
- gcc
- clang
env:
global:
- ORIGINAL_CXXFLAGS="-pedantic -Wall -Wextra -Wabi -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wshadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -D_GLIBCXX_DEBUG -g "
# unfortunately we need this to stay within 50min timelimit given by travis.
- CXXFLAGS="${ORIGINAL_CXXFLAGS} -O2 -march=native -Wstrict-aliasing=2 -Werror=strict-aliasing"
- CPPCHECK=${TRAVIS_BUILD_DIR}/cppcheck
matrix:
- CXXFLAGS="${CXXFLAGS} -DCHECK_INTERNAL"
- CXXFLAGS="${CXXFLAGS} -DCHECK_INTERNAL" MAKEFLAGS="HAVE_RULES=yes" SRCDIR=build VERIFY=1
before_install:
# install needed deps
- travis_retry sudo apt-get update -qq
- travis_retry sudo apt-get install -qq python-pygments qt5-default qt5-qmake qtbase5-dev qtcreator libxml2-utils libpcre3 gdb unzip wx-common xmlstarlet
matrix:
# do notify immediately about it when a job of a build fails.
fast_finish: true
allow_failures:
- name: "rerun dmake?"
compiler: clang
# defined extra jobs that run besides what is configured in the build matrix
include:
# -fsanitize=undefined
- name: "undefined behaviour sanitizers"
compiler: gcc
script:
- CXXFLAGS="-fsanitize=undefined -fno-sanitize-recover=all -Og -g3" make cppcheck test checkcfg -j 2
# -fsanitize=address
- name: "address sanitizers"
compiler: gcc
script:
- CXXFLAGS="-fsanitize=address -Og -g3" make cppcheck test checkcfg -j 2
# check a lot of stuff that only needs to be checked in a single configuration
- name: "misc"
compiler: clang
script:
- make -j 2
# run extra tests
- tools/generate_and_run_more_tests.sh
# check for missing CWE entries
- make checkCWEEntries
# check cfg files
- make checkcfg
# check platform files
- make validatePlatforms
# Validate Result XML
- make validateXML
# note: trusty on travis has python pygments disabled so disable these tests on travis
## check htmlreport stuff
# - ./htmlreport/test_htmlreport.py
# - cd htmlreport
# - ./check.sh
# - cd ../
# check if DESTDIR works TODO: actually execute this
- mkdir install_test
- echo $CXXFLAGS
- make -s DESTDIR=install_test install
# rm everything
- git clean -dfx
# check what happens if we want to install it to some other dir,
- echo $CXXFLAGS
- make -s SRCDIR=build CFGDIR=/usr/share/cppcheck/cfg -j 2
- sudo make SRCDIR=build CFGDIR=/usr/share/cppcheck/cfg install
- sudo mkdir -p /usr/share/cppcheck/cfg
- sudo install -D ./cfg/* -t /usr/share/cppcheck/cfg
# check if it actually works:
- /usr/bin/cppcheck ./cli
# check if showtime=top5 works
- ./tools/test_showtimetop5.sh
# check matchcompiler
- ./tools/test_matchcompiler.py
# check --dump
- ${CPPCHECK} test/testpreprocessor.cpp --dump
- xmllint --noout test/testpreprocessor.cpp.dump
# check python syntax by compiling all addon scripts
- python -m compileall ./addons
- python3 -m compileall ./addons
# check python syntax by compiling some selected scripts
- python -m py_compile ./tools/donate-cpu.py
- python3 -m py_compile ./tools/donate-cpu.py
- python -m py_compile ./tools/donate-cpu-server.py
- python3 -m py_compile ./tools/donate-cpu-server.py
# check addons/misc.py
- cd addons/test
- ${CPPCHECK} --dump misc-test.cpp
- python3 ../misc.py -verify misc-test.cpp.dump
- cd ../../
# check addons/cert.py
- cd addons/test
- ${CPPCHECK} --dump cert-test.c
- python3 ../cert.py -verify cert-test.c.dump
- ${CPPCHECK} --dump cert-test.cpp
- python3 ../cert.py -verify cert-test.cpp.dump
- cd ../../
# check addons/misra.py
- cd addons/test
- ${CPPCHECK} --dump misra-test.c
- python3 ../misra.py -verify misra-test.c.dump
- ${CPPCHECK} --dump misra-test.cpp
- python3 ../misra.py -verify misra-test.cpp.dump
- python ../misra.py --rule-texts=misra2012_rules_dummy_ascii.txt -verify misra-test.cpp.dump
- python3 ../misra.py --rule-texts=misra2012_rules_dummy_ascii.txt -verify misra-test.cpp.dump
- python ../misra.py --rule-texts=misra2012_rules_dummy_utf8.txt -verify misra-test.cpp.dump
- python3 ../misra.py --rule-texts=misra2012_rules_dummy_utf8.txt -verify misra-test.cpp.dump
- python ../misra.py --rule-texts=misra2012_rules_dummy_windows1250.txt -verify misra-test.cpp.dump
- python3 ../misra.py --rule-texts=misra2012_rules_dummy_windows1250.txt -verify misra-test.cpp.dump
- cd ../../
# check addons/naming.py
- cd addons/test
- ${CPPCHECK} --dump naming_test.c
- python3 ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.c.dump
- cd ../..
# check addons/namingng.py
- cd addons/test
- ${CPPCHECK} --dump namingng_test.c
- python3 ../namingng.py --configfile ../naming.json --verify namingng_test.c.dump
- cd ../..
# try CMake
- mkdir cmake.output
- cd cmake.output
- cmake -G "Unix Makefiles" ..
- cd ..
# check clang sources with cppcheck and look for crashes
- name: "check clang sources with cppcheck"
compiler: clang
script:
- wget "https://github.com/llvm-mirror/clang/archive/a1f8bd3778cc5a53236a53500c6ab184e945eefa.zip" & SRCDIR=build VERIFY=1 make -j 2 & wait
- unzip a1f8bd3778cc5a53236a53500c6ab184e945eefa.zip > /dev/null
- touch /tmp/clang.cppcheck
- cd ./clang-a1f8bd3778cc5a53236a53500c6ab184e945eefa
- ${CPPCHECK} . --max-configs=1 --enable=all --inconclusive --exception-handling --template="{callstack} ({severity}) {message} [{id}]" -iINPUTS -itest/Driver/Inputs/gen-response.c -itest/Index/index-many-logical-ops.c -itest/Sema/many-logical-ops.c --suppressions-list=../.travis_llvmcheck_suppressions -j 2 |& grep -v ".* files checked.*done" |& tee /tmp/clang.cppcheck
- cd ../
- echo "CLANG"
- grep "process crashed with signal\|Internal error\. compiled" /tmp/clang.cppcheck || true
- grep -qv "process crashed with signal\|Internal error\. compiled" /tmp/clang.cppcheck
# check llvm sources with cppcheck and look for crashes
- name: "check llvm sources with cppcheck"
compiler: clang
script:
- wget "https://github.com/llvm-mirror/llvm/archive/6fa6453210fa34c1c28bd73a431d04734549f0d6.zip" & SRCDIR=build VERIFY=1 make -j 2 & wait
- unzip 6fa6453210fa34c1c28bd73a431d04734549f0d6.zip > /dev/null
- touch /tmp/llvm.cppcheck
- cd ./llvm-6fa6453210fa34c1c28bd73a431d04734549f0d6
- ${CPPCHECK} . --max-configs=1 --enable=all --inconclusive --exception-handling --template="{callstack} ({severity}) {message} [{id}]" --suppressions-list=../.travis_llvmcheck_suppressions -j 2 |& grep -v ".* files checked.*done" |& tee /tmp/llvm.cppcheck
- cd ../
- echo "LLVM"
- grep "process crashed with signal\|Internal error\. compiled" /tmp/llvm.cppcheck || true
- grep -qv "process crashed with signal\|Internal error\. compiled" /tmp/llvm.cppcheck
# check if dmake needs to be rerun (this job may fail)
- name: "rerun dmake?"
compiler: clang
# we don't need to install any deps for dmake so skip it explicitly
before_install:
- true
script:
- echo "If the following command fails, run 'make dmake; make run-dmake' and commit the resulting change."
- make -s dmake -j2
- make -s run-dmake
- git diff --exit-code
# check if cppcheck builds on precise
- name: "make ubuntu 12.04 precise"
compiler: gcc
dist: precise
before_install:
- travis_retry sudo apt-get update -qq
- travis_retry sudo apt-get install libxml2-utils libpcre3
script:
- CXX=g++ CXXFLAGS="${ORIGINAL_CXXFLAGS}" make cppcheck testrunner -j 2
- make clean
- CXX=clang++ CXXFLAGS="${ORIGINAL_CXXFLAGS}" make cppcheck testrunner -j 2
# check if cppcheck builds on trusty
- name: "make ubuntu 14.04 trusty"
compiler: gcc
dist: trusty
before_install:
- travis_retry sudo apt-get update -qq
- travis_retry sudo apt-get install libxml2-utils libpcre3
script:
- CXX=g++ CXXFLAGS="${ORIGINAL_CXXFLAGS}" make cppcheck testrunner -j 2
- make clean
- CXX=clang++ CXXFLAGS="${ORIGINAL_CXXFLAGS}" make cppcheck testrunner -j 2
# check if cppcheck builds on osx
- name: "make osx"
os: osx
before_install:
- true
script:
- CXX=g++ CXXFLAGS="${ORIGINAL_CXXFLAGS}" make cppcheck testrunner -j 2
- make clean
- CXX=clang++ CXXFLAGS="${ORIGINAL_CXXFLAGS}" make cppcheck testrunner -j 2
script:
# fail the entire job as soon as one of the subcommands exits non-zero to save time and resources
- set -e
# Determine CPU count. As of January 2019 it seems to be 2 - so use this for job count in suitable calls to make or cppcheck
- cat /proc/cpuinfo
# check with TEST_MATHLIB_VALUE enabled
- touch lib/mathlib.cpp test/testmathlib.cpp
- echo $CXXFLAGS
- make -s test -j2 CPPFLAGS=-DTEST_MATHLIB_VALUE
- touch lib/mathlib.cpp test/testmathlib.cpp
# compile cppcheck, default build
- echo $CXXFLAGS
- make -s test -j2
# compile gui
- cd gui
- qmake
- echo $CXXFLAGS
- make -s -j2
# building gui generates some more files that cppcheck can check, so check the repo *after* building gui
- cd ../
# use same hack as for clang to work around cppchecks broken exit status with -j 2 ; create file, tee everything to the file and stdout, grep for errors in the file
- touch /tmp/cppcheck.cppcheck
- ${CPPCHECK} --template=gcc -D__CPPCHECK__ -f --error-exitcode=1 --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml/ -Icli --enable=style,performance,portability,warning,internal --exception-handling --inline-suppr --suppressions-list=.travis_suppressions -itest/synthetic -iaddons -igui . -j 2 |& tee /tmp/cppcheck.cppcheck
# check gui with qt settings
- ${CPPCHECK} --template=gcc --library=qt --error-exitcode=1 -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml/ -Icli --enable=style,performance,portability,warning,internal --exception-handling -j 2 gui --suppressions-list=.travis_suppressions -igui/test |& tee --append /tmp/cppcheck.cppcheck
- sh -c "! grep '^\[' /tmp/cppcheck.cppcheck"
# check naming conventions
- ${CPPCHECK} -i gui/test -j 2 --dump -q gui lib
- find lib gui -maxdepth 1 -name "*.dump" | xargs -n 1 -P 4 python addons/naming.py --private-member-variable='m[A-Z].*'
# Build gui
- cd ./gui
# clean rebuild
- git clean -dfx .
# can't set this as env flags, so try again with HAVE_RULES=yes
- qmake HAVE_RULES=yes
- echo $CXXFLAGS
- make -s -j2
- cd ../
# Build triage
- cd ./tools/triage
- git clean -dfx .
- qmake
- make -s -j2
- cd ../../
notifications:
irc:
channels:
- "irc.freenode.org#cppcheck"
template:
- "[%{commit} : %{author}] %{message}"
- "%{build_url}"
skip_join: true