diff --git a/components/esp_event/host_test/.build-test-rules.yml b/components/esp_event/host_test/.build-test-rules.yml new file mode 100644 index 0000000000..c4369d5869 --- /dev/null +++ b/components/esp_event/host_test/.build-test-rules.yml @@ -0,0 +1,3 @@ +components/esp_event/host_test: + enable: + - if: IDF_TARGET == "linux" diff --git a/components/esp_event/host_test/esp_event_unit_test/main/CMakeLists.txt b/components/esp_event/host_test/esp_event_unit_test/main/CMakeLists.txt index e118569643..0ee0e7d59c 100644 --- a/components/esp_event/host_test/esp_event_unit_test/main/CMakeLists.txt +++ b/components/esp_event/host_test/esp_event_unit_test/main/CMakeLists.txt @@ -1,3 +1,8 @@ idf_component_register(SRCS "esp_event_test.cpp" - INCLUDE_DIRS "../../" $ENV{IDF_PATH}/tools/catch - REQUIRES esp_event cmock) + INCLUDE_DIRS "../../" + REQUIRES esp_event cmock + WHOLE_ARCHIVE) + +# Currently 'main' for IDF_TARGET=linux is defined in freertos component. +# Since we are using a freertos mock here, need to let Catch2 provide 'main'. +target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain) diff --git a/components/esp_event/host_test/esp_event_unit_test/main/esp_event_test.cpp b/components/esp_event/host_test/esp_event_unit_test/main/esp_event_test.cpp index 16c2c590c5..524a3e5e46 100644 --- a/components/esp_event/host_test/esp_event_unit_test/main/esp_event_test.cpp +++ b/components/esp_event/host_test/esp_event_unit_test/main/esp_event_test.cpp @@ -7,12 +7,11 @@ CONDITIONS OF ANY KIND, either express or implied. */ -#define CATCH_CONFIG_MAIN #include #include "esp_event.h" -#include "catch.hpp" +#include #include "fixtures.hpp" diff --git a/components/esp_event/host_test/esp_event_unit_test/main/idf_component.yml b/components/esp_event/host_test/esp_event_unit_test/main/idf_component.yml new file mode 100644 index 0000000000..f7982136b9 --- /dev/null +++ b/components/esp_event/host_test/esp_event_unit_test/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/catch2: "^3.4.0" diff --git a/components/esp_event/host_test/fixtures.hpp b/components/esp_event/host_test/fixtures.hpp index 0ae8ef4780..24c4bfbe04 100644 --- a/components/esp_event/host_test/fixtures.hpp +++ b/components/esp_event/host_test/fixtures.hpp @@ -9,11 +9,12 @@ #include "esp_event.h" -#include "catch.hpp" +#include extern "C" { #include "Mocktask.h" #include "Mockqueue.h" +#include "Mockidf_additions.h" } /** @@ -129,11 +130,11 @@ struct MockTask : public CMockFix { xTaskCreatePinnedToCore_ExpectAnyArgsAndReturn(pdFALSE); } else if (flags == CreateAnd::IGNORE) { xTaskCreatePinnedToCore_IgnoreAndReturn(pdTRUE); - xTaskCreatePinnedToCore_ReturnThruPtr_pvCreatedTask(&task); + xTaskCreatePinnedToCore_ReturnThruPtr_pxCreatedTask(&task); vTaskDelete_Ignore(); } else { xTaskCreatePinnedToCore_ExpectAnyArgsAndReturn(pdTRUE); - xTaskCreatePinnedToCore_ReturnThruPtr_pvCreatedTask(&task); + xTaskCreatePinnedToCore_ReturnThruPtr_pxCreatedTask(&task); vTaskDelete_Expect(task); } } diff --git a/components/esp_rom/test_apps/.build-test-rules.yml b/components/esp_rom/test_apps/.build-test-rules.yml index 15492a369e..1eb663e797 100644 --- a/components/esp_rom/test_apps/.build-test-rules.yml +++ b/components/esp_rom/test_apps/.build-test-rules.yml @@ -1,6 +1,10 @@ # Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps -components/esp_rom/test_apps: +components/esp_rom/test_apps/linux_rom_apis: + enable: + - if: IDF_TARGET == "linux" + +components/esp_rom/test_apps/rom_tests: disable_test: - if: IDF_TARGET in ["esp32", "esp32c2"] temporary: false diff --git a/components/esp_rom/test_apps/linux_rom_apis/main/CMakeLists.txt b/components/esp_rom/test_apps/linux_rom_apis/main/CMakeLists.txt index f0f082fde3..baaac73170 100644 --- a/components/esp_rom/test_apps/linux_rom_apis/main/CMakeLists.txt +++ b/components/esp_rom/test_apps/linux_rom_apis/main/CMakeLists.txt @@ -1,5 +1,8 @@ idf_component_register(SRCS "rom_test.cpp" - INCLUDE_DIRS - "." - $ENV{IDF_PATH}/tools/catch - REQUIRES esp_rom) + INCLUDE_DIRS "." + REQUIRES esp_rom + WHOLE_ARCHIVE) + +# Currently 'main' for IDF_TARGET=linux is defined in freertos component. +# Since we are using a freertos mock here, need to let Catch2 provide 'main'. +target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain) diff --git a/components/esp_rom/test_apps/linux_rom_apis/main/idf_component.yml b/components/esp_rom/test_apps/linux_rom_apis/main/idf_component.yml new file mode 100644 index 0000000000..f7982136b9 --- /dev/null +++ b/components/esp_rom/test_apps/linux_rom_apis/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/catch2: "^3.4.0" diff --git a/components/esp_rom/test_apps/linux_rom_apis/main/rom_test.cpp b/components/esp_rom/test_apps/linux_rom_apis/main/rom_test.cpp index 664f8a6548..96654d8443 100644 --- a/components/esp_rom/test_apps/linux_rom_apis/main/rom_test.cpp +++ b/components/esp_rom/test_apps/linux_rom_apis/main/rom_test.cpp @@ -15,7 +15,6 @@ Note that the printf function is roughly tested in the log host test. */ -#define CATCH_CONFIG_MAIN #include #include #include @@ -24,12 +23,10 @@ #include "esp_rom_crc.h" #include "esp_rom_md5.h" -#include "catch.hpp" +#include using namespace std; -static const char *TEST_TAG = "test"; - // ESP_LOG_EARLY functions are tested in the log host tests and also test rom printf. TEST_CASE("esp_rom printf returns correct char num") { diff --git a/components/fatfs/host_test/.build-test-rules.yml b/components/fatfs/host_test/.build-test-rules.yml new file mode 100644 index 0000000000..668da2d320 --- /dev/null +++ b/components/fatfs/host_test/.build-test-rules.yml @@ -0,0 +1,3 @@ +components/fatfs/host_test: + enable: + - if: IDF_TARGET == "linux" diff --git a/components/fatfs/host_test/CMakeLists.txt b/components/fatfs/host_test/CMakeLists.txt index 48267da8d3..7bf861b1b9 100644 --- a/components/fatfs/host_test/CMakeLists.txt +++ b/components/fatfs/host_test/CMakeLists.txt @@ -2,9 +2,7 @@ cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(COMPONENTS main) -# Freertos is included via common components. However, CATCH isn't compatible with the FreeRTOS component yet, hence -# using the FreeRTOS mock component. -# target. +# This test doesn't require FreeRTOS, uses a mock instead list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") project(fatfs_host_test) diff --git a/components/fatfs/host_test/main/CMakeLists.txt b/components/fatfs/host_test/main/CMakeLists.txt index ef8aeb43db..046433c130 100644 --- a/components/fatfs/host_test/main/CMakeLists.txt +++ b/components/fatfs/host_test/main/CMakeLists.txt @@ -1,6 +1,8 @@ -idf_component_register(SRCS "main.cpp" - "test_fatfs.cpp" - INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch" +idf_component_register(SRCS "test_fatfs.cpp" REQUIRES fatfs WHOLE_ARCHIVE ) + +# Currently 'main' for IDF_TARGET=linux is defined in freertos component. +# Since we are using a freertos mock here, need to let Catch2 provide 'main'. +target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain) diff --git a/components/fatfs/host_test/main/idf_component.yml b/components/fatfs/host_test/main/idf_component.yml new file mode 100644 index 0000000000..f7982136b9 --- /dev/null +++ b/components/fatfs/host_test/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/catch2: "^3.4.0" diff --git a/components/fatfs/host_test/main/main.cpp b/components/fatfs/host_test/main/main.cpp deleted file mode 100644 index cd66dc3083..0000000000 --- a/components/fatfs/host_test/main/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#define CATCH_CONFIG_MAIN -#include "catch.hpp" diff --git a/components/fatfs/host_test/main/test_fatfs.cpp b/components/fatfs/host_test/main/test_fatfs.cpp index 77af2e705a..5ceb732757 100644 --- a/components/fatfs/host_test/main/test_fatfs.cpp +++ b/components/fatfs/host_test/main/test_fatfs.cpp @@ -12,7 +12,7 @@ #include "diskio_impl.h" #include "diskio_wl.h" -#include "catch.hpp" +#include TEST_CASE("Create volume, open file, write and read back data", "[fatfs]") { @@ -158,7 +158,6 @@ TEST_CASE("Test mounting 2 volumes, writing data and formating the 2nd one, read FATFS fs1; wl_handle_t wl_handle1 = WL_INVALID_HANDLE; - size_t allocation_unit_size = CONFIG_WL_SECTOR_SIZE; size_t data_size = 10; diff --git a/components/log/host_test/log_test/main/CMakeLists.txt b/components/log/host_test/log_test/main/CMakeLists.txt index e1f4369f20..20b0d42435 100644 --- a/components/log/host_test/log_test/main/CMakeLists.txt +++ b/components/log/host_test/log_test/main/CMakeLists.txt @@ -1,5 +1,8 @@ idf_component_register(SRCS "log_test.cpp" - INCLUDE_DIRS - "." - $ENV{IDF_PATH}/tools/catch - REQUIRES log) + INCLUDE_DIRS "." + REQUIRES log + WHOLE_ARCHIVE) + +# Currently 'main' for IDF_TARGET=linux is defined in freertos component. +# Since we are using a freertos mock here, need to let Catch2 provide 'main'. +target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain) diff --git a/components/log/host_test/log_test/main/idf_component.yml b/components/log/host_test/log_test/main/idf_component.yml new file mode 100644 index 0000000000..f7982136b9 --- /dev/null +++ b/components/log/host_test/log_test/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/catch2: "^3.4.0" diff --git a/components/log/host_test/log_test/main/log_test.cpp b/components/log/host_test/log_test/main/log_test.cpp index a4befc9a24..40da7d3763 100644 --- a/components/log/host_test/log_test/main/log_test.cpp +++ b/components/log/host_test/log_test/main/log_test.cpp @@ -6,13 +6,12 @@ software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ -#define CATCH_CONFIG_MAIN #include #include #include #include "esp_log.h" -#include "catch.hpp" +#include using namespace std; diff --git a/components/nvs_flash/host_test/nvs_host_test/CMakeLists.txt b/components/nvs_flash/host_test/nvs_host_test/CMakeLists.txt index cd3f3ebece..658d311f49 100644 --- a/components/nvs_flash/host_test/nvs_host_test/CMakeLists.txt +++ b/components/nvs_flash/host_test/nvs_host_test/CMakeLists.txt @@ -2,9 +2,7 @@ cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(COMPONENTS main) -# Freertos is included via common components. However, CATCH isn't compatible with the FreeRTOS component yet, hence -# using the FreeRTOS mock component. -# target. +# This test app doesn't require FreeRTOS, using mock instead list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") project(nvs_host_test) diff --git a/components/nvs_flash/host_test/nvs_host_test/main/CMakeLists.txt b/components/nvs_flash/host_test/nvs_host_test/main/CMakeLists.txt index 508bfa0e17..534f968c53 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/CMakeLists.txt +++ b/components/nvs_flash/host_test/nvs_host_test/main/CMakeLists.txt @@ -1,5 +1,4 @@ -idf_component_register(SRCS "main.cpp" - "test_nvs.cpp" +idf_component_register(SRCS "test_nvs.cpp" "test_partition_manager.cpp" "test_nvs_cxx_api.cpp" "test_nvs_handle.cpp" @@ -9,10 +8,13 @@ idf_component_register(SRCS "main.cpp" "../../../src" "../../../private_include" "../../../../mbedtls/mbedtls/include" - "../../../../../tools/catch" WHOLE_ARCHIVE REQUIRES nvs_flash) if(CMAKE_C_COMPILER_ID MATCHES "Clang") target_compile_options(${COMPONENT_LIB} PRIVATE -std=gnu++20) endif() + +# Currently 'main' for IDF_TARGET=linux is defined in freertos component. +# Since we are using a freertos mock here, need to let Catch2 provide 'main'. +target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain) diff --git a/components/nvs_flash/host_test/nvs_host_test/main/idf_component.yml b/components/nvs_flash/host_test/nvs_host_test/main/idf_component.yml new file mode 100644 index 0000000000..f7982136b9 --- /dev/null +++ b/components/nvs_flash/host_test/nvs_host_test/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/catch2: "^3.4.0" diff --git a/components/nvs_flash/host_test/nvs_host_test/main/main.cpp b/components/nvs_flash/host_test/nvs_host_test/main/main.cpp deleted file mode 100644 index dddf85b1d5..0000000000 --- a/components/nvs_flash/host_test/nvs_host_test/main/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#define CATCH_CONFIG_MAIN -#include "catch.hpp" diff --git a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs.cpp b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs.cpp index 44a9f44a9c..413558a956 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs.cpp +++ b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs.cpp @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "catch.hpp" +#include #include "nvs.hpp" #include "sdkconfig.h" #include "nvs_partition_manager.hpp" @@ -383,7 +383,6 @@ TEST_CASE("storage can find items on second page if first is not fully written a PartitionEmulationFixture f(0, 3); nvs::Storage storage(f.part()); TEST_ESP_OK(storage.init(0, 3)); - int bar = 0; uint8_t bigdata[(nvs::Page::CHUNK_MAX_SIZE - nvs::Page::ENTRY_SIZE) / 2] = {0}; // write one big chunk of data ESP_ERROR_CHECK(storage.writeItem(0, nvs::ItemType::BLOB, "1", bigdata, sizeof(bigdata))); @@ -635,8 +634,6 @@ TEST_CASE("deinit partition doesn't affect other partition's open handles", "[nv const char *OTHER_PARTITION_NAME = "other_part"; PartitionEmulationFixture f(0, 10); PartitionEmulationFixture f_other(0, 10, OTHER_PARTITION_NAME); - const char *str = "value 0123456789abcdef0123456789abcdef"; - const uint8_t blob[8] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7}; nvs_handle_t handle_1; const uint32_t NVS_FLASH_SECTOR = 6; @@ -696,7 +693,6 @@ TEST_CASE("nvs_entry_info fails with ESP_ERR_INVALID_ARG if a parameter is NULL" TEST_CASE("nvs_entry_info doesn't change iterator on parameter error", "[nvs]") { nvs_iterator_t it = reinterpret_cast(0xbeef); - nvs_entry_info_t info; REQUIRE(nvs_entry_info(it, nullptr) == ESP_ERR_INVALID_ARG); CHECK(it == reinterpret_cast(0xbeef)); @@ -1001,8 +997,8 @@ TEST_CASE("wifi test", "[nvs]") TEST_ESP_OK(nvs_set_u8(net80211_handle, "wifi.opmode", opmode)); uint8_t country = 0; - TEST_ESP_ERR(nvs_get_u8(net80211_handle, "wifi.country", &opmode), ESP_ERR_NVS_NOT_FOUND); - TEST_ESP_OK(nvs_set_u8(net80211_handle, "wifi.country", opmode)); + TEST_ESP_ERR(nvs_get_u8(net80211_handle, "wifi.country", &country), ESP_ERR_NVS_NOT_FOUND); + TEST_ESP_OK(nvs_set_u8(net80211_handle, "wifi.country", country)); char ssid[36]; size_t size = sizeof(ssid); @@ -1330,7 +1326,6 @@ public: case nvs::ItemType::SZ: { char buf[strBufLen]; - size_t len = strBufLen; size_t strLen = gen() % (strBufLen - 1); std::generate_n(buf, strLen, [&]() -> char { @@ -1896,8 +1891,6 @@ TEST_CASE("Check that orphaned blobs are erased during init", "[nvs]") { const size_t blob_size = nvs::Page::CHUNK_MAX_SIZE * 3 ; uint8_t blob[blob_size] = {0x11}; - uint8_t blob2[blob_size] = {0x22}; - uint8_t blob3[blob_size] = {0x33}; PartitionEmulationFixture f(0, 5); nvs::Storage storage(f.part()); @@ -2807,7 +2800,6 @@ static void check_nvs_part_gen_args(char const *flash_binary_filename, // n char buf[64] = {0}; uint8_t hexdata[] = {0x01, 0x02, 0x03, 0xab, 0xcd, 0xef}; size_t buflen = 64; - int j; TEST_ESP_OK( nvs_get_blob(handle, "dummyHex2BinKey", buf, &buflen)); CHECK(memcmp(buf, hexdata, buflen) == 0); @@ -2876,7 +2868,6 @@ static void check_nvs_part_gen_args_mfg(char const *flash_binary_filename, // n uint8_t hexdata[] = {0x01, 0x02, 0x03, 0xab, 0xcd, 0xef}; buflen = 64; - int j; TEST_ESP_OK( nvs_get_blob(handle, "dummyHex2BinKey", buf, &buflen)); CHECK(memcmp(buf, hexdata, buflen) == 0); diff --git a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_cxx_api.cpp b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_cxx_api.cpp index 84070fa6d1..d4ebef3a35 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_cxx_api.cpp +++ b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_cxx_api.cpp @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "catch.hpp" +#include #include #include #include "nvs_handle_simple.hpp" diff --git a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_handle.cpp b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_handle.cpp index 6c6e35e1d1..dae567d446 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_handle.cpp +++ b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_handle.cpp @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "catch.hpp" +#include #include #include #include "nvs_handle_simple.hpp" diff --git a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_initialization.cpp b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_initialization.cpp index 2482129535..cd52f19a81 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_initialization.cpp +++ b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_initialization.cpp @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "catch.hpp" +#include #include "nvs.hpp" #include "nvs_partition_manager.hpp" #include "nvs_partition.hpp" @@ -12,8 +12,6 @@ TEST_CASE("nvs_flash_init_partition_ptr fails due to nullptr arg", "[nvs_custom_part]") { - const uint32_t NVS_FLASH_SECTOR = 6; - const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 3; uint8_t *p_part_desc_addr_start; CHECK(esp_partition_file_mmap((const uint8_t **)&p_part_desc_addr_start) == ESP_OK); diff --git a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_storage.cpp b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_storage.cpp index 7e19ce7d5d..769c661260 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_storage.cpp +++ b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_storage.cpp @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "catch.hpp" +#include #include #include "nvs_storage.hpp" #include "nvs_partition_manager.hpp" diff --git a/components/nvs_flash/host_test/nvs_host_test/main/test_partition_manager.cpp b/components/nvs_flash/host_test/nvs_host_test/main/test_partition_manager.cpp index 04989df2d0..4c995eaeec 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/test_partition_manager.cpp +++ b/components/nvs_flash/host_test/nvs_host_test/main/test_partition_manager.cpp @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "catch.hpp" +#include #include #include #include "nvs_handle_simple.hpp" diff --git a/components/tcp_transport/host_test/main/CMakeLists.txt b/components/tcp_transport/host_test/main/CMakeLists.txt index acceea9548..561a14335b 100644 --- a/components/tcp_transport/host_test/main/CMakeLists.txt +++ b/components/tcp_transport/host_test/main/CMakeLists.txt @@ -1,4 +1,4 @@ -idf_component_register(SRCS "test_socks_transport.cpp" "catch_main.cpp" +idf_component_register(SRCS "test_socks_transport.cpp" REQUIRES tcp_transport mocked_transport INCLUDE_DIRS "$ENV{IDF_PATH}/tools" WHOLE_ARCHIVE) @@ -9,4 +9,7 @@ idf_component_get_property(tcp_transport_component tcp_transport COMPONENT_LIB) target_link_libraries(${tcp_transport_component} PUBLIC ${lwip_component} ${esp_timer_component}) target_compile_options(${COMPONENT_LIB} PUBLIC -fsanitize=address -fconcepts) target_link_options(${COMPONENT_LIB} PUBLIC -fsanitize=address) -set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 20) + +# Currently 'main' for IDF_TARGET=linux is defined in freertos component. +# Since we are using a freertos mock here, need to let Catch2 provide 'main'. +target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain) diff --git a/components/tcp_transport/host_test/main/catch_main.cpp b/components/tcp_transport/host_test/main/catch_main.cpp deleted file mode 100644 index eda0c3afe6..0000000000 --- a/components/tcp_transport/host_test/main/catch_main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#define CATCH_CONFIG_MAIN -#include "catch/catch.hpp" diff --git a/components/tcp_transport/host_test/main/idf_component.yml b/components/tcp_transport/host_test/main/idf_component.yml index 7bad6ab6b4..77ad273fe3 100644 --- a/components/tcp_transport/host_test/main/idf_component.yml +++ b/components/tcp_transport/host_test/main/idf_component.yml @@ -1,4 +1,3 @@ dependencies: espressif/fmt: "^9.1.0" - idf: - version: ">=4.1.0" + espressif/catch2: "^3.4.0" diff --git a/components/tcp_transport/host_test/main/test_socks_transport.cpp b/components/tcp_transport/host_test/main/test_socks_transport.cpp index fbd7f15128..c2a09b2d16 100644 --- a/components/tcp_transport/host_test/main/test_socks_transport.cpp +++ b/components/tcp_transport/host_test/main/test_socks_transport.cpp @@ -16,7 +16,8 @@ #include #include "fmt/core.h" #include "fmt/ranges.h" -#include "catch/catch.hpp" +#include +#include #include "esp_transport.h" #include "esp_transport_socks_proxy.h" diff --git a/components/wear_levelling/host_test/CMakeLists.txt b/components/wear_levelling/host_test/CMakeLists.txt index a40e7fc5b6..fbc5730131 100644 --- a/components/wear_levelling/host_test/CMakeLists.txt +++ b/components/wear_levelling/host_test/CMakeLists.txt @@ -2,9 +2,7 @@ cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(COMPONENTS main) -# Freertos is included via common components. However, CATCH isn't compatible with the FreeRTOS component yet, hence -# using the FreeRTOS mock component. -# target. +# This test app doesn't require FreeRTOS, using mock instead list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") project(wear_levelling_host_test) diff --git a/components/wear_levelling/host_test/main/CMakeLists.txt b/components/wear_levelling/host_test/main/CMakeLists.txt index 92fb22c7bd..51cd93762e 100644 --- a/components/wear_levelling/host_test/main/CMakeLists.txt +++ b/components/wear_levelling/host_test/main/CMakeLists.txt @@ -1,8 +1,10 @@ -idf_component_register(SRCS "main.cpp" - "test_wl.cpp" - INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch" +idf_component_register(SRCS "test_wl.cpp" PRIV_INCLUDE_DIRS "../../private_include" "../.." REQUIRES wear_levelling WHOLE_ARCHIVE ) + +# Currently 'main' for IDF_TARGET=linux is defined in freertos component. +# Since we are using a freertos mock here, need to let Catch2 provide 'main'. +target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain) diff --git a/components/wear_levelling/host_test/main/esp_error_check_stub.cpp b/components/wear_levelling/host_test/main/esp_error_check_stub.cpp deleted file mode 100644 index fe407ad079..0000000000 --- a/components/wear_levelling/host_test/main/esp_error_check_stub.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#include "catch.hpp" -#include "esp_err.h" -#include "sdkconfig.h" - -void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) -{ - printf("ESP_ERROR_CHECK failed: esp_err_t 0x%x", rc); -#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP - printf(" (%s)", esp_err_to_name(rc)); -#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP - printf(" at %p\n", __builtin_return_address(0)); - printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression); - abort(); -} diff --git a/components/wear_levelling/host_test/main/idf_component.yml b/components/wear_levelling/host_test/main/idf_component.yml new file mode 100644 index 0000000000..f7982136b9 --- /dev/null +++ b/components/wear_levelling/host_test/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/catch2: "^3.4.0" diff --git a/components/wear_levelling/host_test/main/main.cpp b/components/wear_levelling/host_test/main/main.cpp deleted file mode 100644 index 42286b7501..0000000000 --- a/components/wear_levelling/host_test/main/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#define CATCH_CONFIG_MAIN -#include "catch.hpp" diff --git a/components/wear_levelling/host_test/main/test_wl.cpp b/components/wear_levelling/host_test/main/test_wl.cpp index 4b25b99c65..ebf23830a0 100644 --- a/components/wear_levelling/host_test/main/test_wl.cpp +++ b/components/wear_levelling/host_test/main/test_wl.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2016-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -15,7 +15,7 @@ #include "crc32.h" -#include "catch.hpp" +#include #include "sdkconfig.h" @@ -34,7 +34,6 @@ TEST_CASE("write and read back data", "[wear_levelling]") esp_err_t result; wl_handle_t wl_handle; - int flash_handle; const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "storage"); // Mount wear-levelled partition @@ -105,7 +104,6 @@ TEST_CASE("power down test", "[wear_levelling]") esp_err_t result; wl_handle_t wl_handle; - int flash_handle; const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "storage"); // Disable power down failure counting @@ -295,7 +293,6 @@ TEST_CASE("power down during WL status 1 update", "[wear_levelling]") esp_err_t result; wl_handle_t wl_handle; - int flash_handle; const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "storage"); size_t offset_state_1, offset_state_2, size_state = 0; @@ -339,7 +336,6 @@ TEST_CASE("power down during WL status 2 update", "[wear_levelling]") esp_err_t result; wl_handle_t wl_handle; - int flash_handle; const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "storage"); size_t offset_state_1, offset_state_2, size_state = 0; @@ -383,7 +379,6 @@ TEST_CASE("power down between WL status 1 and WL status 2 update", "[wear_levell esp_err_t result; wl_handle_t wl_handle; - int flash_handle; const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "storage"); size_t offset_state_1, offset_state_2, size_state = 0; diff --git a/tools/ci/ignore_build_warnings.txt b/tools/ci/ignore_build_warnings.txt index d38647094a..7a7a2cf3d4 100644 --- a/tools/ci/ignore_build_warnings.txt +++ b/tools/ci/ignore_build_warnings.txt @@ -40,6 +40,7 @@ warning: unknown kconfig symbol 'ESPTOOLPY_FLASHSIZE_4MB' assigned to 'y' in /bu warning: unknown kconfig symbol 'ESPTOOLPY_FLASHSIZE' assigned to '"4MB"' in /builds/espressif/esp-idf/components/esp_partition/host_test/partition_api_test/sdkconfig.defaults warning: unknown kconfig symbol 'ESPTOOLPY_FLASHSIZE' assigned to '"4MB"' in /builds/espressif/esp-idf/components/spiffs/host_test/sdkconfig.defaults warning: unknown kconfig symbol 'ESPTOOLPY_FLASHSIZE' assigned to '"8MB"' in /builds/espressif/esp-idf/components/wear_levelling/host_test/sdkconfig.defaults +warning: unknown kconfig symbol 'ESPTOOLPY_FLASHSIZE' assigned to '"8MB"' in /builds/espressif/esp-idf/components/fatfs/host_test/sdkconfig.defaults warning: unknown kconfig symbol 'ESPTOOLPY_MONITOR_BAUD_921600B' assigned to 'y' in /builds/espressif/esp-idf/examples/bluetooth/esp_ble_mesh/vendor_models/* warning: unknown kconfig symbol 'FMB_TIMER_GROUP' assigned to '0' in /builds/espressif/esp-idf/examples/protocols/modbus/tcp/* warning: unknown kconfig symbol 'FMB_TIMER_INDEX' assigned to '0' in /builds/espressif/esp-idf/examples/protocols/modbus/tcp/*