mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-26 14:18:20 +00:00
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.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
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.
|
||||
|
||||
2009-08-01 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* sp63/init.c: Correct test case two.
|
||||
|
||||
@@ -13,7 +13,7 @@ SUBDIRS = \
|
||||
sp30 sp31 sp32 sp33 sp34 sp35 sp37 sp38 sp39 \
|
||||
sp40 sp41 sp42 sp43 sp44 sp45 sp46 sp47 sp48 sp49 \
|
||||
sp50 sp51 sp52 sp53 sp54 sp55 sp56 sp57 sp58 sp59 \
|
||||
sp60 sp61 sp62 sp63 \
|
||||
sp60 sp61 sp62 sp63 sp64 \
|
||||
spchain spobjgetnext spprintk spsize spstkalloc spthreadq01 \
|
||||
spwatchdog spwkspace \
|
||||
spfatal01 spfatal02 spfatal03 spfatal04 spfatal05 spfatal06 spfatal07 \
|
||||
|
||||
@@ -90,6 +90,7 @@ sp60/Makefile
|
||||
sp61/Makefile
|
||||
sp62/Makefile
|
||||
sp63/Makefile
|
||||
sp64/Makefile
|
||||
spchain/Makefile
|
||||
spfatal01/Makefile
|
||||
spfatal02/Makefile
|
||||
|
||||
@@ -11,9 +11,14 @@
|
||||
|
||||
#include <tmacros.h>
|
||||
|
||||
uint32_t Memory[256];
|
||||
#define MAX 256
|
||||
uint32_t Memory[MAX];
|
||||
Heap_Control Heap;
|
||||
|
||||
/*
|
||||
* Exercise case in heapresize.c around line 125 when new_block_size
|
||||
* < min_block_size
|
||||
*/
|
||||
void test_case_one(void)
|
||||
{
|
||||
uint32_t heap_size;
|
||||
@@ -35,6 +40,10 @@ void test_case_one(void)
|
||||
assert( !hc );
|
||||
}
|
||||
|
||||
/*
|
||||
* Exercise case in heapresize.c around line 140 when next_is_used AND
|
||||
* free_block_size < min_block_size.
|
||||
*/
|
||||
void test_case_two(void)
|
||||
{
|
||||
uint32_t heap_size;
|
||||
@@ -56,6 +65,44 @@ void test_case_two(void)
|
||||
assert( !hc );
|
||||
}
|
||||
|
||||
/*
|
||||
* Exercise case in heapallocatealigned.c around line 223 when ...
|
||||
*/
|
||||
void test_case_three(void)
|
||||
{
|
||||
uint32_t heap_size;
|
||||
void *ptr1;
|
||||
intptr_t old;
|
||||
intptr_t avail;
|
||||
Heap_Resize_status hc;
|
||||
int pg, al, alloc, sz;
|
||||
|
||||
puts( "Init - _Heap_Allocate_aligned - request impossible - not OK");
|
||||
|
||||
#if 0
|
||||
heap_size =
|
||||
_Heap_Initialize( &Heap, Memory[32], sizeof(Memory), 1 << 16 );
|
||||
ptr1 = _Heap_Allocate_aligned( &Heap, 4, 1 << 16 );
|
||||
ptr1 = _Heap_Allocate_aligned( &Heap, 256, 1 << 16 );
|
||||
#endif
|
||||
#if 1
|
||||
for ( sz=32 ; sz <= 80 ; sz+=4 ) {
|
||||
for ( pg=2 ; pg < 12 ; pg++ ) {
|
||||
|
||||
for ( al=16 ; al >=4 ; al-- ) {
|
||||
for ( alloc=4 ; alloc < sizeof(Memory)/2 ; alloc+=4 ) {
|
||||
heap_size =
|
||||
_Heap_Initialize( &Heap, &Memory[sz], sizeof(Memory)/2, 1 << pg );
|
||||
do {
|
||||
ptr1 = _Heap_Allocate_aligned( &Heap, alloc, 1 <<al );
|
||||
} while ( ptr1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument ignored
|
||||
)
|
||||
@@ -66,6 +113,8 @@ rtems_task Init(
|
||||
|
||||
test_case_two();
|
||||
|
||||
test_case_three();
|
||||
|
||||
puts( "*** END OF TEST 63 ***" );
|
||||
|
||||
rtems_test_exit(0);
|
||||
|
||||
2
testsuites/sptests/sp64/.cvsignore
Normal file
2
testsuites/sptests/sp64/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
29
testsuites/sptests/sp64/Makefile.am
Normal file
29
testsuites/sptests/sp64/Makefile.am
Normal file
@@ -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
|
||||
167
testsuites/sptests/sp64/init.c
Normal file
167
testsuites/sptests/sp64/init.c
Normal file
@@ -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,
|
||||
®ion1
|
||||
);
|
||||
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,
|
||||
®ion2
|
||||
);
|
||||
|
||||
/* 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 */
|
||||
24
testsuites/sptests/sp64/sp64.doc
Normal file
24
testsuites/sptests/sp64/sp64.doc
Normal file
@@ -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.
|
||||
5
testsuites/sptests/sp64/sp64.scn
Normal file
5
testsuites/sptests/sp64/sp64.scn
Normal file
@@ -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 ***
|
||||
Reference in New Issue
Block a user