diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-07-09 16:13:06 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-07-09 16:13:06 +0000 |
commit | 66abaa1e20842490e1ab8a38f4eed9058ab395cf (patch) | |
tree | 79b72cf0fb8864f571db85d1c43ed46317db0670 /testsuites/libtests/malloctest/init.c | |
parent | 2009-07-08 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-66abaa1e20842490e1ab8a38f4eed9058ab395cf.tar.bz2 |
2009-07-09 Joel Sherrill <joel.sherrill@OARcorp.com>
* malloctest/init.c, malloctest/malloctest.scn: Add heap resize test
for shrinking a block enough to need to free the newly unused
portion.
Diffstat (limited to 'testsuites/libtests/malloctest/init.c')
-rw-r--r-- | testsuites/libtests/malloctest/init.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/testsuites/libtests/malloctest/init.c b/testsuites/libtests/malloctest/init.c index f5792a6d25..8796bf9693 100644 --- a/testsuites/libtests/malloctest/init.c +++ b/testsuites/libtests/malloctest/init.c @@ -62,7 +62,7 @@ void test_realloc(void) free(p1); /* Test realloc that should fail "in place", i.e., - * fallback to free()--malloc() + * fallback to free()-- malloc() */ p1 = malloc(32); p2 = malloc(32); @@ -252,6 +252,25 @@ void test_protected_heap_info(void) rtems_test_assert( rc == false ); } +void test_heap_resize(void) +{ + Heap_Resize_status rc; + void *p1; + intptr_t oldsize; + intptr_t avail; + + puts( "Initialize Test Heap" ); + test_heap_init(); + + puts( "Allocate most of heap" ); + p1 = _Heap_Allocate( &TestHeap, TEST_HEAP_SIZE - 32 ); + rtems_test_assert( p1 != NULL ); + + puts( "Resize (shrink) the area to 8 bytes to ensure remainder gets freed" ); + rc = _Heap_Resize_block( &TestHeap, p1, 8, &oldsize, &avail ); + rtems_test_assert( rc == HEAP_RESIZE_SUCCESSFUL ); +} + /* * A simple test of posix_memalign */ @@ -319,6 +338,7 @@ rtems_task Init( test_heap_extend(); test_heap_info(); test_protected_heap_info(); + test_heap_resize(); test_posix_memalign(); |