From 8814cf04cc3f50ea78e8b645b74ae46b462e037a Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 7 May 2009 17:08:28 +0000 Subject: 2009-05-07 Santosh G Vattam * malloctest/init.c: Add test case for heap resize block when the resize creates a free block large enough to free. --- testsuites/libtests/ChangeLog | 5 +++++ testsuites/libtests/malloctest/init.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'testsuites/libtests') diff --git a/testsuites/libtests/ChangeLog b/testsuites/libtests/ChangeLog index 2f1d72168c..63e31bc024 100644 --- a/testsuites/libtests/ChangeLog +++ b/testsuites/libtests/ChangeLog @@ -1,3 +1,8 @@ +2009-05-07 Santosh G Vattam + + * malloctest/init.c: Add test case for heap resize block when the + resize creates a free block large enough to free. + 2009-04-03 Ralf Corsépius * cpuuse/Makefile.am, malloctest/Makefile.am, diff --git a/testsuites/libtests/malloctest/init.c b/testsuites/libtests/malloctest/init.c index 37c9e4d762..2ca8197e5c 100644 --- a/testsuites/libtests/malloctest/init.c +++ b/testsuites/libtests/malloctest/init.c @@ -150,6 +150,25 @@ void test_heap_cases_1() /* XXX what should we expect */ _Heap_Free( &TestHeap, p3 ); _Heap_Free( &TestHeap, p4 ); + _Heap_Free( &TestHeap, p1 ); + + /* + * To tackle a special case of resizing a block in order to cover the + * code in heapresizeblock.c + * + * Re-initialise the heap, so that the blocks created from now on + * are contiguous. + */ + test_heap_init(); + puts( "Heap Initialized" ); + p1 = _Heap_Allocate( &TestHeap, 500 ); + rtems_test_assert( p2 != NULL ); + p2 = _Heap_Allocate( &TestHeap, 500 ); + rtems_test_assert( p2 != NULL ); + rsc = _Heap_Resize_block( &TestHeap, p1, 256, &u1, &u2 ); + rtems_test_assert( rsc == HEAP_RESIZE_SUCCESSFUL ); + _Heap_Free( &TestHeap, p1 ); + _Heap_Free( &TestHeap, p2 ); } void test_heap_extend() -- cgit v1.2.3