[rtems commit] psxtests/psxkey02: Test for proper error case

Sebastian Huber sebh at rtems.org
Mon Apr 7 14:42:13 UTC 2014


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Apr  7 15:59:09 2014 +0200

psxtests/psxkey02: Test for proper error case

---

 testsuites/psxtests/psxkey02/init.c       |   41 +++++++----------------------
 testsuites/psxtests/psxkey02/psxkey02.scn |   10 +++----
 2 files changed, 14 insertions(+), 37 deletions(-)

diff --git a/testsuites/psxtests/psxkey02/init.c b/testsuites/psxtests/psxkey02/init.c
index 684eb4a..5734db7 100644
--- a/testsuites/psxtests/psxkey02/init.c
+++ b/testsuites/psxtests/psxkey02/init.c
@@ -24,49 +24,28 @@ rtems_task Init(rtems_task_argument ignored);
 
 rtems_task Init(rtems_task_argument ignored)
 {
-  pthread_key_t           key;
+  pthread_key_t           key1;
+  pthread_key_t           key2;
   int                     eno;
   bool                    ok;
-  uintptr_t               to_alloc;
-  void                   *alloced;
   rtems_resource_snapshot snapshot;
   void                   *greedy;
 
   TEST_BEGIN();
 
-  greedy = rtems_workspace_greedy_allocate_all_except_largest( &to_alloc );
+  greedy = rtems_workspace_greedy_allocate( NULL, 0 );
   rtems_resource_snapshot_take( &snapshot );
 
-  puts( "Init - pthread_key_create - ENOMEM" );
-  while ( to_alloc > 8 ) {
-    ok = rtems_workspace_allocate( to_alloc, &alloced );
-    rtems_test_assert( ok );
-
-    eno = pthread_key_create( &key, NULL );
-
-    rtems_workspace_free( alloced );
-
-    if ( eno == 0 )
-      break;
-
-    rtems_test_assert( eno == ENOMEM );
-
-    /*
-     * Verify heap is still in same shape if we couldn't allocate a task
-     */
-    ok = rtems_resource_snapshot_check( &snapshot );
-    rtems_test_assert( ok );
-
-    to_alloc -= 8;
-  }
-
+  puts( "Init - pthread_key_create - OK" );
+  eno = pthread_key_create( &key1, NULL );
   rtems_test_assert( eno == 0 );
 
-  /*
-   * Verify heap is still in same shape after we free the task
-   */
+  puts( "Init - pthread_key_create - EAGAIN" );
+  eno = pthread_key_create( &key2, NULL );
+  rtems_test_assert( eno == EAGAIN );
+
   puts( "Init - pthread_key_delete - OK" );
-  eno = pthread_key_delete( key );
+  eno = pthread_key_delete( key1 );
   rtems_test_assert( eno == 0 );
 
   puts( "Init - verify workspace has same memory" );
diff --git a/testsuites/psxtests/psxkey02/psxkey02.scn b/testsuites/psxtests/psxkey02/psxkey02.scn
index f5a5f71..9f6fa4f 100644
--- a/testsuites/psxtests/psxkey02/psxkey02.scn
+++ b/testsuites/psxtests/psxkey02/psxkey02.scn
@@ -1,8 +1,6 @@
-sparc-rtems4.11-run is /home/joel/rtems-4.11-work/tools/bin/sparc-rtems4.11-run
-
-
-*** TEST KEY 02 ***
-Init - pthread_key_create - ENOMEM
+*** BEGIN OF TEST PSXKEY 2 ***
+Init - pthread_key_create - OK
+Init - pthread_key_create - EAGAIN
 Init - pthread_key_delete - OK
 Init - verify workspace has same memory
-*** END OF TEST KEY 02 ***
+*** END OF TEST PSXKEY 2 ***




More information about the vc mailing list