From cd792a86cf61a46b83b09f2b2d4ba8acab693017 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 3 Feb 1999 22:12:28 +0000 Subject: Patch from John S Gwynne for malloctest. His comments: I have a few patches for the efi332 bsp. If you let me know when you expect the next snapshot release, I will try to have them to you before then. Also, the malloctest has some problems that I would think would prevent it from running on almost any platform. I have enclose patches below to fix (1) Task_id and Task_name dimensioning, (2) end of test message, (3) the amount of memory malloc'ed, and (4) retry on unsuccessful (out of memory) molloc's. --- testsuites/libtests/malloctest/system.h | 6 +++--- testsuites/libtests/malloctest/task1.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'testsuites/libtests') diff --git a/testsuites/libtests/malloctest/system.h b/testsuites/libtests/malloctest/system.h index 7c95130900..e640424eed 100644 --- a/testsuites/libtests/malloctest/system.h +++ b/testsuites/libtests/malloctest/system.h @@ -39,13 +39,13 @@ void blow_stack( void ); #define TASK_STACK_SIZE (RTEMS_MINIMUM_STACK_SIZE*3) -#define CONFIGURE_EXTRA_TASK_STACKS (10 * RTEMS_MINIMUM_STACK_SIZE) +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE #include /* global variables */ -TEST_EXTERN rtems_id Task_id[ 4 ]; /* array of task ids */ -TEST_EXTERN rtems_name Task_name[ 4 ]; /* array of task names */ +TEST_EXTERN rtems_id Task_id[ 6 ]; /* array of task ids */ +TEST_EXTERN rtems_name Task_name[ 6 ]; /* array of task names */ /* end of include file */ diff --git a/testsuites/libtests/malloctest/task1.c b/testsuites/libtests/malloctest/task1.c index aa47bd404b..b535e382ed 100644 --- a/testsuites/libtests/malloctest/task1.c +++ b/testsuites/libtests/malloctest/task1.c @@ -17,6 +17,7 @@ #include "system.h" #include /* for malloc_dump, malloc_walk */ #include /* for memset */ +#include #define NUM_PASSES 100 @@ -37,8 +38,10 @@ rtems_task Task_1_through_5( while (TRUE) { - if ( passes++ > NUM_PASSES ) + if ( passes++ > NUM_PASSES ) { + puts("*** END OF MALLOC TEST ***"); exit(0); + } status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); directive_failed( status, "rtems_clock_get" ); @@ -46,9 +49,12 @@ rtems_task Task_1_through_5( put_name( Task_name[ task_number( tid ) ], FALSE ); print_time( " - rtems_clock_get - ", &time, "\n" ); - mem_amt = rand() * task_number( tid ); + mem_amt = ((int)((float)rand()*1000.0/(float)RAND_MAX)); + while (!(mem_ptr = malloc ( mem_amt))) { + printf("out of memory... trying again.\n"); + mem_amt = ((int)((float)rand()*1000.0/(float)RAND_MAX)); + } printf("mallocing %d bytes\n",mem_amt); - mem_ptr = malloc ( mem_amt); memset( mem_ptr, mem_amt, mem_amt ); malloc_dump(); malloc_walk(1,FALSE); -- cgit v1.2.3