forked from Imagelibrary/rtems
Patch from John S Gwynne <jsg@donet.com> 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.
This commit is contained in:
@@ -39,13 +39,13 @@ void blow_stack( void );
|
|||||||
|
|
||||||
#define TASK_STACK_SIZE (RTEMS_MINIMUM_STACK_SIZE*3)
|
#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 <confdefs.h>
|
#include <confdefs.h>
|
||||||
|
|
||||||
/* global variables */
|
/* global variables */
|
||||||
|
|
||||||
TEST_EXTERN rtems_id Task_id[ 4 ]; /* array of task ids */
|
TEST_EXTERN rtems_id Task_id[ 6 ]; /* array of task ids */
|
||||||
TEST_EXTERN rtems_name Task_name[ 4 ]; /* array of task names */
|
TEST_EXTERN rtems_name Task_name[ 6 ]; /* array of task names */
|
||||||
|
|
||||||
/* end of include file */
|
/* end of include file */
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include <libcsupport.h> /* for malloc_dump, malloc_walk */
|
#include <libcsupport.h> /* for malloc_dump, malloc_walk */
|
||||||
#include <string.h> /* for memset */
|
#include <string.h> /* for memset */
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define NUM_PASSES 100
|
#define NUM_PASSES 100
|
||||||
|
|
||||||
@@ -37,8 +38,10 @@ rtems_task Task_1_through_5(
|
|||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
if ( passes++ > NUM_PASSES )
|
if ( passes++ > NUM_PASSES ) {
|
||||||
|
puts("*** END OF MALLOC TEST ***");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
|
status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
|
||||||
directive_failed( status, "rtems_clock_get" );
|
directive_failed( status, "rtems_clock_get" );
|
||||||
@@ -46,9 +49,12 @@ rtems_task Task_1_through_5(
|
|||||||
put_name( Task_name[ task_number( tid ) ], FALSE );
|
put_name( Task_name[ task_number( tid ) ], FALSE );
|
||||||
print_time( " - rtems_clock_get - ", &time, "\n" );
|
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);
|
printf("mallocing %d bytes\n",mem_amt);
|
||||||
mem_ptr = malloc ( mem_amt);
|
|
||||||
memset( mem_ptr, mem_amt, mem_amt );
|
memset( mem_ptr, mem_amt, mem_amt );
|
||||||
malloc_dump();
|
malloc_dump();
|
||||||
malloc_walk(1,FALSE);
|
malloc_walk(1,FALSE);
|
||||||
|
|||||||
@@ -39,13 +39,13 @@ void blow_stack( void );
|
|||||||
|
|
||||||
#define TASK_STACK_SIZE (RTEMS_MINIMUM_STACK_SIZE*3)
|
#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 <confdefs.h>
|
#include <confdefs.h>
|
||||||
|
|
||||||
/* global variables */
|
/* global variables */
|
||||||
|
|
||||||
TEST_EXTERN rtems_id Task_id[ 4 ]; /* array of task ids */
|
TEST_EXTERN rtems_id Task_id[ 6 ]; /* array of task ids */
|
||||||
TEST_EXTERN rtems_name Task_name[ 4 ]; /* array of task names */
|
TEST_EXTERN rtems_name Task_name[ 6 ]; /* array of task names */
|
||||||
|
|
||||||
/* end of include file */
|
/* end of include file */
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include <libcsupport.h> /* for malloc_dump, malloc_walk */
|
#include <libcsupport.h> /* for malloc_dump, malloc_walk */
|
||||||
#include <string.h> /* for memset */
|
#include <string.h> /* for memset */
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define NUM_PASSES 100
|
#define NUM_PASSES 100
|
||||||
|
|
||||||
@@ -37,8 +38,10 @@ rtems_task Task_1_through_5(
|
|||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
if ( passes++ > NUM_PASSES )
|
if ( passes++ > NUM_PASSES ) {
|
||||||
|
puts("*** END OF MALLOC TEST ***");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
|
status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
|
||||||
directive_failed( status, "rtems_clock_get" );
|
directive_failed( status, "rtems_clock_get" );
|
||||||
@@ -46,9 +49,12 @@ rtems_task Task_1_through_5(
|
|||||||
put_name( Task_name[ task_number( tid ) ], FALSE );
|
put_name( Task_name[ task_number( tid ) ], FALSE );
|
||||||
print_time( " - rtems_clock_get - ", &time, "\n" );
|
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);
|
printf("mallocing %d bytes\n",mem_amt);
|
||||||
mem_ptr = malloc ( mem_amt);
|
|
||||||
memset( mem_ptr, mem_amt, mem_amt );
|
memset( mem_ptr, mem_amt, mem_amt );
|
||||||
malloc_dump();
|
malloc_dump();
|
||||||
malloc_walk(1,FALSE);
|
malloc_walk(1,FALSE);
|
||||||
|
|||||||
Reference in New Issue
Block a user