diff --git a/components/heap/test_apps/heap_tests/main/test_heap_align_hw.c b/components/heap/test_apps/heap_tests/main/test_heap_align_hw.c index a3fa60cfaae..2dd6601cfa6 100644 --- a/components/heap/test_apps/heap_tests/main/test_heap_align_hw.c +++ b/components/heap/test_apps/heap_tests/main/test_heap_align_hw.c @@ -15,6 +15,7 @@ #include "esp_memory_utils.h" #include "hal/cache_ll.h" #include "hal/cache_hal.h" +#include "soc/soc_caps.h" TEST_CASE("test heap_caps_malloc_prefer for dma memory", "[hw-align]") { @@ -41,13 +42,21 @@ TEST_CASE("test heap_caps_calloc_prefer for dma memory", "[hw-align]") #define TEST_ALLOC_COUNT 100 static bool test_alignment(uint32_t caps, int expected_alignment) { bool ret=true; + int alignment = (expected_alignment > 1) ? expected_alignment : 1; void *mem[TEST_ALLOC_COUNT]; size_t size[TEST_ALLOC_COUNT]; //First, check if we can allocate memory with these caps anyway. + if ((caps & MALLOC_CAP_SPIRAM) && heap_caps_get_total_size(MALLOC_CAP_SPIRAM) == 0) { + printf("skipping caps 0x%" PRIx32 ": no PSRAM heap registered\n", caps); + return true; + } void *tst=heap_caps_malloc(1, caps); - if (!tst) return true; + if (!tst) { + printf("caps 0x%" PRIx32 ": cannot allocate 1 byte with alignment %d\n", caps, alignment); + return false; + } free(tst); //Step 1: generate sizes and allocate memory. @@ -59,9 +68,20 @@ static bool test_alignment(uint32_t caps, int expected_alignment) { // Step 2: check alignment and fill up memory up to the aligned size // (which should succeed as we expect to get an integer amount of cache lines) for (int i=0; i8?int_cache_size:8); - test_alignment(MALLOC_CAP_DMA|MALLOC_CAP_SPIRAM, ext_cache_size); + TEST_ASSERT_TRUE_MESSAGE(test_alignment(MALLOC_CAP_DMA, int_cache_size), "MALLOC_CAP_DMA"); + TEST_ASSERT_TRUE_MESSAGE(test_alignment(MALLOC_CAP_DMA_DESC_AHB, int_cache_size), "MALLOC_CAP_DMA_DESC_AHB"); +#if SOC_HAS(AXI_GDMA) + int axi_desc_alignment = int_cache_size > 8 ? int_cache_size : 8; +#else + int axi_desc_alignment = int_cache_size; +#endif + TEST_ASSERT_TRUE_MESSAGE(test_alignment(MALLOC_CAP_DMA_DESC_AXI, axi_desc_alignment), "MALLOC_CAP_DMA_DESC_AXI"); + TEST_ASSERT_TRUE_MESSAGE(test_alignment(MALLOC_CAP_DMA|MALLOC_CAP_SPIRAM, ext_cache_size), "MALLOC_CAP_DMA|MALLOC_CAP_SPIRAM"); } diff --git a/components/heap/test_apps/heap_tests/pytest_heap.py b/components/heap/test_apps/heap_tests/pytest_heap.py index ab1bb25b12b..825b6cb9194 100644 --- a/components/heap/test_apps/heap_tests/pytest_heap.py +++ b/components/heap/test_apps/heap_tests/pytest_heap.py @@ -48,6 +48,7 @@ def test_heap_in_flash(dut: Dut) -> None: @pytest.mark.parametrize('config', ['psram', 'psram_all_ext']) def test_heap(dut: Dut) -> None: dut.run_all_single_board_cases(group='psram') + dut.run_all_single_board_cases(group='hw-align') @pytest.mark.generic