This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=fc94ac887d42291dfd573c4794ec7336f5dec127 commit fc94ac887d42291dfd573c4794ec7336f5dec127 Author: Guillem Jover <[email protected]> AuthorDate: Tue Jun 5 05:37:14 2018 +0200 test: Add new cppcheck integration author test --- .gitlab-ci.yml | 2 +- Makefile.am | 2 ++ README | 1 + debian/changelog | 1 + t/{synopsis.t => cppcheck.t} | 23 ++++++++++++++++++----- t/cppcheck/cppcheck.supp | 43 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 66 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 898b0a212..f36669fd1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ unit-tests: stage: test script: - eatmydata apt install -qq -y --no-install-recommends - fakeroot gpg aspell aspell-en i18nspector + fakeroot gpg cppcheck aspell aspell-en i18nspector libtest-strict-perl libtest-minimumversion-perl libtest-perl-critic-perl libtest-pod-perl libtest-pod-coverage-perl libtest-spelling-perl libtest-synopsis-perl diff --git a/Makefile.am b/Makefile.am index 058a8ae03..0445daaa1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -160,10 +160,12 @@ test_scripts = \ t/syntax.t \ t/strict.t \ t/critic.t \ + t/cppcheck.t \ $(nil) test_data = \ t/critic/perlcriticrc \ + t/cppcheck/cppcheck.supp \ $(nil) # We need to use absolute paths here due to strict.t invoking a sub-perl, diff --git a/README b/README index f092aaaa7..723ae3eed 100644 --- a/README +++ b/README @@ -88,6 +88,7 @@ To run the test suite («make check»): Test::Perl::Critic perl module (optional, author) aspell (optional, author) aspell-en (optional, author) + cppcheck (optional, author) fakeroot (optional) gpg (optional) i18nspector (optional, author) diff --git a/debian/changelog b/debian/changelog index 35de1e660..0a247a18c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -198,6 +198,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Add new po author test case (use i18nspector if available). - Add new test cases to clarify arch-qualified dependency simplification. - Add several TODO tests cases for dependency simplification. + - Add new cppcheck author test. [ Updated programs translations ] * Dutch (Frans Spiesschaert). Closes: #881401 diff --git a/t/synopsis.t b/t/cppcheck.t similarity index 63% copy from t/synopsis.t copy to t/cppcheck.t index 99835b602..696b6b08c 100644 --- a/t/synopsis.t +++ b/t/cppcheck.t @@ -20,13 +20,26 @@ use Test::More; use Test::Dpkg qw(:needs); test_needs_author(); -test_needs_module('Test::Synopsis'); +test_needs_command('cppcheck'); test_needs_srcdir_switch(); -my @files = Test::Dpkg::all_perl_files(); +plan tests => 1; -plan tests => scalar @files; +my @cppcheck_opts = (qw( + -q --force --error-exitcode=2 + --suppressions-list=t/cppcheck/cppcheck.supp +), ( + '--enable=warning,performance,portability,style', + '--template=\'{file}:{line}: {severity} ({id}): {message}\'' +)); +my $tags = qx(cppcheck @cppcheck_opts . 2>&1); -for my $file (@files) { - synopsis_ok($file); +# Fixup the output: +chomp $tags; + +my $ok = length $tags == 0; + +ok($ok, 'cppcheck'); +if (not $ok) { + diag($tags); } diff --git a/t/cppcheck/cppcheck.supp b/t/cppcheck/cppcheck.supp new file mode 100644 index 000000000..37e4a9ef9 --- /dev/null +++ b/t/cppcheck/cppcheck.supp @@ -0,0 +1,43 @@ +// +// Suppression file for cppcheck. +/// + +// We assume that the system has a sane NULL definition. +varFuncNullUB + +// TODO: While perhaps valid there are many to handle right away. +variableScope + +// Ignore, this is an imported module. +unusedStructMember:lib/compat/obstack.c +nullPointerArithmetic:lib/compat/obstack.c + +// Ignore, we use this construct to ease portability. +knownConditionTrueFalse:src/script.c:162 + +// Ignore, We use our own test assertions macros. +literalWithCharPtrCompare:lib/dpkg/t/t-test.c + +// Ignore, the code is used only for its binary artifacts. +uninitMemberVar:scripts/t/Dpkg_Shlibs/patterns.cpp + +// BUG: False positive, the macros from lib/dpkg/dlist.h use the tail member. +unusedStructMember:lib/dpkg/triglib.c:378 + +// BUG: False positive, does not understand must-allocate functions. +nullPointer:src/unpack.c:195 + +// BUG: False positive, does not understand setjmp-style error handling. +redundantAssignment:lib/dpkg/t/t-ehandle.c:108 +uninitStructMember:utils/update-alternatives.c:1246 +uninitStructMember:utils/update-alternatives.c:1247 +uninitStructMember:utils/update-alternatives.c:1248 + +// BUG: False positive, does not understand ohshit(), ohshite() and +// bad_format as error terminators. +doubleFree:src/script.c +doubleFree:utils/update-alternatives.c:1154 +va_end_missing:lib/dpkg/parsehelp.c:68 + +// BUG: False positive, the code uses va_copy(). +va_list_usedBeforeStarted:lib/compat/vasprintf.c -- Dpkg.Org's dpkg

