From 478625c8026d0cc53f75bd569e10e42fdcb3003c Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 17 Oct 2019 21:29:32 +0200 Subject: [PATCH] kde.cfg: Add KDE configuration and tests (#2278) Reference: https://kde.org --- cfg/kde.cfg | 51 ++++++++++++++++++++++++++++++++++++++++++++ test/cfg/kde.cpp | 32 +++++++++++++++++++++++++++ test/cfg/runtests.sh | 30 ++++++++++++++++++++++++++ tools/donate-cpu.py | 1 + 4 files changed, 114 insertions(+) create mode 100644 cfg/kde.cfg create mode 100644 test/cfg/kde.cpp diff --git a/cfg/kde.cfg b/cfg/kde.cfg new file mode 100644 index 000000000..5973916fd --- /dev/null +++ b/cfg/kde.cfg @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + diff --git a/test/cfg/kde.cpp b/test/cfg/kde.cpp new file mode 100644 index 000000000..c238bf7ea --- /dev/null +++ b/test/cfg/kde.cpp @@ -0,0 +1,32 @@ + +// Test library configuration for kde.cfg +// +// Usage: +// $ cppcheck --check-library --enable=information --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/kde.cpp +// => +// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 +// + +#include +#include +#include + +class k_global_static_testclass1 {}; +K_GLOBAL_STATIC(k_global_static_testclass1, k_global_static_testinstance1); + +void valid_code(KConfigGroup &cfgGroup) +{ + k_global_static_testclass1 * pk_global_static_testclass1 = k_global_static_testinstance1; + printf("%p", pk_global_static_testclass1); + + bool entryTest = cfgGroup.readEntry("test", false); + if (entryTest) {} +} + +void ignoredReturnValue(KConfigGroup & cfgGroup) +{ + // cppcheck-suppress ignoredReturnValue + cfgGroup.readEntry("test", "default"); + // cppcheck-suppress ignoredReturnValue + cfgGroup.readEntry("test"); +} diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index 5f46fcf02..9b6c5e33a 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -282,6 +282,36 @@ ${CPPCHECK} ${CPPCHECK_OPT} --library=cairo ${DIR}cairo.c ${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=googletest ${DIR}googletest.cpp +# kde.cpp +set +e +set -x +KDECONFIG=$(kde4-config --path include) +KDECONFIG_RETURNCODE=$? +set -e +if [ $KDECONFIG_RETURNCODE -ne 0 ]; then + echo "kde4-config does not work, skipping syntax check." +else + set +e + KDEQTCONFIG=$(pkg-config --cflags QtCore) + KDEQTCONFIG_RETURNCODE=$? + set -e + if [ $KDEQTCONFIG_RETURNCODE -ne 0 ]; then + echo "Suitable Qt not present, Qt is necessary for KDE. Skipping syntax check." + else + set +e + echo -e "#include \n" | ${CXX} ${CXX_OPT} -I${KDECONFIG} ${KDEQTCONFIG} -x c++ - + KDECHECK_RETURNCODE=$? + set -e + if [ $KDECHECK_RETURNCODE -ne 0 ]; then + echo "KDE headers not completely present or not working, skipping syntax check with ${CXX}." + else + echo "KDE found, checking syntax with ${CXX} now." + ${CXX} ${CXX_OPT} -I${KDECONFIG} ${KDEQTCONFIG} ${DIR}kde.cpp + fi + fi +fi +${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=kde ${DIR}kde.cpp + # Check the syntax of the defines in the configuration files set +e xmlstarlet --version diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py index c0427f6d4..c40c02012 100644 --- a/tools/donate-cpu.py +++ b/tools/donate-cpu.py @@ -451,6 +451,7 @@ def get_libraries(): 'cppunit': [''], 'gtk': ['', '', ''], + # 'kde': ['', '', ''], 'libcurl': [''], 'lua': ['', '"lua.h"'],