From bbcc716217a1d5de12a18385fd897432edb4a284 Mon Sep 17 00:00:00 2001 From: CIPop Date: Tue, 25 Jul 2023 21:07:01 +0000 Subject: [PATCH] Renaming V5 reason code public API to avoid collisions. Disabling deprecation warnings for tests to avoid build warnings. --- MQTTClient-C/test/CMakeLists.txt | 4 ++ MQTTClient/test/CMakeLists.txt | 5 ++ MQTTPacket/src/V5/MQTTReasonCodes.h | 90 ++++++++++++++--------------- MQTTPacket/test/CMakeLists.txt | 77 ++++++++++++++++++++++++ MQTTPacket/test/test2.c | 8 +-- 5 files changed, 135 insertions(+), 49 deletions(-) diff --git a/MQTTClient-C/test/CMakeLists.txt b/MQTTClient-C/test/CMakeLists.txt index 9df121af..167ea186 100644 --- a/MQTTClient-C/test/CMakeLists.txt +++ b/MQTTClient-C/test/CMakeLists.txt @@ -18,3 +18,7 @@ ADD_TEST( NAME testc1 COMMAND "testc1" "--host" ${MQTT_TEST_BROKER_HOST} ) + +# Disabling deprecation warnings: +# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations] +target_compile_options(testc1 PRIVATE -Wno-deprecated-declarations) diff --git a/MQTTClient/test/CMakeLists.txt b/MQTTClient/test/CMakeLists.txt index 6a485d81..21f65591 100644 --- a/MQTTClient/test/CMakeLists.txt +++ b/MQTTClient/test/CMakeLists.txt @@ -14,7 +14,12 @@ target_compile_definitions(testcpp1 PRIVATE MQTTCLIENT_QOS1=1 MQTTCLIENT_QOS2=1) target_include_directories(testcpp1 PRIVATE "../src" "../src/linux") target_link_libraries(testcpp1 MQTTPacketClient MQTTPacketServer) +# Disabling deprecation warnings: +# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations] +target_compile_options(testcpp1 PRIVATE -Wno-deprecated-declarations) + ADD_TEST( NAME testcpp1 COMMAND "testcpp1" "--host" ${MQTT_TEST_BROKER_HOST} ) + diff --git a/MQTTPacket/src/V5/MQTTReasonCodes.h b/MQTTPacket/src/V5/MQTTReasonCodes.h index 02a090a5..070c978f 100644 --- a/MQTTPacket/src/V5/MQTTReasonCodes.h +++ b/MQTTPacket/src/V5/MQTTReasonCodes.h @@ -15,49 +15,49 @@ *******************************************************************************/ enum ReasonCodes { - SUCCESS = 0, - NORMAL_DISCONNECTION = 0, - GRANTED_QOS_0 = 0, - GRANTED_QOS_1 = 1, - GRANTED_QOS_2 = 2, - DISCONNECT_WITH_WILL_MESSAGE = 4, - NO_MATCHING_SUBSCRIBERS = 16, - NO_SUBSCRIPTION_FOUND = 17, - CONTINUE_AUTHENTICATION = 24, - RE_AUTHENTICATE = 25, - UNSPECIFIED_ERROR = 128, - MALFORMED_PACKET = 129, - PROTOCOL_ERROR = 130, - IMPLEMENTATION_SPECIFIC_ERROR = 131, - UNSUPPORTED_PROTOCOL_VERSION = 132, - CLIENT_IDENTIFIER_NOT_VALID = 133, - BAD_USER_NAME_OR_PASSWORD = 134, - NOT_AUTHORIZED = 135, - SERVER_UNAVAILABLE = 136, - SERVER_BUSY = 137, - BANNED = 138, - SERVER_SHUTTING_DOWN = 139, - BAD_AUTHENTICATION_METHOD = 140, - KEEP_ALIVE_TIMEOUT = 141, - SESSION_TAKEN_OVER = 142, - TOPIC_FILTER_INVALID = 143, - TOPIC_NAME_INVALID = 144, - PACKET_IDENTIFIER_IN_USE = 145, - PACKET_IDENTIFIER_NOT_FOUND = 146, - RECEIVE_MAXIMUM_EXCEEDED = 147, - TOPIC_ALIAS_INVALID = 148, - PACKET_TOO_LARGE = 149, - MESSAGE_RATE_TOO_HIGH = 150, - QUOTA_EXCEEDED = 151, - ADMINISTRATIVE_ACTION = 152, - PAYLOAD_FORMAT_INVALID = 153, - RETAIN_NOT_SUPPORTED = 154, - QOS_NOT_SUPPORTED = 155, - USE_ANOTHER_SERVER = 156, - SERVER_MOVED = 157, - SHARED_SUBSCRIPTION_NOT_SUPPORTED = 158, - CONNECTION_RATE_EXCEEDED = 159, - MAXIMUM_CONNECT_TIME = 160, - SUBSCRIPTION_IDENTIFIERS_NOT_SUPPORTED = 161, - WILDCARD_SUBSCRIPTION_NOT_SUPPORTED = 162 + MQTTV5_SUCCESS = 0, + MQTTV5_NORMAL_DISCONNECTION = 0, + MQTTV5_GRANTED_QOS_0 = 0, + MQTTV5_GRANTED_QOS_1 = 1, + MQTTV5_GRANTED_QOS_2 = 2, + MQTTV5_DISCONNECT_WITH_WILL_MESSAGE = 4, + MQTTV5_NO_MATCHING_SUBSCRIBERS = 16, + MQTTV5_NO_SUBSCRIPTION_FOUND = 17, + MQTTV5_CONTINUE_AUTHENTICATION = 24, + MQTTV5_RE_AUTHENTICATE = 25, + MQTTV5_UNSPECIFIED_ERROR = 128, + MQTTV5_MALFORMED_PACKET = 129, + MQTTV5_PROTOCOL_ERROR = 130, + MQTTV5_IMPLEMENTATION_SPECIFIC_ERROR = 131, + MQTTV5_UNSUPPORTED_PROTOCOL_VERSION = 132, + MQTTV5_CLIENT_IDENTIFIER_NOT_VALID = 133, + MQTTV5_BAD_USER_NAME_OR_PASSWORD = 134, + MQTTV5_NOT_AUTHORIZED = 135, + MQTTV5_SERVER_UNAVAILABLE = 136, + MQTTV5_SERVER_BUSY = 137, + MQTTV5_BANNED = 138, + MQTTV5_SERVER_SHUTTING_DOWN = 139, + MQTTV5_BAD_AUTHENTICATION_METHOD = 140, + MQTTV5_KEEP_ALIVE_TIMEOUT = 141, + MQTTV5_SESSION_TAKEN_OVER = 142, + MQTTV5_TOPIC_FILTER_INVALID = 143, + MQTTV5_TOPIC_NAME_INVALID = 144, + MQTTV5_PACKET_IDENTIFIER_IN_USE = 145, + MQTTV5_PACKET_IDENTIFIER_NOT_FOUND = 146, + MQTTV5_RECEIVE_MAXIMUM_EXCEEDED = 147, + MQTTV5_TOPIC_ALIAS_INVALID = 148, + MQTTV5_PACKET_TOO_LARGE = 149, + MQTTV5_MESSAGE_RATE_TOO_HIGH = 150, + MQTTV5_QUOTA_EXCEEDED = 151, + MQTTV5_ADMINISTRATIVE_ACTION = 152, + MQTTV5_PAYLOAD_FORMAT_INVALID = 153, + MQTTV5_RETAIN_NOT_SUPPORTED = 154, + MQTTV5_QOS_NOT_SUPPORTED = 155, + MQTTV5_USE_ANOTHER_SERVER = 156, + MQTTV5_SERVER_MOVED = 157, + MQTTV5_SHARED_SUBSCRIPTION_NOT_SUPPORTED = 158, + MQTTV5_CONNECTION_RATE_EXCEEDED = 159, + MQTTV5_MAXIMUM_CONNECT_TIME = 160, + MQTTV5_SUBSCRIPTION_IDENTIFIERS_NOT_SUPPORTED = 161, + MQTTV5_WILDCARD_SUBSCRIPTION_NOT_SUPPORTED = 162 }; diff --git a/MQTTPacket/test/CMakeLists.txt b/MQTTPacket/test/CMakeLists.txt index f3dc00ee..e3f2455f 100644 --- a/MQTTPacket/test/CMakeLists.txt +++ b/MQTTPacket/test/CMakeLists.txt @@ -19,6 +19,10 @@ ADD_EXECUTABLE( test1.c ) +# Disabling deprecation warnings: +# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations] +target_compile_options(test1 PRIVATE -Wno-deprecated-declarations) + TARGET_LINK_LIBRARIES( test1 paho-embed-mqtt3c @@ -33,3 +37,76 @@ SET_TESTS_PROPERTIES( test1 PROPERTIES TIMEOUT 540 ) + +ADD_EXECUTABLE( + test15 + test1.c +) + +# Disabling deprecation warnings: +# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations] +target_compile_options(test15 PRIVATE -Wno-deprecated-declarations) + +TARGET_LINK_LIBRARIES( + test15 + paho-embed-mqtt5c +) + +ADD_TEST( + NAME test15 + COMMAND "test15" "--connection" ${MQTT_TEST_BROKER} +) + +SET_TESTS_PROPERTIES( + test15 + PROPERTIES TIMEOUT 540 +) + +ADD_EXECUTABLE( + test2 + test2.c +) + +TARGET_LINK_LIBRARIES( + test2 + paho-embed-mqtt5c +) + +# Disabling deprecation warnings: +# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations] +target_compile_options(test2 PRIVATE -Wno-deprecated-declarations) + +ADD_TEST( + NAME test2 + COMMAND "test2" "--connection" ${MQTT_TEST_BROKER} +) + +SET_TESTS_PROPERTIES( + test2 + PROPERTIES TIMEOUT 540 +) + + +ADD_EXECUTABLE( + test3 + test3.c +) + +# Disabling deprecation warnings: +# warning: ‘ftime’ is deprecated [-Wdeprecated-declarations] +target_compile_options(test3 PRIVATE -Wno-deprecated-declarations) + +TARGET_LINK_LIBRARIES( + test3 + paho-embed-mqtt5c +) + +ADD_TEST( + NAME test3 + COMMAND "test3" "--connection" ${MQTT_TEST_BROKER} +) + +SET_TESTS_PROPERTIES( + test3 + PROPERTIES TIMEOUT 540 +) diff --git a/MQTTPacket/test/test2.c b/MQTTPacket/test/test2.c index d353ba1b..342f9e90 100644 --- a/MQTTPacket/test/test2.c +++ b/MQTTPacket/test/test2.c @@ -800,7 +800,7 @@ int test7(struct Options options) one.identifier = SESSION_EXPIRY_INTERVAL; one.value.integer4 = 45; rc = MQTTProperties_add(&disconnectProperties, &one); - reasonCode = TOPIC_ALIAS_INVALID; // (148) test signed char to unsigned char conversion. + reasonCode = MQTTV5_TOPIC_ALIAS_INVALID; // (148) test signed char to unsigned char conversion. rc = MQTTV5Serialize_disconnect(buf, buflen, reasonCode, &disconnectProperties); assert("good rc from serialize disconnect", rc > 0, "rc was %d\n", rc); @@ -834,7 +834,7 @@ int test8(struct Options options) int count = TOPIC_COUNT; int reasonCodes[TOPIC_COUNT] = { 2, - QOS_NOT_SUPPORTED // (155) test signed char to unsigned char conversion. + MQTTV5_QOS_NOT_SUPPORTED // (155) test signed char to unsigned char conversion. }; unsigned short msgid2 = 2223; @@ -893,8 +893,8 @@ int test9(struct Options options) int rc = 0; unsigned char buf[100]; int buflen = sizeof(buf); - int reasonCode = BAD_AUTHENTICATION_METHOD; // // (140) test signed char to unsigned char conversion. - int reasonCode2 = 44; + unsigned char reasonCode = MQTTV5_BAD_AUTHENTICATION_METHOD; // (140) test signed char to unsigned char conversion. + unsigned char reasonCode2 = 44; MQTTProperties properties = MQTTProperties_initializer; MQTTProperties outProperties = MQTTProperties_initializer;