From ce217f969911ea27d963f572b2a76cde4a86c323 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 9 Mar 2011 15:39:58 +0000 Subject: 2011-03-09 Sebastian Huber * malloctest/init.c: Improve coverage. * malloctest/malloctest.scn: Update. --- testsuites/libtests/ChangeLog | 5 +++++ testsuites/libtests/malloctest/init.c | 24 +++++++++++++++++------- testsuites/libtests/malloctest/malloctest.scn | 9 +++++++-- 3 files changed, 29 insertions(+), 9 deletions(-) (limited to 'testsuites') diff --git a/testsuites/libtests/ChangeLog b/testsuites/libtests/ChangeLog index e52fcb088d..68e59c2e26 100644 --- a/testsuites/libtests/ChangeLog +++ b/testsuites/libtests/ChangeLog @@ -1,3 +1,8 @@ +2011-03-09 Sebastian Huber + + * malloctest/init.c: Improve coverage. + * malloctest/malloctest.scn: Update. + 2011-02-22 Ralf Corsépius * configure.ac: Add AC_CONFIG_HEADER(config.h). diff --git a/testsuites/libtests/malloctest/init.c b/testsuites/libtests/malloctest/init.c index 791e172626..35cb0c7f72 100644 --- a/testsuites/libtests/malloctest/init.c +++ b/testsuites/libtests/malloctest/init.c @@ -940,32 +940,42 @@ static void test_heap_assert(bool ret, bool expected) static void test_heap_extend(void) { bool ret = false; + Heap_Control *heap = &TestHeap; + uint8_t *area_begin = TestHeapMemory; - _Heap_Initialize( &TestHeap, TestHeapMemory + 768, 256, 0 ); + _Heap_Initialize( heap, area_begin + 768, 256, 0 ); puts( "heap extend - link below" ); - ret = _Protected_heap_Extend( &TestHeap, TestHeapMemory + 0, 256 ); + ret = _Protected_heap_Extend( heap, area_begin + 0, 256 ); test_heap_assert( ret, true ); puts( "heap extend - merge below" ); - ret = _Protected_heap_Extend( &TestHeap, TestHeapMemory + 512, 256 ); + ret = _Protected_heap_Extend( heap, area_begin + 512, 256 ); test_heap_assert( ret, true ); puts( "heap extend - merge above" ); - ret = _Protected_heap_Extend( &TestHeap, TestHeapMemory + 1024, 256 ); + ret = _Protected_heap_Extend( heap, area_begin + 1024, 256 ); test_heap_assert( ret, true ); puts( "heap extend - link above" ); - ret = _Protected_heap_Extend( &TestHeap, TestHeapMemory + 1536, 256 ); + ret = _Protected_heap_Extend( heap, area_begin + 1536, 256 ); test_heap_assert( ret, true ); puts( "heap extend - area too small" ); - ret = _Protected_heap_Extend( &TestHeap, TestHeapMemory + 2048, 0 ); + ret = _Protected_heap_Extend( heap, area_begin + 2048, 0 ); test_heap_assert( ret, false ); puts( "heap extend - invalid area" ); - ret = _Protected_heap_Extend( &TestHeap, (void *) -1, 2 ); + ret = _Protected_heap_Extend( heap, (void *) -1, 2 ); test_heap_assert( ret, false ); + + area_begin = (uint8_t *) (((uintptr_t) area_begin) | 1); + + _Heap_Initialize( heap, area_begin + 768, 256, 0 ); + + puts( "heap extend - merge below with align up" ); + ret = _Protected_heap_Extend( heap, area_begin + 512, 256 ); + test_heap_assert( ret, true ); } static void test_heap_info(void) diff --git a/testsuites/libtests/malloctest/malloctest.scn b/testsuites/libtests/malloctest/malloctest.scn index 7e46ac0c18..ba0e19d999 100644 --- a/testsuites/libtests/malloctest/malloctest.scn +++ b/testsuites/libtests/malloctest/malloctest.scn @@ -44,8 +44,13 @@ run tests for _Heap_Resize_Block() malloc_walk - normal path malloc_walk - in critical section path Heap Initialized -heap extend - bad address -heap extend - OK +heap extend - link below +heap extend - merge below +heap extend - merge above +heap extend - link above +heap extend - area too small +heap extend - invalid area +heap extend - merge below with align up malloc_free_space - check malloc space drops after malloc malloc_free_space - verify free space returns to previous value malloc_info - called with NULL -- cgit v1.2.3