mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
[MQTT] Simplifies MQTT CMakeLists file
- Uses mocks from tools instead of creating them. - Move host based definition to test code.
This commit is contained in:
parent
dd441ef713
commit
736424c366
@ -7,122 +7,7 @@ endif()
|
|||||||
idf_component_register(SRCS "${srcs}"
|
idf_component_register(SRCS "${srcs}"
|
||||||
INCLUDE_DIRS esp-mqtt/include
|
INCLUDE_DIRS esp-mqtt/include
|
||||||
PRIV_INCLUDE_DIRS "esp-mqtt/lib/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")
|
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()
|
|
||||||
|
@ -2,9 +2,15 @@ cmake_minimum_required(VERSION 3.16)
|
|||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
set(COMPONENTS main)
|
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_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)
|
project(host_mqtt_client_test)
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
idf_component_register(SRCS "test_mqtt_client.cpp"
|
idf_component_register(SRCS "test_mqtt_client.cpp"
|
||||||
INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch"
|
INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch"
|
||||||
REQUIRES cmock mqtt esp_timer)
|
REQUIRES cmock mqtt esp_timer esp_hw_support http_parser log)
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "Mockesp_event.h"
|
#include "Mockesp_event.h"
|
||||||
#include "Mockesp_log.h"
|
|
||||||
#include "Mockesp_mac.h"
|
#include "Mockesp_mac.h"
|
||||||
#include "Mockesp_transport.h"
|
#include "Mockesp_transport.h"
|
||||||
#include "Mockesp_transport_ssl.h"
|
#include "Mockesp_transport_ssl.h"
|
||||||
@ -37,14 +36,12 @@ struct ClientInitializedFixture {
|
|||||||
int transport;
|
int transport;
|
||||||
int event_group;
|
int event_group;
|
||||||
uint8_t mac[] = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55};
|
uint8_t mac[] = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55};
|
||||||
esp_log_write_Ignore();
|
|
||||||
esp_timer_get_time_IgnoreAndReturn(0);
|
esp_timer_get_time_IgnoreAndReturn(0);
|
||||||
xQueueTakeMutexRecursive_IgnoreAndReturn(true);
|
xQueueTakeMutexRecursive_IgnoreAndReturn(true);
|
||||||
xQueueGiveMutexRecursive_IgnoreAndReturn(true);
|
xQueueGiveMutexRecursive_IgnoreAndReturn(true);
|
||||||
xQueueCreateMutex_ExpectAnyArgsAndReturn(
|
xQueueCreateMutex_ExpectAnyArgsAndReturn(
|
||||||
reinterpret_cast<QueueHandle_t>(&mtx));
|
reinterpret_cast<QueueHandle_t>(&mtx));
|
||||||
xEventGroupCreate_IgnoreAndReturn(reinterpret_cast<EventGroupHandle_t>(&event_group));
|
xEventGroupCreate_IgnoreAndReturn(reinterpret_cast<EventGroupHandle_t>(&event_group));
|
||||||
esp_log_timestamp_IgnoreAndReturn(0);
|
|
||||||
esp_transport_list_init_IgnoreAndReturn(reinterpret_cast<esp_transport_list_handle_t>(&transport_list));
|
esp_transport_list_init_IgnoreAndReturn(reinterpret_cast<esp_transport_list_handle_t>(&transport_list));
|
||||||
esp_transport_tcp_init_IgnoreAndReturn(reinterpret_cast<esp_transport_handle_t>(&transport));
|
esp_transport_tcp_init_IgnoreAndReturn(reinterpret_cast<esp_transport_handle_t>(&transport));
|
||||||
esp_transport_ssl_init_IgnoreAndReturn(reinterpret_cast<esp_transport_handle_t>(&transport));
|
esp_transport_ssl_init_IgnoreAndReturn(reinterpret_cast<esp_transport_handle_t>(&transport));
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
#define configUSE_TRACE_FACILITY 1
|
|
@ -104,4 +104,5 @@ TEST_CASE("mqtt broker tests", "[mqtt][test_env=UT_T2_Ethernet]")
|
|||||||
|
|
||||||
connect_test_fixture_teardown();
|
connect_test_fixture_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SOC_EMAC_SUPPORTED
|
#endif // SOC_EMAC_SUPPORTED
|
||||||
|
@ -1,22 +1,15 @@
|
|||||||
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// 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.
|
|
||||||
|
|
||||||
#ifndef _ESP_TRANSPORT_TCP_H_
|
#ifndef _ESP_TRANSPORT_TCP_H_
|
||||||
#define _ESP_TRANSPORT_TCP_H_
|
#define _ESP_TRANSPORT_TCP_H_
|
||||||
|
|
||||||
#include "esp_transport.h"
|
#include "esp_transport.h"
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -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_out_of_bounds_write.c
|
||||||
components/spi_flash/test/test_partition_ext.c
|
components/spi_flash/test/test_partition_ext.c
|
||||||
components/spi_flash/test/test_spi_flash.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/include/esp_transport_ws.h
|
||||||
components/tcp_transport/test/tcp_transport_fixtures.h
|
components/tcp_transport/test/tcp_transport_fixtures.h
|
||||||
components/tcp_transport/test/test_transport_basic.c
|
components/tcp_transport/test/test_transport_basic.c
|
||||||
|
12
tools/mocks/esp-tls/CMakeLists.txt
Normal file
12
tools/mocks/esp-tls/CMakeLists.txt
Normal file
@ -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)
|
16
tools/mocks/esp-tls/mock/mock_config.yaml
Normal file
16
tools/mocks/esp-tls/mock/mock_config.yaml
Normal file
@ -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*\(+.*?\)+)'
|
10
tools/mocks/esp_event/CMakeLists.txt
Normal file
10
tools/mocks/esp_event/CMakeLists.txt
Normal file
@ -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
|
||||||
|
)
|
9
tools/mocks/esp_event/mock/mock_config.yaml
Normal file
9
tools/mocks/esp_event/mock/mock_config.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
:cmock:
|
||||||
|
:plugins:
|
||||||
|
- expect
|
||||||
|
- expect_any_args
|
||||||
|
- return_thru_ptr
|
||||||
|
- array
|
||||||
|
- ignore
|
||||||
|
- ignore_arg
|
||||||
|
- callback
|
10
tools/mocks/esp_hw_support/CMakeLists.txt
Normal file
10
tools/mocks/esp_hw_support/CMakeLists.txt
Normal file
@ -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
|
||||||
|
)
|
7
tools/mocks/esp_hw_support/mock/mock_config.yaml
Normal file
7
tools/mocks/esp_hw_support/mock/mock_config.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
:cmock:
|
||||||
|
:plugins:
|
||||||
|
- expect
|
||||||
|
- expect_any_args
|
||||||
|
- ignore
|
||||||
|
- ignore_arg
|
||||||
|
- return_thru_ptr
|
@ -1,10 +1,11 @@
|
|||||||
# NOTE: This kind of mocking currently works on Linux targets only.
|
# NOTE: This kind of mocking currently works on Linux targets only.
|
||||||
# On Espressif chips, too many dependencies are missing at the moment.
|
# 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)
|
idf_component_get_property(original_freertos_dir freertos COMPONENT_OVERRIDEN_DIR)
|
||||||
|
|
||||||
set(include_dirs
|
set(include_dirs
|
||||||
|
"include"
|
||||||
"${original_freertos_dir}/FreeRTOS-Kernel/include"
|
"${original_freertos_dir}/FreeRTOS-Kernel/include"
|
||||||
"${original_freertos_dir}/esp_additions/include"
|
"${original_freertos_dir}/esp_additions/include"
|
||||||
"${original_freertos_dir}/esp_additions/include/freertos"
|
"${original_freertos_dir}/esp_additions/include/freertos"
|
||||||
@ -15,4 +16,5 @@ idf_component_mock(INCLUDE_DIRS ${include_dirs}
|
|||||||
REQUIRES esp_common
|
REQUIRES esp_common
|
||||||
MOCK_HEADER_FILES
|
MOCK_HEADER_FILES
|
||||||
${original_freertos_dir}/FreeRTOS-Kernel/include/freertos/task.h
|
${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)
|
${original_freertos_dir}/FreeRTOS-Kernel/include/freertos/queue.h)
|
||||||
|
25
tools/mocks/freertos/include/FreeRTOSConfig.h
Normal file
25
tools/mocks/freertos/include/FreeRTOSConfig.h
Normal file
@ -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
|
@ -1,5 +1,6 @@
|
|||||||
:cmock:
|
:cmock:
|
||||||
:includes_h_pre_orig_header:
|
:includes_h_pre_orig_header:
|
||||||
|
- FreeRTOSConfig.h
|
||||||
- FreeRTOS.h
|
- FreeRTOS.h
|
||||||
:plugins:
|
:plugins:
|
||||||
- expect
|
- expect
|
||||||
|
8
tools/mocks/http_parser/CMakeLists.txt
Normal file
8
tools/mocks/http_parser/CMakeLists.txt
Normal file
@ -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)
|
9
tools/mocks/http_parser/mock/mock_config.yaml
Normal file
9
tools/mocks/http_parser/mock/mock_config.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
:cmock:
|
||||||
|
:plugins:
|
||||||
|
- expect
|
||||||
|
- expect_any_args
|
||||||
|
- return_thru_ptr
|
||||||
|
- array
|
||||||
|
- ignore
|
||||||
|
- ignore_arg
|
||||||
|
- callback
|
10
tools/mocks/lwip/CMakeLists.txt
Normal file
10
tools/mocks/lwip/CMakeLists.txt
Normal file
@ -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 )
|
9
tools/mocks/lwip/mock/mock_config.yaml
Normal file
9
tools/mocks/lwip/mock/mock_config.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
:cmock:
|
||||||
|
:plugins:
|
||||||
|
- expect
|
||||||
|
- expect_any_args
|
||||||
|
- return_thru_ptr
|
||||||
|
- array
|
||||||
|
- ignore
|
||||||
|
- ignore_arg
|
||||||
|
- callback
|
13
tools/mocks/tcp_transport/CMakeLists.txt
Normal file
13
tools/mocks/tcp_transport/CMakeLists.txt
Normal file
@ -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
|
||||||
|
)
|
9
tools/mocks/tcp_transport/mock/mock_config.yaml
Normal file
9
tools/mocks/tcp_transport/mock/mock_config.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
:cmock:
|
||||||
|
:plugins:
|
||||||
|
- expect
|
||||||
|
- expect_any_args
|
||||||
|
- return_thru_ptr
|
||||||
|
- ignore
|
||||||
|
- ignore_arg
|
||||||
|
- callback
|
||||||
|
:when_ptr: :compare_ptr
|
Loading…
Reference in New Issue
Block a user