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. --- c/src/tests/libtests/malloctest/task1.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'c/src/tests/libtests/malloctest/task1.c') diff --git a/c/src/tests/libtests/malloctest/task1.c b/c/src/tests/libtests/malloctest/task1.c index aa47bd404b..b535e382ed 100644 --- a/c/src/tests/libtests/malloctest/task1.c +++ b/c/src/tests/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