Skip to content

Commit

Permalink
Updated local CI (buildtst.sh) for current compilers and unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
fpagliughi committed Jan 6, 2025
1 parent 9d81b72 commit 37921d6
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions buildtst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,48 @@
#
# Build test for the Paho C++ library.
#
# This is a local CI for testing the build on a dev machine.
#
# This test the build with a few compilers on Linux. It does a build using
# CMake, for the library, tests, and examples, then runs the unit tests.
# This is repeated for each of the compilers in the list. If a particular
# compiler is not installed on the system, it is just skipped.
#
# This is not meant to replace Travis or other CI on the repo server, but
# is a quick test to use locally during development.
# This is not meant to replace any CI on the repo server, but is a quick
# test to use locally during development.
#

COMPILERS="g++-5 g++-6 g++-7 g++-8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8"
COMPILERS="g++-9 g++-11 g++-13 clang++-14 clang++-17 clang++-20"

[ "$#" -gt 0 ] && COMPILERS="$@"

[ -z "${BUILD_JOBS}" ] && BUILD_JOBS=4
[ -n "${PAHO_C_PATH}" ] && PAHO_C_SWITCH="-DCMAKE_PREFIX_PATH=${PAHO_C_PATH}"

for COMPILER in $COMPILERS; do
if [ -z "$(which ${COMPILER})" ]; then
printf "Compiler not found: %s\n" "${COMPILER}"
else
printf "===== Testing: %s =====\n\n" "${COMPILER}"
rm -rf buildtst-build/
mkdir buildtst-build ; pushd buildtst-build &> /dev/null
mkdir buildtst-build
pushd buildtst-build &> /dev/null

if ! cmake -DCMAKE_CXX_COMPILER=${COMPILER} -DPAHO_WITH_SSL=ON -DPAHO_BUILD_SAMPLES=ON -DPAHO_BUILD_TESTS=ON ${PAHO_C_SWITCH} .. ; then
if ! cmake .. -DCMAKE_CXX_COMPILER=${COMPILER} -DPAHO_WITH_SSL=ON -DPAHO_BUILD_SAMPLES=ON -DPAHO_BUILD_TESTS=ON -DPAHO_WITH_MQTT_C=ON ; then
printf "\nCMake configuration failed for %s\n" "${COMPILER}"
exit 1
fi

if ! make -j${BUILD_JOBS} ; then
printf "\nCompilation failed for %s\n" "${COMPILER}"
if ! cmake --build . -j ${BUILD_JOBS} ; then
printf "\nBuild failed for %s\n" "${COMPILER}"
exit 2
fi

printf "Running Catch2 Unit tests for %s:\n" "${COMPILER}"
printf "\nRunning Catch2 Unit tests for %s:\n" "${COMPILER}"
if ! ./test/unit/unit_tests ; then
printf "\nCatch2 unit test failed for %s\n" "${COMPILER}"
exit 3
fi

printf "Running CppUnit tests for %s:\n" "${COMPILER}"
if ! ./test/cppunit/paho-mqttpp-test ; then
printf "\nUnit test failed for %s\n" "${COMPILER}"
exit 4
fi

popd &> /dev/null
fi
printf "\n"
Expand All @@ -57,7 +54,7 @@ done
rm -rf buildtst-build/
printf "\nAll builds completed successfully\n\n"

if ! cppcheck --enable=all --std=c++11 --force --quiet src/*.cpp ; then
if ! cppcheck --enable=all --std=c++17 --force --quiet src/*.cpp ; then
printf "\ncppcheck failed\n"
exit 5
fi
Expand Down

0 comments on commit 37921d6

Please sign in to comment.