diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-10-12 17:02:30 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-10-25 14:54:06 +0200 |
commit | e4278f2050a276f07e23d630adc78ee4e4c143dc (patch) | |
tree | 21cf405726c2b5d880ba73e335ae4a28428fcc31 /testsuites | |
parent | score: Change _Heap_Extend() API (diff) | |
download | rtems-e4278f2050a276f07e23d630adc78ee4e4c143dc.tar.bz2 |
score: Append to free list in _Heap_Extend()
Diffstat (limited to 'testsuites')
-rw-r--r-- | testsuites/libtests/malloctest/init.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/testsuites/libtests/malloctest/init.c b/testsuites/libtests/malloctest/init.c index c2080e8469..f7839246c3 100644 --- a/testsuites/libtests/malloctest/init.c +++ b/testsuites/libtests/malloctest/init.c @@ -984,6 +984,46 @@ static void test_heap_extend(void) test_heap_assert( ret, true ); } +static void test_heap_extend_allocation_order(void) +{ + Heap_Control *heap = &TestHeap; + uintptr_t size = 256; + uintptr_t gap = 256; + uint8_t *init_area_begin = TestHeapMemory; + uint8_t *extend_area_begin = init_area_begin + size + gap; + bool ret; + uint8_t *p; + + _Heap_Initialize( heap, init_area_begin, size, 0 ); + + ret = _Protected_heap_Extend( heap, extend_area_begin, size ); + test_heap_assert( ret, true ); + + p = _Heap_Allocate( heap, 1 ); + rtems_test_assert( (uintptr_t) (p - init_area_begin) < size ); +} + +static void test_heap_extend_allocation_order_with_empty_heap(void) +{ + Heap_Control *heap = &TestHeap; + uintptr_t size = 256; + uintptr_t gap = 256; + uint8_t *init_area_begin = TestHeapMemory; + uint8_t *extend_area_begin = init_area_begin + size + gap; + bool ret; + uint8_t *p; + + _Heap_Initialize( heap, init_area_begin, size, 0 ); + + _Heap_Greedy_allocate( heap, NULL, 0 ); + + ret = _Protected_heap_Extend( heap, extend_area_begin, size ); + test_heap_assert( ret, true ); + + p = _Heap_Allocate( heap, 1 ); + rtems_test_assert( (uintptr_t) (p - extend_area_begin) < size ); +} + static void test_heap_no_extend(void) { uintptr_t extended_space = _Heap_No_extend( NULL, 0, 0, 0 ); @@ -1148,6 +1188,8 @@ rtems_task Init( test_realloc(); test_heap_cases_1(); test_heap_extend(); + test_heap_extend_allocation_order(); + test_heap_extend_allocation_order_with_empty_heap(); test_heap_no_extend(); test_heap_info(); test_protected_heap_info(); |