Merge branch 'feature/update_catch2' into 'master'

ci: upgrade host tests to use espressif/catch2 component, add missing build rules

Closes IDF-8775

See merge request espressif/esp-idf!27455
This commit is contained in:
Ivan Grokhotkov
2023-12-01 21:25:25 +08:00
39 changed files with 89 additions and 120 deletions

View File

@@ -0,0 +1,3 @@
components/esp_event/host_test:
enable:
- if: IDF_TARGET == "linux"

View File

@@ -1,3 +1,8 @@
idf_component_register(SRCS "esp_event_test.cpp" idf_component_register(SRCS "esp_event_test.cpp"
INCLUDE_DIRS "../../" $ENV{IDF_PATH}/tools/catch INCLUDE_DIRS "../../"
REQUIRES esp_event cmock) 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)

View File

@@ -7,12 +7,11 @@
CONDITIONS OF ANY KIND, either express or implied. CONDITIONS OF ANY KIND, either express or implied.
*/ */
#define CATCH_CONFIG_MAIN
#include <stdio.h> #include <stdio.h>
#include "esp_event.h" #include "esp_event.h"
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
#include "fixtures.hpp" #include "fixtures.hpp"

View File

@@ -0,0 +1,2 @@
dependencies:
espressif/catch2: "^3.4.0"

View File

