Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 69 additions & 54 deletions test/cfg/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,28 @@ function get_pkg_config_cflags {
echo "$PKGCONFIG"
}

function cc_syntax {
${CC} "${CC_OPT[@]}" "$@"
}

function cxx_syntax {
${CXX} "${CXX_OPT[@]}" "$@"
}

function cppcheck_run {
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" "$@"
}

# posix.c
function posix_fn {
echo "POSIX assumed to be present, checking syntax with ${CC} now."
${CC} "${CC_OPT[@]}" ${DIR}posix.c
cc_syntax ${DIR}posix.c
}

# gnu.c
function gnu_fn {
echo "GNU assumed to be present, checking syntax with ${CC} now."
${CC} "${CC_OPT[@]}" ${DIR}gnu.c
cc_syntax ${DIR}gnu.c
}

# qt.cpp
Expand All @@ -92,7 +104,7 @@ function qt_fn {
exit_if_strict
else
echo "Qt found and working, checking syntax with ${CXX} now."
${CXX} "${CXX_OPT[@]}" ${QTCONFIG} ${DIR}qt.cpp
cxx_syntax ${QTCONFIG} ${DIR}qt.cpp
fi
else
echo "Qt not present, skipping syntax check with ${CXX}."
Expand All @@ -110,19 +122,19 @@ function bsd_fn {
# std.c
function std_c_fn {
echo "C standard library assumed to be present, checking syntax with ${CC} now."
${CC} "${CC_OPT[@]}" "${DIR}"std.c
cc_syntax "${DIR}"std.c
}

# std.cpp
function std_cpp_fn {
echo "C++ standard library assumed to be present, checking syntax with ${CXX} now."
${CXX} "${CXX_OPT[@]}" "${DIR}"std.cpp
cxx_syntax "${DIR}"std.cpp
}

# windows.cpp
function windows_fn {
# TODO: Syntax check via g++ does not work because it can not find a valid windows.h
#${CXX} "${CXX_OPT[@]}" ${DIR}windows.cpp
#cxx_syntax ${DIR}windows.cpp
true
}

Expand Down Expand Up @@ -153,7 +165,7 @@ function wxwidgets_fn {
exit_if_strict
else
echo "wxWidgets found, checking syntax with ${CXX} now."
${CXX} "${CXX_OPT[@]}" ${WXCONFIG} -Wno-deprecated-declarations "${DIR}"wxwidgets.cpp
cxx_syntax ${WXCONFIG} -Wno-deprecated-declarations "${DIR}"wxwidgets.cpp
fi
fi
}
Expand All @@ -172,14 +184,14 @@ function gtk_fn {
GTKCHECK_RETURNCODE=$?
set -e
if [ $GTKCHECK_RETURNCODE -ne 0 ]; then
echo "GTK+ not completely present or not working, skipping syntax check with ${CXX}."
echo "GTK+ not completely present or not working, skipping syntax check with ${CC}."
exit_if_strict
else
echo "GTK+ found and working, checking syntax with ${CXX} now."
${CC} "${CC_OPT[@]}" ${GTKCONFIG} "${DIR}"gtk.c
echo "GTK+ found and working, checking syntax with ${CC} now."
cc_syntax ${GTKCONFIG} "${DIR}"gtk.c
fi
else
echo "GTK+ not present, skipping syntax check with ${CXX}."
echo "GTK+ not present, skipping syntax check with ${CC}."
exit_if_strict
fi
fi
Expand All @@ -189,15 +201,15 @@ function gtk_fn {
function boost_fn {
# TODO: get rid of the error enabling/disabling?
set +e
echo -e "#include <boost/config.hpp>" | ${CXX} "${CXX_OPT[@]}" -x c++ -
echo -e "#include <boost/config.hpp>" | ${CXX} "${CXX_OPT[@]}" -x c++ -
BOOSTCHECK_RETURNCODE=$?
set -e
if [ ${BOOSTCHECK_RETURNCODE} -ne 0 ]; then
echo "Boost not completely present or not working, skipping syntax check with ${CXX}."
exit_if_strict
else
echo "Boost found and working, checking syntax with ${CXX} now."
${CXX} "${CXX_OPT[@]}" "${DIR}"boost.cpp
cxx_syntax "${DIR}"boost.cpp
fi
}

Expand All @@ -216,7 +228,7 @@ function sqlite3_fn {
exit_if_strict
else
echo "SQLite3 found and working, checking syntax with ${CC} now."
${CC} "${CC_OPT[@]}" ${SQLITE3CONFIG} "${DIR}"sqlite3.c
cc_syntax ${SQLITE3CONFIG} "${DIR}"sqlite3.c
fi
else
echo "SQLite3 not present, skipping syntax check with ${CC}."
Expand All @@ -230,7 +242,7 @@ function openmp_fn {
# MacOS compiler has no OpenMP by default
if ! command -v sw_vers; then
echo "OpenMP assumed to be present, checking syntax with ${CC} now."
${CC} "${CC_OPT[@]}" -fopenmp ${DIR}openmp.c
cc_syntax -fopenmp ${DIR}openmp.c
fi
}

Expand All @@ -249,7 +261,7 @@ function python_fn {
exit_if_strict
else
echo "Python 3 found and working, checking syntax with ${CC} now."
${CC} "${CC_OPT[@]}" ${PYTHON3CONFIG} "${DIR}"python.c
cc_syntax ${PYTHON3CONFIG} "${DIR}"python.c
fi
else
echo "Python 3 not present, skipping syntax check with ${CC}."
Expand All @@ -261,7 +273,10 @@ function python_fn {
# lua.c
function lua_fn {
if [ $HAS_PKG_CONFIG -eq 1 ]; then
LUACONFIG=$(get_pkg_config_cflags lua-5.3)
LUACONFIG=$(get_pkg_config_cflags lua)
if [ -z "$LUACONFIG" ]; then
LUACONFIG=$(get_pkg_config_cflags lua-5.3)
fi
if [ -n "$LUACONFIG" ]; then
# TODO: get rid of the error enabling/disabling?
set +e
Expand All @@ -273,7 +288,7 @@ function lua_fn {
exit_if_strict
else
echo "Lua found and working, checking syntax with ${CC} now."
${CC} "${CC_OPT[@]}" ${LUACONFIG} "${DIR}"lua.c
cc_syntax ${LUACONFIG} "${DIR}"lua.c
fi
else
echo "Lua not present, skipping syntax check with ${CC}."
Expand All @@ -297,7 +312,7 @@ function libcurl_fn {
exit_if_strict
else
echo "libcurl found and working, checking syntax with ${CC} now."
${CC} "${CC_OPT[@]}" ${LIBCURLCONFIG} "${DIR}"libcurl.c
cc_syntax ${LIBCURLCONFIG} "${DIR}"libcurl.c
fi
else
echo "libcurl not present, skipping syntax check with ${CC}."
Expand All @@ -321,7 +336,7 @@ function cairo_fn {
exit_if_strict
else
echo "cairo found and working, checking syntax with ${CC} now."
${CC} "${CC_OPT[@]}" ${CAIROCONFIG} "${DIR}"cairo.c
cc_syntax ${CAIROCONFIG} "${DIR}"cairo.c
fi
else
echo "cairo not present, skipping syntax check with ${CC}."
Expand Down Expand Up @@ -354,15 +369,15 @@ function kde_fn {
else
# TODO: get rid of the error enabling/disabling?
set +e
echo -e "#include <KDE/KGlobal>\n" | ${CXX} "${CXX_OPT[@]}" -I${KDECONFIG} ${KDEQTCONFIG} -x c++ -
echo -e "#include <KDE/KGlobal>\n" | ${CXX} "${CXX_OPT[@]}" -isystem${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}."
exit_if_strict
else
echo "KDE found, checking syntax with ${CXX} now."
${CXX} "${CXX_OPT[@]}" -I${KDECONFIG} ${KDEQTCONFIG} "${DIR}"kde.cpp
cxx_syntax -isystem${KDECONFIG} ${KDEQTCONFIG} "${DIR}"kde.cpp
fi
fi
fi
Expand All @@ -383,7 +398,7 @@ function libsigcpp_fn {
exit_if_strict
else
echo "libsigc++ found and working, checking syntax with ${CXX} now."
${CXX} "${CXX_OPT[@]}" ${LIBSIGCPPCONFIG} "${DIR}"libsigc++.cpp
cxx_syntax ${LIBSIGCPPCONFIG} "${DIR}"libsigc++.cpp
fi
else
echo "libsigc++ not present, skipping syntax check with ${CXX}."
Expand All @@ -407,7 +422,7 @@ function openssl_fn {
exit_if_strict
else
echo "OpenSSL found and working, checking syntax with ${CC} now."
${CC} "${CC_OPT[@]}" ${OPENSSLCONFIG} "${DIR}"openssl.c
cc_syntax ${OPENSSLCONFIG} "${DIR}"openssl.c
fi
else
echo "OpenSSL not present, skipping syntax check with ${CC}."
Expand All @@ -431,7 +446,7 @@ function opencv2_fn {
exit_if_strict
else
echo "OpenCV found and working, checking syntax with ${CXX} now."
${CXX} "${CXX_OPT[@]}" ${OPENCVCONFIG} "${DIR}"opencv2.cpp
cxx_syntax ${OPENCVCONFIG} "${DIR}"opencv2.cpp
fi
else
echo "OpenCV not present, skipping syntax check with ${CXX}."
Expand All @@ -448,15 +463,15 @@ function cppunit_fn {
exit_if_strict
else
echo "cppunit found, checking syntax with ${CXX} now."
${CXX} "${CXX_OPT[@]}" -Wno-deprecated-declarations "${DIR}"cppunit.cpp
cxx_syntax -Wno-deprecated-declarations "${DIR}"cppunit.cpp
fi
fi
}

# emscripten.cpp
function emscripten_fn {
# TODO: Syntax check via g++ does not work because it can not find a valid emscripten.h
# ${CXX} "${CXX_OPT[@]}" ${DIR}emscripten.cpp
# cxx_syntax ${DIR}emscripten.cpp
true
}

Expand All @@ -472,109 +487,109 @@ function check_file {
case $f in
boost.cpp)
boost_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
bsd.c)
bsd_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
cairo.c)
cairo_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
cppunit.cpp)
cppunit_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
emscripten.cpp)
emscripten_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
gnu.c)
gnu_fn
# 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
cppcheck_run --library=posix,"$lib" "${DIR}"gnu.c
;;
googletest.cpp)
googletest_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
gtk.c)
gtk_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
kde.cpp)
# TODO: "kde-4config" is no longer commonly available in recent distros
#kde_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" --library=qt "${DIR}""$f"
cppcheck_run --library="$lib" --library=qt "${DIR}""$f"
;;
libcurl.c)
libcurl_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
libsigc++.cpp)
libsigcpp_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
lua.c)
lua_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
mfc.cpp)
mfc_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --platform=win64 --library="$lib" "${DIR}""$f"
cppcheck_run --platform=win64 --library="$lib" "${DIR}""$f"
;;
opencv2.cpp)
# TODO: "opencv.pc" is not commonly available in distros
#opencv2_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
openmp.c)
openmp_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
openssl.c)
openssl_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
posix.c)
posix_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
python.c)
python_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
qt.cpp)
qt_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
selinux.c)
selinux_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
sqlite3.c)
sqlite3_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
std.c)
std_c_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" "${DIR}""$f"
cppcheck_run "${DIR}""$f"
;;
std.cpp)
std_cpp_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" "${DIR}""$f"
cppcheck_run "${DIR}""$f"
;;
windows.cpp)
windows_fn
"${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"
cppcheck_run --platform=win32A --library="$lib" "${DIR}""$f"
cppcheck_run --platform=win32W --library="$lib" "${DIR}""$f"
cppcheck_run --platform=win64 --library="$lib" "${DIR}""$f"
;;
wxwidgets.cpp)
wxwidgets_fn
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f"
cppcheck_run --library="$lib" "${DIR}""$f"
;;
*)
echo "Unhandled file $f"
Expand Down
Loading