From aaee3a9179e3586a7530aa8a1a0166f4428fcadc Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Sat, 22 Dec 2012 16:38:45 +0100 Subject: libtests/malloctest: Add test case --- testsuites/libtests/malloctest/init.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/testsuites/libtests/malloctest/init.c b/testsuites/libtests/malloctest/init.c index 008377ca5e..2f09f3a582 100644 --- a/testsuites/libtests/malloctest/init.c +++ b/testsuites/libtests/malloctest/init.c @@ -586,6 +586,30 @@ static void test_heap_allocate(void) p1 = test_init_and_alloc( alloc_size, alignment, boundary, NULL ); } +static void test_heap_free(void) +{ + Heap_Control *heap = &TestHeap; + void *p; + Heap_Block *block; + bool ok; + + _Heap_Initialize( heap, &TestHeapMemory[0], sizeof(TestHeapMemory), 0 ); + + p = _Heap_Allocate( heap, 1 ); + rtems_test_assert( p != NULL ); + + block = _Heap_Block_of_alloc_area( (uintptr_t) p, heap->page_size ); + + /* + * This will kick the next block outside of the heap area and the next + * _Heap_Free() will detect this. + */ + block->size_and_flag += sizeof(TestHeapMemory); + + ok = _Heap_Free( heap, p ); + rtems_test_assert( !ok ); +} + static void *test_create_used_block( void ) { uintptr_t const alloc_size = 3 * TEST_DEFAULT_PAGE_SIZE; @@ -1207,6 +1231,7 @@ rtems_task Init( test_heap_initialize(); test_heap_block_allocate(); test_heap_allocate(); + test_heap_free(); test_heap_resize_block(); test_realloc(); test_heap_cases_1(); -- cgit v1.2.3