mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 03:27:56 +08:00
2010-07-08 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, configure.ac: Add test for exercising sbrk() extension to Malloc Family. * malloc04/.cvsignore, malloc04/Makefile.am, malloc04/init.c, malloc04/malloc04.doc, malloc04/malloc04.scn: New files.
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
2010-07-08 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* Makefile.am, configure.ac: Add test for exercising sbrk() extension
|
||||
to Malloc Family.
|
||||
* malloc04/.cvsignore, malloc04/Makefile.am, malloc04/init.c,
|
||||
malloc04/malloc04.doc, malloc04/malloc04.scn: New files.
|
||||
|
||||
2010-07-06 Joel Sherrill <joel.sherrilL@OARcorp.com>
|
||||
|
||||
* termios06/init.c, termios06/termios06.scn: Add a couple more PPPDISC
|
||||
|
||||
@@ -6,7 +6,8 @@ ACLOCAL_AMFLAGS = -I ../aclocal
|
||||
|
||||
SUBDIRS = POSIX
|
||||
|
||||
SUBDIRS += bspcmdline01 cpuuse gxx01 malloctest malloc02 malloc03 heapwalk \
|
||||
SUBDIRS += bspcmdline01 cpuuse gxx01 \
|
||||
malloctest malloc02 malloc03 malloc04 heapwalk \
|
||||
putenvtest monitor monitor02 rtmonuse stackchk stackchk01 \
|
||||
termios termios01 termios02 termios03 termios04 termios05 termios06 \
|
||||
rtems++ tztest block01 block02 block03 block04 block05 block06 block07 \
|
||||
|
||||
@@ -50,6 +50,7 @@ heapwalk/Makefile
|
||||
malloctest/Makefile
|
||||
malloc02/Makefile
|
||||
malloc03/Makefile
|
||||
malloc04/Makefile
|
||||
monitor/Makefile
|
||||
monitor02/Makefile
|
||||
putenvtest/Makefile
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -0,0 +1,26 @@
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
MANAGERS = all
|
||||
|
||||
rtems_tests_PROGRAMS = malloc04
|
||||
malloc04_SOURCES = init.c
|
||||
|
||||
dist_rtems_tests_DATA = malloc04.scn
|
||||
dist_rtems_tests_DATA += malloc04.doc
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../automake/compile.am
|
||||
include $(top_srcdir)/../automake/leaf.am
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
|
||||
LINK_OBJS = $(malloc04_OBJECTS) $(malloc04_LDADD)
|
||||
LINK_LIBS = $(malloc04_LDLIBS)
|
||||
|
||||
malloc04$(EXEEXT): $(malloc04_OBJECTS) $(malloc04_DEPENDENCIES)
|
||||
@rm -f malloc04$(EXEEXT)
|
||||
$(make-exe)
|
||||
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2010.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <tmacros.h>
|
||||
#include "test_support.h"
|
||||
#include <rtems/libcsupport.h>
|
||||
#include <rtems/malloc.h>
|
||||
|
||||
char Malloc_Heap[ 128 ] CPU_STRUCTURE_ALIGNMENT;
|
||||
int sbrk_count;
|
||||
Heap_Control Heap_Holder;
|
||||
|
||||
/* Heap variables we need to peek and poke at */
|
||||
extern Heap_Control *RTEMS_Malloc_Heap;
|
||||
extern size_t RTEMS_Malloc_Sbrk_amount;
|
||||
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) ) {
|
||||
p = &Malloc_Heap[ offset ];
|
||||
offset += incr;
|
||||
} else {
|
||||
if ( sbrk_count == 0 )
|
||||
p = (void *) rtems_task_create;
|
||||
sbrk_count++;
|
||||
}
|
||||
|
||||
sbrk_count++;
|
||||
return p;
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
{
|
||||
void *p1, *p2, *p3, *p4;
|
||||
|
||||
sbrk_count = 0;
|
||||
offset = 0;
|
||||
|
||||
puts( "\n\n*** TEST MALLOC 04 ***" );
|
||||
|
||||
/* Safe information on real heap */
|
||||
Heap_Holder = *RTEMS_Malloc_Heap;
|
||||
rtems_malloc_sbrk_helpers = &rtems_malloc_sbrk_helpers_table;
|
||||
|
||||
puts( "Initialize heap with some memory" );
|
||||
offset = 64;
|
||||
sbrk_count = 0;
|
||||
RTEMS_Malloc_Initialize( Malloc_Heap, 64, 64 );
|
||||
p1 = malloc(64);
|
||||
p2 = malloc(64);
|
||||
p3 = malloc(48);
|
||||
p4 = malloc(48);
|
||||
|
||||
puts( "Initialize heap with some unaligned memory" );
|
||||
offset = 65;
|
||||
sbrk_count = 0;
|
||||
RTEMS_Malloc_Initialize( &Malloc_Heap[1], 64, 64 );
|
||||
p1 = malloc(64);
|
||||
p2 = malloc(64);
|
||||
p3 = malloc(48);
|
||||
|
||||
puts( "Initialize heap with no memory (sbrk aligned)" );
|
||||
offset = 7;
|
||||
sbrk_count = 0;
|
||||
RTEMS_Malloc_Initialize( NULL, 0, 64 );
|
||||
p1 = malloc(64);
|
||||
p2 = malloc(64);
|
||||
p3 = malloc(48);
|
||||
p4 = malloc(48);
|
||||
|
||||
puts( "Initialize heap with no memory (sbrk aligned)" );
|
||||
offset = 0;
|
||||
sbrk_count = 0;
|
||||
RTEMS_Malloc_Initialize( NULL, 0, 64 );
|
||||
p1 = malloc(64);
|
||||
|
||||
puts( "Set sbrk amount in heap to 0" );
|
||||
offset = 0;
|
||||
sbrk_count = 0;
|
||||
RTEMS_Malloc_Initialize( NULL, 0, 64 );
|
||||
RTEMS_Malloc_Sbrk_amount = 0;
|
||||
p4 = malloc(48);
|
||||
|
||||
/* Restore information on real heap */
|
||||
*RTEMS_Malloc_Heap = Heap_Holder;
|
||||
rtems_malloc_sbrk_helpers = NULL;
|
||||
|
||||
|
||||
puts( "*** END OF TEST MALLOC 04 ***" );
|
||||
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
/* end of file */
|
||||
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# COPYRIGHT (c) 1989-2010.
|
||||
# On-Line Applications Research Corporation (OAR).
|
||||
#
|
||||
# The license and distribution terms for this file may be
|
||||
# found in the file LICENSE in this distribution or at
|
||||
# http://www.rtems.com/license/LICENSE.
|
||||
#
|
||||
|
||||
This file describes the directives and concepts tested by this test set.
|
||||
|
||||
test set name: malloc04
|
||||
|
||||
directives:
|
||||
|
||||
Malloc family sbrk extension capability
|
||||
|
||||
concepts:
|
||||
|
||||
+ Exercise all non-fatal paths in the sbrk() support in the malloc family.
|
||||
@@ -0,0 +1,20 @@
|
||||
*** TEST MALLOC 04 ***
|
||||
Initialize heap with some memory
|
||||
sbrk(128)
|
||||
sbrk(128)
|
||||
sbrk(64)
|
||||
Initialize heap with some unaligned memory
|
||||
sbrk(128)
|
||||
sbrk(128)
|
||||
sbrk(64)
|
||||
Initialize heap with no memory (sbrk aligned)
|
||||
sbrk(64)
|
||||
sbrk(128)
|
||||
sbrk(128)
|
||||
sbrk(64)
|
||||
Initialize heap with no memory (sbrk aligned)
|
||||
sbrk(64)
|
||||
sbrk(128)
|
||||
Set sbrk amount in heap to 0
|
||||
sbrk(64)
|
||||
*** END OF TEST MALLOC 04 ***
|
||||
Reference in New Issue
Block a user