summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-07-08 20:11:48 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-07-08 20:11:48 +0000
commit843ad7b5ffae3626d7097ba121c7af915556e7a4 (patch)
treead34a68750b4e795ab3a56d472722f50826e6a57 /testsuites
parent2010-07-08 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-843ad7b5ffae3626d7097ba121c7af915556e7a4.tar.bz2
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.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/libtests/ChangeLog7
-rw-r--r--testsuites/libtests/Makefile.am3
-rw-r--r--testsuites/libtests/configure.ac1
-rw-r--r--testsuites/libtests/malloc04/.cvsignore2
-rw-r--r--testsuites/libtests/malloc04/Makefile.am26
-rw-r--r--testsuites/libtests/malloc04/init.c121
-rw-r--r--testsuites/libtests/malloc04/malloc04.doc22
-rw-r--r--testsuites/libtests/malloc04/malloc04.scn20
8 files changed, 201 insertions, 1 deletions
diff --git a/testsuites/libtests/ChangeLog b/testsuites/libtests/ChangeLog
index c8b23787a8..9bf4e04a6c 100644
--- a/testsuites/libtests/ChangeLog
+++ b/testsuites/libtests/ChangeLog
@@ -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
diff --git a/testsuites/libtests/Makefile.am b/testsuites/libtests/Makefile.am
index 47acaf775f..5b329dd6e8 100644
--- a/testsuites/libtests/Makefile.am
+++ b/testsuites/libtests/Makefile.am
@@ -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 \
diff --git a/testsuites/libtests/configure.ac b/testsuites/libtests/configure.ac
index 7a49310fa2..52f7127139 100644
--- a/testsuites/libtests/configure.ac
+++ b/testsuites/libtests/configure.ac
@@ -50,6 +50,7 @@ heapwalk/Makefile
malloctest/Makefile
malloc02/Makefile
malloc03/Makefile
+malloc04/Makefile
monitor/Makefile
monitor02/Makefile
putenvtest/Makefile
diff --git a/testsuites/libtests/malloc04/.cvsignore b/testsuites/libtests/malloc04/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/libtests/malloc04/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/libtests/malloc04/Makefile.am b/testsuites/libtests/malloc04/Makefile.am
new file mode 100644
index 0000000000..d04fb680a8
--- /dev/null
+++ b/testsuites/libtests/malloc04/Makefile.am
@@ -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
diff --git a/testsuites/libtests/malloc04/init.c b/testsuites/libtests/malloc04/init.c
new file mode 100644
index 0000000000..17ece56980
--- /dev/null
+++ b/testsuites/libtests/malloc04/init.c
@@ -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 */
diff --git a/testsuites/libtests/malloc04/malloc04.doc b/testsuites/libtests/malloc04/malloc04.doc
new file mode 100644
index 0000000000..a920f92b8c
--- /dev/null
+++ b/testsuites/libtests/malloc04/malloc04.doc
@@ -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.
diff --git a/testsuites/libtests/malloc04/malloc04.scn b/testsuites/libtests/malloc04/malloc04.scn
new file mode 100644
index 0000000000..a2ad14aee9
--- /dev/null
+++ b/testsuites/libtests/malloc04/malloc04.scn
@@ -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 ***