2017-04-17 12:15:02 +08:00
|
|
|
#!/bin/bash
|
2017-04-13 05:24:01 +08:00
|
|
|
#
|
2018-12-07 09:01:36 +08:00
|
|
|
# buildtst.sh
|
|
|
|
#
|
|
|
|
# Build test for the Paho C++ library.
|
2017-04-13 05:24:01 +08:00
|
|
|
#
|
2018-12-07 09:01:36 +08:00
|
|
|
# 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.
|
2017-04-13 05:24:01 +08:00
|
|
|
#
|
2017-04-17 12:15:02 +08:00
|
|
|
# This is not meant to replace Travis or other CI on the repo server, but
|
2018-12-07 09:01:36 +08:00
|
|
|
# is a quick test to use locally during development.
|
2017-04-13 05:24:01 +08:00
|
|
|
#
|
|
|
|
|
2018-12-09 05:30:38 +08:00
|
|
|
COMPILERS="g++-5 g++-6 g++-7 g++-8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0"
|
2017-04-17 12:50:14 +08:00
|
|
|
[ "$#" -gt 0 ] && COMPILERS="$@"
|
2017-04-13 20:48:01 +08:00
|
|
|
|
2017-04-24 01:37:03 +08:00
|
|
|
[ -z "${BUILD_JOBS}" ] && BUILD_JOBS=4
|
2018-12-07 09:01:36 +08:00
|
|
|
[ -n "${PAHO_C_PATH}" ] && PAHO_C_SWITCH="-DCMAKE_PREFIX_PATH=${PAHO_C_PATH}"
|
2017-04-24 01:37:03 +08:00
|
|
|
|
2018-12-07 09:01:36 +08:00
|
|
|
for COMPILER in $COMPILERS; do
|
2017-04-13 05:24:01 +08:00
|
|
|
if [ -z "$(which ${COMPILER})" ]; then
|
|
|
|
printf "Compiler not found: %s\n" "${COMPILER}"
|
|
|
|
else
|
|
|
|
printf "===== Testing: %s =====\n\n" "${COMPILER}"
|
2018-12-07 09:01:36 +08:00
|
|
|
rm -rf buildtst-build/
|
|
|
|
mkdir buildtst-build ; pushd buildtst-build &> /dev/null
|
|
|
|
|
2018-12-08 23:41:45 +08:00
|
|
|
if ! cmake -DCMAKE_CXX_COMPILER=${COMPILER} -DPAHO_WITH_SSL=ON -DPAHO_BUILD_SAMPLES=ON -DPAHO_BUILD_TESTS=ON ${PAHO_C_SWITCH} .. ; then
|
2018-12-07 09:01:36 +08:00
|
|
|
printf "\nCMake configuration failed for %s\n" "${COMPILER}"
|
2017-04-13 05:24:01 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
2018-12-07 09:01:36 +08:00
|
|
|
|
|
|
|
if ! make -j${BUILD_JOBS} ; then
|
|
|
|
printf "\nCompilation failed for %s\n" "${COMPILER}"
|
|
|
|
exit 1
|
2017-04-13 05:24:01 +08:00
|
|
|
fi
|
2018-12-07 09:01:36 +08:00
|
|
|
|
2018-12-09 07:39:01 +08:00
|
|
|
printf "Running unit tests for %s:\n" "${COMPILER}"
|
2018-12-09 05:30:38 +08:00
|
|
|
if ! ./test/unit/paho-mqttpp-test ; then
|
2018-12-09 07:39:01 +08:00
|
|
|
printf "\nUnit test failed for %s\n" "${COMPILER}"
|
2018-12-08 23:41:45 +08:00
|
|
|
exit 3
|
|
|
|
fi
|
2018-12-07 09:01:36 +08:00
|
|
|
|
2017-04-13 05:24:01 +08:00
|
|
|
popd &> /dev/null
|
|
|
|
fi
|
|
|
|
printf "\n"
|
|
|
|
done
|
|
|
|
|
2018-12-07 09:01:36 +08:00
|
|
|
rm -rf buildtst-build/
|
2017-04-13 05:24:01 +08:00
|
|
|
printf "\n===== All tests completed successfully =====\n\n"
|
|
|
|
|
|
|
|
exit 0
|