Merge branch 'feat/remove-catch-from-tools' into 'master'

feat(tools): Remove tools/catch

Closes IDF-9203

See merge request espressif/esp-idf!40413
This commit is contained in:
Marius Vikhammer
2025-09-25 10:16:55 +08:00
36 changed files with 152 additions and 10741 deletions

2
.gitignore vendored
View File

@@ -66,8 +66,6 @@ build_summary_*.xml
coverage.info
coverage_report/
test_multi_heap_host
# VS Code Settings
.vscode/

View File

@@ -215,7 +215,6 @@
/tools/ @esp-idf-codeowners/tools
/tools/ble/ @esp-idf-codeowners/app-utilities
/tools/bt/ @esp-idf-codeowners/bluetooth
/tools/catch/ @esp-idf-codeowners/ci
/tools/ci/ @esp-idf-codeowners/ci
/tools/cmake/ @esp-idf-codeowners/build-config
/tools/cmake/toolchain-*.cmake @esp-idf-codeowners/toolchain

View File

@@ -77,24 +77,12 @@ test_fatfsgen_on_host:
- ./test_wl_fatfsgen.py
- ./test_fatfsparse.py
test_multi_heap_on_host:
extends: .host_test_template
script:
- cd components/heap/test_multi_heap_host
- ./test_all_configs.sh
test_certificate_bundle_on_host:
extends: .host_test_template
script:
- cd components/mbedtls/esp_crt_bundle/test_gen_crt_bundle/
- ./test_gen_crt_bundle.py
test_gdbstub_on_host:
extends: .host_test_template
script:
- cd components/esp_gdbstub/test_gdbstub_host
- make test
# Test for create virtualenv. It must be invoked from Python, not from virtualenv.
# Use docker image system python without any extra dependencies
test_cli_installer:

View File

@@ -0,0 +1,3 @@
components/esp_gdbstub/test_gdbstub_host/rv_decode:
enable:
- if: IDF_TARGET == "linux"

View File

@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.22)
add_compile_options(-D__riscv_c)
add_link_options(-D__riscv_c)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(COMPONENTS main)
# This test app doesn't require FreeRTOS, using mock instead
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
project(rv_decode_test)

View File

@@ -1,66 +0,0 @@
TEST_PROGRAM=test_gdbstub_rv
GDBSTUB_SRC_DIR=../..
all: $(TEST_PROGRAM)
SOURCE_FILES = \
$(addprefix $(GDBSTUB_SRC_DIR)/src/, \
port/riscv/rv_decode.c \
) \
test_rv_decode.cpp \
main.cpp
INCLUDE_FLAGS = -I./include \
-I$(GDBSTUB_SRC_DIR)/private_include \
-I$(GDBSTUB_SRC_DIR)/include \
-I$(GDBSTUB_SRC_DIR)/src/port/riscv/include \
-I$(GDBSTUB_SRC_DIR)/../../tools/catch \
-I$(GDBSTUB_SRC_DIR)/../esp_hw_support/include \
-I$(GDBSTUB_SRC_DIR)/../soc/esp32c3/include \
-I$(GDBSTUB_SRC_DIR)/../esp_common/include \
-I$(GDBSTUB_SRC_DIR)/../riscv/include
CPPFLAGS += $(INCLUDE_FLAGS) -D__riscv_c -Wall -Werror -g --coverage
CFLAGS += $(INCLUDE_FLAGS) -D__riscv_c -Wall -Werror -g --coverage
LDFLAGS += -lstdc++ --coverage
ifeq ($(CC),clang)
CFLAGS += -fsanitize=address
CXXFLAGS += -fsanitize=address
LDFLAGS += -fsanitize=address
endif
OBJ_FILES = $(filter %.o, $(SOURCE_FILES:.cpp=.o) $(SOURCE_FILES:.c=.o))
COVERAGE_FILES = $(OBJ_FILES:.o=.gc*)
$(TEST_PROGRAM): $(OBJ_FILES)
$(CC) -o $@ $^ $(LDFLAGS)
$(OUTPUT_DIR):
mkdir -p $(OUTPUT_DIR)
test: $(TEST_PROGRAM)
./$(TEST_PROGRAM) -d yes exclude:[long]
long-test: $(TEST_PROGRAM)
./$(TEST_PROGRAM) -d yes
$(COVERAGE_FILES): $(TEST_PROGRAM) long-test
coverage.info: $(COVERAGE_FILES)
find $(GDBSTUB_SRC_DIR)/src/ -name "*.gcno" -exec gcov -r -pb {} +
lcov --capture --directory $(GDBSTUB_SRC_DIR)/src --output-file coverage.info
coverage_report: coverage.info
genhtml coverage.info --output-directory coverage_report
@echo "Coverage report is in coverage_report/index.html"
clean-coverage:
rm -f $(COVERAGE_FILES) *.gcov
rm -rf coverage_report/
rm -f coverage.info
clean: clean-coverage
rm -f $(OBJ_FILES) $(TEST_PROGRAM)
.PHONY: clean clean-coverage all test long-test

