mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 13:44:32 +02:00
heap: add test case for region overlap check condition
This commit is contained in:
@@ -162,6 +162,7 @@ esp_err_t heap_caps_add_region(intptr_t start, intptr_t end)
|
|||||||
return ESP_ERR_NOT_FOUND;
|
return ESP_ERR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This API is used for internal test purpose and hence its not marked as static */
|
||||||
bool heap_caps_check_add_region_allowed(intptr_t heap_start, intptr_t heap_end, intptr_t start, intptr_t end)
|
bool heap_caps_check_add_region_allowed(intptr_t heap_start, intptr_t heap_end, intptr_t start, intptr_t end)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@@ -71,3 +71,20 @@ TEST_CASE("Add .bss memory to heap region runtime", "[heap][ignore]")
|
|||||||
/* Twice add must be failed */
|
/* Twice add must be failed */
|
||||||
TEST_ASSERT( (heap_caps_add_region((intptr_t)s_buffer, (intptr_t)s_buffer + BUF_SZ) != ESP_OK) );
|
TEST_ASSERT( (heap_caps_add_region((intptr_t)s_buffer, (intptr_t)s_buffer + BUF_SZ) != ESP_OK) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern esp_err_t heap_caps_check_add_region_allowed(intptr_t heap_start, intptr_t heap_end, intptr_t start, intptr_t end);
|
||||||
|
|
||||||
|
TEST_CASE("Add heap region address range checks", "[heap]")
|
||||||
|
{
|
||||||
|
const intptr_t heap_start = 0x1000;
|
||||||
|
const intptr_t heap_end = 0x3000;
|
||||||
|
|
||||||
|
TEST_ASSERT_TRUE(heap_caps_check_add_region_allowed(heap_start, heap_end, 0x0, 0x1000));
|
||||||
|
TEST_ASSERT_TRUE(heap_caps_check_add_region_allowed(heap_start, heap_end, 0x1000, 0x2000));
|
||||||
|
TEST_ASSERT_TRUE(heap_caps_check_add_region_allowed(heap_start, heap_end, 0x1000, 0x3000));
|
||||||
|
TEST_ASSERT_TRUE(heap_caps_check_add_region_allowed(heap_start, heap_end, 0x3000, 0x4000));
|
||||||
|
TEST_ASSERT_FALSE(heap_caps_check_add_region_allowed(heap_start, heap_end, 0x0, 0x2000));
|
||||||
|
TEST_ASSERT_FALSE(heap_caps_check_add_region_allowed(heap_start, heap_end, 0x0, 0x4000));
|
||||||
|
TEST_ASSERT_FALSE(heap_caps_check_add_region_allowed(heap_start, heap_end, 0x1000, 0x4000));
|
||||||
|
TEST_ASSERT_FALSE(heap_caps_check_add_region_allowed(heap_start, heap_end, 0x2000, 0x4000));
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user