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;