summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-06-25 14:03:51 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-06-25 17:06:16 +0200
commitb9acb4eaf073c0d8d570daa0854e48aa737cc3f7 (patch)
tree7495ad9eddeb688cd4be500db1054d961f5c46c7
parentsptests/sp62: Rework to avoid heap internals (diff)
downloadrtems-b9acb4eaf073c0d8d570daa0854e48aa737cc3f7.tar.bz2
sptests/sp64: Simplify
This avoids problems with debugging enabled.
-rw-r--r--testsuites/sptests/sp64/init.c103
1 files changed, 25 insertions, 78 deletions
diff --git a/testsuites/sptests/sp64/init.c b/testsuites/sptests/sp64/init.c
index 42b9c4581d..1930fd5d5e 100644
--- a/testsuites/sptests/sp64/init.c
+++ b/testsuites/sptests/sp64/init.c
@@ -11,6 +11,8 @@
#include "config.h"
#endif
+#include <rtems/libcsupport.h>
+
#include "tmacros.h"
/* forward declarations to avoid warnings */
@@ -26,11 +28,11 @@ rtems_task Init(
rtems_id region1;
rtems_id region2;
rtems_status_code sc;
- bool sb;
- Heap_Information_block start;
- Heap_Information_block info;
- size_t to_alloc;
+ bool ok;
+ uintptr_t to_alloc;
void *alloced;
+ rtems_resource_snapshot snapshot;
+ void *greedy;
puts( "\n\n*** TEST 64 ***" );
@@ -43,46 +45,15 @@ rtems_task Init(
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 );
- rtems_test_assert( sb );
-
- #if 0
- printf( "Init - workspace free = %d\n", start.Free.largest );
- printf( "Init - workspace free blocks = %d\n", start.Free.number );
- #endif
- rtems_test_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_test_assert( sc == RTEMS_SUCCESSFUL );
- 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 );
- rtems_test_assert( sb );
- rtems_test_assert( info.Free.largest == start.Free.largest );
- rtems_test_assert( info.Free.number == start.Free.number );
+ greedy = rtems_workspace_greedy_allocate_all_except_largest( &to_alloc );
+ rtems_resource_snapshot_take( &snapshot );
puts( "Init - rtems_region_create - auto-extend - RTEMS_UNSATISFIED" );
- while (1) {
-
- sb = rtems_workspace_allocate( to_alloc, &alloced );
- rtems_test_assert( sb );
+ while ( to_alloc > 8 ) {
+ ok = rtems_workspace_allocate( to_alloc, &alloced );
+ rtems_test_assert( ok );
sc = rtems_region_create(
rtems_build_name( 'R', 'N', '2', ' ' ),
@@ -93,61 +64,35 @@ rtems_task Init(
&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);
- }
+ rtems_test_assert( sc == RTEMS_TOO_MANY );
/*
* Verify heap is still in same shape if we couldn't allocate a region
*/
- sb = rtems_workspace_get_information( &info );
- #if 0
- printf( "Init - workspace free/blocks = %d/%d\n",
- info.Free.largest, info.Free.number );
- #endif
- rtems_test_assert( sb );
- rtems_test_assert( info.Free.largest == start.Free.largest );
- rtems_test_assert( info.Free.number == start.Free.number );
+ ok = rtems_resource_snapshot_check( &snapshot );
+ rtems_test_assert( ok );
to_alloc -= 8;
- if ( to_alloc == 0 )
- break;
}
- if ( sc )
- rtems_test_exit(0);
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
/*
* Verify heap is still in same shape after we free the region
*/
puts( "Init - rtems_region_delete - OK" );
sc = rtems_region_delete( region2 );
- rtems_test_assert( sc == 0 );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
- /*
- * Although it is intuitive that after deleting the region the
- * object space would shrink and go back to its original shape,
- * we could end up with fragmentation which prevents a simple
- * check from verifying this.
- */
- #if 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
- rtems_test_assert( sb );
- rtems_test_assert( info.Free.largest == start.Free.largest );
- rtems_test_assert( info.Free.number == start.Free.number );
- #endif
+ puts( "Init - verify workspace has same memory" );
+ ok = rtems_resource_snapshot_check( &snapshot );
+ rtems_test_assert( ok );
+ rtems_workspace_greedy_free( greedy );
puts( "*** END OF TEST 64 ***" );
rtems_test_exit(0);
@@ -158,10 +103,12 @@ rtems_task Init(
#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_MAXIMUM_TASKS 1
+#define CONFIGURE_MAXIMUM_REGIONS rtems_resource_unlimited( 2 )
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+#define CONFIGURE_MEMORY_OVERHEAD 1
+
#define CONFIGURE_INIT
#include <rtems/confdefs.h>