From b0e81c9689019725d7fc519f5e35629444caa8cf Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 7 Jun 2010 09:33:32 +0000 Subject: 2010-06-07 Sebastian Huber * heapwalk/init.c, malloctest/init.c: Update for heap extend changes. --- testsuites/libtests/ChangeLog | 4 ++++ testsuites/libtests/heapwalk/init.c | 5 ----- testsuites/libtests/malloctest/init.c | 42 +++++++++++++++++++++++++---------- 3 files changed, 34 insertions(+), 17 deletions(-) (limited to 'testsuites/libtests') diff --git a/testsuites/libtests/ChangeLog b/testsuites/libtests/ChangeLog index b37e04e7ec..f838f1e501 100644 --- a/testsuites/libtests/ChangeLog +++ b/testsuites/libtests/ChangeLog @@ -1,3 +1,7 @@ +2010-06-07 Sebastian Huber + + * heapwalk/init.c, malloctest/init.c: Update for heap extend changes. + 2010-05-17 Sebastian Huber PR 1433/cpukit diff --git a/testsuites/libtests/heapwalk/init.c b/testsuites/libtests/heapwalk/init.c index 56cf0627b1..4d13976790 100644 --- a/testsuites/libtests/heapwalk/init.c +++ b/testsuites/libtests/heapwalk/init.c @@ -127,11 +127,6 @@ static void test_check_control(void) TestHeap.first_block->size_and_flag &= ~HEAP_PREV_BLOCK_USED; test_call_heap_walk( false ); - puts( "\tset the previous block size of the first block to an invalid value" ); - test_heap_init_custom(); - TestHeap.first_block->prev_size = 0; - test_call_heap_walk( false ); - puts( "\tset invalid next block for last block" ); test_heap_init_custom(); TestHeap.last_block->size_and_flag = 0; diff --git a/testsuites/libtests/malloctest/init.c b/testsuites/libtests/malloctest/init.c index 4210372ff5..625e9569bb 100644 --- a/testsuites/libtests/malloctest/init.c +++ b/testsuites/libtests/malloctest/init.c @@ -925,23 +925,41 @@ static void test_heap_resize_block(void) test_simple_resize_block( p1, new_alloc_size, HEAP_RESIZE_SUCCESSFUL ); } +static void test_heap_assert(bool ret, bool expected) +{ + rtems_test_assert( ret == expected ); + rtems_test_assert( _Heap_Walk( &TestHeap, 0, false ) ); +} + static void test_heap_extend(void) { - bool ret; + bool ret = false; - /* - * Easier to hit extend with a dedicated heap. - * - */ - _Heap_Initialize( &TestHeap, TestHeapMemory, 512, 0 ); + _Heap_Initialize( &TestHeap, TestHeapMemory + 768, 256, 0 ); + + puts( "heap extend - link below" ); + ret = _Protected_heap_Extend( &TestHeap, TestHeapMemory + 0, 256 ); + test_heap_assert( ret, true ); + + puts( "heap extend - merge below" ); + ret = _Protected_heap_Extend( &TestHeap, TestHeapMemory + 512, 256 ); + test_heap_assert( ret, true ); + + puts( "heap extend - merge above" ); + ret = _Protected_heap_Extend( &TestHeap, TestHeapMemory + 1024, 256 ); + test_heap_assert( ret, true ); + + puts( "heap extend - link above" ); + ret = _Protected_heap_Extend( &TestHeap, TestHeapMemory + 1536, 256 ); + test_heap_assert( ret, true ); - puts( "heap extend - bad address" ); - ret = _Protected_heap_Extend( &TestHeap, TestHeapMemory - 512, 512 ); - rtems_test_assert( ret == false ); + puts( "heap extend - area too small" ); + ret = _Protected_heap_Extend( &TestHeap, TestHeapMemory + 2048, 0 ); + test_heap_assert( ret, false ); - puts( "heap extend - OK" ); - ret = _Protected_heap_Extend( &TestHeap, &TestHeapMemory[ 512 ], 512 ); - rtems_test_assert( ret == true ); + puts( "heap extend - invalid area" ); + ret = _Protected_heap_Extend( &TestHeap, (void *) -1, 2 ); + test_heap_assert( ret, false ); } static void test_heap_info(void) -- cgit v1.2.3