diff options
Diffstat (limited to 'testsuites/libtests')
-rw-r--r-- | testsuites/libtests/ChangeLog | 6 | ||||
-rw-r--r-- | testsuites/libtests/malloc04/init.c | 17 | ||||
-rw-r--r-- | testsuites/libtests/malloc04/malloc04.scn | 3 |
3 files changed, 24 insertions, 2 deletions
diff --git a/testsuites/libtests/ChangeLog b/testsuites/libtests/ChangeLog index ae6f3af3df..28b9dd9916 100644 --- a/testsuites/libtests/ChangeLog +++ b/testsuites/libtests/ChangeLog @@ -1,5 +1,11 @@ 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. + +2010-07-14 Joel Sherrill <joel.sherrill@oarcorp.com> + * termios01/init.c, termios01/termios01.scn: Fully exercise tcsetattr. 2010-07-08 Joel Sherrill <joel.sherrill@oarcorp.com> 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) |