mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 12:44:33 +02:00
Merge branch 'feature/heap_pytest' into 'master'
heap: move unit tests to pytest Closes IDF-5591 See merge request espressif/esp-idf!20229
This commit is contained in:
@@ -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")
|
6
components/heap/test_apps/CMakeLists.txt
Normal file
6
components/heap/test_apps/CMakeLists.txt
Normal file
@@ -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)
|
2
components/heap/test_apps/README.md
Normal file
2
components/heap/test_apps/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- |
|
14
components/heap/test_apps/main/CMakeLists.txt
Normal file
14
components/heap/test_apps/main/CMakeLists.txt
Normal file
@@ -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)
|
@@ -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 <sys/param.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
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);
|
@@ -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 <esp_types.h>
|
||||
#include <stdio.h>
|
||||
@@ -7,7 +12,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
#include <string.h>
|
||||
#include <test_utils.h>
|
||||
|
||||
//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);
|
41
components/heap/test_apps/main/test_app_main.c
Normal file
41
components/heap/test_apps/main/test_app_main.c
Normal file
@@ -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();
|
||||
}
|
@@ -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
|
@@ -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)
|
@@ -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
|
||||
|
@@ -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
|
||||
*/
|
@@ -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;
|
||||
}
|
||||
|
@@ -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)
|
@@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#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);
|
||||
|
66
components/heap/test_apps/pytest_heap.py
Normal file
66
components/heap/test_apps/pytest_heap.py
Normal file
@@ -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)
|
2
components/heap/test_apps/sdkconfig.ci.8bit_access
Normal file
2
components/heap/test_apps/sdkconfig.ci.8bit_access
Normal file
@@ -0,0 +1,2 @@
|
||||
CONFIG_FREERTOS_UNICORE=y
|
||||
CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY=y
|
1
components/heap/test_apps/sdkconfig.ci.abort_alloc_fail
Normal file
1
components/heap/test_apps/sdkconfig.ci.abort_alloc_fail
Normal file
@@ -0,0 +1 @@
|
||||
CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS=y
|
@@ -0,0 +1,3 @@
|
||||
CONFIG_HEAP_POISONING_DISABLED=n
|
||||
CONFIG_HEAP_POISONING_LIGHT=n
|
||||
CONFIG_HEAP_POISONING_COMPREHENSIVE=y
|
@@ -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
|
3
components/heap/test_apps/sdkconfig.ci.no_poisoning
Normal file
3
components/heap/test_apps/sdkconfig.ci.no_poisoning
Normal file
@@ -0,0 +1,3 @@
|
||||
CONFIG_HEAP_POISONING_DISABLED=y
|
||||
CONFIG_HEAP_POISONING_LIGHT=n
|
||||
CONFIG_HEAP_POISONING_COMPREHENSIVE=n
|
1
components/heap/test_apps/sdkconfig.ci.psram
Normal file
1
components/heap/test_apps/sdkconfig.ci.psram
Normal file
@@ -0,0 +1 @@
|
||||
CONFIG_SPIRAM=y
|
2
components/heap/test_apps/sdkconfig.ci.psram_all_ext
Normal file
2
components/heap/test_apps/sdkconfig.ci.psram_all_ext
Normal file
@@ -0,0 +1,2 @@
|
||||
CONFIG_SPIRAM=y
|
||||
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0
|
2
components/heap/test_apps/sdkconfig.defaults
Normal file
2
components/heap/test_apps/sdkconfig.defaults
Normal file
@@ -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
|
@@ -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);
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -1,4 +0,0 @@
|
||||
CONFIG_IDF_TARGET="esp32c2"
|
||||
TEST_COMPONENTS=heap
|
||||
CONFIG_HEAP_POISONING_COMPREHENSIVE=n
|
||||
CONFIG_HEAP_POISONING_LIGHT=y
|
@@ -1,4 +0,0 @@
|
||||
CONFIG_IDF_TARGET="esp32c3"
|
||||
TEST_COMPONENTS=heap
|
||||
CONFIG_HEAP_POISONING_COMPREHENSIVE=n
|
||||
CONFIG_HEAP_POISONING_LIGHT=y
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user