heap: added test case for realloc to verify if successive realloc in IRAM still ends there.

This commit is contained in:
Felipe Neves 2019-12-20 13:48:09 -03:00
parent 4909fdfe02
commit 8795b2681c

View file

@ -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";