diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-14 23:23:12 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-14 23:23:12 +0000 |
commit | 830c6eee8e91caf594a9f8cfbe3f9bbe1f5dd60b (patch) | |
tree | b8036be482b29a2fa1f4b3fe5e1828c45d542c82 /testsuites/libtests/malloc04 | |
parent | 2010-07-14 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-830c6eee8e91caf594a9f8cfbe3f9bbe1f5dd60b.tar.bz2 |
2010-07-14 Joel Sherrill <joel.sherrill@oarcorp.com>
PR 1535/tests
* malloc04/init.c, malloc04/malloc04.scn: Address issues in test. A mix
of work by Ralf and Joel.
Diffstat (limited to 'testsuites/libtests/malloc04')
-rw-r--r-- | testsuites/libtests/malloc04/init.c | 17 | ||||
-rw-r--r-- | testsuites/libtests/malloc04/malloc04.scn | 3 |
2 files changed, 18 insertions, 2 deletions
diff --git a/testsuites/libtests/malloc04/init.c b/testsuites/libtests/malloc04/init.c index 17ece56980..afb6eae0a9 100644 --- a/testsuites/libtests/malloc04/init.c +++ b/testsuites/libtests/malloc04/init.c @@ -13,6 +13,7 @@ #include "test_support.h" #include <rtems/libcsupport.h> #include <rtems/malloc.h> +#include <errno.h> char Malloc_Heap[ 128 ] CPU_STRUCTURE_ALIGNMENT; int sbrk_count; @@ -25,12 +26,15 @@ extern rtems_malloc_sbrk_functions_t *rtems_malloc_sbrk_helpers; extern rtems_malloc_sbrk_functions_t rtems_malloc_sbrk_helpers_table; size_t offset; + void * sbrk(ptrdiff_t incr) { void *p = (void *) -1; printf( "sbrk(%td)\n", incr ); - if ( offset + incr < sizeof(Malloc_Heap) ) { + if ( sbrk_count == -1 ) { + p = (void *) (NULL - 2); + } else if ( offset + incr < sizeof(Malloc_Heap) ) { p = &Malloc_Heap[ offset ]; offset += incr; } else { @@ -67,6 +71,16 @@ rtems_task Init( p3 = malloc(48); p4 = malloc(48); + puts( "Initialize heap with some memory - return address out of heap" ); + RTEMS_Malloc_Initialize( &Malloc_Heap[1], 64, 64 ); + offset = 64; + sbrk_count = -1; + p1 = malloc( 127 ); + rtems_test_assert( p1 == (void *) NULL ); + rtems_test_assert( errno == ENOMEM ); + + + RTEMS_Malloc_Initialize( Malloc_Heap, 64, 64 ); puts( "Initialize heap with some unaligned memory" ); offset = 65; sbrk_count = 0; @@ -101,7 +115,6 @@ rtems_task Init( *RTEMS_Malloc_Heap = Heap_Holder; rtems_malloc_sbrk_helpers = NULL; - puts( "*** END OF TEST MALLOC 04 ***" ); rtems_test_exit(0); diff --git a/testsuites/libtests/malloc04/malloc04.scn b/testsuites/libtests/malloc04/malloc04.scn index a2ad14aee9..df95a81bde 100644 --- a/testsuites/libtests/malloc04/malloc04.scn +++ b/testsuites/libtests/malloc04/malloc04.scn @@ -3,6 +3,9 @@ Initialize heap with some memory sbrk(128) sbrk(128) sbrk(64) +Initialize heap with some memory - return address out of heap +sbrk(128) +sbrk(-128) Initialize heap with some unaligned memory sbrk(128) sbrk(128) |