diff --git a/components/heap/test/test_realloc.c b/components/heap/test/test_realloc.c index 763cddab6..ed2fe17b3 100644 --- a/components/heap/test/test_realloc.c +++ b/components/heap/test/test_realloc.c @@ -7,6 +7,7 @@ #include "unity.h" #include "sdkconfig.h" #include "esp_heap_caps.h" +#include "soc/soc_memory_layout.h" #ifndef CONFIG_HEAP_POISONING_COMPREHENSIVE @@ -22,6 +23,21 @@ TEST_CASE("realloc shrink buffer in place", "[heap]") #endif +TEST_CASE("realloc shrink buffer with EXEC CAPS", "[heap]") +{ + const size_t buffer_size = 64; + + void *x = heap_caps_malloc(buffer_size, MALLOC_CAP_EXEC); + TEST_ASSERT(x); + void *y = heap_caps_realloc(x, buffer_size - 16, MALLOC_CAP_EXEC); + TEST_ASSERT(y); + + //y needs to fall in a compatible memory area of IRAM: + TEST_ASSERT(esp_ptr_executable(y)); + + free(y); +} + TEST_CASE("realloc move data to a new heap type", "[heap]") { const char *test = "I am some test content to put in the heap";