diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 388346ae..2eb6775c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,7 @@ jobs: -G "Unix Makefiles" \ -DCMAKE_BUILD_TYPE=Debug \ -DBUILD_CLONE_SUBMODULES=ON \ + -DUNITTEST=1 \ -DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror -DNDEBUG -DLIBRARY_LOG_LEVEL=LOG_DEBUG' make -C build/ all @@ -90,7 +91,7 @@ jobs: echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" mkdir -p source/dependency/coreMQTT/docs/doxygen/output wget -O source/dependency/coreMQTT/docs/doxygen/output/mqtt.tag \ - "https://freertos.org/Documentation/api-ref/coreMQTT/docs/doxygen/output/mqtt.tag" + "https://freertos.github.io/coreMQTT/main/mqtt.tag" echo -e "::endgroup::" echo -e "${{env.bashPass}} ${{ env.stepName }} ${{ env.bashEnd }}" diff --git a/README.md b/README.md index 50737d81..d9e013e7 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ git submodule update --init --recursive ## coreMQTT Agent Library Configurations -The MQTT Agent library uses the same `core_mqtt_config.h` configuration file as coreMQTT, with the addition of configuration constants listed at the top of [core_mqtt_agent.h](source/include/core_mqtt_agent.h) and [core_mqtt_agent_command_functions.h](source/include/core_mqtt_agent_command_functions.h). Documentation for these configurations can be found [here](https://freertos.org/Documentation/api-ref/coreMQTT-Agent/docs/doxygen/output/html/core_mqtt_agent_config.html). +The MQTT Agent library uses the same `core_mqtt_config.h` configuration file as coreMQTT, with the addition of configuration constants listed at the top of [core_mqtt_agent.h](source/include/core_mqtt_agent.h) and [core_mqtt_agent_command_functions.h](source/include/core_mqtt_agent_command_functions.h). Documentation for these configurations can be found [here](https://freertos.github.io/coreMQTT-Agent/main/core_mqtt_agent_config.html). To provide values for these configuration values, they must be either: * Defined in `core_mqtt_config.h` used by coreMQTT @@ -131,7 +131,7 @@ Please refer to the demos of the MQTT Agent library in the following locations f ## Documentation -The MQTT Agent API documentation can be found [here](https://freertos.org/Documentation/api-ref/coreMQTT-Agent/docs/doxygen/output/html/index.html). +The MQTT Agent API documentation can be found [here](https://freertos.github.io/coreMQTT-Agent/main/index.html). ### Generating documentation @@ -143,7 +143,7 @@ doxygen docs/doxygen/config.doxyfile ``` ## Getting help -You can use your Github login to get support from both the FreeRTOS community and directly from the primary FreeRTOS developers on our [active support forum](https://forums.freertos.org). You can find a list of [frequently asked questions](https://www.freertos.org/FAQ.html) here. +You can use your Github login to get support from both the FreeRTOS community and directly from the primary FreeRTOS developers on our [active support forum](https://forums.freertos.org). You can find a list of [frequently asked questions](https://www.freertos.org/Why-FreeRTOS/FAQs) here. ## Contributing diff --git a/source/include/core_mqtt_agent.h b/source/include/core_mqtt_agent.h index 11a17083..ff024e3b 100644 --- a/source/include/core_mqtt_agent.h +++ b/source/include/core_mqtt_agent.h @@ -201,8 +201,8 @@ typedef struct MQTTAgentCommandInfo * @param[in] pMqttAgentContext Pointer to struct to initialize. * @param[in] pMsgInterface Command interface to use for allocating and sending commands. * @param[in] pNetworkBuffer Pointer to network buffer to use. - * @param[in] pTransportInterface Transport interface to use with the MQTT - * library. See https://www.freertos.org/network-interface.html + * @param[in] pTransportInterface Transport interface to use with the MQTT library. + * See https://www.freertos.org/Documentation/03-Libraries/03-FreeRTOS-core/06-Transport-Interface/01-Transport-interface * @param[in] getCurrentTimeMs Pointer to a function that returns a count value * that increments every millisecond. * @param[in] incomingCallback The callback to execute when receiving publishes. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 62295abd..9a5cc186 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ -cmake_minimum_required ( VERSION 3.13.0 ) -project ( "MQTTAgent unit test" - VERSION 1.0.0 +cmake_minimum_required ( VERSION 3.22.0 ) +project ( "MQTTAgent tests" + VERSION 1.2.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,70 @@ set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) # ===================================== Coverity Analysis Configuration ================================================= -# Include filepaths for source and include. -include( ${MODULE_ROOT_DIR}/source/dependency/coreMQTT/mqttFilePaths.cmake ) -include( ${MODULE_ROOT_DIR}/mqttAgentFilePaths.cmake ) -# Target for Coverity analysis that builds the library. -add_library( coverity_analysis - ${MQTT_AGENT_SOURCES} - ${MQTT_SOURCES} - ${MQTT_SERIALIZER_SOURCES} ) +if( COV_ANALYSIS ) + # Include filepaths for source and include. + include( ${MODULE_ROOT_DIR}/source/dependency/coreMQTT/mqttFilePaths.cmake ) + include( ${MODULE_ROOT_DIR}/mqttAgentFilePaths.cmake ) + # Target for Coverity analysis that builds the library. + add_library( coverity_analysis + ${MQTT_AGENT_SOURCES} + ${MQTT_SOURCES} + ${MQTT_SERIALIZER_SOURCES} ) -# Build MQTT library target without custom config dependency. -target_compile_definitions( coverity_analysis PUBLIC MQTT_DO_NOT_USE_CUSTOM_CONFIG=1 MQTT_AGENT_DO_NOT_USE_CUSTOM_CONFIG=1 ) + # Build MQTT library target without custom config dependency. + target_compile_definitions( coverity_analysis PUBLIC MQTT_DO_NOT_USE_CUSTOM_CONFIG=1 MQTT_AGENT_DO_NOT_USE_CUSTOM_CONFIG=1 ) -# MQTT AGENT public include path. -target_include_directories( coverity_analysis PUBLIC ${MQTT_AGENT_INCLUDE_PUBLIC_DIRS} ${MQTT_INCLUDE_PUBLIC_DIRS} ) + # MQTT AGENT public include path. + target_include_directories( coverity_analysis PUBLIC ${MQTT_AGENT_INCLUDE_PUBLIC_DIRS} ${MQTT_INCLUDE_PUBLIC_DIRS} ) -# ==================================== Test Configuration ======================================== + # Remove inclusion of assert. + add_compile_definitions( NDEBUG=1 ) -# Define a CMock resource path. -set( CMOCK_DIR ${MODULE_ROOT_DIR}/test/unit-test/CMock CACHE INTERNAL "CMock library source directory." ) +endif() -# Include CMock build configuration. -include( unit-test/cmock_build.cmake ) +# ==================================== Test Configuration ======================================== -# 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." ) +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}/source/dependency/coreMQTT/tools/cmock/create_test.cmake ) + # Add function to enable CMock based tests and coverage. + include( ${MODULE_ROOT_DIR}/source/dependency/coreMQTT/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 mqtt_agent_utest mqtt_agent_command_functions_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 mqtt_agent_utest mqtt_agent_command_functions_utest + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) +endif() diff --git a/test/unit-test/CMakeLists.txt b/test/unit-test/CMakeLists.txt index 7a6e5f8e..1582d6a0 100644 --- a/test/unit-test/CMakeLists.txt +++ b/test/unit-test/CMakeLists.txt @@ -1,3 +1,7 @@ +# Include filepaths for source and include. +include( ${MODULE_ROOT_DIR}/source/dependency/coreMQTT/mqttFilePaths.cmake ) +include( ${MODULE_ROOT_DIR}/mqttAgentFilePaths.cmake ) + # ==================== Define your project name (edit) ======================== set(project_name "mqtt_agent") diff --git a/tools/coverity/misra.config b/tools/coverity/misra.config index 79760568..8a5031b3 100644 --- a/tools/coverity/misra.config +++ b/tools/coverity/misra.config @@ -1,42 +1,40 @@ -// MISRA C-2012 Rules - { - version : "2.0", - standard : "c2012", - title: "Coverity MISRA Configuration", - deviations : [ + "version" : "2.0", + "standard" : "c2012", + "title": "Coverity MISRA Configuration", + "deviations" : [ // Disable the following rules. { - deviation: "Directive 4.5", - reason: "Allow names that MISRA considers ambiguous." + "deviation": "Directive 4.5", + "reason": "Allow names that MISRA considers ambiguous." }, { - deviation: "Directive 4.8", - reason: "Allow inclusion of unused types. Header files for coreMQTT, which are needed by all files, define types that are not used by the agent." + "deviation": "Directive 4.8", + "reason": "Allow inclusion of unused types. Header files for coreMQTT, which are needed by all files, define types that are not used by the agent." }, { - deviation: "Directive 4.9", - reason: "Allow inclusion of function like macros. Asserts and logging are done using function like macros." + "deviation": "Directive 4.9", + "reason": "Allow inclusion of function like macros. Asserts and logging are done using function like macros." }, { - deviation: "Rule 2.3", - reason: "Allow unused types. coreMQTT Library headers define types intended for the application's use, but are not used by the agent files." + "deviation": "Rule 2.3", + "reason": "Allow unused types. coreMQTT Library headers define types intended for the application's use, but are not used by the agent files." }, { - deviation: "Rule 2.4", - reason: "Allow unused tags. Some compilers warn if types are not tagged." + "deviation": "Rule 2.4", + "reason": "Allow unused tags. Some compilers warn if types are not tagged." }, { - deviation: "Rule 2.5", - reason: "Allow unused macros. coreMQTT Library headers define macros intended for the application's use, but are not used by the agent." + "deviation": "Rule 2.5", + "reason": "Allow unused macros. coreMQTT Library headers define macros intended for the application's use, but are not used by the agent." }, { - deviation: "Rule 3.1", - reason: "Allow nested comments. Documentation blocks contain comments for example code." + "deviation": "Rule 3.1", + "reason": "Allow nested comments. Documentation blocks contain comments for example code." }, { - deviation: "Rule 11.5", - reason: "Allow casts from void *. Contexts are passed as void * and must be cast to the correct data type before use." + "deviation": "Rule 11.5", + "reason": "Allow casts from void *. Contexts are passed as void * and must be cast to the correct data type before use." } ] }