test/cfg: enabled `information` and `--inconclusive` in all cases / some cleanups (#4784)

This commit is contained in:
Oliver Stöneberg 2023-02-24 21:37:56 +01:00 committed by GitHub
parent 8583fcf96e
commit da09a92b0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 79 additions and 76 deletions

View File

@ -671,6 +671,7 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
if (name.empty())
return Error(ErrorCode::OK);
// TODO: write debug warning if we modify an existing entry
Function& func = functions[name];
for (const tinyxml2::XMLElement *functionnode = node->FirstChildElement(); functionnode; functionnode = functionnode->NextSiblingElement()) {

View File

@ -88,15 +88,15 @@ if (BUILD_TESTS)
endforeach()
function(add_cfg CFG_TEST)
set(options INCONCLUSIVE)
set(oneValueArgs PLATFORM NAME)
set(multiValueArgs LIBRARY)
set(multiValueArgs ADD_LIBRARY)
cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(PARSE_LIBRARY)
string(REPLACE ";" "," LIBRARY "${PARSE_LIBRARY}")
else()
get_filename_component(LIBRARY ${CFG_TEST} NAME_WE)
get_filename_component(LIBRARY ${CFG_TEST} NAME_WE)
# TODO: get rid of this
if(PARSE_ADD_LIBRARY)
string(REPLACE ";" "," ADD_LIBRARY "${PARSE_ADD_LIBRARY}")
set(LIBRARY "${ADD_LIBRARY},${LIBRARY}")
endif()
set(PLATFORM unix64)
if(PARSE_PLATFORM)
@ -107,10 +107,6 @@ if (BUILD_TESTS)
else()
string(MAKE_C_IDENTIFIER ${CFG_TEST} TEST_NAME)
endif()
set(INCONCLUSIVE)
if(PARSE_INCONCLUSIVE)
set(INCONCLUSIVE "--inconclusive")
endif()
if ("cfg-${TEST_NAME}" IN_LIST SKIP_TESTS)
else()
# TODO: add syntax check
@ -119,24 +115,27 @@ if (BUILD_TESTS)
--check-library
--platform=${PLATFORM}
--library=${LIBRARY}
--enable=information
--enable=style
--enable=style,information
--inconclusive
--force
--error-exitcode=1
--suppress=missingIncludeSystem
--inline-suppr
${INCONCLUSIVE}
${CMAKE_CURRENT_SOURCE_DIR}/cfg/${CFG_TEST}
)
endif()
endfunction()
add_cfg(boost.cpp INCONCLUSIVE)
# TODO: glob this
add_cfg(boost.cpp)
add_cfg(bsd.c)
add_cfg(cairo.c)
add_cfg(cppunit.cpp INCONCLUSIVE)
add_cfg(gnu.c LIBRARY posix;gnu)
add_cfg(googletest.cpp INCONCLUSIVE)
add_cfg(gtk.c INCONCLUSIVE)
add_cfg(kde.cpp INCONCLUSIVE)
add_cfg(cppunit.cpp)
# TODO: posix needs to specified first or it has a different mmap() config
# TODO: get rid of posix dependency
add_cfg(gnu.c ADD_LIBRARY posix)
add_cfg(googletest.cpp)
add_cfg(gtk.c)
add_cfg(kde.cpp)
add_cfg(libcurl.c)
add_cfg(libsigc++.cpp)
add_cfg(lua.c)
@ -145,14 +144,14 @@ if (BUILD_TESTS)
add_cfg(openssl.c)
add_cfg(posix.c)
add_cfg(python.c)
add_cfg(qt.cpp INCONCLUSIVE)
add_cfg(sqlite3.c INCONCLUSIVE)
add_cfg(std.c INCONCLUSIVE)
add_cfg(std.cpp INCONCLUSIVE)
add_cfg(windows.cpp INCONCLUSIVE NAME windows32A PLATFORM win32A)
add_cfg(windows.cpp INCONCLUSIVE NAME windows32W PLATFORM win32W)
add_cfg(windows.cpp INCONCLUSIVE NAME windows64 PLATFORM win64)
add_cfg(wxwidgets.cpp INCONCLUSIVE)
add_cfg(qt.cpp)
add_cfg(sqlite3.c)
add_cfg(std.c)
add_cfg(std.cpp)
add_cfg(windows.cpp NAME windows32A PLATFORM win32A)
add_cfg(windows.cpp NAME windows32W PLATFORM win32W)
add_cfg(windows.cpp NAME windows64 PLATFORM win64)
add_cfg(wxwidgets.cpp)
function(fixture_cost NAME COST)
if(TEST ${NAME})

View File

@ -2,7 +2,7 @@
// Test library configuration for boost.cfg
//
// Usage:
// $ cppcheck --check-library --library=boost --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/boost.cpp
// $ cppcheck --check-library --library=boost --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/boost.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -1,7 +1,7 @@
// Test library configuration for bsd.cfg
//
// Usage:
// $ cppcheck --check-library --library=bsd --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/bsd.c
// $ cppcheck --check-library --library=bsd --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/bsd.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for cairo.cfg
//
// Usage:
// $ cppcheck --check-library --library=cairo --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/cairo.c
// $ cppcheck --check-library --library=cairo --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/cairo.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -1,7 +1,7 @@
// Test library configuration for cppunit.cfg
//
// Usage:
// $ cppcheck --check-library --library=cppunit --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/cppunit.cpp
// $ cppcheck --check-library --library=cppunit --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/cppunit.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for gnu.cfg
//
// Usage:
// $ cppcheck --check-library --library=gnu --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/gnu.c
// $ cppcheck --check-library --library=gnu --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/gnu.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for googletest.cfg
//
// Usage:
// $ cppcheck --check-library --library=googletest --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/googletest.cpp
// $ cppcheck --check-library --library=googletest --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/googletest.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for gtk.cfg
//
// Usage:
// $ cppcheck --check-library --library=gtk --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr --library=gtk test/cfg/gtk.cpp
// $ cppcheck --check-library --library=gtk --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr --library=gtk test/cfg/gtk.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for kde.cfg
//
// Usage:
// $ cppcheck --check-library --library=kde --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/kde.cpp
// $ cppcheck --check-library --library=kde --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/kde.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for libcurl.cfg
//
// Usage:
// $ cppcheck --check-library --library=libcurl --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/libcurl.c
// $ cppcheck --check-library --library=libcurl --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/libcurl.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for libsigc++.cfg
//
// Usage:
// $ cppcheck --check-library --library=libsigc++ --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/libsigc++.cpp
// $ cppcheck --check-library --library=libsigc++ --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/libsigc++.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for lua.cfg
//
// Usage:
// $ cppcheck --check-library --library=lua --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/lua.c
// $ cppcheck --check-library --library=lua --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/lua.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for opencv2.cfg
//
// Usage:
// $ cppcheck --check-library --library=opencv2 --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/opencv2.cpp
// $ cppcheck --check-library --library=opencv2 --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/opencv2.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for openmp.cfg
//
// Usage:
// $ cppcheck --check-library --library=openmp --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/openmp.c
// $ cppcheck --check-library --library=openmp --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/openmp.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for openssl.cfg
//
// Usage:
// $ cppcheck --check-library --library=openssl --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/openssl.c
// $ cppcheck --check-library --library=openssl --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/openssl.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for posix.cfg
//
// Usage:
// $ cppcheck --check-library --library=posix --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/posix.c
// $ cppcheck --check-library --library=posix --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/posix.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
@ -1235,11 +1235,11 @@ void uninitvar_types(void)
{
// cppcheck-suppress unassignedVariable
blkcnt_t b;
// cppcheck-suppress uninitvar
// cppcheck-suppress [uninitvar,constStatement]
b + 1;
struct dirent d;
// TODO cppcheck-suppress uninitvar
// cppcheck-suppress constStatement - TODO: uninitvar
d.d_ino + 1;
}

View File

@ -2,7 +2,7 @@
// Test library configuration for python.cfg
//
// Usage:
// $ cppcheck --check-library --library=python --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/python.c
// $ cppcheck --check-library --library=python --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/python.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for qt.cfg
//
// Usage:
// $ cppcheck --check-library --library=qt --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/qt.cpp
// $ cppcheck --check-library --library=qt --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/qt.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -23,7 +23,7 @@ CPPCHECK="$DIR"../../cppcheck
CFG="$DIR"../../cfg/
# Cppcheck options
CPPCHECK_OPT='--check-library --platform=unix64 --enable=style --error-exitcode=-1 --suppress=missingIncludeSystem --inline-suppr --template="{file}:{line}:{severity}:{id}:{message}"'
CPPCHECK_OPT='--check-library --platform=unix64 --enable=style,information --inconclusive --force --error-exitcode=-1 --suppress=missingIncludeSystem --inline-suppr --template="{file}:{line}:{severity}:{id}:{message}"'
# Compiler settings
CXX=g++
@ -408,98 +408,101 @@ function cppunit_fn {
function check_file {
f=$(basename $1)
lib="${f%%.*}"
case $f in
boost.cpp)
boost_fn
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=boost ${DIR}boost.cpp
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
bsd.c)
bsd_fn
${CPPCHECK} ${CPPCHECK_OPT} --library=bsd ${DIR}bsd.c
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
cairo.c)
cairo_fn
${CPPCHECK} ${CPPCHECK_OPT} --library=cairo ${DIR}cairo.c
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
cppunit.cpp)
cppunit_fn
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=cppunit -f ${DIR}cppunit.cpp
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
gnu.c)
gnu_fn
${CPPCHECK} ${CPPCHECK_OPT} --library=posix,gnu ${DIR}gnu.c
# TODO: posix needs to specified first or it has a different mmap() config
# TODO: get rid of posix dependency
${CPPCHECK} ${CPPCHECK_OPT} --library=posix,$lib ${DIR}gnu.c
;;
googletest.cpp)
googletest_fn
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=googletest ${DIR}googletest.cpp
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
gtk.c)
gtk_fn
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=gtk -f ${DIR}gtk.c
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
kde.cpp)
# TODO: "kde-4config" is no longer commonly available in recent distros
#kde_fn
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=kde ${DIR}kde.cpp
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
libcurl.c)
libcurl_fn
${CPPCHECK} ${CPPCHECK_OPT} --library=libcurl ${DIR}libcurl.c
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
libsigc++.cpp)
libsigcpp_fn
${CPPCHECK} ${CPPCHECK_OPT} --library=libsigc++ ${DIR}libsigc++.cpp
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
lua.c)
lua_fn
${CPPCHECK} ${CPPCHECK_OPT} --library=lua ${DIR}lua.c
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
opencv2.cpp)
# TODO: "opencv.pc" is not commonly available in distros
#opencv2_fn
${CPPCHECK} ${CPPCHECK_OPT} --library=opencv2 ${DIR}opencv2.cpp
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
openmp.c)
openmp_fn
${CPPCHECK} ${CPPCHECK_OPT} --library=openmp ${DIR}openmp.c
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
openssl.c)
openssl_fn
${CPPCHECK} ${CPPCHECK_OPT} --library=openssl ${DIR}openssl.c
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
posix.c)
posix_fn
${CPPCHECK} ${CPPCHECK_OPT} --library=posix ${DIR}posix.c
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
python.c)
python_fn
${CPPCHECK} ${CPPCHECK_OPT} --library=python ${DIR}python.c
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
qt.cpp)
qt_fn
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=qt ${DIR}qt.cpp
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
sqlite3.c)
sqlite3_fn
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=sqlite3 ${DIR}sqlite3.c
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
std.c)
std_c_fn
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive ${DIR}std.c
${CPPCHECK} ${CPPCHECK_OPT} ${DIR}$f
;;
std.cpp)
std_cpp_fn
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive ${DIR}std.cpp
${CPPCHECK} ${CPPCHECK_OPT} ${DIR}$f
;;
windows.cpp)
windows_fn
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --platform=win32A --library=windows ${DIR}windows.cpp
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --platform=win32W --library=windows ${DIR}windows.cpp
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --platform=win64 --library=windows ${DIR}windows.cpp
${CPPCHECK} ${CPPCHECK_OPT} --platform=win32A --library=$lib ${DIR}$f
${CPPCHECK} ${CPPCHECK_OPT} --platform=win32W --library=$lib ${DIR}$f
${CPPCHECK} ${CPPCHECK_OPT} --platform=win64 --library=$lib ${DIR}$f
;;
wxwidgets.cpp)
wxwidgets_fn
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=wxwidgets,windows -f ${DIR}wxwidgets.cpp
${CPPCHECK} ${CPPCHECK_OPT} --library=$lib ${DIR}$f
;;
*)
echo "Unhandled file $f"

View File

@ -2,7 +2,7 @@
// Test library configuration for sqlite3.cfg
//
// Usage:
// $ cppcheck --check-library --enable=style --library=sqlite3 --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/sqlite3.c
// $ cppcheck --check-library --library=sqlite3 --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/sqlite3.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for std.cfg
//
// Usage:
// $ cppcheck --check-library --library=std --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/std.c
// $ cppcheck --check-library --library=std --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/std.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for std.cfg
//
// Usage:
// $ cppcheck --check-library --library=std --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/std.cpp
// $ cppcheck --check-library --library=std --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/std.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for windows.cfg
//
// Usage:
// $ cppcheck --check-library --library=windows --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/windows.cpp
// $ cppcheck --check-library --library=windows --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/windows.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

View File

@ -2,7 +2,7 @@
// Test library configuration for wxwidgets.cfg
//
// Usage:
// $ ./cppcheck --check-library --library=wxwidgets --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/wxwidgets.cpp
// $ ./cppcheck --check-library --library=wxwidgets --enable=style,information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/wxwidgets.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//