From 33fccf6405a302e4f54913b55d7bd6299cfefd72 Mon Sep 17 00:00:00 2001 From: Euripedes Rocha Date: Tue, 7 Jun 2022 08:10:38 -0300 Subject: [PATCH] [MQTT] - Adds esp-timer as dependency and change version. - Current time is now from esp_timer. --- components/mqtt/CMakeLists.txt | 4 +++- components/mqtt/esp-mqtt | 2 +- components/mqtt/host_test/CMakeLists.txt | 4 +++- components/mqtt/host_test/main/CMakeLists.txt | 2 +- components/mqtt/host_test/main/test_mqtt_client.cpp | 8 +++++--- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/components/mqtt/CMakeLists.txt b/components/mqtt/CMakeLists.txt index ae35aefc02..2e57327202 100644 --- a/components/mqtt/CMakeLists.txt +++ b/components/mqtt/CMakeLists.txt @@ -3,7 +3,9 @@ idf_component_register(SRCS "esp-mqtt/mqtt_client.c" "esp-mqtt/lib/mqtt_outbox.c" "esp-mqtt/lib/platform_esp32_idf.c" INCLUDE_DIRS esp-mqtt/include - PRIV_INCLUDE_DIRS "esp-mqtt/lib/include") + PRIV_INCLUDE_DIRS "esp-mqtt/lib/include" + PRIV_REQUIRES esp_timer + ) if(TEST_BUILD) message(STATUS "building MOCKS") diff --git a/components/mqtt/esp-mqtt b/components/mqtt/esp-mqtt index a21c387d62..89e5c6014f 160000 --- a/components/mqtt/esp-mqtt +++ b/components/mqtt/esp-mqtt @@ -1 +1 @@ -Subproject commit a21c387d6280260894981c22494017c893d505b9 +Subproject commit 89e5c6014f8dbcfcd98af35fb507ca7b96ac8aee diff --git a/components/mqtt/host_test/CMakeLists.txt b/components/mqtt/host_test/CMakeLists.txt index fedde21076..7137910836 100644 --- a/components/mqtt/host_test/CMakeLists.txt +++ b/components/mqtt/host_test/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(COMPONENTS main) -list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") +list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/" + "$ENV{IDF_PATH}/tools/mocks/esp_timer/" + ) option(TEST_BUILD "" ON) project(host_mqtt_client_test) diff --git a/components/mqtt/host_test/main/CMakeLists.txt b/components/mqtt/host_test/main/CMakeLists.txt index c89e9bfb29..90692f6cce 100644 --- a/components/mqtt/host_test/main/CMakeLists.txt +++ b/components/mqtt/host_test/main/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRCS "test_mqtt_client.cpp" INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch" - REQUIRES cmock mqtt) + REQUIRES cmock mqtt esp_timer) diff --git a/components/mqtt/host_test/main/test_mqtt_client.cpp b/components/mqtt/host_test/main/test_mqtt_client.cpp index a28cbc2092..e0c0160f94 100644 --- a/components/mqtt/host_test/main/test_mqtt_client.cpp +++ b/components/mqtt/host_test/main/test_mqtt_client.cpp @@ -13,6 +13,7 @@ extern "C" { #include "Mockhttp_parser.h" #include "Mockqueue.h" #include "Mocktask.h" +#include "Mockesp_timer.h" /* * The following functions are not directly called but the generation of them @@ -30,15 +31,16 @@ struct ClientInitializedFixture { esp_mqtt_client_handle_t client; ClientInitializedFixture() { - TEST_PROTECT(); + [[maybe_unused]] auto protect = TEST_PROTECT(); int mtx; int transport_list; int transport; int event_group; uint8_t mac[] = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55}; esp_log_write_Ignore(); - xQueueTakeMutexRecursive_CMockIgnoreAndReturn(0, true); - xQueueGiveMutexRecursive_CMockIgnoreAndReturn(0, true); + esp_timer_get_time_IgnoreAndReturn(0); + xQueueTakeMutexRecursive_IgnoreAndReturn(true); + xQueueGiveMutexRecursive_IgnoreAndReturn(true); xQueueCreateMutex_ExpectAnyArgsAndReturn( reinterpret_cast(&mtx)); xEventGroupCreate_IgnoreAndReturn(reinterpret_cast(&event_group));