diff --git a/.github/.cSpellWords.txt b/.github/.cSpellWords.txt
index f2aa350f3..526fa1220 100644
--- a/.github/.cSpellWords.txt
+++ b/.github/.cSpellWords.txt
@@ -43,4 +43,5 @@ utest
vect
Vect
VECT
+Werror
Wunused
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a08d0ca74..6dd9e59c2 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -31,7 +31,8 @@ jobs:
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_CLONE_SUBMODULES=ON \
- -DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror -DNDEBUG -DLIBRARY_LOG_LEVEL=LOG_DEBUG'
+ -DUNITTEST=1 \
+ -DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Wsign-compare -Werror -DNDEBUG -DLIBRARY_LOG_LEVEL=LOG_DEBUG'
make -C build/ all
echo "::endgroup::"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 97cc09941..15300513f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,26 @@
# Changelog for coreMQTT Client Library
+## v2.2.0 (April 2024)
+
+### Changes
+
+- [#283](https://github.com/FreeRTOS/coreMQTT/pull/283) Fix build error with Werror=sign-compare is enabled.
+- [#279](https://github.com/FreeRTOS/coreMQTT/pull/279) Add documentation about timer behavior when it overflows.
+- [#275](https://github.com/FreeRTOS/coreMQTT/pull/275) Correct TransportRecv_t documentation.
+- [#268](https://github.com/FreeRTOS/coreMQTT/pull/268) Typecast outgoing and incoming publish count to unsigned longs to match format specifier.
+- [#255](https://github.com/FreeRTOS/coreMQTT/pull/255) Fix MQTT_Status_strerror to return correct error on NeedMoreBytes error.
+- [#252](https://github.com/FreeRTOS/coreMQTT/pull/252) Fix sending empty strings in MQTT packets.
+- [#258](https://github.com/FreeRTOS/coreMQTT/pull/258) Fix race condition in handleKeepAlive.
+- [#250](https://github.com/FreeRTOS/coreMQTT/pull/250) Fix timeout calculation in sendVector function to account for overflow.
+- [#249](https://github.com/FreeRTOS/coreMQTT/pull/249) Replace magic numbers with macros and add explaining comments.
+- [#235](https://github.com/FreeRTOS/coreMQTT/pull/235) Fix to update the timestamp of the last packet received.
+
+## v2.1.1 (November 2022)
+
+### Changes
+- [#230](https://github.com/FreeRTOS/coreMQTT/pull/230) Fix a broken link in MISRA.md.
+- [#229](https://github.com/FreeRTOS/coreMQTT/pull/229) Fixed multiple Sub/Unsub request sending logic.
+
## v2.1.0 (October 2022)
### Changes
diff --git a/README.md b/README.md
index 46096af2e..cc962f81c 100644
--- a/README.md
+++ b/README.md
@@ -87,18 +87,18 @@ Example
- Actual_Username = “iotuser”, OS_Name = FreeRTOS, OS_Version = V10.4.3,
Hardware_Platform_Name = WinSim, MQTT_Library_Name = coremqtt,
- MQTT_Library_version = 2.1.0. If username is not used, then “iotuser” can be
+ MQTT_Library_version = 2.2.0. If username is not used, then “iotuser” can be
removed.
```
/* Username string:
- * iotuser?SDK=FreeRTOS&Version=v10.4.3&Platform=WinSim&MQTTLib=coremqtt@2.1.0
+ * iotuser?SDK=FreeRTOS&Version=v10.4.3&Platform=WinSim&MQTTLib=coremqtt@2.2.0
*/
#define OS_NAME "FreeRTOS"
#define OS_VERSION "V10.4.3"
#define HARDWARE_PLATFORM_NAME "WinSim"
-#define MQTT_LIB "coremqtt@2.1.0"
+#define MQTT_LIB "coremqtt@2.2.0"
#define USERNAME_STRING "iotuser?SDK=" OS_NAME "&Version=" OS_VERSION "&Platform=" HARDWARE_PLATFORM_NAME "&MQTTLib=" MQTT_LIB
#define USERNAME_STRING_LENGTH ( ( uint16_t ) ( sizeof( USERNAME_STRING ) - 1 ) )
diff --git a/docs/doxygen/config.doxyfile b/docs/doxygen/config.doxyfile
index 2e27e817c..b4f68296c 100644
--- a/docs/doxygen/config.doxyfile
+++ b/docs/doxygen/config.doxyfile
@@ -48,7 +48,7 @@ PROJECT_NAME = coreMQTT
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = v2.1.0
+PROJECT_NUMBER = v2.2.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/manifest.yml b/manifest.yml
index 98c33fd91..a3d9dca84 100644
--- a/manifest.yml
+++ b/manifest.yml
@@ -1,5 +1,5 @@
name : "coreMQTT"
-version: "v2.1.0"
+version: "v2.2.0"
description: |
"Client implementation of the MQTT 3.1.1 specification for embedded devices.\n"
license: "MIT"
diff --git a/source/core_mqtt.c b/source/core_mqtt.c
index ce119737c..cf200eeb1 100644
--- a/source/core_mqtt.c
+++ b/source/core_mqtt.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -35,8 +35,6 @@
/* Include config defaults header to get default values of configs. */
#include "core_mqtt_config_defaults.h"
-#include "core_mqtt_default_logging.h"
-
#ifndef MQTT_PRE_SEND_HOOK
/**
@@ -2219,7 +2217,7 @@ static MQTTStatus_t sendConnectWithoutCopy( MQTTContext_t * pContext,
pWillInfo,
remainingLength );
- assert( ( pIndex - connectPacketHeader ) <= sizeof( connectPacketHeader ) );
+ assert( ( ( size_t ) ( pIndex - connectPacketHeader ) ) <= sizeof( connectPacketHeader ) );
/* The header gets sent first. */
iterator->iov_base = connectPacketHeader;
diff --git a/source/core_mqtt_serializer.c b/source/core_mqtt_serializer.c
index 537925996..8eaff4db2 100644
--- a/source/core_mqtt_serializer.c
+++ b/source/core_mqtt_serializer.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -34,8 +34,6 @@
/* Include config defaults header to get default values of configs. */
#include "core_mqtt_config_defaults.h"
-#include "core_mqtt_default_logging.h"
-
/**
* @brief MQTT protocol version 3.1.1.
*/
diff --git a/source/core_mqtt_state.c b/source/core_mqtt_state.c
index 9cd1f221c..613099e2d 100644
--- a/source/core_mqtt_state.c
+++ b/source/core_mqtt_state.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -33,8 +33,6 @@
/* Include config defaults header to get default values of configs. */
#include "core_mqtt_config_defaults.h"
-#include "core_mqtt_default_logging.h"
-
/*-----------------------------------------------------------*/
/**
diff --git a/source/include/core_mqtt.h b/source/include/core_mqtt.h
index 1493f3794..0f7bb7f3b 100644
--- a/source/include/core_mqtt.h
+++ b/source/include/core_mqtt.h
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -69,6 +69,14 @@ struct MQTTDeserializedInfo;
* @note The timer should be a monotonic timer. It just needs to provide an
* incrementing count of milliseconds elapsed since a given epoch.
*
+ * @note As the timer is supposed to be a millisecond timer returning a 32-bit
+ * value, it will overflow in just under 50 days. But it will not cause any issues
+ * in the library as the time function is only used for calculating durations for
+ * timeouts and keep alive periods. The difference in unsigned numbers is
+ * used where unsigned wrap around is defined. Unless the timeout is bigger than
+ * 100 days (50*2) where the numbers can wrap around more than once the code
+ * should work properly.
+ *
* @return The time elapsed in milliseconds.
*/
typedef uint32_t (* MQTTGetCurrentTimeFunc_t )( void );
diff --git a/source/include/core_mqtt_config_defaults.h b/source/include/core_mqtt_config_defaults.h
index a573967f9..a8c1a2c1d 100644
--- a/source/include/core_mqtt_config_defaults.h
+++ b/source/include/core_mqtt_config_defaults.h
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -195,6 +195,86 @@
#error MQTT_SEND_RETRY_TIMEOUT_MS is deprecated. Instead use MQTT_SEND_TIMEOUT_MS.
#endif
+/**
+ * @brief Macro that is called in the MQTT library for logging "Error" level
+ * messages.
+ *
+ * To enable error level logging in the MQTT library, this macro should be mapped to the
+ * application-specific logging implementation that supports error logging.
+ *
+ * @note This logging macro is called in the MQTT library with parameters wrapped in
+ * double parentheses to be ISO C89/C90 standard compliant. For a reference
+ * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
+ * logging-stack in demos folder of the
+ * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C).
+ *
+ * Default value: Error logging is turned off, and no code is generated for calls
+ * to the macro in the MQTT library on compilation.
+ */
+#ifndef LogError
+ #define LogError( message )
+#endif
+
+/**
+ * @brief Macro that is called in the MQTT library for logging "Warning" level
+ * messages.
+ *
+ * To enable warning level logging in the MQTT library, this macro should be mapped to the
+ * application-specific logging implementation that supports warning logging.
+ *
+ * @note This logging macro is called in the MQTT library with parameters wrapped in
+ * double parentheses to be ISO C89/C90 standard compliant. For a reference
+ * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
+ * logging-stack in demos folder of the
+ * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C/).
+ *
+ * Default value: Warning logs are turned off, and no code is generated for calls
+ * to the macro in the MQTT library on compilation.
+ */
+#ifndef LogWarn
+ #define LogWarn( message )
+#endif
+
+/**
+ * @brief Macro that is called in the MQTT library for logging "Info" level
+ * messages.
+ *
+ * To enable info level logging in the MQTT library, this macro should be mapped to the
+ * application-specific logging implementation that supports info logging.
+ *
+ * @note This logging macro is called in the MQTT library with parameters wrapped in
+ * double parentheses to be ISO C89/C90 standard compliant. For a reference
+ * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
+ * logging-stack in demos folder of the
+ * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C/).
+ *
+ * Default value: Info logging is turned off, and no code is generated for calls
+ * to the macro in the MQTT library on compilation.
+ */
+#ifndef LogInfo
+ #define LogInfo( message )
+#endif
+
+/**
+ * @brief Macro that is called in the MQTT library for logging "Debug" level
+ * messages.
+ *
+ * To enable debug level logging from MQTT library, this macro should be mapped to the
+ * application-specific logging implementation that supports debug logging.
+ *
+ * @note This logging macro is called in the MQTT library with parameters wrapped in
+ * double parentheses to be ISO C89/C90 standard compliant. For a reference
+ * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
+ * logging-stack in demos folder of the
+ * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C/).
+ *
+ * Default value: Debug logging is turned off, and no code is generated for calls
+ * to the macro in the MQTT library on compilation.
+ */
+#ifndef LogDebug
+ #define LogDebug( message )
+#endif
+
/* *INDENT-OFF* */
#ifdef __cplusplus
}
diff --git a/source/include/core_mqtt_default_logging.h b/source/include/core_mqtt_default_logging.h
deleted file mode 100644
index 85f8011f0..000000000
--- a/source/include/core_mqtt_default_logging.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * coreMQTT v2.1.0
- * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * @file core_mqtt_default_logging.h
- * @brief This represents the default values for the logging macros for the MQTT
- * library.
- *
- * @note This file SHOULD NOT be modified. If custom values are needed for
- * any configuration macro, a core_mqtt_config.h file should be provided to
- * the MQTT library to override the default values defined in this file.
- * To use the custom config file, the MQTT_DO_NOT_USE_CUSTOM_CONFIG preprocessor
- * macro SHOULD NOT be set.
- */
-
-#ifndef CORE_MQTT_DEFAULT_LOGGING_H_
-#define CORE_MQTT_DEFAULT_LOGGING_H_
-
-/* *INDENT-OFF* */
-#ifdef __cplusplus
- extern "C" {
-#endif
-/* *INDENT-ON* */
-
-/**
- * @brief Macro that is called in the MQTT library for logging "Error" level
- * messages.
- *
- * To enable error level logging in the MQTT library, this macro should be mapped to the
- * application-specific logging implementation that supports error logging.
- *
- * @note This logging macro is called in the MQTT library with parameters wrapped in
- * double parentheses to be ISO C89/C90 standard compliant. For a reference
- * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
- * logging-stack in demos folder of the
- * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C).
- *
- * Default value: Error logging is turned off, and no code is generated for calls
- * to the macro in the MQTT library on compilation.
- */
-#ifndef LogError
- #define LogError( message )
-#endif
-
-/**
- * @brief Macro that is called in the MQTT library for logging "Warning" level
- * messages.
- *
- * To enable warning level logging in the MQTT library, this macro should be mapped to the
- * application-specific logging implementation that supports warning logging.
- *
- * @note This logging macro is called in the MQTT library with parameters wrapped in
- * double parentheses to be ISO C89/C90 standard compliant. For a reference
- * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
- * logging-stack in demos folder of the
- * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C/).
- *
- * Default value: Warning logs are turned off, and no code is generated for calls
- * to the macro in the MQTT library on compilation.
- */
-#ifndef LogWarn
- #define LogWarn( message )
-#endif
-
-/**
- * @brief Macro that is called in the MQTT library for logging "Info" level
- * messages.
- *
- * To enable info level logging in the MQTT library, this macro should be mapped to the
- * application-specific logging implementation that supports info logging.
- *
- * @note This logging macro is called in the MQTT library with parameters wrapped in
- * double parentheses to be ISO C89/C90 standard compliant. For a reference
- * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
- * logging-stack in demos folder of the
- * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C/).
- *
- * Default value: Info logging is turned off, and no code is generated for calls
- * to the macro in the MQTT library on compilation.
- */
-#ifndef LogInfo
- #define LogInfo( message )
-#endif
-
-/**
- * @brief Macro that is called in the MQTT library for logging "Debug" level
- * messages.
- *
- * To enable debug level logging from MQTT library, this macro should be mapped to the
- * application-specific logging implementation that supports debug logging.
- *
- * @note This logging macro is called in the MQTT library with parameters wrapped in
- * double parentheses to be ISO C89/C90 standard compliant. For a reference
- * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
- * logging-stack in demos folder of the
- * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C/).
- *
- * Default value: Debug logging is turned off, and no code is generated for calls
- * to the macro in the MQTT library on compilation.
- */
-#ifndef LogDebug
- #define LogDebug( message )
-#endif
-
-/* *INDENT-OFF* */
-#ifdef __cplusplus
- }
-#endif
-/* *INDENT-ON* */
-
-#endif /* ifndef CORE_MQTT_DEFAULT_LOGGING_H_ */
diff --git a/source/include/core_mqtt_serializer.h b/source/include/core_mqtt_serializer.h
index da2e7e4ed..5888cd1c0 100644
--- a/source/include/core_mqtt_serializer.h
+++ b/source/include/core_mqtt_serializer.h
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -42,18 +42,6 @@
#endif
/* *INDENT-ON */
-/* MQTT_DO_NOT_USE_CUSTOM_CONFIG allows building the MQTT library
- * without a custom config. If a custom config is provided, the
- * MQTT_DO_NOT_USE_CUSTOM_CONFIG macro should not be defined. */
-#ifndef MQTT_DO_NOT_USE_CUSTOM_CONFIG
- /* Include custom config file before other headers. */
- #include "core_mqtt_config.h"
-#endif
-
-/* Include config defaults header to get default values of configs not
- * defined in core_mqtt_config.h file. */
-#include "core_mqtt_config_defaults.h"
-
#include "transport_interface.h"
/* MQTT packet types. */
diff --git a/source/include/core_mqtt_state.h b/source/include/core_mqtt_state.h
index b1c99093d..bc3978a02 100644
--- a/source/include/core_mqtt_state.h
+++ b/source/include/core_mqtt_state.h
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/source/interface/transport_interface.h b/source/interface/transport_interface.h
index 634885e7a..db82bccd1 100644
--- a/source/interface/transport_interface.h
+++ b/source/interface/transport_interface.h
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -195,14 +195,11 @@ typedef struct NetworkContext NetworkContext_t;
* @transportcallback
* @brief Transport interface for receiving data on the network.
*
- * @note It is RECOMMENDED that the transport receive implementation
- * does NOT block when requested to read a single byte. A single byte
- * read request can be made by the caller to check whether there is a
- * new frame available on the network for reading.
- * However, the receive implementation MAY block for a timeout period when
- * it is requested to read more than 1 byte. This is because once the caller
- * is aware that a new frame is available to read on the network, then
- * the likelihood of reading more than one byte over the network becomes high.
+ * @note It is HIGHLY RECOMMENDED that the transport receive
+ * implementation does NOT block.
+ * coreMQTT will continue to call the transport interface if it receives
+ * a partial packet until it accumulates enough data to get the complete
+ * MQTT packet.
*
* @param[in] pNetworkContext Implementation-defined network context.
* @param[in] pBuffer Buffer to receive the data into.
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index cd2a88121..7736ded3c 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,6 +1,6 @@
-cmake_minimum_required ( VERSION 3.13.0 )
-project ( "CoreMQTT unit test"
- VERSION 1.0.0
+cmake_minimum_required ( VERSION 3.22.0 )
+project ( "CoreMQTT tests"
+ VERSION 2.1.0
LANGUAGES C )
# Allow the project to be organized into folders.
@@ -14,6 +14,12 @@ if( NOT DEFINED CMAKE_C_STANDARD_REQUIRED )
set( CMAKE_C_STANDARD_REQUIRED ON )
endif()
+# If no configuration is defined, turn everything on.
+if( NOT DEFINED COV_ANALYSIS AND NOT DEFINED UNITTEST )
+ set( COV_ANALYSIS TRUE )
+ set( UNITTEST TRUE )
+endif()
+
# Do not allow in-source build.
if( ${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR} )
message( FATAL_ERROR "In-source build is not allowed. Please build in a separate directory, such as ${PROJECT_SOURCE_DIR}/build." )
@@ -35,61 +41,67 @@ set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
# ===================================== Coverity Analysis Configuration =================================================
-# Include filepaths for source and include.
-include( ${MODULE_ROOT_DIR}/mqttFilePaths.cmake )
-
-# Target for Coverity analysis that builds the library.
-add_library( coverity_analysis
- ${MQTT_SOURCES}
- ${MQTT_SERIALIZER_SOURCES} )
+if( COV_ANALYSIS )
+ # Include filepaths for source and include.
+ include( ${MODULE_ROOT_DIR}/mqttFilePaths.cmake )
-# Build MQTT library target without custom config dependency.
-target_compile_definitions( coverity_analysis PUBLIC MQTT_DO_NOT_USE_CUSTOM_CONFIG=1 )
-target_compile_definitions( coverity_analysis PUBLIC NDEBUG=1 )
+ # Target for Coverity analysis that builds the library.
+ add_library( coverity_analysis
+ ${MQTT_SOURCES}
+ ${MQTT_SERIALIZER_SOURCES} )
-# MQTT public include path.
-target_include_directories( coverity_analysis PUBLIC ${MQTT_INCLUDE_PUBLIC_DIRS} )
-
-# ==================================== Test Configuration ========================================
+ # Build MQTT library target without custom config dependency.
+ target_compile_definitions( coverity_analysis PUBLIC MQTT_DO_NOT_USE_CUSTOM_CONFIG=1 )
-# Define a CMock resource path.
-set( CMOCK_DIR ${MODULE_ROOT_DIR}/test/unit-test/CMock CACHE INTERNAL "CMock library source directory." )
+ # MQTT public include path.
+ target_include_directories( coverity_analysis PUBLIC ${MQTT_INCLUDE_PUBLIC_DIRS} )
-# Include CMock build configuration.
-include( unit-test/cmock_build.cmake )
+ # Remove inclusion of assert.
+ add_compile_definitions( NDEBUG=1 )
+endif()
-# Check if the CMock source directory exists, and if not present, clone the submodule
-# if BUILD_CLONE_SUBMODULES configuration is enabled.
-if( NOT EXISTS ${CMOCK_DIR}/src )
- # Attempt to clone CMock.
- if( ${BUILD_CLONE_SUBMODULES} )
- clone_cmock()
- else()
- message( FATAL_ERROR "The required submodule CMock does not exist. Either clone it manually, or set BUILD_CLONE_SUBMODULES to 1 to automatically clone it during build." )
+# ==================================== Test Configuration ========================================
+if( UNITTEST )
+ # Define a CMock resource path.
+ set( CMOCK_DIR ${MODULE_ROOT_DIR}/test/unit-test/CMock CACHE INTERNAL "CMock library source directory." )
+
+ # Include CMock build configuration.
+ include( unit-test/cmock_build.cmake )
+
+ # Check if the CMock source directory exists, and if not present, clone the submodule
+ # if BUILD_CLONE_SUBMODULES configuration is enabled.
+ if( NOT EXISTS ${CMOCK_DIR}/src )
+ # Attempt to clone CMock.
+ if( ${BUILD_CLONE_SUBMODULES} )
+ clone_cmock()
+ else()
+ message( FATAL_ERROR "The required submodule CMock does not exist. Either clone it manually, or set\
+ BUILD_CLONE_SUBMODULES to 1 to automatically clone it during build." )
+ endif()
endif()
-endif()
-# Add unit test and coverage configuration.
+ # Add unit test and coverage configuration.
-# Use CTest utility for managing test runs. This has to be added BEFORE
-# defining test targets with add_test()
-enable_testing()
+ # Use CTest utility for managing test runs. This has to be added BEFORE
+ # defining test targets with add_test()
+ enable_testing()
-# Add build targets for CMock and Unit, required for unit testing.
-add_cmock_targets()
+ # Add build targets for CMock and Unit, required for unit testing.
+ add_cmock_targets()
-# Add function to enable CMock based tests and coverage.
-include( ${MODULE_ROOT_DIR}/tools/cmock/create_test.cmake )
+ # Add function to enable CMock based tests and coverage.
+ include( ${MODULE_ROOT_DIR}/tools/cmock/create_test.cmake )
-# Include build configuration for unit tests.
-add_subdirectory( unit-test )
+ # Include build configuration for unit tests.
+ add_subdirectory( unit-test )
-# ==================================== Coverage Analysis configuration ========================================
+ # ==================================== Coverage Analysis configuration ========================================
-# Add a target for running coverage on tests.
-add_custom_target( coverage
- COMMAND ${CMAKE_COMMAND} -DCMOCK_DIR=${CMOCK_DIR}
- -P ${MODULE_ROOT_DIR}/tools/cmock/coverage.cmake
- DEPENDS cmock unity core_mqtt_utest core_mqtt_serializer_utest core_mqtt_state_utest
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
-)
+ # Add a target for running coverage on tests.
+ add_custom_target( coverage
+ COMMAND ${CMAKE_COMMAND} -DCMOCK_DIR=${CMOCK_DIR}
+ -P ${MODULE_ROOT_DIR}/tools/cmock/coverage.cmake
+ DEPENDS cmock unity core_mqtt_utest core_mqtt_serializer_utest core_mqtt_state_utest
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ )
+endif()
diff --git a/test/cbmc/include/core_mqtt_config.h b/test/cbmc/include/core_mqtt_config.h
index 14d562336..4b29fef11 100644
--- a/test/cbmc/include/core_mqtt_config.h
+++ b/test/cbmc/include/core_mqtt_config.h
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -29,12 +29,6 @@
#ifndef CORE_MQTT_CONFIG_H_
#define CORE_MQTT_CONFIG_H_
-/* Mock a network context for the CBMC proofs. */
-struct NetworkContext
-{
- int NetworkContext;
-};
-
/**
* @brief Determines the maximum number of MQTT PUBLISH messages, pending
* acknowledgement at a time, that are supported for incoming and outgoing
diff --git a/test/cbmc/include/event_callback_stub.h b/test/cbmc/include/event_callback_stub.h
index 763a00ddd..b3f704198 100644
--- a/test/cbmc/include/event_callback_stub.h
+++ b/test/cbmc/include/event_callback_stub.h
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/include/get_time_stub.h b/test/cbmc/include/get_time_stub.h
index 9f9de88b8..3df589e5d 100644
--- a/test/cbmc/include/get_time_stub.h
+++ b/test/cbmc/include/get_time_stub.h
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/include/mqtt_cbmc_state.h b/test/cbmc/include/mqtt_cbmc_state.h
index 4336fa1ba..7b8d069e5 100644
--- a/test/cbmc/include/mqtt_cbmc_state.h
+++ b/test/cbmc/include/mqtt_cbmc_state.h
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/include/network_interface_stubs.h b/test/cbmc/include/network_interface_stubs.h
index 80178e7b3..e65f25835 100644
--- a/test/cbmc/include/network_interface_stubs.h
+++ b/test/cbmc/include/network_interface_stubs.h
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_Connect/MQTT_Connect_harness.c b/test/cbmc/proofs/MQTT_Connect/MQTT_Connect_harness.c
index dce4d5642..988f56a00 100644
--- a/test/cbmc/proofs/MQTT_Connect/MQTT_Connect_harness.c
+++ b/test/cbmc/proofs/MQTT_Connect/MQTT_Connect_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -28,6 +28,7 @@
*/
#include "core_mqtt.h"
#include "mqtt_cbmc_state.h"
+#include "core_mqtt_config_defaults.h"
/**
* @brief Implement a get time function to return timeout after certain
diff --git a/test/cbmc/proofs/MQTT_DeserializeAck/MQTT_DeserializeAck_harness.c b/test/cbmc/proofs/MQTT_DeserializeAck/MQTT_DeserializeAck_harness.c
index c5be8f4a4..ad69cf7f7 100644
--- a/test/cbmc/proofs/MQTT_DeserializeAck/MQTT_DeserializeAck_harness.c
+++ b/test/cbmc/proofs/MQTT_DeserializeAck/MQTT_DeserializeAck_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_DeserializePublish/MQTT_DeserializePublish_harness.c b/test/cbmc/proofs/MQTT_DeserializePublish/MQTT_DeserializePublish_harness.c
index 8ccc71949..a21e7fb84 100644
--- a/test/cbmc/proofs/MQTT_DeserializePublish/MQTT_DeserializePublish_harness.c
+++ b/test/cbmc/proofs/MQTT_DeserializePublish/MQTT_DeserializePublish_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_Disconnect/MQTT_Disconnect_harness.c b/test/cbmc/proofs/MQTT_Disconnect/MQTT_Disconnect_harness.c
index 36e160edd..7fbf167e0 100644
--- a/test/cbmc/proofs/MQTT_Disconnect/MQTT_Disconnect_harness.c
+++ b/test/cbmc/proofs/MQTT_Disconnect/MQTT_Disconnect_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_GetIncomingPacketTypeAndLength/MQTT_GetIncomingPacketTypeAndLength_harness.c b/test/cbmc/proofs/MQTT_GetIncomingPacketTypeAndLength/MQTT_GetIncomingPacketTypeAndLength_harness.c
index 09cee88f1..701bde02f 100644
--- a/test/cbmc/proofs/MQTT_GetIncomingPacketTypeAndLength/MQTT_GetIncomingPacketTypeAndLength_harness.c
+++ b/test/cbmc/proofs/MQTT_GetIncomingPacketTypeAndLength/MQTT_GetIncomingPacketTypeAndLength_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -30,6 +30,11 @@
#include "network_interface_stubs.h"
#include "mqtt_cbmc_state.h"
+struct NetworkContext
+{
+ int NetworkContext;
+};
+
void harness()
{
/* NetworkContext_t is an application defined network interface context. It
diff --git a/test/cbmc/proofs/MQTT_GetPacketId/MQTT_GetPacketId_harness.c b/test/cbmc/proofs/MQTT_GetPacketId/MQTT_GetPacketId_harness.c
index b064feca8..08e1d4502 100644
--- a/test/cbmc/proofs/MQTT_GetPacketId/MQTT_GetPacketId_harness.c
+++ b/test/cbmc/proofs/MQTT_GetPacketId/MQTT_GetPacketId_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_GetSubAckStatusCodes/MQTT_GetSubAckStatusCodes_harness.c b/test/cbmc/proofs/MQTT_GetSubAckStatusCodes/MQTT_GetSubAckStatusCodes_harness.c
index 5ce124cc7..0f398532c 100644
--- a/test/cbmc/proofs/MQTT_GetSubAckStatusCodes/MQTT_GetSubAckStatusCodes_harness.c
+++ b/test/cbmc/proofs/MQTT_GetSubAckStatusCodes/MQTT_GetSubAckStatusCodes_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_Init/MQTT_Init_harness.c b/test/cbmc/proofs/MQTT_Init/MQTT_Init_harness.c
index 94fceba8a..7cb7ed59a 100644
--- a/test/cbmc/proofs/MQTT_Init/MQTT_Init_harness.c
+++ b/test/cbmc/proofs/MQTT_Init/MQTT_Init_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_MatchTopic/MQTT_MatchTopic_harness.c b/test/cbmc/proofs/MQTT_MatchTopic/MQTT_MatchTopic_harness.c
index fce1a071d..0038c74fc 100644
--- a/test/cbmc/proofs/MQTT_MatchTopic/MQTT_MatchTopic_harness.c
+++ b/test/cbmc/proofs/MQTT_MatchTopic/MQTT_MatchTopic_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_Ping/MQTT_Ping_harness.c b/test/cbmc/proofs/MQTT_Ping/MQTT_Ping_harness.c
index e4e4742a6..2bce62092 100644
--- a/test/cbmc/proofs/MQTT_Ping/MQTT_Ping_harness.c
+++ b/test/cbmc/proofs/MQTT_Ping/MQTT_Ping_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_ProcessLoop/MQTT_ProcessLoop_harness.c b/test/cbmc/proofs/MQTT_ProcessLoop/MQTT_ProcessLoop_harness.c
index 55bfa475b..ddbcfeff9 100644
--- a/test/cbmc/proofs/MQTT_ProcessLoop/MQTT_ProcessLoop_harness.c
+++ b/test/cbmc/proofs/MQTT_ProcessLoop/MQTT_ProcessLoop_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_Publish/MQTT_Publish_harness.c b/test/cbmc/proofs/MQTT_Publish/MQTT_Publish_harness.c
index 68d923be5..34e2366f3 100644
--- a/test/cbmc/proofs/MQTT_Publish/MQTT_Publish_harness.c
+++ b/test/cbmc/proofs/MQTT_Publish/MQTT_Publish_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -28,6 +28,7 @@
*/
#include "core_mqtt.h"
#include "mqtt_cbmc_state.h"
+#include "core_mqtt_config_defaults.h"
/**
* @brief Implement a get time function to return timeout after certain
diff --git a/test/cbmc/proofs/MQTT_ReceiveLoop/MQTT_ReceiveLoop_harness.c b/test/cbmc/proofs/MQTT_ReceiveLoop/MQTT_ReceiveLoop_harness.c
index 0a0261f4c..b31ca0a2a 100644
--- a/test/cbmc/proofs/MQTT_ReceiveLoop/MQTT_ReceiveLoop_harness.c
+++ b/test/cbmc/proofs/MQTT_ReceiveLoop/MQTT_ReceiveLoop_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_SerializeAck/MQTT_SerializeAck_harness.c b/test/cbmc/proofs/MQTT_SerializeAck/MQTT_SerializeAck_harness.c
index 79a727a19..41a4e0457 100644
--- a/test/cbmc/proofs/MQTT_SerializeAck/MQTT_SerializeAck_harness.c
+++ b/test/cbmc/proofs/MQTT_SerializeAck/MQTT_SerializeAck_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_SerializeConnect/MQTT_SerializeConnect_harness.c b/test/cbmc/proofs/MQTT_SerializeConnect/MQTT_SerializeConnect_harness.c
index d5a361f98..2b37e8535 100644
--- a/test/cbmc/proofs/MQTT_SerializeConnect/MQTT_SerializeConnect_harness.c
+++ b/test/cbmc/proofs/MQTT_SerializeConnect/MQTT_SerializeConnect_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_SerializeDisconnect/MQTT_SerializeDisconnect_harness.c b/test/cbmc/proofs/MQTT_SerializeDisconnect/MQTT_SerializeDisconnect_harness.c
index cf1944b7c..d3d77c432 100644
--- a/test/cbmc/proofs/MQTT_SerializeDisconnect/MQTT_SerializeDisconnect_harness.c
+++ b/test/cbmc/proofs/MQTT_SerializeDisconnect/MQTT_SerializeDisconnect_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_SerializePingreq/MQTT_SerializePingreq_harness.c b/test/cbmc/proofs/MQTT_SerializePingreq/MQTT_SerializePingreq_harness.c
index 0c89b217c..0f8326bc1 100644
--- a/test/cbmc/proofs/MQTT_SerializePingreq/MQTT_SerializePingreq_harness.c
+++ b/test/cbmc/proofs/MQTT_SerializePingreq/MQTT_SerializePingreq_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_SerializePublish/MQTT_SerializePublish_harness.c b/test/cbmc/proofs/MQTT_SerializePublish/MQTT_SerializePublish_harness.c
index 61b445f02..1b1c2ad5e 100644
--- a/test/cbmc/proofs/MQTT_SerializePublish/MQTT_SerializePublish_harness.c
+++ b/test/cbmc/proofs/MQTT_SerializePublish/MQTT_SerializePublish_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_SerializePublishHeader/MQTT_SerializePublishHeader_harness.c b/test/cbmc/proofs/MQTT_SerializePublishHeader/MQTT_SerializePublishHeader_harness.c
index 92212d3a5..e8e972fbd 100644
--- a/test/cbmc/proofs/MQTT_SerializePublishHeader/MQTT_SerializePublishHeader_harness.c
+++ b/test/cbmc/proofs/MQTT_SerializePublishHeader/MQTT_SerializePublishHeader_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_SerializeSubscribe/MQTT_SerializeSubscribe_harness.c b/test/cbmc/proofs/MQTT_SerializeSubscribe/MQTT_SerializeSubscribe_harness.c
index c59113243..5df2b9f7e 100644
--- a/test/cbmc/proofs/MQTT_SerializeSubscribe/MQTT_SerializeSubscribe_harness.c
+++ b/test/cbmc/proofs/MQTT_SerializeSubscribe/MQTT_SerializeSubscribe_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_SerializeUnsubscribe/MQTT_SerializeUnsubscribe_harness.c b/test/cbmc/proofs/MQTT_SerializeUnsubscribe/MQTT_SerializeUnsubscribe_harness.c
index 3deae70d6..78ea57130 100644
--- a/test/cbmc/proofs/MQTT_SerializeUnsubscribe/MQTT_SerializeUnsubscribe_harness.c
+++ b/test/cbmc/proofs/MQTT_SerializeUnsubscribe/MQTT_SerializeUnsubscribe_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/proofs/MQTT_Subscribe/MQTT_Subscribe_harness.c b/test/cbmc/proofs/MQTT_Subscribe/MQTT_Subscribe_harness.c
index 6798c1c0c..ee34fb8a6 100644
--- a/test/cbmc/proofs/MQTT_Subscribe/MQTT_Subscribe_harness.c
+++ b/test/cbmc/proofs/MQTT_Subscribe/MQTT_Subscribe_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -28,6 +28,7 @@
*/
#include "core_mqtt.h"
#include "mqtt_cbmc_state.h"
+#include "core_mqtt_config_defaults.h"
/**
* @brief Implement a get time function to return timeout after certain
diff --git a/test/cbmc/proofs/MQTT_Unsubscribe/MQTT_Unsubscribe_harness.c b/test/cbmc/proofs/MQTT_Unsubscribe/MQTT_Unsubscribe_harness.c
index a441c662d..c3c485b5c 100644
--- a/test/cbmc/proofs/MQTT_Unsubscribe/MQTT_Unsubscribe_harness.c
+++ b/test/cbmc/proofs/MQTT_Unsubscribe/MQTT_Unsubscribe_harness.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -28,6 +28,7 @@
*/
#include "core_mqtt.h"
#include "mqtt_cbmc_state.h"
+#include "core_mqtt_config_defaults.h"
/**
* @brief Implement a get time function to return timeout after certain
diff --git a/test/cbmc/sources/mqtt_cbmc_state.c b/test/cbmc/sources/mqtt_cbmc_state.c
index 1744820e0..9891ee32b 100644
--- a/test/cbmc/sources/mqtt_cbmc_state.c
+++ b/test/cbmc/sources/mqtt_cbmc_state.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/stubs/event_callback_stub.c b/test/cbmc/stubs/event_callback_stub.c
index 3cb3a1f71..6d5bc6d85 100644
--- a/test/cbmc/stubs/event_callback_stub.c
+++ b/test/cbmc/stubs/event_callback_stub.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/stubs/get_time_stub.c b/test/cbmc/stubs/get_time_stub.c
index 32b007507..e78bac814 100644
--- a/test/cbmc/stubs/get_time_stub.c
+++ b/test/cbmc/stubs/get_time_stub.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/stubs/memmove.c b/test/cbmc/stubs/memmove.c
index 166d13c31..f438622cd 100644
--- a/test/cbmc/stubs/memmove.c
+++ b/test/cbmc/stubs/memmove.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/cbmc/stubs/network_interface_stubs.c b/test/cbmc/stubs/network_interface_stubs.c
index 72b689047..3f0dc9d29 100644
--- a/test/cbmc/stubs/network_interface_stubs.c
+++ b/test/cbmc/stubs/network_interface_stubs.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/unit-test/cmock_opaque_types.h b/test/unit-test/cmock_opaque_types.h
new file mode 100644
index 000000000..d42b67468
--- /dev/null
+++ b/test/unit-test/cmock_opaque_types.h
@@ -0,0 +1,36 @@
+/*
+ * coreMQTT v2.2.0
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef CMOCK_OPAQUE_TYPES_H_
+#define CMOCK_OPAQUE_TYPES_H_
+
+/* CMock does not support opaque types so needs concrete definitions for them.
+ * This file is included in CMock .c files. */
+
+struct NetworkContext
+{
+ int a;
+};
+
+#endif /* ifndef CMOCK_OPAQUE_TYPES_H_ */
diff --git a/test/unit-test/core_mqtt_config.h b/test/unit-test/core_mqtt_config.h
index ba1d9a02f..cc373d1ca 100644
--- a/test/unit-test/core_mqtt_config.h
+++ b/test/unit-test/core_mqtt_config.h
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -69,14 +69,8 @@
*/
#define MQTT_MAX_CONNACK_RECEIVE_RETRY_COUNT ( 2U )
-/* Set network context to double pointer to buffer (uint8_t**). */
-struct NetworkContext
-{
- uint8_t ** buffer;
-};
+#define MQTT_SUB_UNSUB_MAX_VECTORS ( 6U )
-#define MQTT_SUB_UNSUB_MAX_VECTORS ( 6U )
-
-#define MQTT_SEND_TIMEOUT_MS ( 20U )
+#define MQTT_SEND_TIMEOUT_MS ( 20U )
#endif /* ifndef CORE_MQTT_CONFIG_H_ */
diff --git a/test/unit-test/core_mqtt_serializer_utest.c b/test/unit-test/core_mqtt_serializer_utest.c
index 648917ca1..9b0e8acf5 100644
--- a/test/unit-test/core_mqtt_serializer_utest.c
+++ b/test/unit-test/core_mqtt_serializer_utest.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -27,12 +27,19 @@
* @brief Unit tests for functions in core_mqtt_serializer.h.
*/
#include
+#include
#include "unity.h"
/* Include paths for public enums, structures, and macros. */
#include "core_mqtt_serializer.h"
+/* Set network context to double pointer to buffer (uint8_t**). */
+struct NetworkContext
+{
+ uint8_t ** buffer;
+};
+
#define MQTT_MAX_REMAINING_LENGTH ( 268435455UL )
#define MQTT_PACKET_CONNACK_REMAINING_LENGTH ( ( uint8_t ) 2U ) /**< @brief A CONNACK packet always has a "Remaining length" of 2. */
#define MQTT_PACKET_CONNACK_SESSION_PRESENT_MASK ( ( uint8_t ) 0x01U ) /**< @brief The "Session Present" bit is always the lowest bit. */
diff --git a/test/unit-test/core_mqtt_state_utest.c b/test/unit-test/core_mqtt_state_utest.c
index b230af22a..269cb8ef5 100644
--- a/test/unit-test/core_mqtt_state_utest.c
+++ b/test/unit-test/core_mqtt_state_utest.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/unit-test/core_mqtt_utest.c b/test/unit-test/core_mqtt_utest.c
index 97f87c080..3bcc8d793 100644
--- a/test/unit-test/core_mqtt_utest.c
+++ b/test/unit-test/core_mqtt_utest.c
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
@@ -28,6 +28,7 @@
*/
#include
#include
+#include
#include "unity.h"
@@ -37,6 +38,14 @@
#include "mock_core_mqtt_serializer.h"
#include "mock_core_mqtt_state.h"
+#include "core_mqtt_config_defaults.h"
+
+/* Set network context to double pointer to buffer (uint8_t**). */
+struct NetworkContext
+{
+ uint8_t ** buffer;
+};
+
/**
* @brief MQTT client identifier.
*/
diff --git a/test/unit-test/logging/logging_levels.h b/test/unit-test/logging/logging_levels.h
index 92405138f..07edb54ce 100644
--- a/test/unit-test/logging/logging_levels.h
+++ b/test/unit-test/logging/logging_levels.h
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/test/unit-test/logging/logging_stack.h b/test/unit-test/logging/logging_stack.h
index 62c71afec..86f14ee23 100644
--- a/test/unit-test/logging/logging_stack.h
+++ b/test/unit-test/logging/logging_stack.h
@@ -1,5 +1,5 @@
/*
- * coreMQTT v2.1.0
+ * coreMQTT v2.2.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
diff --git a/tools/cmock/project.yml b/tools/cmock/project.yml
index 8a90416b7..560136ebf 100644
--- a/tools/cmock/project.yml
+++ b/tools/cmock/project.yml
@@ -21,6 +21,8 @@
:includes: # This will add these includes to each mock.
-
-
+ :includes_c_post_header:
+ -
:treat_externs: :exclude # Now the extern-ed functions will be mocked.
:weak: __attribute__((weak))
:treat_externs: :include
diff --git a/tools/coverity/misra.config b/tools/coverity/misra.config
index da2ed5b01..4753f5ddf 100644
--- a/tools/coverity/misra.config
+++ b/tools/coverity/misra.config
@@ -1,43 +1,40 @@
-// MISRA C-2012 Rules
-
{
- version : "2.0",
- standard : "c2012",
- title: "Coverity MISRA Configuration",
- deviations : [
- // Disable the following rules.
- {
- deviation: "Directive 4.8",
- reason: "Allow inclusion of unused types. Header files for a specific port, which are needed by all files, may define types that are not used by a specific file."
- },
+ "version" : "2.0",
+ "standard" : "c2012",
+ "title": "Coverity MISRA Configuration",
+ "deviations" : [
{
- deviation: "Directive 4.9",
- reason: "Allow inclusion of function like macros. Logging is done using function like macros."
+ "deviation": "Directive 4.8",
+ "reason": "Allow inclusion of unused types. Header files for a specific port, which are needed by all files, may define types that are not used by a specific file."
},
{
- deviation: "Rule 2.3",
- reason: "Allow unused types. Library headers may define types intended for the application's use, but not used within the library files."
+ "deviation": "Directive 4.9",
+ "reason": "Allow inclusion of function like macros. Logging is done using function like macros."
},
{
- deviation: "Rule 2.4",
- reason: "Allow unused tags. Some compilers warn if types are not tagged."
+ "deviation": "Rule 2.3",
+ "reason": "Allow unused types. Library headers may define types intended for the application's use, but not used within the library files."
},
{
- deviation: "Rule 2.5",
- reason: "Allow unused macros. Library headers may define macros intended for the application's use, but not used by a specific file."
+ "deviation": "Rule 2.4",
+ "reason": "Allow unused tags. Some compilers warn if types are not tagged."
},
{
- deviation: "Rule 3.1",
- reason: "Allow nested comments. Documentation blocks contain comments for example code."
+ "deviation": "Rule 2.5",
+ "reason": "Allow unused macros. Library headers may define macros intended for the application's use, but not used by a specific file."
},
{
- deviation: "Rule 8.7",
- reason: "API functions are not used by the library outside of the files they are defined; however, they must be externally visible in order to be used by an application."
+ "deviation": "Rule 3.1",
+ "reason": "Allow nested comments. Documentation blocks contain comments for example code."
},
{
- deviation: "Rule 11.5",
- reason: "Allow casts from `void *`. The payload buffers are stored as `void *` and are cast to various types for use in functions."
+ "deviation": "Rule 8.7",
+ "reason": "API functions are not used by the library outside of the files they are defined; however, they must be externally visible in order to be used by an application."
},
+ {
+ "deviation": "Rule 11.5",
+ "reason": "Allow casts from `void *`. The payload buffers are stored as `void *` and are cast to various types for use in functions."
+ }
]
}