View File

@@ -0,0 +1,2 @@
| Supported Targets | Linux |
| ----------------- | ----- |

View File

@@ -1,8 +0,0 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#define CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME 1

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

@@ -0,0 +1,16 @@
idf_component_register(SRCS
"test_rv_decode.cpp"
"../../../src/port/riscv/rv_decode.c"
INCLUDE_DIRS
"../../../private_include"
"../../../include"
"../../../src/port/riscv/include"
"../../../../esp_hw_support/include"
"../../../../soc/esp32c3/include"
"../../../../esp_common/include"
"../../../../riscv/include"
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,9 +1,9 @@
/*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "catch.hpp"
#include <catch2/catch_test_macros.hpp>
extern "C" {
#include "esp_gdbstub_common.h"
@@ -468,7 +468,6 @@ struct inst_list_s xesppie_nojump[] = {
TEST_CASE("decode rv32i instructions")
{
uintptr_t pc;
uint32_t inst;
uintptr_t inst_addr = (uintptr_t)&inst;
@@ -615,7 +614,6 @@ TEST_CASE("decode rv32i instructions")
TEST_CASE("decode rv32c instructions")
{
uintptr_t pc;
uint32_t inst;
uintptr_t inst_addr = (uintptr_t)&inst;
@@ -675,7 +673,6 @@ TEST_CASE("decode rv32c instructions")
TEST_CASE("decode rv32a instructions")
{
uintptr_t pc;
uint32_t inst;
uintptr_t inst_addr = (uintptr_t)&inst;
@@ -688,7 +685,6 @@ TEST_CASE("decode rv32a instructions")
TEST_CASE("decode rv32m instructions")
{
uintptr_t pc;
uint32_t inst;
uintptr_t inst_addr = (uintptr_t)&inst;
@@ -701,7 +697,6 @@ TEST_CASE("decode rv32m instructions")
TEST_CASE("decode xesppie instructions")
{
uintptr_t pc;
uint32_t inst;
uintptr_t inst_addr = (uintptr_t)&inst;

View File

@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import pytest
from pytest_embedded import Dut
from pytest_embedded_idf.utils import idf_parametrize
@pytest.mark.host_test
@idf_parametrize('target', ['linux'], indirect=['target'])
def test_rv_decode(dut: Dut) -> None:
dut.expect_exact('All tests passed', timeout=180)

View File

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

View File

@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.22)
add_compile_options(-m32)
add_link_options(-m32)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(COMPONENTS main)
# This test app doesn't require FreeRTOS, using mock instead
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
project(multi_heap_test)

View File

@@ -1,54 +0,0 @@
TEST_PROGRAM=test_multi_heap
all: $(TEST_PROGRAM)
ifneq ($(filter clean,$(MAKECMDGOALS)),)
.NOTPARALLEL: # prevent make clean racing the other targets
endif
SOURCE_FILES = $(abspath \
test_multi_heap.cpp \
../multi_heap_poisoning.c \
../multi_heap.c \
../tlsf/tlsf.c \
main.cpp \
)
INCLUDE_FLAGS = -I../include -I../../../tools/catch -I../tlsf -I../tlsf/include
GCOV ?= gcov
CPPFLAGS += $(INCLUDE_FLAGS) -D CONFIG_LOG_DEFAULT_LEVEL -g -fstack-protector-all -m32
CFLAGS += -Wall -Werror -fprofile-arcs -ftest-coverage
CXXFLAGS += -std=c++11 -Wall -Werror -fprofile-arcs -ftest-coverage
LDFLAGS += -lstdc++ -fprofile-arcs -ftest-coverage -m32
OBJ_FILES = $(filter %.o, $(SOURCE_FILES:.cpp=.o) $(SOURCE_FILES:.c=.o))
COVERAGE_FILES = $(OBJ_FILES:.o=.gc*)
$(TEST_PROGRAM): $(OBJ_FILES)
g++ $(LDFLAGS) -o $(TEST_PROGRAM) $(OBJ_FILES)
$(OUTPUT_DIR):
mkdir -p $(OUTPUT_DIR)
test: $(TEST_PROGRAM)
./$(TEST_PROGRAM)
$(COVERAGE_FILES): $(TEST_PROGRAM) test
coverage.info: $(COVERAGE_FILES)
find ../ -name "*.gcno" -exec $(GCOV) -r -pb {} +
lcov --capture --directory $(abspath ../) --no-external --output-file coverage.info --gcov-tool $(GCOV)
coverage_report: coverage.info
genhtml coverage.info --output-directory coverage_report
@echo "Coverage report is in coverage_report/index.html"
clean:
rm -f $(OBJ_FILES) $(TEST_PROGRAM)
rm -f $(COVERAGE_FILES) *.gcov
rm -rf coverage_report/
rm -f coverage.info
.PHONY: clean all test

View File

@@ -0,0 +1,2 @@
| Supported Targets | Linux |
| ----------------- | ----- |

View File

@@ -1,8 +0,0 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#define CATCH_CONFIG_MAIN
#include "catch.hpp"

View File

@@ -0,0 +1,13 @@
idf_component_register(SRCS "test_multi_heap.cpp"
"../../multi_heap_poisoning.c"
"../../multi_heap.c"
"../../tlsf/tlsf.c"
INCLUDE_DIRS
"../../include"
"../../tlsf"
"../../tlsf/include"
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,10 +1,10 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "catch.hpp"
#include "catch2/catch_test_macros.hpp"
#include "multi_heap.h"
#include "../multi_heap_config.h"
@@ -42,11 +42,28 @@ static void __free__(void *ptr)
#undef realloc
#define realloc #error
static uint8_t s_small_heap[4 * 1024];
static multi_heap_handle_t s_small_heap_hdl = NULL;
void get_small_heap(uint8_t **heap, multi_heap_handle_t *heap_hdl, size_t *heap_size)
{
if (s_small_heap_hdl == NULL) {
memset(s_small_heap, 0, sizeof(s_small_heap));
s_small_heap_hdl = multi_heap_register(s_small_heap, sizeof(s_small_heap));
}
*heap = s_small_heap;
*heap_hdl = s_small_heap_hdl;
*heap_size = sizeof(s_small_heap);
multi_heap_dump(*heap_hdl);
}
TEST_CASE("multi_heap simple allocations", "[multi_heap]")
{
uint8_t small_heap[4 * 1024];
multi_heap_handle_t heap = multi_heap_register(small_heap, sizeof(small_heap));
uint8_t *small_heap = NULL;
multi_heap_handle_t heap = NULL;
size_t small_heap_size = 0;
get_small_heap(&small_heap, &heap, &small_heap_size);
size_t test_alloc_size = (multi_heap_free_size(heap) + 4) / 2;
@@ -59,7 +76,7 @@ TEST_CASE("multi_heap simple allocations", "[multi_heap]")
printf("small_heap %p buf %p\n", small_heap, buf);
REQUIRE( buf != NULL );
REQUIRE((intptr_t)buf >= (intptr_t)small_heap);
REQUIRE( (intptr_t)buf < (intptr_t)(small_heap + sizeof(small_heap)));
REQUIRE( (intptr_t)buf < (intptr_t)(small_heap + small_heap_size));
REQUIRE( multi_heap_get_allocated_size(heap, buf) >= test_alloc_size );
printf("test alloc size %d\n", test_alloc_size);
@@ -82,12 +99,12 @@ TEST_CASE("multi_heap simple allocations", "[multi_heap]")
REQUIRE( multi_heap_free_size(heap) > multi_heap_minimum_free_size(heap) );
}
TEST_CASE("multi_heap fragmentation", "[multi_heap]")
{
const size_t HEAP_SIZE = 4 * 1024;
uint8_t small_heap[HEAP_SIZE];
multi_heap_handle_t heap = multi_heap_register(small_heap, sizeof(small_heap));
uint8_t *small_heap = NULL;
multi_heap_handle_t heap = NULL;
size_t small_heap_size = 0;
get_small_heap(&small_heap, &heap, &small_heap_size);
const size_t alloc_size = 500;
@@ -135,13 +152,15 @@ TEST_CASE("multi_heap fragmentation", "[multi_heap]")
/* Test that malloc/free does not leave free space fragmented */
TEST_CASE("multi_heap defrag", "[multi_heap]")
{
uint8_t *small_heap = NULL;
multi_heap_handle_t heap = NULL;
size_t small_heap_size = 0;
get_small_heap(&small_heap, &heap, &small_heap_size);
void *p[4];
uint8_t small_heap[4 * 1024];
multi_heap_info_t info, info2;
multi_heap_handle_t heap = multi_heap_register(small_heap, sizeof(small_heap));
printf("0 ---\n");
multi_heap_dump(heap);
REQUIRE( multi_heap_check(heap, true) );
multi_heap_get_info(heap, &info);
REQUIRE( 0 == info.allocated_blocks );
@@ -149,9 +168,13 @@ TEST_CASE("multi_heap defrag", "[multi_heap]")
printf("1 ---\n");
p[0] = multi_heap_malloc(heap, 128);
p[1] = multi_heap_malloc(heap, 32);
multi_heap_dump(heap);
REQUIRE(p[0] != NULL);
REQUIRE( multi_heap_check(heap, true) );
multi_heap_dump(heap);
p[1] = multi_heap_malloc(heap, 32);
REQUIRE(p[1] != NULL);
REQUIRE( multi_heap_check(heap, true) );
multi_heap_dump(heap);
printf("2 ---\n");
multi_heap_free(heap, p[0]);
@@ -388,7 +411,6 @@ TEST_CASE("multi_heap minimum-size allocations", "[multi_heap]")
uint8_t heapdata[4096];
void *p[sizeof(heapdata) / sizeof(void *)] = {NULL};
const size_t NUM_P = sizeof(p) / sizeof(void *);
size_t allocated_size = 0;
multi_heap_handle_t heap = multi_heap_register(heapdata, sizeof(heapdata));
size_t before_free = multi_heap_free_size(heap);

View File

@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import pytest
from pytest_embedded import Dut
from pytest_embedded_idf.utils import idf_parametrize
@pytest.mark.host_test
@pytest.mark.parametrize(
'config',
[
'no_poisoning',
'light_poisoning',
'comprehensive_poisoning',
],
)
@idf_parametrize('target', ['linux'], indirect=['target'])
def test_multi_heap_linux(dut: Dut) -> None:
dut.expect_exact('All tests passed', timeout=180)

View File

@@ -0,0 +1,3 @@
CONFIG_HEAP_POISONING_COMPREHENSIVE=y
CONFIG_HEAP_POISONING_LIGHT=n
CONFIG_HEAP_POISONING_DISABLED=n

View File

@@ -0,0 +1,3 @@
CONFIG_HEAP_POISONING_COMPREHENSIVE=n
CONFIG_HEAP_POISONING_LIGHT=y
CONFIG_HEAP_POISONING_DISABLED=n

View File

@@ -0,0 +1,3 @@
CONFIG_HEAP_POISONING_COMPREHENSIVE=n
CONFIG_HEAP_POISONING_LIGHT=n
CONFIG_HEAP_POISONING_DISABLED=y

View File

@@ -0,0 +1 @@
CONFIG_ESP_TASK_WDT_EN=n

View File

@@ -1,20 +0,0 @@
#!/usr/bin/env bash
#
# Run the test suite with all configurations enabled
#
FAIL=0
for FLAGS in "CONFIG_HEAP_POISONING_NONE" "CONFIG_HEAP_POISONING_LIGHT" "CONFIG_HEAP_POISONING_COMPREHENSIVE" ; do
echo "==== Testing with config: ${FLAGS} ===="
CPPFLAGS="-D${FLAGS}" make clean test || FAIL=1
done
make clean
if [ $FAIL == 0 ]; then
echo "All configurations passed"
else
echo "Some configurations failed, see log."
exit 1
fi

View File

@@ -62,3 +62,8 @@ The legacy unit-test-app has been moved out of ESP-IDF repository as no ESP-IDF
.. code-block:: bash
idf.py create-project-from-example espressif/unit-test-app:unit-test-app
Catch
-----
The header-only copy of Catch2 unit testing library previously located in tools/catch directory has been removed. To continue using Catch2 in your project, migrate to Catch2 3.x, available from the `ESP component registry <https://components.espressif.com/components/espressif/catch2>`_. For an example of migrating from Catch2 2.x to Catch2 3.x, see commit 79a2c15477dc327550ff46a64ee0f8b4679cc417.

View File

@@ -1,23 +0,0 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@@ -1,4 +0,0 @@
This directory contains header-only version of Catch C++ unit test library,
mostly used in host-side tests.
See https://github.com/philsquared/catch for more info.

File diff suppressed because it is too large Load Diff

View File

@@ -134,8 +134,6 @@ components_not_formatted_permanent:
- "/components/console/argtable3/"
# Linenoise (upstream source code)
- "/components/console/linenoise/"
# Catch (upstream source code)
- "/tools/catch/catch.hpp"
# FreeRTOS kernel files (upstream source code)
- "/components/freertos/FreeRTOS-Kernel/"
- "/components/freertos/FreeRTOS-Kernel-SMP/"

View File

@@ -956,7 +956,6 @@ examples/wifi/wps/main/wps.c
tools/ble/lib_ble_client.py
tools/ble/lib_gap.py
tools/ble/lib_gatt.py
tools/catch/catch.hpp
tools/ldgen/samples/template.ld
tools/ldgen/test/data/linker_script.ld
tools/test_apps/build_system/embed_test/main/test_main.c

View File

@@ -1,6 +1,5 @@
tools/ble/**/*
tools/bt/**/*
tools/catch/**/*
tools/check_term.py
tools/ci/*exclude*.txt
tools/ci/astyle-rules.yml

View File

@@ -12,7 +12,6 @@ components/fatfs/test_fatfsgen/test_fatfsgen.py
components/fatfs/test_fatfsgen/test_fatfsparse.py
components/fatfs/test_fatfsgen/test_wl_fatfsgen.py
components/fatfs/wl_fatfsgen.py
components/heap/test_multi_heap_host/test_all_configs.sh
components/mbedtls/esp_crt_bundle/gen_crt_bundle.py
components/mbedtls/esp_crt_bundle/test_gen_crt_bundle/test_gen_crt_bundle.py
components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py