Skip to content

Commit

Permalink
Refactoring tests to avoid code duplication.
Browse files Browse the repository at this point in the history
  • Loading branch information
CIPop committed Aug 16, 2023
1 parent 3a18e05 commit 9afea97
Show file tree
Hide file tree
Showing 6 changed files with 437 additions and 640 deletions.
49 changes: 39 additions & 10 deletions MQTTPacket/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ENDIF ()
# transport.h/c are reused from ../samples:
include_directories(../src ../src/V5 ../samples)

# test1 - MQTTv3 serializer test
ADD_EXECUTABLE(
test1
test1.c
Expand All @@ -39,6 +40,7 @@ SET_TESTS_PROPERTIES(
PROPERTIES TIMEOUT 540
)

# test2 - MQTTv5 serializer test
ADD_EXECUTABLE(
test2
test2.c
Expand All @@ -63,7 +65,7 @@ SET_TESTS_PROPERTIES(
PROPERTIES TIMEOUT 540
)


# test3 - MQTTv3 broker test
ADD_EXECUTABLE(
test3
test3.c
Expand All @@ -76,7 +78,7 @@ target_compile_options(test3 PRIVATE -Wno-deprecated-declarations)

TARGET_LINK_LIBRARIES(
test3
paho-embed-mqtt5c
paho-embed-mqtt3c
)

ADD_TEST(
Expand All @@ -89,29 +91,56 @@ SET_TESTS_PROPERTIES(
PROPERTIES TIMEOUT 540
)

# test4 - MQTTv5 broker test
ADD_EXECUTABLE(
test4
test4.c
../samples/transport.c
)

# Disabling deprecation warnings:
# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations]
target_compile_options(test4 PRIVATE -Wno-deprecated-declarations)

TARGET_LINK_LIBRARIES(
test4
paho-embed-mqtt5c
)

ADD_TEST(
NAME test4
COMMAND "test4" "--connection" ${MQTT_TEST_BROKER}
)

SET_TESTS_PROPERTIES(
test4
PROPERTIES TIMEOUT 540
)

# test5 - MQTTv3 side-by-side with MQTTv5 broker test
ADD_EXECUTABLE(
test35
test35.c
test5
test5.c
../samples/transport.c
)

# Disabling deprecation warnings:
# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations]
target_compile_options(test35 PRIVATE -Wno-deprecated-declarations)
target_compile_definitions(test35 PRIVATE NOSIGPIPE)
target_compile_options(test5 PRIVATE -Wno-deprecated-declarations)
target_compile_definitions(test5 PRIVATE NOSIGPIPE)

TARGET_LINK_LIBRARIES(
test35
test5
paho-embed-mqtt3c
paho-embed-mqtt5c
)

ADD_TEST(
NAME test35
COMMAND "test35" "--connection" ${MQTT_TEST_BROKER}
NAME test5
COMMAND "test5" "--connection" ${MQTT_TEST_BROKER}
)

SET_TESTS_PROPERTIES(
test35
test5
PROPERTIES TIMEOUT 540
)
Loading

0 comments on commit 9afea97

Please sign in to comment.