summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests/sp64
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-08-05 20:58:17 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-08-05 20:58:17 +0000
commitabc4af35f87e8e0122d3b26fef9ed830694c4156 (patch)
tree0283d44c1c228c963f423e9c817ca5a009acb4a7 /testsuites/sptests/sp64
parent2009-08-05 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-abc4af35f87e8e0122d3b26fef9ed830694c4156.tar.bz2
2009-08-05 Joel Sherrill <joel.sherrill@OARcorp.com>
* Makefile.am, configure.ac, sp63/init.c: Add new test for exercising when we are unable to allocate the memory needed for an object extend. Make sure all is handled properly. * sp64/.cvsignore, sp64/Makefile.am, sp64/init.c, sp64/sp64.doc, sp64/sp64.scn: New files.
Diffstat (limited to 'testsuites/sptests/sp64')
-rw-r--r--testsuites/sptests/sp64/.cvsignore2
-rw-r--r--testsuites/sptests/sp64/Makefile.am29
-rw-r--r--testsuites/sptests/sp64/init.c167
-rw-r--r--testsuites/sptests/sp64/sp64.doc24
-rw-r--r--testsuites/sptests/sp64/sp64.scn5
5 files changed, 227 insertions, 0 deletions
diff --git a/testsuites/sptests/sp64/.cvsignore b/testsuites/sptests/sp64/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/sptests/sp64/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/sptests/sp64/Makefile.am b/testsuites/sptests/sp64/Makefile.am
new file mode 100644
index 0000000000..7ea889f95d
--- /dev/null
+++ b/testsuites/sptests/sp64/Makefile.am
@@ -0,0 +1,29 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = sp64
+sp64_SOURCES = init.c
+
+dist_rtems_tests_DATA = sp64.scn
+dist_rtems_tests_DATA += sp64.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+sp64_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(sp64_OBJECTS) $(sp64_LDADD)
+LINK_LIBS = $(sp64_LDLIBS)
+
+sp64$(EXEEXT): $(sp64_OBJECTS) $(sp64_DEPENDENCIES)
+ @rm -f sp64$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/sp64/init.c b/testsuites/sptests/sp64/init.c
new file mode 100644
index 0000000000..b435e827fd
--- /dev/null
+++ b/testsuites/sptests/sp64/init.c
@@ -0,0 +1,167 @@
+/*
+ * COPYRIGHT (c) 1989-2009.
+ * 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"
+
+uint32_t Area1[50];
+uint32_t Area2[50];
+
+rtems_task Init(
+ rtems_task_argument ignored
+)
+{
+ rtems_id region1;
+ rtems_id region2;
+ rtems_status_code sc;
+ bool sb;
+ Heap_Information_block start;
+ Heap_Information_block info;
+ size_t to_alloc;
+ void *alloced;
+
+ puts( "\n\n*** TEST 64 ***" );
+
+ puts( "Allocate one region -- so second auto extends" );
+ sc = rtems_region_create(
+ rtems_build_name( 'R', 'N', '1', ' ' ),
+ Area1,
+ sizeof(Area1),
+ 8,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &region1
+ );
+ directive_failed( sc, "rtems_region_create of RN1" );
+
+ puts( "Init - rtems_workspace_get_information - OK" );
+ sb = rtems_workspace_get_information( &start );
+ assert( sb );
+
+ #if 0
+ printf( "Init - workspace free = %d\n", start.Free.largest );
+ printf( "Init - workspace free blocks = %d\n", start.Free.number );
+ #endif
+ assert( start.Free.number == 1 );
+ to_alloc = start.Free.largest;
+
+ /* find the largest we can actually allocate */
+ while ( 1 ) {
+ sb = rtems_workspace_allocate( to_alloc, &alloced );
+ if ( sb )
+ break;
+ to_alloc -= 4;
+ }
+
+ rtems_workspace_free( alloced );
+
+ #if 0
+ printf( "Init - start with to_alloc of = %d\n", to_alloc );
+ #endif
+
+ /*
+ * Verify heap is still in same shape if we couldn't allocate a region
+ */
+ sb = rtems_workspace_get_information( &info );
+ assert( sb );
+ assert( info.Free.largest == start.Free.largest );
+ assert( info.Free.number == start.Free.number );
+
+ puts( "Init - rtems_region_create - auto-extend - RTEMS_UNSATISFIED" );
+ while (1) {
+
+ sb = rtems_workspace_allocate( to_alloc, &alloced );
+ assert( sb );
+
+ sc = rtems_region_create(
+ rtems_build_name( 'R', 'N', '2', ' ' ),
+ Area2,
+ sizeof(Area2),
+ 8,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &region2
+ );
+
+ /* free the memory we snagged, then check the status */
+ rtems_workspace_free( alloced );
+
+ if ( sc == RTEMS_SUCCESSFUL )
+ break;
+
+ if ( sc != RTEMS_TOO_MANY ) {
+ printf( "region create returned %d or %s\n", sc, rtems_status_text(sc) );
+ rtems_test_exit(0);
+ }
+
+/*
+ * Extending the object structure can fail after it has extended one
+ * part of the object management information but not another. Chris
+ * needs to think about this. XXX TBD
+ */
+#if 0
+ /*
+ * Verify heap is still in same shape if we couldn't allocate a task
+ */
+ sb = rtems_workspace_get_information( &info );
+ #if 0
+ printf( "Init - workspace free/blocks = %d/%d\n",
+ info.Free.largest, info.Free.number );
+ #endif
+ assert( sb );
+ assert( info.Free.largest == start.Free.largest );
+ assert( info.Free.number == start.Free.number );
+#endif
+
+ to_alloc -= 8;
+ if ( to_alloc == 0 )
+ break;
+ }
+
+ if ( sc )
+ rtems_test_exit(0);
+
+ /* another Chris thinking case .. will this shrink back to exactly
+ * the same? TBD XXX
+ */
+#if 0
+ /*
+ * Verify heap is still in same shape after we free the region
+ */
+ puts( "Init - rtems_region_delete - OK" );
+ sc = rtems_region_delete( region2 );
+ assert( sc == 0 );
+
+ puts( "Init - verify workspace has same memory" );
+ sb = rtems_workspace_get_information( &info );
+ #if 0
+ printf( "Init - workspace free/blocks = %d/%d\n",
+ info.Free.largest, info.Free.number );
+ #endif
+ assert( sb );
+ assert( info.Free.largest == start.Free.largest );
+ assert( info.Free.number == start.Free.number );
+#endif
+
+ puts( "*** END OF TEST 63 ***" );
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 2
+#define CONFIGURE_MAXIMUM_REGIONS rtems_resource_unlimited(1)
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+
+/* global variables */
diff --git a/testsuites/sptests/sp64/sp64.doc b/testsuites/sptests/sp64/sp64.doc
new file mode 100644
index 0000000000..0b582abb62
--- /dev/null
+++ b/testsuites/sptests/sp64/sp64.doc
@@ -0,0 +1,24 @@
+#
+# $Id$
+#
+# COPYRIGHT (c) 1989-2009.
+# 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: sp64
+
+directives:
+
+ rtems_region_create
+ really _Objects_Extend_information when unlimited extension fails
+
+concepts:
+
++ Ensure that being unable to allocate memory when extending an object class
+ works as expected.
diff --git a/testsuites/sptests/sp64/sp64.scn b/testsuites/sptests/sp64/sp64.scn
new file mode 100644
index 0000000000..bb52ee4dda
--- /dev/null
+++ b/testsuites/sptests/sp64/sp64.scn
@@ -0,0 +1,5 @@
+*** TEST 64 ***
+Allocate one region -- so second auto extends
+Init - rtems_workspace_get_information - OK
+Init - rtems_region_create - auto-extend - RTEMS_UNSATISFIED
+*** END OF TEST 63 ***