[rtems commit] sptests/sp18: Simplify

Sebastian Huber sebh at rtems.org
Tue Jun 25 15:01:51 UTC 2013


Module:    rtems
Branch:    master
Commit:    9f37fb19746a317435f9e889b0d86bb96c0c9e19
Changeset: http://git.rtems.org/rtems/commit/?id=9f37fb19746a317435f9e889b0d86bb96c0c9e19

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Jun 25 12:16:13 2013 +0200

sptests/sp18: Simplify

This avoids problems with debugging enabled.

---

 testsuites/sptests/sp18/init.c   |   41 ++++++++++++++-----------------------
 testsuites/sptests/sp18/sp18.scn |    1 -
 2 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/testsuites/sptests/sp18/init.c b/testsuites/sptests/sp18/init.c
index dc3f9f0..40b44aa 100644
--- a/testsuites/sptests/sp18/init.c
+++ b/testsuites/sptests/sp18/init.c
@@ -11,6 +11,8 @@
 #include "config.h"
 #endif
 
+#include <rtems/libcsupport.h>
+
 #include <tmacros.h>
 
 /* forward declarations to avoid warnings */
@@ -22,27 +24,18 @@ rtems_task Init(
 {
   rtems_id                task_id;
   rtems_status_code       sc;
-  bool                    sb;
-  Heap_Information_block  start;
-  Heap_Information_block  info;
-  size_t                  stack_size;
+  bool                    ok;
+  uintptr_t               stack_size;
+  rtems_resource_snapshot snapshot;
+  void                   *greedy;
 
   puts( "\n\n*** TEST 18 ***" );
 
-  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 );
-  stack_size = start.Free.largest;
+  greedy = rtems_workspace_greedy_allocate_all_except_largest( &stack_size );
+  rtems_resource_snapshot_take( &snapshot );
 
-  #if 0
-    printf( "Init - start with stack size of = %d\n", stack_size );
-  #endif
+  /* Make sure the first allocation fails */
+  ++stack_size;
 
   puts( "Init - rtems_task_create - Unsatisfied on Extensions" );
   while (1) {
@@ -64,10 +57,8 @@ rtems_task Init(
     /*
      * Verify heap is still in same shape if we couldn't allocate a task
      */
-    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  );
+    ok = rtems_resource_snapshot_check( &snapshot );
+    rtems_test_assert( ok );
 
     stack_size -= 8;
     if ( stack_size <= RTEMS_MINIMUM_STACK_SIZE )
@@ -85,10 +76,10 @@ rtems_task Init(
   directive_failed( sc, "rtems_task_delete" );
 
   puts( "Init - verify workspace has same memory" );
-  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  );
+  ok = rtems_resource_snapshot_check( &snapshot );
+  rtems_test_assert( ok );
+
+  rtems_workspace_greedy_free( greedy );
 
   puts( "*** END OF TEST 18 ***" );
   rtems_test_exit(0);
diff --git a/testsuites/sptests/sp18/sp18.scn b/testsuites/sptests/sp18/sp18.scn
index 9effef4..5f7e298 100644
--- a/testsuites/sptests/sp18/sp18.scn
+++ b/testsuites/sptests/sp18/sp18.scn
@@ -1,5 +1,4 @@
 *** TEST 18 ***
-Init - rtems_workspace_get_information - OK
 Init - rtems_task_create - Unsatisfied on Extensions
 Init - rtems_task_delete - OK
 Init - verify workspace has same memory




More information about the vc mailing list