@@ -9,11 +9,12 @@
#include "esp_event.h" #include "esp_event.h"
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
extern "C" { extern "C" {
#include "Mocktask.h" #include "Mocktask.h"
#include "Mockqueue.h" #include "Mockqueue.h"
#include "Mockidf_additions.h"
} }
/** /**
@@ -129,11 +130,11 @@ struct MockTask : public CMockFix {
xTaskCreatePinnedToCore_ExpectAnyArgsAndReturn(pdFALSE); xTaskCreatePinnedToCore_ExpectAnyArgsAndReturn(pdFALSE);
} else if (flags == CreateAnd::IGNORE) { } else if (flags == CreateAnd::IGNORE) {
xTaskCreatePinnedToCore_IgnoreAndReturn(pdTRUE); xTaskCreatePinnedToCore_IgnoreAndReturn(pdTRUE);
xTaskCreatePinnedToCore_ReturnThruPtr_pvCreatedTask(&task); xTaskCreatePinnedToCore_ReturnThruPtr_pxCreatedTask(&task);
vTaskDelete_Ignore(); vTaskDelete_Ignore();
} else { } else {
xTaskCreatePinnedToCore_ExpectAnyArgsAndReturn(pdTRUE); xTaskCreatePinnedToCore_ExpectAnyArgsAndReturn(pdTRUE);
xTaskCreatePinnedToCore_ReturnThruPtr_pvCreatedTask(&task); xTaskCreatePinnedToCore_ReturnThruPtr_pxCreatedTask(&task);
vTaskDelete_Expect(task); vTaskDelete_Expect(task);
} }
} }

View File

@@ -1,6 +1,10 @@
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps # 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: disable_test:
- if: IDF_TARGET in ["esp32", "esp32c2"] - if: IDF_TARGET in ["esp32", "esp32c2"]
temporary: false temporary: false

View File

@@ -1,5 +1,8 @@
idf_component_register(SRCS "rom_test.cpp" idf_component_register(SRCS "rom_test.cpp"
INCLUDE_DIRS INCLUDE_DIRS "."
"." REQUIRES esp_rom
$ENV{IDF_PATH}/tools/catch WHOLE_ARCHIVE)
REQUIRES esp_rom)
# 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)

View File

@@ -0,0 +1,2 @@
dependencies:
espressif/catch2: "^3.4.0"

View File

@@ -15,7 +15,6 @@
Note that the printf function is roughly tested in the log host test. Note that the printf function is roughly tested in the log host test.
*/ */
#define CATCH_CONFIG_MAIN
#include <cstdio> #include <cstdio>
#include <regex> #include <regex>
#include <cstring> #include <cstring>
@@ -24,12 +23,10 @@
#include "esp_rom_crc.h" #include "esp_rom_crc.h"
#include "esp_rom_md5.h" #include "esp_rom_md5.h"
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
using namespace std; 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. // 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") TEST_CASE("esp_rom printf returns correct char num")
{ {

View File

@@ -0,0 +1,3 @@
components/fatfs/host_test:
enable:
- if: IDF_TARGET == "linux"

View File

@@ -2,9 +2,7 @@ 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)
# Freertos is included via common components. However, CATCH isn't compatible with the FreeRTOS component yet, hence # This test doesn't require FreeRTOS, uses a mock instead
# using the FreeRTOS mock component.
# target.
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
project(fatfs_host_test) project(fatfs_host_test)

View File

@@ -1,6 +1,8 @@
idf_component_register(SRCS "main.cpp" idf_component_register(SRCS "test_fatfs.cpp"
"test_fatfs.cpp"
INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch"
REQUIRES fatfs REQUIRES fatfs
WHOLE_ARCHIVE 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)

View File

@@ -0,0 +1,2 @@
dependencies:
espressif/catch2: "^3.4.0"

View File

@@ -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"

View File

@@ -12,7 +12,7 @@
#include "diskio_impl.h" #include "diskio_impl.h"
#include "diskio_wl.h" #include "diskio_wl.h"
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
TEST_CASE("Create volume, open file, write and read back data", "[fatfs]") 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; FATFS fs1;
wl_handle_t wl_handle1 = WL_INVALID_HANDLE; wl_handle_t wl_handle1 = WL_INVALID_HANDLE;
size_t allocation_unit_size = CONFIG_WL_SECTOR_SIZE;
size_t data_size = 10; size_t data_size = 10;

View File

@@ -1,5 +1,8 @@
idf_component_register(SRCS "log_test.cpp" idf_component_register(SRCS "log_test.cpp"
INCLUDE_DIRS INCLUDE_DIRS "."
"." REQUIRES log
$ENV{IDF_PATH}/tools/catch WHOLE_ARCHIVE)
REQUIRES log)
# 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)

View File

@@ -0,0 +1,2 @@
dependencies:
espressif/catch2: "^3.4.0"

View File

@@ -6,13 +6,12 @@
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. CONDITIONS OF ANY KIND, either express or implied.
*/ */
#define CATCH_CONFIG_MAIN
#include <cstdio> #include <cstdio>
#include <regex> #include <regex>
#include <iostream> #include <iostream>
#include "esp_log.h" #include "esp_log.h"
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
using namespace std; using namespace std;

View File

@@ -2,9 +2,7 @@ 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)
# Freertos is included via common components. However, CATCH isn't compatible with the FreeRTOS component yet, hence # This test app doesn't require FreeRTOS, using mock instead
# using the FreeRTOS mock component.
# target.
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
project(nvs_host_test) project(nvs_host_test)

View File

@@ -1,5 +1,4 @@
idf_component_register(SRCS "main.cpp" idf_component_register(SRCS "test_nvs.cpp"
"test_nvs.cpp"
"test_partition_manager.cpp" "test_partition_manager.cpp"
"test_nvs_cxx_api.cpp" "test_nvs_cxx_api.cpp"
"test_nvs_handle.cpp" "test_nvs_handle.cpp"
@@ -9,10 +8,13 @@ idf_component_register(SRCS "main.cpp"
"../../../src" "../../../src"
"../../../private_include" "../../../private_include"
"../../../../mbedtls/mbedtls/include" "../../../../mbedtls/mbedtls/include"
"../../../../../tools/catch"
WHOLE_ARCHIVE WHOLE_ARCHIVE
REQUIRES nvs_flash) REQUIRES nvs_flash)
if(CMAKE_C_COMPILER_ID MATCHES "Clang") if(CMAKE_C_COMPILER_ID MATCHES "Clang")
target_compile_options(${COMPONENT_LIB} PRIVATE -std=gnu++20) target_compile_options(${COMPONENT_LIB} PRIVATE -std=gnu++20)
endif() 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)

View File

@@ -0,0 +1,2 @@
dependencies:
espressif/catch2: "^3.4.0"

View File

@@ -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"

View File

@@ -3,7 +3,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
#include "nvs.hpp" #include "nvs.hpp"
#include "sdkconfig.h" #include "sdkconfig.h"
#include "nvs_partition_manager.hpp" #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); PartitionEmulationFixture f(0, 3);
nvs::Storage storage(f.part()); nvs::Storage storage(f.part());
TEST_ESP_OK(storage.init(0, 3)); TEST_ESP_OK(storage.init(0, 3));
int bar = 0;
uint8_t bigdata[(nvs::Page::CHUNK_MAX_SIZE - nvs::Page::ENTRY_SIZE) / 2] = {0}; uint8_t bigdata[(nvs::Page::CHUNK_MAX_SIZE - nvs::Page::ENTRY_SIZE) / 2] = {0};
// write one big chunk of data // write one big chunk of data
ESP_ERROR_CHECK(storage.writeItem(0, nvs::ItemType::BLOB, "1", bigdata, sizeof(bigdata))); 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"; const char *OTHER_PARTITION_NAME = "other_part";
PartitionEmulationFixture f(0, 10); PartitionEmulationFixture f(0, 10);
PartitionEmulationFixture f_other(0, 10, OTHER_PARTITION_NAME); 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; nvs_handle_t handle_1;
const uint32_t NVS_FLASH_SECTOR = 6; 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]") TEST_CASE("nvs_entry_info doesn't change iterator on parameter error", "[nvs]")
{ {
nvs_iterator_t it = reinterpret_cast<nvs_iterator_t>(0xbeef); nvs_iterator_t it = reinterpret_cast<nvs_iterator_t>(0xbeef);
nvs_entry_info_t info;
REQUIRE(nvs_entry_info(it, nullptr) == ESP_ERR_INVALID_ARG); REQUIRE(nvs_entry_info(it, nullptr) == ESP_ERR_INVALID_ARG);
CHECK(it == reinterpret_cast<nvs_iterator_t>(0xbeef)); CHECK(it == reinterpret_cast<nvs_iterator_t>(0xbeef));
@@ -1001,8 +997,8 @@ TEST_CASE("wifi test", "[nvs]")
TEST_ESP_OK(nvs_set_u8(net80211_handle, "wifi.opmode", opmode)); TEST_ESP_OK(nvs_set_u8(net80211_handle, "wifi.opmode", opmode));
uint8_t country = 0; uint8_t country = 0;
TEST_ESP_ERR(nvs_get_u8(net80211_handle, "wifi.country", &opmode), ESP_ERR_NVS_NOT_FOUND); 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", opmode)); TEST_ESP_OK(nvs_set_u8(net80211_handle, "wifi.country", country));
char ssid[36]; char ssid[36];
size_t size = sizeof(ssid); size_t size = sizeof(ssid);
@@ -1330,7 +1326,6 @@ public:
case nvs::ItemType::SZ: { case nvs::ItemType::SZ: {
char buf[strBufLen]; char buf[strBufLen];
size_t len = strBufLen;
size_t strLen = gen() % (strBufLen - 1); size_t strLen = gen() % (strBufLen - 1);
std::generate_n(buf, strLen, [&]() -> char { 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 ; const size_t blob_size = nvs::Page::CHUNK_MAX_SIZE * 3 ;
uint8_t blob[blob_size] = {0x11}; uint8_t blob[blob_size] = {0x11};
uint8_t blob2[blob_size] = {0x22};
uint8_t blob3[blob_size] = {0x33};
PartitionEmulationFixture f(0, 5); PartitionEmulationFixture f(0, 5);
nvs::Storage storage(f.part()); 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}; char buf[64] = {0};
uint8_t hexdata[] = {0x01, 0x02, 0x03, 0xab, 0xcd, 0xef}; uint8_t hexdata[] = {0x01, 0x02, 0x03, 0xab, 0xcd, 0xef};
size_t buflen = 64; size_t buflen = 64;
int j;
TEST_ESP_OK( nvs_get_blob(handle, "dummyHex2BinKey", buf, &buflen)); TEST_ESP_OK( nvs_get_blob(handle, "dummyHex2BinKey", buf, &buflen));
CHECK(memcmp(buf, hexdata, buflen) == 0); 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}; uint8_t hexdata[] = {0x01, 0x02, 0x03, 0xab, 0xcd, 0xef};
buflen = 64; buflen = 64;
int j;
TEST_ESP_OK( nvs_get_blob(handle, "dummyHex2BinKey", buf, &buflen)); TEST_ESP_OK( nvs_get_blob(handle, "dummyHex2BinKey", buf, &buflen));
CHECK(memcmp(buf, hexdata, buflen) == 0); CHECK(memcmp(buf, hexdata, buflen) == 0);

View File

@@ -3,7 +3,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include "nvs_handle_simple.hpp" #include "nvs_handle_simple.hpp"

View File

@@ -3,7 +3,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include "nvs_handle_simple.hpp" #include "nvs_handle_simple.hpp"

View File

@@ -3,7 +3,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
#include "nvs.hpp" #include "nvs.hpp"
#include "nvs_partition_manager.hpp" #include "nvs_partition_manager.hpp"
#include "nvs_partition.hpp" #include "nvs_partition.hpp"
@@ -12,8 +12,6 @@
TEST_CASE("nvs_flash_init_partition_ptr fails due to nullptr arg", "[nvs_custom_part]") 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; uint8_t *p_part_desc_addr_start;
CHECK(esp_partition_file_mmap((const uint8_t **)&p_part_desc_addr_start) == ESP_OK); CHECK(esp_partition_file_mmap((const uint8_t **)&p_part_desc_addr_start) == ESP_OK);

View File

@@ -3,7 +3,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
#include <cstring> #include <cstring>
#include "nvs_storage.hpp" #include "nvs_storage.hpp"
#include "nvs_partition_manager.hpp" #include "nvs_partition_manager.hpp"

View File

@@ -3,7 +3,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include "nvs_handle_simple.hpp" #include "nvs_handle_simple.hpp"

View File

@@ -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 REQUIRES tcp_transport mocked_transport
INCLUDE_DIRS "$ENV{IDF_PATH}/tools" INCLUDE_DIRS "$ENV{IDF_PATH}/tools"
WHOLE_ARCHIVE) 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_link_libraries(${tcp_transport_component} PUBLIC ${lwip_component} ${esp_timer_component})
target_compile_options(${COMPONENT_LIB} PUBLIC -fsanitize=address -fconcepts) target_compile_options(${COMPONENT_LIB} PUBLIC -fsanitize=address -fconcepts)
target_link_options(${COMPONENT_LIB} PUBLIC -fsanitize=address) 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)

View File

@@ -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"

View File

@@ -1,4 +1,3 @@
dependencies: dependencies:
espressif/fmt: "^9.1.0" espressif/fmt: "^9.1.0"
idf: espressif/catch2: "^3.4.0"
version: ">=4.1.0"

View File

@@ -16,7 +16,8 @@
#include <netdb.h> #include <netdb.h>
#include "fmt/core.h" #include "fmt/core.h"
#include "fmt/ranges.h" #include "fmt/ranges.h"
#include "catch/catch.hpp" #include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_all.hpp>
#include "esp_transport.h" #include "esp_transport.h"
#include "esp_transport_socks_proxy.h" #include "esp_transport_socks_proxy.h"

View File

@@ -2,9 +2,7 @@ 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)
# Freertos is included via common components. However, CATCH isn't compatible with the FreeRTOS component yet, hence # This test app doesn't require FreeRTOS, using mock instead
# using the FreeRTOS mock component.
# target.
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
project(wear_levelling_host_test) project(wear_levelling_host_test)

View File

@@ -1,8 +1,10 @@
idf_component_register(SRCS "main.cpp" idf_component_register(SRCS "test_wl.cpp"
"test_wl.cpp"
INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch"
PRIV_INCLUDE_DIRS "../../private_include" PRIV_INCLUDE_DIRS "../../private_include"
"../.." "../.."
REQUIRES wear_levelling REQUIRES wear_levelling
WHOLE_ARCHIVE 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)

View File

@@ -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();
}

View File

@@ -0,0 +1,2 @@
dependencies:
espressif/catch2: "^3.4.0"

View File

@@ -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"

View File

@@ -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 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -15,7 +15,7 @@
#include "crc32.h" #include "crc32.h"
#include "catch.hpp" #include <catch2/catch_test_macros.hpp>
#include "sdkconfig.h" #include "sdkconfig.h"
@@ -34,7 +34,6 @@ TEST_CASE("write and read back data", "[wear_levelling]")
esp_err_t result; esp_err_t result;
wl_handle_t wl_handle; 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"); const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "storage");
// Mount wear-levelled partition // Mount wear-levelled partition
@@ -105,7 +104,6 @@ TEST_CASE("power down test", "[wear_levelling]")
esp_err_t result; esp_err_t result;
wl_handle_t wl_handle; 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"); const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "storage");
// Disable power down failure counting // Disable power down failure counting
@@ -295,7 +293,6 @@ TEST_CASE("power down during WL status 1 update", "[wear_levelling]")
esp_err_t result; esp_err_t result;
wl_handle_t wl_handle; 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"); 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; 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; esp_err_t result;
wl_handle_t wl_handle; 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"); 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; 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; esp_err_t result;
wl_handle_t wl_handle; 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"); 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; size_t offset_state_1, offset_state_2, size_state = 0;

View File

@@ -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/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 '"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/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 '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_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/* warning: unknown kconfig symbol 'FMB_TIMER_INDEX' assigned to '0' in /builds/espressif/esp-idf/examples/protocols/modbus/tcp/*