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.
This commit is contained in:
Joel Sherrill
2010-07-14 23:23:12 +00:00
parent ba959a4b1c
commit 830c6eee8e
3 changed files with 24 additions and 2 deletions

View File

@@ -1,3 +1,9 @@
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.

View File

@@ -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);

View File

@@ -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)