Skip to content

Commit 509b133

Browse files
author
Ian Craggs
committed
Enable Travis build and test
1 parent 845d615 commit 509b133

File tree

6 files changed

+116
-4
lines changed

6 files changed

+116
-4
lines changed

.travis.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
sudo: true
2+
language: c
3+
4+
compiler:
5+
- gcc
6+
7+
os:
8+
- linux
9+
10+
sudo: required
11+
12+
script:
13+
- if [[ "$COVERITY_SCAN_BRANCH" != 1 ]]; then ./travis-build.sh; fi
14+
15+
addons:
16+
apt:
17+
sources:
18+
- george-edison55-precise-backports # cmake 3.2.3 / doxygen 1.8.3
19+
- sourceline: 'ppa:mosquitto-dev/mosquitto-ppa'
20+
packages:
21+
- cmake
22+
- cmake-data
23+
- mosquitto
24+
- doxygen
25+
26+

CMakeLists.txt

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ add_executable(qos0pub
2525
"${CMAKE_CURRENT_SOURCE_DIR}/MQTTPacket/samples/transport.c")
2626
target_link_libraries(qos0pub paho-embed-mqtt3c)
2727

28-
# Tests
29-
add_executable(test1
30-
"${CMAKE_CURRENT_SOURCE_DIR}/MQTTPacket/test/test1.c")
31-
target_link_libraries(test1 paho-embed-mqtt3c)
28+
29+
ENABLE_TESTING()
30+
31+
ADD_SUBDIRECTORY(MQTTPacket/test)
32+

MQTTPacket/test/CMakeLists.txt

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
PROJECT(mqttpacket-tests)
2+
3+
IF (WIN32)
4+
SET(MQTT_TEST_BROKER "tcp://mqtt.iotree.co.uk:1883" CACHE STRING "Hostname of a test MQTT broker to use")
5+
SET(MQTT_TEST_PROXY "tcp://localhost:1883" CACHE STRING "Hostname of the test proxy to use")
6+
SET(MQTT_SSL_HOSTNAME "mqtt.iotree.co.uk" CACHE STRING "Hostname of a test SSL MQTT broker to use")
7+
SET(CERTDIR $ENV{APPVEYOR_BUILD_FOLDER}/test/ssl)
8+
ELSE ()
9+
SET(MQTT_TEST_BROKER "tcp://localhost:1883" CACHE STRING "Hostname of a test MQTT broker to use")
10+
SET(MQTT_TEST_PROXY "tcp://localhost:1884" CACHE STRING "Hostname of the test proxy to use")
11+
SET(MQTT_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT broker to use")
12+
SET(CERTDIR $ENV{TRAVIS_BUILD_DIR}/test/ssl)
13+
ENDIF ()
14+
15+
16+
ADD_EXECUTABLE(
17+
test1
18+
test1.c
19+
)
20+
21+
TARGET_LINK_LIBRARIES(
22+
test1
23+
paho-embed-mqtt3c
24+
)
25+
26+
27+
ADD_TEST(
28+
NAME test1
29+
COMMAND "test1" "--connection" ${MQTT_TEST_BROKER}
30+
)
31+
32+
33+
SET_TESTS_PROPERTIES(
34+
test1
35+
PROPERTIES TIMEOUT 540
36+
)
37+

travis-build.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
6+
mkdir build.paho
7+
cd build.paho
8+
echo "travis build dir $TRAVIS_BUILD_DIR pwd $PWD"
9+
cmake ..
10+
make
11+
python ../test/mqttsas2.py &
12+
ctest -VV --timeout 600
13+
kill %1
14+
killall mosquitto
15+
fi
16+
17+
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
18+
rm -rf build.paho
19+
mkdir build.paho
20+
cd build.paho
21+
echo "travis build dir $TRAVIS_BUILD_DIR pwd $PWD"
22+
cmake ..
23+
make
24+
#python ../test/mqttsas2.py &
25+
ctest -VV --timeout 600
26+
#kill %1
27+
killall mosquitto
28+
fi

travis-env-vars

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export TRAVIS_OS_NAME=linux
2+
export TRAVIS_BUILD_DIR=/home/icraggs/git/paho.mqtt.embedded-c

travis-install.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
4+
pwd
5+
sudo service mosquitto stop
6+
# Stop any mosquitto instance which may be still running from previous runs
7+
killall mosquitto
8+
mosquitto -h
9+
mosquitto -c test/tls-testing/mosquitto.conf &
10+
fi
11+
12+
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
13+
pwd
14+
brew update
15+
brew install openssl mosquitto
16+
brew services stop mosquitto
17+
/usr/local/sbin/mosquitto -c test/tls-testing/mosquitto.conf &
18+
fi

0 commit comments

Comments
 (0)