[rtems commit] libtests/malloctest: Add test case
Sebastian Huber
sebh at rtems.org
Sat Dec 22 15:36:45 UTC 2012
Module: rtems
Branch: master
Commit: aaee3a9179e3586a7530aa8a1a0166f4428fcadc
Changeset: http://git.rtems.org/rtems/commit/?id=aaee3a9179e3586a7530aa8a1a0166f4428fcadc
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Sat Dec 22 16:38:45 2012 +0100
libtests/malloctest: Add test case
---
testsuites/libtests/malloctest/init.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/testsuites/libtests/malloctest/init.c b/testsuites/libtests/malloctest/init.c
index 008377c..2f09f3a 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();
More information about the vc
mailing list