From 736424c3662532c63bc7fa4b94c2c102ee74a1c6 Mon Sep 17 00:00:00 2001 From: Euripedes Rocha Date: Mon, 5 Sep 2022 15:46:10 +0200 Subject: [PATCH] [MQTT] Simplifies MQTT CMakeLists file - Uses mocks from tools instead of creating them. - Move host based definition to test code. --- components/mqtt/CMakeLists.txt | 119 +----------------- components/mqtt/host_test/CMakeLists.txt | 10 +- components/mqtt/host_test/main/CMakeLists.txt | 2 +- .../mqtt/host_test/main/test_mqtt_client.cpp | 3 - .../mocks/include/local_FreeRTOS_config.h | 6 - components/mqtt/test/test_mqtt.c | 1 + .../tcp_transport/include/esp_transport_tcp.h | 19 +-- tools/ci/check_copyright_ignore.txt | 1 - tools/mocks/esp-tls/CMakeLists.txt | 12 ++ tools/mocks/esp-tls/mock/mock_config.yaml | 16 +++ tools/mocks/esp_event/CMakeLists.txt | 10 ++ tools/mocks/esp_event/mock/mock_config.yaml | 9 ++ tools/mocks/esp_hw_support/CMakeLists.txt | 10 ++ .../esp_hw_support/mock/mock_config.yaml | 7 ++ tools/mocks/freertos/CMakeLists.txt | 4 +- tools/mocks/freertos/include/FreeRTOSConfig.h | 25 ++++ tools/mocks/freertos/mock/mock_config.yaml | 43 +++---- tools/mocks/http_parser/CMakeLists.txt | 8 ++ tools/mocks/http_parser/mock/mock_config.yaml | 9 ++ tools/mocks/lwip/CMakeLists.txt | 10 ++ tools/mocks/lwip/mock/mock_config.yaml | 9 ++ tools/mocks/tcp_transport/CMakeLists.txt | 13 ++ .../mocks/tcp_transport/mock/mock_config.yaml | 9 ++ 23 files changed, 190 insertions(+), 165 deletions(-) delete mode 100644 components/mqtt/host_test/mocks/include/local_FreeRTOS_config.h create mode 100644 tools/mocks/esp-tls/CMakeLists.txt create mode 100644 tools/mocks/esp-tls/mock/mock_config.yaml create mode 100644 tools/mocks/esp_event/CMakeLists.txt create mode 100644 tools/mocks/esp_event/mock/mock_config.yaml create mode 100644 tools/mocks/esp_hw_support/CMakeLists.txt create mode 100644 tools/mocks/esp_hw_support/mock/mock_config.yaml create mode 100644 tools/mocks/freertos/include/FreeRTOSConfig.h create mode 100644 tools/mocks/http_parser/CMakeLists.txt create mode 100644 tools/mocks/http_parser/mock/mock_config.yaml create mode 100644 tools/mocks/lwip/CMakeLists.txt create mode 100644 tools/mocks/lwip/mock/mock_config.yaml create mode 100644 tools/mocks/tcp_transport/CMakeLists.txt create mode 100644 tools/mocks/tcp_transport/mock/mock_config.yaml diff --git a/components/mqtt/CMakeLists.txt b/components/mqtt/CMakeLists.txt index 15aea3d745..29aa3497d5 100644 --- a/components/mqtt/CMakeLists.txt +++ b/components/mqtt/CMakeLists.txt @@ -7,122 +7,7 @@ endif() idf_component_register(SRCS "${srcs}" INCLUDE_DIRS esp-mqtt/include PRIV_INCLUDE_DIRS "esp-mqtt/lib/include" - PRIV_REQUIRES esp_timer + REQUIRES esp_event tcp_transport + PRIV_REQUIRES esp_timer http_parser esp_hw_support ) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") - -if(TEST_BUILD) -message(STATUS "building MOCKS") -idf_component_get_property(tcp_transport_dir tcp_transport COMPONENT_DIR) -idf_component_get_property(esp_hw_support_dir esp_hw_support COMPONENT_DIR) -idf_component_get_property(esp_event_dir esp_event COMPONENT_DIR) -idf_component_get_property(log_dir log COMPONENT_DIR) -idf_component_get_property(freertos_dir freertos COMPONENT_OVERRIDEN_DIR) -idf_component_get_property(http_parser_dir http_parser COMPONENT_DIR) -idf_component_get_property(esp_wifi_dir esp_wifi COMPONENT_DIR) -idf_component_get_property(esp_tls_dir esp-tls COMPONENT_DIR) -idf_component_get_property(esp_netif_dir esp_netif COMPONENT_DIR) -idf_component_get_property(esp_common_dir esp_common COMPONENT_DIR) -idf_component_get_property(esp_rom_dir esp_rom COMPONENT_DIR) -idf_component_get_property(esp_system_dir esp_system COMPONENT_DIR) -idf_component_get_property(mbedtls_dir mbedtls COMPONENT_DIR) - - idf_component_get_property(cmock_lib cmock COMPONENT_LIB) - set(IDF_PATH $ENV{IDF_PATH}) - set(CMOCK_DIR "${IDF_PATH}/components/cmock/CMock") - set(MOCK_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/mocks") - set(ENV{UNITY_DIR} "$ENV{IDF_PATH}/components/cmock/CMock") - file(MAKE_DIRECTORY ${MOCK_GEN_DIR}) - - set(MOCK_OUTPUT - "${MOCK_GEN_DIR}/Mockesp_transport.c" "${MOCK_GEN_DIR}/Mockesp_transport.h" - "${MOCK_GEN_DIR}/Mockesp_transport_ssl.c" "${MOCK_GEN_DIR}/Mockesp_transport_ssl.h" - "${MOCK_GEN_DIR}/Mockesp_transport_ws.c" "${MOCK_GEN_DIR}/Mockesp_transport_ws.h" - "${MOCK_GEN_DIR}/Mockesp_transport_tcp.c" "${MOCK_GEN_DIR}/Mockesp_transport_tcp.h" - "${MOCK_GEN_DIR}/Mockesp_event.c" "${MOCK_GEN_DIR}/Mockesp_event.h" - "${MOCK_GEN_DIR}/Mockesp_mac.c" "${MOCK_GEN_DIR}/Mockesp_mac.h" - "${MOCK_GEN_DIR}/Mockesp_random.c" "${MOCK_GEN_DIR}/Mockesp_random.h" - "${MOCK_GEN_DIR}/Mockesp_system.c" "${MOCK_GEN_DIR}/Mockesp_system.h" - "${MOCK_GEN_DIR}/Mockesp_tls.c" "${MOCK_GEN_DIR}/Mockesp_tls.h" - "${MOCK_GEN_DIR}/Mockevent_groups.c" "${MOCK_GEN_DIR}/Mockevent_groups.h" - "${MOCK_GEN_DIR}/Mockqueue.c" "${MOCK_GEN_DIR}/Mockqueue.h" - "${MOCK_GEN_DIR}/Mocktask.c" "${MOCK_GEN_DIR}/Mocktask.h" - "${MOCK_GEN_DIR}/Mockesp_log.c" "${MOCK_GEN_DIR}/Mockesp_log.h" - "${MOCK_GEN_DIR}/Mockhttp_parser.c" "${MOCK_GEN_DIR}/Mockhttp_parser.h" - ) - - set(HEADERS_TO_MOCK - ${tcp_transport_dir}/include/esp_transport_tcp.h - ${tcp_transport_dir}/include/esp_transport_ws.h - ${tcp_transport_dir}/include/esp_transport_ssl.h - ${tcp_transport_dir}/include/esp_transport.h - ${esp_event_dir}/include/esp_event.h - ${esp_hw_support_dir}/include/esp_mac.h - ${esp_hw_support_dir}/include/esp_random.h - ${freertos_dir}/FreeRTOS-Kernel/include/freertos/event_groups.h - ${log_dir}/include/esp_log.h - ${http_parser_dir}/http_parser.h - ) - - set(srcs - ${MOCK_GEN_DIR}/Mockesp_transport.c - ${MOCK_GEN_DIR}/Mockesp_transport_ws.c - ${MOCK_GEN_DIR}/Mockesp_transport_ssl.c - ${MOCK_GEN_DIR}/Mockesp_transport_tcp.c - ${MOCK_GEN_DIR}/Mockesp_transport_tcp.c - ${MOCK_GEN_DIR}/Mockesp_event.c - ${MOCK_GEN_DIR}/Mockesp_mac.c - ${MOCK_GEN_DIR}/Mockesp_random.c - ${MOCK_GEN_DIR}/Mockesp_log.c - ${MOCK_GEN_DIR}/Mockhttp_parser.c - ${MOCK_GEN_DIR}/Mockevent_groups.c - ) - - add_custom_command( - OUTPUT ruby_found SYMBOLIC - COMMAND "ruby" "-v" - COMMENT "Try to find ruby. If this fails, you need to install ruby" - ) - - add_custom_command( - OUTPUT ${MOCK_OUTPUT} - DEPENDS ruby_found - COMMAND ${CMAKE_COMMAND} -E env "UNITY_DIR=${IDF_PATH}/components/unity/unity" - ruby - ${CMOCK_DIR}/lib/cmock.rb - -o${CMAKE_CURRENT_SOURCE_DIR}/host_test/mocks/config.yaml - ${HEADERS_TO_MOCK} - ) - - add_library(mocks ${srcs}) - target_include_directories(mocks PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/host_test/mocks/include - ${tcp_transport_dir}/include - ${esp_tls_dir} - ${freertos_dir}/FreeRTOS-Kernel/include - ${esp_event_dir}/include - ${esp_system_dir}/include - ${esp_common_dir}/include - ${esp_wifi_dir}/include - ${esp_hw_support_dir}/include - ${esp_netif_dir}/include - ${log_dir}/include - ${esp_rom_dir}/include - ${mbedtls_dir}/port/include - ${http_parser_dir} - ${mbedtls_dir}/mbedtls/include - ${freertos_dir}/FreeRTOS-Kernel/include/freertos - esp-mqtt/lib/include - ${MOCK_GEN_DIR} - ) - target_link_libraries(mocks PUBLIC ${cmock_lib}) - target_compile_definitions(mocks PUBLIC - CONFIG_LOG_TIMESTAMP_SOURCE_RTOS) - target_link_options(${COMPONENT_LIB} INTERFACE -fsanitize=address) - - target_link_libraries(${COMPONENT_LIB} PUBLIC mocks) - -else() - idf_component_optional_requires(PUBLIC esp_event tcp_transport) - idf_component_optional_requires(PRIVATE http_parser) -endif() diff --git a/components/mqtt/host_test/CMakeLists.txt b/components/mqtt/host_test/CMakeLists.txt index 7137910836..d1c1ac6ab8 100644 --- a/components/mqtt/host_test/CMakeLists.txt +++ b/components/mqtt/host_test/CMakeLists.txt @@ -2,9 +2,15 @@ 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/esp_hw_support/" + "$ENV{IDF_PATH}/tools/mocks/freertos/" "$ENV{IDF_PATH}/tools/mocks/esp_timer/" + "$ENV{IDF_PATH}/tools/mocks/esp_event/" + "$ENV{IDF_PATH}/tools/mocks/lwip/" + "$ENV{IDF_PATH}/tools/mocks/esp-tls/" + "$ENV{IDF_PATH}/tools/mocks/http_parser/" + "$ENV{IDF_PATH}/tools/mocks/tcp_transport/" ) -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 90692f6cce..6c4a9c708a 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 esp_timer) + REQUIRES cmock mqtt esp_timer esp_hw_support http_parser log) diff --git a/components/mqtt/host_test/main/test_mqtt_client.cpp b/components/mqtt/host_test/main/test_mqtt_client.cpp index 4979c194f1..8ebbf1eefc 100644 --- a/components/mqtt/host_test/main/test_mqtt_client.cpp +++ b/components/mqtt/host_test/main/test_mqtt_client.cpp @@ -3,7 +3,6 @@ extern "C" { #include "Mockesp_event.h" -#include "Mockesp_log.h" #include "Mockesp_mac.h" #include "Mockesp_transport.h" #include "Mockesp_transport_ssl.h" @@ -37,14 +36,12 @@ struct ClientInitializedFixture { int transport; int event_group; uint8_t mac[] = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55}; - esp_log_write_Ignore(); esp_timer_get_time_IgnoreAndReturn(0); xQueueTakeMutexRecursive_IgnoreAndReturn(true); xQueueGiveMutexRecursive_IgnoreAndReturn(true); xQueueCreateMutex_ExpectAnyArgsAndReturn( reinterpret_cast(&mtx)); xEventGroupCreate_IgnoreAndReturn(reinterpret_cast(&event_group)); - esp_log_timestamp_IgnoreAndReturn(0); esp_transport_list_init_IgnoreAndReturn(reinterpret_cast(&transport_list)); esp_transport_tcp_init_IgnoreAndReturn(reinterpret_cast(&transport)); esp_transport_ssl_init_IgnoreAndReturn(reinterpret_cast(&transport)); diff --git a/components/mqtt/host_test/mocks/include/local_FreeRTOS_config.h b/components/mqtt/host_test/mocks/include/local_FreeRTOS_config.h deleted file mode 100644 index e7e1014beb..0000000000 --- a/components/mqtt/host_test/mocks/include/local_FreeRTOS_config.h +++ /dev/null @@ -1,6 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#define configUSE_TRACE_FACILITY 1 diff --git a/components/mqtt/test/test_mqtt.c b/components/mqtt/test/test_mqtt.c index 2494d03c8a..d997bceb98 100644 --- a/components/mqtt/test/test_mqtt.c +++ b/components/mqtt/test/test_mqtt.c @@ -104,4 +104,5 @@ TEST_CASE("mqtt broker tests", "[mqtt][test_env=UT_T2_Ethernet]") connect_test_fixture_teardown(); } + #endif // SOC_EMAC_SUPPORTED diff --git a/components/tcp_transport/include/esp_transport_tcp.h b/components/tcp_transport/include/esp_transport_tcp.h index 6941820f0e..e5b0a46638 100644 --- a/components/tcp_transport/include/esp_transport_tcp.h +++ b/components/tcp_transport/include/esp_transport_tcp.h @@ -1,22 +1,15 @@ -// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_TRANSPORT_TCP_H_ #define _ESP_TRANSPORT_TCP_H_ #include "esp_transport.h" #include +#include #ifdef __cplusplus extern "C" { diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 1a83f09b8f..7160ebc59e 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -1254,7 +1254,6 @@ components/spi_flash/test/test_mmap.c components/spi_flash/test/test_out_of_bounds_write.c components/spi_flash/test/test_partition_ext.c components/spi_flash/test/test_spi_flash.c -components/tcp_transport/include/esp_transport_tcp.h components/tcp_transport/include/esp_transport_ws.h components/tcp_transport/test/tcp_transport_fixtures.h components/tcp_transport/test/test_transport_basic.c diff --git a/tools/mocks/esp-tls/CMakeLists.txt b/tools/mocks/esp-tls/CMakeLists.txt new file mode 100644 index 0000000000..ffe9866874 --- /dev/null +++ b/tools/mocks/esp-tls/CMakeLists.txt @@ -0,0 +1,12 @@ +# NOTE: This kind of mocking currently works on Linux targets only. +# On Espressif chips, too many dependencies are missing at the moment. +message(STATUS "building ESP-TLS MOCKS") + +idf_component_get_property(original_esp_tls_dir esp-tls COMPONENT_OVERRIDEN_DIR) + +idf_component_mock(INCLUDE_DIRS "${original_esp_tls_dir}" + "${original_esp_tls_dir}/esp-tls-crypto" + MOCK_HEADER_FILES ${original_esp_tls_dir}/esp_tls.h + ${original_esp_tls_dir}/esp-tls-crypto/esp_tls_crypto.h + ) +target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-array-parameter) diff --git a/tools/mocks/esp-tls/mock/mock_config.yaml b/tools/mocks/esp-tls/mock/mock_config.yaml new file mode 100644 index 0000000000..60a445dc0c --- /dev/null +++ b/tools/mocks/esp-tls/mock/mock_config.yaml @@ -0,0 +1,16 @@ + +:cmock: + :plugins: + - expect + - expect_any_args + - return_thru_ptr + - ignore + - ignore_arg + :when_ptr: :compare_ptr + :strippables: + - '(?:esp_tls_cfg_server_session_tickets_init\s*\(+.*?\)+)' + - '(?:esp_tls_cfg_server_session_tickets_free\s*\(+.*?\)+)' + - '(?:esp_tls_server_session_create\s*\(+.*?\)+)' + - '(?:esp_tls_get_global_ca_store\s*\(+.*?\)+)' + - '(?:esp_tls_get_client_session\s*\(+.*?\)+)' + - '(?:esp_tls_free_client_session\s*\(+.*?\)+)' diff --git a/tools/mocks/esp_event/CMakeLists.txt b/tools/mocks/esp_event/CMakeLists.txt new file mode 100644 index 0000000000..24629a6ef6 --- /dev/null +++ b/tools/mocks/esp_event/CMakeLists.txt @@ -0,0 +1,10 @@ +# NOTE: This kind of mocking currently works on Linux targets only. +# On Espressif chips, too many dependencies are missing at the moment. +message(STATUS "building ESP EVENT MOCKS") + +idf_component_get_property(original_esp_event_dir esp_event COMPONENT_OVERRIDEN_DIR) + +idf_component_mock(INCLUDE_DIRS "${original_esp_event_dir}/include" + MOCK_HEADER_FILES ${original_esp_event_dir}/include/esp_event.h + ${original_esp_event_dir}/include/esp_event_base.h + ) diff --git a/tools/mocks/esp_event/mock/mock_config.yaml b/tools/mocks/esp_event/mock/mock_config.yaml new file mode 100644 index 0000000000..596255b0ce --- /dev/null +++ b/tools/mocks/esp_event/mock/mock_config.yaml @@ -0,0 +1,9 @@ + :cmock: + :plugins: + - expect + - expect_any_args + - return_thru_ptr + - array + - ignore + - ignore_arg + - callback diff --git a/tools/mocks/esp_hw_support/CMakeLists.txt b/tools/mocks/esp_hw_support/CMakeLists.txt new file mode 100644 index 0000000000..724c3b42a4 --- /dev/null +++ b/tools/mocks/esp_hw_support/CMakeLists.txt @@ -0,0 +1,10 @@ +# NOTE: This kind of mocking currently works on Linux targets only. +# On Espressif chips, too many dependencies are missing at the moment. +message(STATUS "building ESP HW SUPPORT MOCKS") + +idf_component_get_property(original_esp_hw_support_dir esp_hw_support COMPONENT_OVERRIDEN_DIR) + +idf_component_mock(INCLUDE_DIRS "${original_esp_hw_support_dir}/include" + MOCK_HEADER_FILES ${original_esp_hw_support_dir}/include/esp_mac.h + ${original_esp_hw_support_dir}/include/esp_random.h + ) diff --git a/tools/mocks/esp_hw_support/mock/mock_config.yaml b/tools/mocks/esp_hw_support/mock/mock_config.yaml new file mode 100644 index 0000000000..e250ea354d --- /dev/null +++ b/tools/mocks/esp_hw_support/mock/mock_config.yaml @@ -0,0 +1,7 @@ + :cmock: + :plugins: + - expect + - expect_any_args + - ignore + - ignore_arg + - return_thru_ptr diff --git a/tools/mocks/freertos/CMakeLists.txt b/tools/mocks/freertos/CMakeLists.txt index 4409be36f3..410855eace 100644 --- a/tools/mocks/freertos/CMakeLists.txt +++ b/tools/mocks/freertos/CMakeLists.txt @@ -1,10 +1,11 @@ # NOTE: This kind of mocking currently works on Linux targets only. # On Espressif chips, too many dependencies are missing at the moment. -message(STATUS "building FREERTOS MOCKS (only task and queue)") +message(STATUS "building FREERTOS MOCKS (only task, event-groups and queue)") idf_component_get_property(original_freertos_dir freertos COMPONENT_OVERRIDEN_DIR) set(include_dirs + "include" "${original_freertos_dir}/FreeRTOS-Kernel/include" "${original_freertos_dir}/esp_additions/include" "${original_freertos_dir}/esp_additions/include/freertos" @@ -15,4 +16,5 @@ idf_component_mock(INCLUDE_DIRS ${include_dirs} REQUIRES esp_common MOCK_HEADER_FILES ${original_freertos_dir}/FreeRTOS-Kernel/include/freertos/task.h + ${original_freertos_dir}/FreeRTOS-Kernel/include/freertos/event_groups.h ${original_freertos_dir}/FreeRTOS-Kernel/include/freertos/queue.h) diff --git a/tools/mocks/freertos/include/FreeRTOSConfig.h b/tools/mocks/freertos/include/FreeRTOSConfig.h new file mode 100644 index 0000000000..eb1f4defe2 --- /dev/null +++ b/tools/mocks/freertos/include/FreeRTOSConfig.h @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#define STACK_OVERHEAD_CHECKER 256 +#define STACK_OVERHEAD_OPTIMIZATION 320 +#define STACK_OVERHEAD_APPTRACE 1280 +#define STACK_OVERHEAD_WATCHPOINT 60 +#define configSTACK_OVERHEAD_TOTAL ( \ + STACK_OVERHEAD_CHECKER + \ + STACK_OVERHEAD_OPTIMIZATION + \ + STACK_OVERHEAD_APPTRACE + \ + STACK_OVERHEAD_WATCHPOINT \ + ) +#define configMINIMAL_STACK_SIZE ( 768 + configSTACK_OVERHEAD_TOTAL ) +#define configMAX_PRIORITIES ( 25 ) //This has impact on speed of search for highest priority +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK CONFIG_FREERTOS_USE_IDLE_HOOK +#define configUSE_TICK_HOOK CONFIG_FREERTOS_USE_TICK_HOOK +#define configUSE_16_BIT_TICKS 0 +#define configUSE_TRACE_FACILITY 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configUSE_MUTEXES 1 +#define configUSE_RECURSIVE_MUTEXES 1 diff --git a/tools/mocks/freertos/mock/mock_config.yaml b/tools/mocks/freertos/mock/mock_config.yaml index dad1a6e2a4..9b7eab92eb 100644 --- a/tools/mocks/freertos/mock/mock_config.yaml +++ b/tools/mocks/freertos/mock/mock_config.yaml @@ -1,21 +1,22 @@ - :cmock: - :includes_h_pre_orig_header: - - FreeRTOS.h - :plugins: - - expect - - expect_any_args - - return_thru_ptr - - array - - ignore - - ignore_arg - - callback - :strippables: - - '(?:__attribute__\s*\(+.*?\)+)' - # following functions are disabled by configQUEUE_REGISTRY_SIZE - - '(?:vQueueAddToRegistry\s*\([\s\w\*_,]*\))' - - '(?:vQueueUnregisterQueue\s*\([\s\w\*_,]*\))' - - '(?:pcQueueGetName\s*\([\s\w\*_,]*\))' - # following function is disabled by configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS - - '(?:vTaskSetThreadLocalStoragePointerAndDelCallback\s*\([\s\w\*_,]*\))' - - PRIVILEGED_FUNCTION - - portDONT_DISCARD +:cmock: + :includes_h_pre_orig_header: + - FreeRTOSConfig.h + - FreeRTOS.h + :plugins: + - expect + - expect_any_args + - return_thru_ptr + - array + - ignore + - ignore_arg + - callback + :strippables: + - '(?:__attribute__\s*\(+.*?\)+)' + # following functions are disabled by configQUEUE_REGISTRY_SIZE + - '(?:vQueueAddToRegistry\s*\([\s\w\*_,]*\))' + - '(?:vQueueUnregisterQueue\s*\([\s\w\*_,]*\))' + - '(?:pcQueueGetName\s*\([\s\w\*_,]*\))' + # following function is disabled by configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS + - '(?:vTaskSetThreadLocalStoragePointerAndDelCallback\s*\([\s\w\*_,]*\))' + - PRIVILEGED_FUNCTION + - portDONT_DISCARD diff --git a/tools/mocks/http_parser/CMakeLists.txt b/tools/mocks/http_parser/CMakeLists.txt new file mode 100644 index 0000000000..7050914da3 --- /dev/null +++ b/tools/mocks/http_parser/CMakeLists.txt @@ -0,0 +1,8 @@ +# NOTE: This kind of mocking currently works on Linux targets only. +# On Espressif chips, too many dependencies are missing at the moment. +message(STATUS "building HTTP PARSER MOCKS") + +idf_component_get_property(original_http_parser_dir http_parser COMPONENT_OVERRIDEN_DIR) + +idf_component_mock(INCLUDE_DIRS "${original_http_parser_dir}" + MOCK_HEADER_FILES ${original_http_parser_dir}/http_parser.h) diff --git a/tools/mocks/http_parser/mock/mock_config.yaml b/tools/mocks/http_parser/mock/mock_config.yaml new file mode 100644 index 0000000000..1923353c61 --- /dev/null +++ b/tools/mocks/http_parser/mock/mock_config.yaml @@ -0,0 +1,9 @@ +:cmock: + :plugins: + - expect + - expect_any_args + - return_thru_ptr + - array + - ignore + - ignore_arg + - callback diff --git a/tools/mocks/lwip/CMakeLists.txt b/tools/mocks/lwip/CMakeLists.txt new file mode 100644 index 0000000000..ea9f075886 --- /dev/null +++ b/tools/mocks/lwip/CMakeLists.txt @@ -0,0 +1,10 @@ +# NOTE: This kind of mocking currently works on Linux targets only. +# On Espressif chips, too many dependencies are missing at the moment. +message(STATUS "building LWIP MOCKS (only netdb)") + +idf_component_get_property(original_lwip_dir lwip COMPONENT_OVERRIDEN_DIR) + +idf_component_mock(INCLUDE_DIRS "${original_lwip_dir}/port" + "${original_lwip_dir}/include/lwip" + "${original_lwip_dir}/lwip/src/include" + MOCK_HEADER_FILES ${original_lwip_dir}/lwip/src/include/lwip/netdb.h ) diff --git a/tools/mocks/lwip/mock/mock_config.yaml b/tools/mocks/lwip/mock/mock_config.yaml new file mode 100644 index 0000000000..596255b0ce --- /dev/null +++ b/tools/mocks/lwip/mock/mock_config.yaml @@ -0,0 +1,9 @@ + :cmock: + :plugins: + - expect + - expect_any_args + - return_thru_ptr + - array + - ignore + - ignore_arg + - callback diff --git a/tools/mocks/tcp_transport/CMakeLists.txt b/tools/mocks/tcp_transport/CMakeLists.txt new file mode 100644 index 0000000000..9ff6b93510 --- /dev/null +++ b/tools/mocks/tcp_transport/CMakeLists.txt @@ -0,0 +1,13 @@ +# NOTE: This kind of mocking currently works on Linux targets only. +# On Espressif chips, too many dependencies are missing at the moment. +message(STATUS "building TCP TRANSPORT MOCKS") + +idf_component_get_property(original_tcp_transport_dir tcp_transport COMPONENT_OVERRIDEN_DIR) + +idf_component_mock(INCLUDE_DIRS "${original_tcp_transport_dir}/include" + MOCK_HEADER_FILES ${original_tcp_transport_dir}/include/esp_transport.h + ${original_tcp_transport_dir}/include/esp_transport_tcp.h + ${original_tcp_transport_dir}/include/esp_transport_ssl.h + ${original_tcp_transport_dir}/include/esp_transport_ws.h + REQUIRES esp-tls + ) diff --git a/tools/mocks/tcp_transport/mock/mock_config.yaml b/tools/mocks/tcp_transport/mock/mock_config.yaml new file mode 100644 index 0000000000..fcf2722bc1 --- /dev/null +++ b/tools/mocks/tcp_transport/mock/mock_config.yaml @@ -0,0 +1,9 @@ +:cmock: + :plugins: + - expect + - expect_any_args + - return_thru_ptr + - ignore + - ignore_arg + - callback + :when_ptr: :compare_ptr