File: buildtst.sh

package info (click to toggle)
paho.mqtt.cpp 1.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,672 kB
  • sloc: cpp: 13,068; ansic: 113; sh: 55; makefile: 22
file content (63 lines) | stat: -rwxr-xr-x 1,907 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
#
# buildtst.sh
# 
# 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 any CI on the repo server, but is a quick
# test to use locally during development.
#

COMPILERS="g++-9 g++-11 g++-13 clang++-14 clang++-17 clang++-20"

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

[ -z "${BUILD_JOBS}" ] && BUILD_JOBS=4

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

        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 ! cmake --build . -j ${BUILD_JOBS} ; then
            printf "\nBuild failed for %s\n" "${COMPILER}"
            exit 2
        fi

        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

        popd &> /dev/null
    fi
    printf "\n"
done

rm -rf buildtst-build/
printf "\nAll builds completed successfully\n\n"

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

printf "\n===== All tests completed successfully =====\n\n"
exit 0