diff --git a/components/heap/test/CMakeLists.txt b/components/heap/test/CMakeLists.txt deleted file mode 100644 index 3ccce3753e..0000000000 --- a/components/heap/test/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -idf_component_register(SRC_DIRS "." - PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES cmock test_utils heap) -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/heap/test_apps/CMakeLists.txt b/components/heap/test_apps/CMakeLists.txt new file mode 100644 index 0000000000..df2d30eeb0 --- /dev/null +++ b/components/heap/test_apps/CMakeLists.txt @@ -0,0 +1,6 @@ +# The following lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.16) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(test_heap) diff --git a/components/heap/test_apps/README.md b/components/heap/test_apps/README.md new file mode 100644 index 0000000000..284564238d --- /dev/null +++ b/components/heap/test_apps/README.md @@ -0,0 +1,2 @@ +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | \ No newline at end of file diff --git a/components/heap/test_apps/main/CMakeLists.txt b/components/heap/test_apps/main/CMakeLists.txt new file mode 100644 index 0000000000..25d6596721 --- /dev/null +++ b/components/heap/test_apps/main/CMakeLists.txt @@ -0,0 +1,14 @@ +set(src_test "test_app_main.c" + "test_aligned_alloc_caps.c" + "test_allocator_timings.c" + "test_corruption_check.c" + "test_diram.c" + "test_heap_trace.c" + "test_malloc_caps.c" + "test_malloc.c" + "test_realloc.c" + "test_runtime_heap_reg.c") + +idf_component_register(SRCS ${src_test} + INCLUDE_DIRS "." + WHOLE_ARCHIVE) diff --git a/components/heap/test/test_aligned_alloc_caps.c b/components/heap/test_apps/main/test_aligned_alloc_caps.c similarity index 83% rename from components/heap/test/test_aligned_alloc_caps.c rename to components/heap/test_apps/main/test_aligned_alloc_caps.c index 60b8866f12..4da12332ef 100644 --- a/components/heap/test/test_aligned_alloc_caps.c +++ b/components/heap/test_apps/main/test_aligned_alloc_caps.c @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ /* Tests for the capabilities-based memory allocator. */ @@ -12,6 +17,7 @@ #include #include #include +#include TEST_CASE("Capabilities aligned allocator test", "[heap]") { @@ -23,10 +29,10 @@ TEST_CASE("Capabilities aligned allocator test", "[heap]") uint8_t *buf = (uint8_t *)memalign(alignments, (alignments + 137)); if(((alignments & (alignments - 1)) != 0) || (!alignments)) { TEST_ASSERT( buf == NULL ); - //printf("[ALIGNED_ALLOC] alignment: %u is not a power of two, don't allow allocation \n", aligments); + //printf("[ALIGNED_ALLOC] alignment: %"PRIu32" is not a power of two, don't allow allocation \n", aligments); } else { TEST_ASSERT( buf != NULL ); - printf("[ALIGNED_ALLOC] alignment required: %u \n", alignments); + printf("[ALIGNED_ALLOC] alignment required: %"PRIu32" \n", alignments); printf("[ALIGNED_ALLOC] address of allocated memory: %p \n\n", (void *)buf); //Address of obtained block must be aligned with selected value TEST_ASSERT(((intptr_t)buf & (alignments - 1)) == 0); @@ -52,10 +58,10 @@ TEST_CASE("Capabilities aligned allocator test", "[heap]") uint8_t *buf = (uint8_t *)heap_caps_aligned_alloc(alignments, 10*1024, MALLOC_CAP_SPIRAM); if(((alignments & (alignments - 1)) != 0) || (!alignments)) { TEST_ASSERT( buf == NULL ); - //printf("[ALIGNED_ALLOC] alignment: %u is not a power of two, don't allow allocation \n", aligments); + //printf("[ALIGNED_ALLOC] alignment: %"PRIu32" is not a power of two, don't allow allocation \n", aligments); } else { TEST_ASSERT( buf != NULL ); - printf("[ALIGNED_ALLOC] alignment required: %u \n", alignments); + printf("[ALIGNED_ALLOC] alignment required: %"PRIu32" \n", alignments); printf("[ALIGNED_ALLOC] address of allocated memory: %p \n\n", (void *)buf); //Address of obtained block must be aligned with selected value TEST_ASSERT(((intptr_t)buf & (alignments - 1)) == 0); @@ -80,10 +86,10 @@ TEST_CASE("Capabilities aligned calloc test", "[heap]") uint8_t *buf = (uint8_t *)heap_caps_aligned_calloc(alignments, 1, (alignments + 137), MALLOC_CAP_DEFAULT); if(((alignments & (alignments - 1)) != 0) || (!alignments)) { TEST_ASSERT( buf == NULL ); - //printf("[ALIGNED_ALLOC] alignment: %u is not a power of two, don't allow allocation \n", aligments); + //printf("[ALIGNED_ALLOC] alignment: %"PRIu32" is not a power of two, don't allow allocation \n", aligments); } else { TEST_ASSERT( buf != NULL ); - printf("[ALIGNED_ALLOC] alignment required: %u \n", alignments); + printf("[ALIGNED_ALLOC] alignment required: %"PRIu32" \n", alignments); printf("[ALIGNED_ALLOC] address of allocated memory: %p \n\n", (void *)buf); //Address of obtained block must be aligned with selected value TEST_ASSERT(((intptr_t)buf & (alignments - 1)) == 0); @@ -120,10 +126,10 @@ TEST_CASE("Capabilities aligned calloc test", "[heap]") uint8_t *buf = (uint8_t *)(uint8_t *)heap_caps_aligned_calloc(alignments, 1, 10*1024, MALLOC_CAP_SPIRAM); if(((alignments & (alignments - 1)) != 0) || (!alignments)) { TEST_ASSERT( buf == NULL ); - //printf("[ALIGNED_ALLOC] alignment: %u is not a power of two, don't allow allocation \n", aligments); + //printf("[ALIGNED_ALLOC] alignment: %"PRIu32" is not a power of two, don't allow allocation \n", aligments); } else { TEST_ASSERT( buf != NULL ); - printf("[ALIGNED_ALLOC] alignment required: %u \n", alignments); + printf("[ALIGNED_ALLOC] alignment required: %"PRIu32" \n", alignments); printf("[ALIGNED_ALLOC] address of allocated memory: %p \n\n", (void *)buf); //Address of obtained block must be aligned with selected value TEST_ASSERT(((intptr_t)buf & (alignments - 1)) == 0); diff --git a/components/heap/test/test_allocator_timings.c b/components/heap/test_apps/main/test_allocator_timings.c similarity index 93% rename from components/heap/test/test_allocator_timings.c rename to components/heap/test_apps/main/test_allocator_timings.c index 0e130c95b6..af9acd5838 100644 --- a/components/heap/test/test_allocator_timings.c +++ b/components/heap/test_apps/main/test_allocator_timings.c @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ #include "freertos/FreeRTOS.h" #include #include @@ -7,7 +12,6 @@ #include #include #include -#include //This test only makes sense with poisoning disabled (light or comprehensive) #if !defined(CONFIG_HEAP_POISONING_COMPREHENSIVE) && !defined(CONFIG_HEAP_POISONING_LIGHT) @@ -26,13 +30,13 @@ TEST_CASE("Heap many random allocations timings", "[heap]") uint64_t realloc_time_average = 0; for (int i = 0; i < ITERATIONS; i++) { - uint8_t n = esp_random() % NUM_POINTERS; + uint8_t n = (uint32_t)rand() % NUM_POINTERS; - if (esp_random() % 4 == 0) { + if (ITERATIONS % 4 == 0) { /* 1 in 4 iterations, try to realloc the buffer instead of using malloc/free */ - size_t new_size = esp_random() % 1024; + size_t new_size = (uint32_t)rand() % 1024; cycles_before = portGET_RUN_TIME_COUNTER_VALUE(); void *new_p = heap_caps_realloc(p[n], new_size, MALLOC_CAP_DEFAULT); diff --git a/components/heap/test_apps/main/test_app_main.c b/components/heap/test_apps/main/test_app_main.c new file mode 100644 index 0000000000..fdae5be5fb --- /dev/null +++ b/components/heap/test_apps/main/test_app_main.c @@ -0,0 +1,41 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "unity.h" +#include "unity_test_runner.h" +#include "esp_heap_caps.h" + +#define TEST_MEMORY_LEAK_THRESHOLD (-1024) + +static size_t before_free_8bit; +static size_t before_free_32bit; + +static void check_leak(size_t before_free, size_t after_free, const char *type) +{ + ssize_t delta = after_free - before_free; + printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta); + TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak"); +} + +void setUp(void) +{ + before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT); + before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT); +} + +void tearDown(void) +{ + size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT); + size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT); + check_leak(before_free_8bit, after_free_8bit, "8BIT"); + check_leak(before_free_32bit, after_free_32bit, "32BIT"); +} + +void app_main(void) +{ + printf("Running heap component tests\n"); + unity_run_menu(); +} diff --git a/components/heap/test/test_corruption_check.c b/components/heap/test_apps/main/test_corruption_check.c similarity index 93% rename from components/heap/test/test_corruption_check.c rename to components/heap/test_apps/main/test_corruption_check.c index 9c4dd47eb2..d7dc8125ac 100644 --- a/components/heap/test/test_corruption_check.c +++ b/components/heap/test_apps/main/test_corruption_check.c @@ -8,6 +8,9 @@ #include "esp_heap_caps.h" +//This test only makes sense with poisoning enabled (light or comprehensive) +#if defined(CONFIG_HEAP_POISONING_COMPREHENSIVE) || defined(CONFIG_HEAP_POISONING_LIGHT) + /* executing multi_heap_internal_check_block_poisoning() * takes longer on external RAM and therefore the timeout * in the test of 30 seconds is exceeded. Execute the test @@ -66,3 +69,5 @@ TEST_CASE("multi_heap poisoning detection", "[heap]") TEST_ASSERT_TRUE(is_heap_ok); } } + +#endif diff --git a/components/heap/test/test_diram.c b/components/heap/test_apps/main/test_diram.c similarity index 90% rename from components/heap/test/test_diram.c rename to components/heap/test_apps/main/test_diram.c index f31aecb673..569139f93b 100644 --- a/components/heap/test/test_diram.c +++ b/components/heap/test_apps/main/test_diram.c @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ /* Tests for D/IRAM support in heap capability allocator */ @@ -12,6 +17,7 @@ #if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) //IDF-5167 +#ifndef CONFIG_ESP_SYSTEM_MEMPROT_FEATURE static void *malloc_block_diram(uint32_t caps) { void *attempts[256] = { 0 }; // Allocate up to 256 ALLOC_SZ blocks to exhaust all non-D/IRAM memory temporarily @@ -74,4 +80,5 @@ TEST_CASE("Allocate D/IRAM as IRAM", "[heap]") free(iram); } +#endif // CONFIG_ESP_SYSTEM_MEMPROT_FEATURE #endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) diff --git a/components/heap/test/test_heap_trace.c b/components/heap/test_apps/main/test_heap_trace.c similarity index 97% rename from components/heap/test/test_heap_trace.c rename to components/heap/test_apps/main/test_heap_trace.c index 909aa31b5c..b88e270b18 100644 --- a/components/heap/test/test_heap_trace.c +++ b/components/heap/test_apps/main/test_heap_trace.c @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ /* Generic test for heap tracing support diff --git a/components/heap/test/test_malloc.c b/components/heap/test_apps/main/test_malloc.c similarity index 97% rename from components/heap/test/test_malloc.c rename to components/heap/test_apps/main/test_malloc.c index 995a64da33..0fe523a7a0 100644 --- a/components/heap/test/test_malloc.c +++ b/components/heap/test_apps/main/test_malloc.c @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ /* Generic test for malloc/free */ diff --git a/components/heap/test/test_malloc_caps.c b/components/heap/test_apps/main/test_malloc_caps.c similarity index 97% rename from components/heap/test/test_malloc_caps.c rename to components/heap/test_apps/main/test_malloc_caps.c index 0010327441..2eb69625db 100644 --- a/components/heap/test/test_malloc_caps.c +++ b/components/heap/test_apps/main/test_malloc_caps.c @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ /* Tests for the capabilities-based memory allocator. */ @@ -106,7 +111,7 @@ TEST_CASE("Capabilities allocator test", "[heap]") free(m1); printf("Done.\n"); } -#endif +#endif // CONFIG_ESP_SYSTEM_MEMPROT_FEATURE #endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) #ifdef CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY @@ -175,6 +180,7 @@ TEST_CASE("heap_caps metadata test", "[heap]") /* Small function runs from IRAM to check that malloc/free/realloc all work OK when cache is disabled... */ +#ifndef CONFIG_ESP_SYSTEM_MEMPROT_FEATURE static IRAM_ATTR __attribute__((noinline)) bool iram_malloc_test(void) { spi_flash_guard_get()->start(); // Disables flash cache @@ -196,6 +202,7 @@ TEST_CASE("heap_caps_xxx functions work with flash cache disabled", "[heap]") { TEST_ASSERT( iram_malloc_test() ); } +#endif // CONFIG_ESP_SYSTEM_MEMPROT_FEATURE #endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) #ifdef CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS @@ -212,7 +219,7 @@ static bool called_user_failed_hook = false; void heap_caps_alloc_failed_hook(size_t requested_size, uint32_t caps, const char *function_name) { - printf("%s was called but failed to allocate %d bytes with 0x%X capabilities. \n",function_name, requested_size, caps); + printf("%s was called but failed to allocate %d bytes with 0x%lX capabilities. \n",function_name, requested_size, caps); called_user_failed_hook = true; } diff --git a/components/heap/test/test_realloc.c b/components/heap/test_apps/main/test_realloc.c similarity index 91% rename from components/heap/test/test_realloc.c rename to components/heap/test_apps/main/test_realloc.c index c106c57f19..d6e91e940d 100644 --- a/components/heap/test/test_realloc.c +++ b/components/heap/test_apps/main/test_realloc.c @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ /* Generic test for realloc */ @@ -64,5 +69,5 @@ TEST_CASE("realloc move data to a new heap type", "[heap]") free(c); } -#endif +#endif // CONFIG_ESP_SYSTEM_MEMPROT_FEATURE #endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) diff --git a/components/heap/test/test_runtime_heap_reg.c b/components/heap/test_apps/main/test_runtime_heap_reg.c similarity index 92% rename from components/heap/test/test_runtime_heap_reg.c rename to components/heap/test_apps/main/test_runtime_heap_reg.c index c7a9dc493c..c2729708f4 100644 --- a/components/heap/test/test_runtime_heap_reg.c +++ b/components/heap/test_apps/main/test_runtime_heap_reg.c @@ -1,9 +1,15 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ /* Tests for registering new heap memory at runtime */ #include #include +#include #include "unity.h" #include "esp_heap_caps_init.h" #include "esp_system.h" @@ -20,7 +26,7 @@ TEST_CASE("Allocate new heap at runtime", "[heap][ignore]") uint32_t before_free = esp_get_free_heap_size(); TEST_ESP_OK( heap_caps_add_region((intptr_t)buffer, (intptr_t)buffer + BUF_SZ) ); uint32_t after_free = esp_get_free_heap_size(); - printf("Before %u after %u\n", before_free, after_free); + printf("Before %"PRIu32" after %"PRIu32"\n", before_free, after_free); /* allow for some 'heap overhead' from accounting structures */ TEST_ASSERT(after_free >= before_free + BUF_SZ - HEAP_OVERHEAD_MAX); } @@ -64,7 +70,7 @@ TEST_CASE("Add .bss memory to heap region runtime", "[heap][ignore]") uint32_t before_free = esp_get_free_heap_size(); TEST_ESP_OK( heap_caps_add_region((intptr_t)s_buffer, (intptr_t)s_buffer + BUF_SZ) ); uint32_t after_free = esp_get_free_heap_size(); - printf("Before %u after %u\n", before_free, after_free); + printf("Before %"PRIu32" after %"PRIu32"\n", before_free, after_free); /* allow for some 'heap overhead' from accounting structures */ TEST_ASSERT(after_free >= before_free + BUF_SZ - HEAP_OVERHEAD_MAX); diff --git a/components/heap/test_apps/pytest_heap.py b/components/heap/test_apps/pytest_heap.py new file mode 100644 index 0000000000..8c43daa550 --- /dev/null +++ b/components/heap/test_apps/pytest_heap.py @@ -0,0 +1,66 @@ +# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: CC0-1.0 + +import pytest +from pytest_embedded import Dut + + +@pytest.mark.generic +@pytest.mark.supported_targets +@pytest.mark.parametrize( + 'config', + [ + 'no_poisoning', + 'light_poisoning', + 'comprehensive_poisoning' + ] +) +def test_heap_poisoning(dut: Dut) -> None: + dut.expect_exact('Press ENTER to see the list of tests') + dut.write('![ignore]') + dut.expect_unity_test_output(timeout=300) + + +@pytest.mark.generic +@pytest.mark.esp32 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.parametrize( + 'config', + [ + 'psram', + 'psram_all_ext' + ] +) +def test_heap(dut: Dut) -> None: + dut.expect_exact('Press ENTER to see the list of tests') + dut.write('![ignore]') + dut.expect_unity_test_output(timeout=300) + + +@pytest.mark.generic +@pytest.mark.esp32 +@pytest.mark.parametrize( + 'config', + [ + 'abort_alloc_fail' + ] +) +def test_heap_abort_on_alloc_failure(dut: Dut) -> None: + dut.expect_exact('Press ENTER to see the list of tests') + dut.write('"When enabled, allocation operation failure generates an abort"') + dut.expect('Backtrace: ') + + +@pytest.mark.generic +@pytest.mark.esp32 +@pytest.mark.parametrize( + 'config', + [ + '8bit_access' + ] +) +def test_heap_8bit_access(dut: Dut) -> None: + dut.expect_exact('Press ENTER to see the list of tests') + dut.write('"IRAM_8BIT capability test"') + dut.expect_unity_test_output(timeout=300) diff --git a/components/heap/test_apps/sdkconfig.ci.8bit_access b/components/heap/test_apps/sdkconfig.ci.8bit_access new file mode 100644 index 0000000000..c8710c4043 --- /dev/null +++ b/components/heap/test_apps/sdkconfig.ci.8bit_access @@ -0,0 +1,2 @@ +CONFIG_FREERTOS_UNICORE=y +CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY=y diff --git a/components/heap/test_apps/sdkconfig.ci.abort_alloc_fail b/components/heap/test_apps/sdkconfig.ci.abort_alloc_fail new file mode 100644 index 0000000000..1dd2c31d33 --- /dev/null +++ b/components/heap/test_apps/sdkconfig.ci.abort_alloc_fail @@ -0,0 +1 @@ +CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS=y diff --git a/components/heap/test_apps/sdkconfig.ci.comprehensive_poisoning b/components/heap/test_apps/sdkconfig.ci.comprehensive_poisoning new file mode 100644 index 0000000000..864e4213dd --- /dev/null +++ b/components/heap/test_apps/sdkconfig.ci.comprehensive_poisoning @@ -0,0 +1,3 @@ +CONFIG_HEAP_POISONING_DISABLED=n +CONFIG_HEAP_POISONING_LIGHT=n +CONFIG_HEAP_POISONING_COMPREHENSIVE=y diff --git a/tools/unit-test-app/configs/heap_light_poison b/components/heap/test_apps/sdkconfig.ci.light_poisoning similarity index 59% rename from tools/unit-test-app/configs/heap_light_poison rename to components/heap/test_apps/sdkconfig.ci.light_poisoning index 540d65168b..0e2c3bc1d2 100644 --- a/tools/unit-test-app/configs/heap_light_poison +++ b/components/heap/test_apps/sdkconfig.ci.light_poisoning @@ -1,4 +1,3 @@ -CONFIG_IDF_TARGET="esp32" -TEST_COMPONENTS=heap -CONFIG_HEAP_POISONING_COMPREHENSIVE=n +CONFIG_HEAP_POISONING_DISABLED=n CONFIG_HEAP_POISONING_LIGHT=y +CONFIG_HEAP_POISONING_COMPREHENSIVE=n diff --git a/components/heap/test_apps/sdkconfig.ci.no_poisoning b/components/heap/test_apps/sdkconfig.ci.no_poisoning new file mode 100644 index 0000000000..657a760928 --- /dev/null +++ b/components/heap/test_apps/sdkconfig.ci.no_poisoning @@ -0,0 +1,3 @@ +CONFIG_HEAP_POISONING_DISABLED=y +CONFIG_HEAP_POISONING_LIGHT=n +CONFIG_HEAP_POISONING_COMPREHENSIVE=n diff --git a/components/heap/test_apps/sdkconfig.ci.psram b/components/heap/test_apps/sdkconfig.ci.psram new file mode 100644 index 0000000000..cc641ea603 --- /dev/null +++ b/components/heap/test_apps/sdkconfig.ci.psram @@ -0,0 +1 @@ +CONFIG_SPIRAM=y diff --git a/components/heap/test_apps/sdkconfig.ci.psram_all_ext b/components/heap/test_apps/sdkconfig.ci.psram_all_ext new file mode 100644 index 0000000000..db575808cf --- /dev/null +++ b/components/heap/test_apps/sdkconfig.ci.psram_all_ext @@ -0,0 +1,2 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 diff --git a/components/heap/test_apps/sdkconfig.defaults b/components/heap/test_apps/sdkconfig.defaults new file mode 100644 index 0000000000..0e8a2c2557 --- /dev/null +++ b/components/heap/test_apps/sdkconfig.defaults @@ -0,0 +1,2 @@ +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n +CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=n # memory protection needs to be disabled for certain tests diff --git a/components/heap/test/test_leak.c b/tools/unit-test-app/components/test_utils/test/leak_test.c similarity index 57% rename from components/heap/test/test_leak.c rename to tools/unit-test-app/components/test_utils/test/leak_test.c index 0144cd937e..46b783507c 100644 --- a/components/heap/test/test_leak.c +++ b/tools/unit-test-app/components/test_utils/test/leak_test.c @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* Tests for a leak tag */ @@ -16,23 +21,23 @@ static char* check_calloc(int size) return arr; } -TEST_CASE("Check for leaks (no leak)", "[heap]") +TEST_CASE("Check for leaks (no leak)", "[test_utils]") { char *arr = check_calloc(1000); free(arr); } -TEST_CASE("Check for leaks (leak)", "[heap][ignore]") +TEST_CASE("Check for leaks (leak)", "[test_utils][ignore]") { check_calloc(1000); } -TEST_CASE("Not check for leaks", "[heap][leaks]") +TEST_CASE("Not check for leaks", "[test_utils][leaks]") { check_calloc(1000); } -TEST_CASE("Set a leak level = 7016", "[heap][leaks=7016]") +TEST_CASE("Set a leak level = 7016", "[test_utils][leaks=7016]") { check_calloc(7000); } @@ -42,9 +47,9 @@ static void test_fn(void) check_calloc(1000); } -TEST_CASE_MULTIPLE_STAGES("Not check for leaks in MULTIPLE_STAGES mode", "[heap][leaks]", test_fn, test_fn, test_fn); +TEST_CASE_MULTIPLE_STAGES("Not check for leaks in MULTIPLE_STAGES mode", "[test_utils][leaks]", test_fn, test_fn, test_fn); -TEST_CASE_MULTIPLE_STAGES("Check for leaks in MULTIPLE_STAGES mode (leak)", "[heap][ignore]", test_fn, test_fn, test_fn); +TEST_CASE_MULTIPLE_STAGES("Check for leaks in MULTIPLE_STAGES mode (leak)", "[test_utils][ignore]", test_fn, test_fn, test_fn); static void test_fn2(void) { @@ -57,4 +62,4 @@ static void test_fn3(void) check_calloc(1000); } -TEST_CASE_MULTIPLE_STAGES("Check for leaks in MULTIPLE_STAGES mode (manual reset)", "[heap][leaks][reset=SW_CPU_RESET, SW_CPU_RESET]", test_fn2, test_fn2, test_fn3); +TEST_CASE_MULTIPLE_STAGES("Check for leaks in MULTIPLE_STAGES mode (manual reset)", "[test_utils][leaks][reset=SW_CPU_RESET, SW_CPU_RESET]", test_fn2, test_fn2, test_fn3); diff --git a/tools/unit-test-app/configs/default b/tools/unit-test-app/configs/default index b3048b444d..8738fb2b14 100644 --- a/tools/unit-test-app/configs/default +++ b/tools/unit-test-app/configs/default @@ -1,5 +1,5 @@ # This config is split between targets since different component needs to be included (esp32, esp32s2) # IRAM is full... split some component to default_32_2 CONFIG_IDF_TARGET="esp32" -TEST_COMPONENTS=freertos esp_hw_support esp_ipc esp_system esp_timer driver heap +TEST_COMPONENTS=freertos esp_hw_support esp_ipc esp_system esp_timer driver CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD=y diff --git a/tools/unit-test-app/configs/default_2 b/tools/unit-test-app/configs/default_2 index bbf1475f3e..4d29040218 100644 --- a/tools/unit-test-app/configs/default_2 +++ b/tools/unit-test-app/configs/default_2 @@ -1,3 +1,3 @@ # This config is split between targets since different component needs to be excluded (esp32, esp32s2) CONFIG_IDF_TARGET="esp32" -TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp_hw_support esp_ipc esp_pm esp_system esp_timer driver heap soc spi_flash vfs test_utils experimental_cpp_component +TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp_hw_support esp_ipc esp_pm esp_system esp_timer driver soc spi_flash vfs test_utils experimental_cpp_component diff --git a/tools/unit-test-app/configs/default_2_c3 b/tools/unit-test-app/configs/default_2_c3 index 01cf74a066..00c6c1f926 100644 --- a/tools/unit-test-app/configs/default_2_c3 +++ b/tools/unit-test-app/configs/default_2_c3 @@ -1,3 +1,3 @@ # This config is split between targets since different component needs to be excluded CONFIG_IDF_TARGET="esp32c3" -TEST_EXCLUDE_COMPONENTS=bt app_update esp_pm freertos esp_hw_support esp_ipc esp_system esp_timer driver heap soc spi_flash vfs lwip spiffs experimental_cpp_component perfmon test_utils +TEST_EXCLUDE_COMPONENTS=bt app_update esp_pm freertos esp_hw_support esp_ipc esp_system esp_timer driver soc spi_flash vfs lwip spiffs experimental_cpp_component perfmon test_utils diff --git a/tools/unit-test-app/configs/default_2_s2 b/tools/unit-test-app/configs/default_2_s2 index 2a34eb0c6b..0654e9e024 100644 --- a/tools/unit-test-app/configs/default_2_s2 +++ b/tools/unit-test-app/configs/default_2_s2 @@ -1,3 +1,3 @@ # This config is split between targets since different component needs to be excluded (esp32, esp32s2) CONFIG_IDF_TARGET="esp32s2" -TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp_hw_support esp_ipc esp_pm esp_system esp_timer driver heap soc spi_flash vfs experimental_cpp_component +TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp_hw_support esp_ipc esp_pm esp_system esp_timer driver soc spi_flash vfs experimental_cpp_component diff --git a/tools/unit-test-app/configs/default_2_s3 b/tools/unit-test-app/configs/default_2_s3 index 0cf5359969..dd1a42050f 100644 --- a/tools/unit-test-app/configs/default_2_s3 +++ b/tools/unit-test-app/configs/default_2_s3 @@ -1,3 +1,3 @@ # This config is split between targets since different component needs to be excluded (esp32, esp32s2) CONFIG_IDF_TARGET="esp32s3" -TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp32s3 esp_ipc esp_pm esp_system esp_timer driver heap soc spi_flash vfs experimental_cpp_component test_utils +TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp32s3 esp_ipc esp_pm esp_system esp_timer driver soc spi_flash vfs experimental_cpp_component test_utils diff --git a/tools/unit-test-app/configs/default_3_c2 b/tools/unit-test-app/configs/default_3_c2 index 475aaf583a..a4d0073792 100644 --- a/tools/unit-test-app/configs/default_3_c2 +++ b/tools/unit-test-app/configs/default_3_c2 @@ -1,3 +1,3 @@ # This config is split between targets since different component needs to be included CONFIG_IDF_TARGET="esp32c2" -TEST_EXCLUDE_COMPONENTS=app_trace console efuse esp_common esp_eth esp_event esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns mqtt newlib nvs_flash partition_table sdmmc spiffs freertos esp_hw_support esp_ipc esp_system esp_timer driver heap soc spi_flash vfs +TEST_EXCLUDE_COMPONENTS=app_trace console efuse esp_common esp_eth esp_event esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns mqtt newlib nvs_flash partition_table sdmmc spiffs freertos esp_hw_support esp_ipc esp_system esp_timer driver soc spi_flash vfs diff --git a/tools/unit-test-app/configs/default_c2 b/tools/unit-test-app/configs/default_c2 index 3033b1cef8..7009dfe166 100644 --- a/tools/unit-test-app/configs/default_c2 +++ b/tools/unit-test-app/configs/default_c2 @@ -1,3 +1,3 @@ # This config is split between targets since different component needs to be included CONFIG_IDF_TARGET="esp32c2" -TEST_COMPONENTS=freertos esp_hw_support esp_ipc esp_system esp_timer driver heap soc spi_flash vfs +TEST_COMPONENTS=freertos esp_hw_support esp_ipc esp_system esp_timer driver soc spi_flash vfs diff --git a/tools/unit-test-app/configs/default_c3 b/tools/unit-test-app/configs/default_c3 index fe48965abf..67c9a75f90 100644 --- a/tools/unit-test-app/configs/default_c3 +++ b/tools/unit-test-app/configs/default_c3 @@ -1,3 +1,3 @@ # This config is split between targets since different component needs to be included CONFIG_IDF_TARGET="esp32c3" -TEST_COMPONENTS=freertos esp_hw_support esp_ipc esp_system esp_timer driver heap +TEST_COMPONENTS=freertos esp_hw_support esp_ipc esp_system esp_timer driver diff --git a/tools/unit-test-app/configs/default_s2_1 b/tools/unit-test-app/configs/default_s2_1 index 3ef5b19050..ec990e29a4 100644 --- a/tools/unit-test-app/configs/default_s2_1 +++ b/tools/unit-test-app/configs/default_s2_1 @@ -1,3 +1,3 @@ # This config is split between targets since different component needs to be included (esp32, esp32s2) CONFIG_IDF_TARGET="esp32s2" -TEST_COMPONENTS=freertos esp_hw_support esp_system esp_timer driver heap +TEST_COMPONENTS=freertos esp_hw_support esp_system esp_timer driver diff --git a/tools/unit-test-app/configs/default_s3 b/tools/unit-test-app/configs/default_s3 index d39dd39f8e..0d78b2ff2a 100644 --- a/tools/unit-test-app/configs/default_s3 +++ b/tools/unit-test-app/configs/default_s3 @@ -1,3 +1,3 @@ # This config is split between targets since different component needs to be included CONFIG_IDF_TARGET="esp32s3" -TEST_COMPONENTS=freertos esp_hw_support esp_ipc esp_system esp_timer driver heap soc spi_flash vfs +TEST_COMPONENTS=freertos esp_hw_support esp_ipc esp_system esp_timer driver soc spi_flash vfs diff --git a/tools/unit-test-app/configs/heap_light_poison_c2 b/tools/unit-test-app/configs/heap_light_poison_c2 deleted file mode 100644 index 1c165b4765..0000000000 --- a/tools/unit-test-app/configs/heap_light_poison_c2 +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG_IDF_TARGET="esp32c2" -TEST_COMPONENTS=heap -CONFIG_HEAP_POISONING_COMPREHENSIVE=n -CONFIG_HEAP_POISONING_LIGHT=y diff --git a/tools/unit-test-app/configs/heap_light_poison_c3 b/tools/unit-test-app/configs/heap_light_poison_c3 deleted file mode 100644 index 270ffb6109..0000000000 --- a/tools/unit-test-app/configs/heap_light_poison_c3 +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG_IDF_TARGET="esp32c3" -TEST_COMPONENTS=heap -CONFIG_HEAP_POISONING_COMPREHENSIVE=n -CONFIG_HEAP_POISONING_LIGHT=y diff --git a/tools/unit-test-app/configs/psram b/tools/unit-test-app/configs/psram index b5d8dc18b5..0b5da79b5c 100644 --- a/tools/unit-test-app/configs/psram +++ b/tools/unit-test-app/configs/psram @@ -1,5 +1,5 @@ CONFIG_IDF_TARGET="esp32" -TEST_EXCLUDE_COMPONENTS=bt app_update driver esp_hw_support esp_ipc esp_pm esp_system esp_timer spi_flash test_utils heap soc experimental_cpp_component esp-tls freertos sdmmc +TEST_EXCLUDE_COMPONENTS=bt app_update driver esp_hw_support esp_ipc esp_pm esp_system esp_timer spi_flash test_utils soc experimental_cpp_component esp-tls freertos sdmmc CONFIG_SPIRAM=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=800 CONFIG_SPIRAM_OCCUPY_NO_HOST=y diff --git a/tools/unit-test-app/configs/psram_2 b/tools/unit-test-app/configs/psram_2 index 69f028cacf..c95fbb5015 100644 --- a/tools/unit-test-app/configs/psram_2 +++ b/tools/unit-test-app/configs/psram_2 @@ -1,5 +1,5 @@ CONFIG_IDF_TARGET="esp32" -TEST_COMPONENTS=esp_hw_support esp_ipc esp_system esp_timer spi_flash heap soc +TEST_COMPONENTS=esp_hw_support esp_ipc esp_system esp_timer spi_flash soc CONFIG_SPIRAM=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=800 CONFIG_SPIRAM_OCCUPY_NO_HOST=y diff --git a/tools/unit-test-app/configs/psram_all_ext_2 b/tools/unit-test-app/configs/psram_all_ext_2 index dd3db07122..9106054015 100644 --- a/tools/unit-test-app/configs/psram_all_ext_2 +++ b/tools/unit-test-app/configs/psram_all_ext_2 @@ -1,5 +1,5 @@ CONFIG_IDF_TARGET="esp32" -TEST_COMPONENTS=heap soc spi_flash +TEST_COMPONENTS=soc spi_flash CONFIG_SPIRAM=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=800 CONFIG_SPIRAM_OCCUPY_NO_HOST=y diff --git a/tools/unit-test-app/configs/release b/tools/unit-test-app/configs/release index d6739ff95f..c48959fc34 100644 --- a/tools/unit-test-app/configs/release +++ b/tools/unit-test-app/configs/release @@ -1,5 +1,5 @@ CONFIG_IDF_TARGET="esp32" -TEST_COMPONENTS=freertos esp_hw_support esp_system esp_ipc esp_timer driver heap soc spi_flash vfs +TEST_COMPONENTS=freertos esp_hw_support esp_system esp_ipc esp_timer driver soc spi_flash vfs CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y diff --git a/tools/unit-test-app/configs/release_2 b/tools/unit-test-app/configs/release_2 index bfe8572019..da9ea704a4 100644 --- a/tools/unit-test-app/configs/release_2 +++ b/tools/unit-test-app/configs/release_2 @@ -1,6 +1,6 @@ # This config is split between targets since different component needs to be included (esp32, esp32s2) CONFIG_IDF_TARGET="esp32" -TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp_hw_support esp_ipc esp_pm esp_system esp_timer driver heap soc spi_flash vfs test_utils experimental_cpp_component +TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp_hw_support esp_ipc esp_pm esp_system esp_timer driver soc spi_flash vfs test_utils experimental_cpp_component CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y diff --git a/tools/unit-test-app/configs/release_2_s2 b/tools/unit-test-app/configs/release_2_s2 index 8cefb25eba..baf847dfed 100644 --- a/tools/unit-test-app/configs/release_2_s2 +++ b/tools/unit-test-app/configs/release_2_s2 @@ -1,6 +1,6 @@ # This config is split between targets since different component needs to be excluded (esp32, esp32s2) CONFIG_IDF_TARGET="esp32s2" -TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp_hw_support esp_ipc esp_pm esp_system esp_timer driver heap soc spi_flash vfs test_utils experimental_cpp_component +TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp_hw_support esp_ipc esp_pm esp_system esp_timer driver soc spi_flash vfs test_utils experimental_cpp_component CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y diff --git a/tools/unit-test-app/configs/release_c2 b/tools/unit-test-app/configs/release_c2 index 7005427151..e836324554 100644 --- a/tools/unit-test-app/configs/release_c2 +++ b/tools/unit-test-app/configs/release_c2 @@ -1,5 +1,5 @@ CONFIG_IDF_TARGET="esp32c2" -TEST_COMPONENTS=freertos esp_hw_support esp_system esp_ipc esp_timer driver heap soc spi_flash vfs sdmmc +TEST_COMPONENTS=freertos esp_hw_support esp_system esp_ipc esp_timer driver soc spi_flash vfs sdmmc CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y diff --git a/tools/unit-test-app/configs/release_c3 b/tools/unit-test-app/configs/release_c3 index 4f96f6e161..e5cc761843 100644 --- a/tools/unit-test-app/configs/release_c3 +++ b/tools/unit-test-app/configs/release_c3 @@ -1,5 +1,5 @@ CONFIG_IDF_TARGET="esp32c3" -TEST_COMPONENTS=freertos esp_hw_support esp_ipc esp_system esp_timer driver heap +TEST_COMPONENTS=freertos esp_hw_support esp_ipc esp_system esp_timer driver CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y diff --git a/tools/unit-test-app/configs/release_s2 b/tools/unit-test-app/configs/release_s2 index 8ef561462d..71e26b6e8f 100644 --- a/tools/unit-test-app/configs/release_s2 +++ b/tools/unit-test-app/configs/release_s2 @@ -1,6 +1,6 @@ # This config is split between targets since different component needs to be included (esp32, esp32s2) CONFIG_IDF_TARGET="esp32s2" -TEST_COMPONENTS=freertos esp_hw_support esp_system esp_timer driver heap soc spi_flash vfs +TEST_COMPONENTS=freertos esp_hw_support esp_system esp_timer driver soc spi_flash vfs CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y diff --git a/tools/unit-test-app/configs/release_s3 b/tools/unit-test-app/configs/release_s3 index 022c6665f4..bb50ddbf3f 100644 --- a/tools/unit-test-app/configs/release_s3 +++ b/tools/unit-test-app/configs/release_s3 @@ -1,5 +1,5 @@ CONFIG_IDF_TARGET="esp32s3" -TEST_COMPONENTS=freertos esp_hw_support esp_system esp_ipc esp_timer driver heap soc spi_flash vfs +TEST_COMPONENTS=freertos esp_hw_support esp_system esp_ipc esp_timer driver soc spi_flash vfs CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y diff --git a/tools/unit-test-app/configs/single_core b/tools/unit-test-app/configs/single_core index fc734c5df7..ef974638b8 100644 --- a/tools/unit-test-app/configs/single_core +++ b/tools/unit-test-app/configs/single_core @@ -1,6 +1,6 @@ # This config is split between targets since different component needs to be included (esp32, esp32s2) CONFIG_IDF_TARGET="esp32" -TEST_COMPONENTS=freertos esp_hw_support esp_system esp_timer driver heap soc spi_flash vfs +TEST_COMPONENTS=freertos esp_hw_support esp_system esp_timer driver soc spi_flash vfs CONFIG_MEMMAP_SMP=n CONFIG_FREERTOS_UNICORE=y CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY=y diff --git a/tools/unit-test-app/configs/single_core_2 b/tools/unit-test-app/configs/single_core_2 index 4df28be5ea..bfa9e19bba 100644 --- a/tools/unit-test-app/configs/single_core_2 +++ b/tools/unit-test-app/configs/single_core_2 @@ -1,6 +1,6 @@ # This config is split between targets since different component needs to be excluded (esp32, esp32s2) CONFIG_IDF_TARGET="esp32" -TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp_hw_support esp_system esp_pm esp_ipc esp_timer driver heap soc spi_flash vfs test_utils experimental_cpp_component +TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp_hw_support esp_system esp_pm esp_ipc esp_timer driver soc spi_flash vfs test_utils experimental_cpp_component CONFIG_MEMMAP_SMP=n CONFIG_FREERTOS_UNICORE=y CONFIG_ESP32_RTCDATA_IN_FAST_MEM=y diff --git a/tools/unit-test-app/configs/single_core_2_s2 b/tools/unit-test-app/configs/single_core_2_s2 index 241a56affb..f8ca87e765 100644 --- a/tools/unit-test-app/configs/single_core_2_s2 +++ b/tools/unit-test-app/configs/single_core_2_s2 @@ -1,6 +1,6 @@ # This config is split between targets since different component needs to be excluded (esp32, esp32s2) CONFIG_IDF_TARGET="esp32s2" -TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp_hw_support esp_ipc esp_system esp_pm esp_timer driver heap soc spi_flash vfs experimental_cpp_component +TEST_EXCLUDE_COMPONENTS=bt app_update freertos esp_hw_support esp_ipc esp_system esp_pm esp_timer driver soc spi_flash vfs experimental_cpp_component CONFIG_MEMMAP_SMP=n CONFIG_FREERTOS_UNICORE=y CONFIG_ESP32S2_RTCDATA_IN_FAST_MEM=y diff --git a/tools/unit-test-app/configs/single_core_s2 b/tools/unit-test-app/configs/single_core_s2 index 3e9e6dd08e..687e6da57b 100644 --- a/tools/unit-test-app/configs/single_core_s2 +++ b/tools/unit-test-app/configs/single_core_s2 @@ -1,4 +1,4 @@ # This config is split between targets since different component needs to be included (esp32, esp32s2) CONFIG_IDF_TARGET="esp32s2" -TEST_COMPONENTS=esp_hw_support esp_system esp_timer driver heap soc spi_flash test_utils +TEST_COMPONENTS=esp_hw_support esp_system esp_timer driver soc spi_flash test_utils CONFIG_ESP32S2_RTCDATA_IN_FAST_MEM=y