diff options
author | Guillem Jover <guillem@debian.org> | 2018-06-05 05:37:14 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2018-08-01 06:00:40 +0200 |
commit | fc94ac887d42291dfd573c4794ec7336f5dec127 (patch) | |
tree | 4b7776591d108a33fda0dcde42a9b59d61341570 | |
parent | 31ba2b1b10cfcc2149bb43fe9b918355177e4341 (diff) | |
download | dpkg-fc94ac887d42291dfd573c4794ec7336f5dec127.tar.gz |
test: Add new cppcheck integration author test
-rw-r--r-- | .gitlab-ci.yml | 2 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | t/cppcheck.t | 45 | ||||
-rw-r--r-- | t/cppcheck/cppcheck.supp | 43 |
6 files changed, 93 insertions, 1 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, @@ -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/cppcheck.t b/t/cppcheck.t new file mode 100644 index 000000000..696b6b08c --- /dev/null +++ b/t/cppcheck.t @@ -0,0 +1,45 @@ +#!/usr/bin/perl +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +use strict; +use warnings; + +use Test::More; +use Test::Dpkg qw(:needs); + +test_needs_author(); +test_needs_command('cppcheck'); +test_needs_srcdir_switch(); + +plan tests => 1; + +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); + +# 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 |