ci(wear_levelling): upgrade to Catch2 as a component

This commit is contained in:
Ivan Grokhotkov
2023-11-27 14:34:40 +01:00
parent 33896fe67e
commit ae3da4a383
6 changed files with 10 additions and 39 deletions

View File

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

View File

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

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
*/
@@ -15,7 +15,7 @@
#include "crc32.h"
#include "catch.hpp"
#include <catch2/catch_test_macros.hpp>
#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;