[PATCH] score: Add _Objects_Get_by_name()

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Mar 18 06:48:32 UTC 2016


Replace _Objects_Name_to_id_string() with _Objects_Get_by_name() since
all users of this function are interested in the object itself and not
the identifier.

Use the object allocator lock to protect the search.

Update #2555.
---
 cpukit/posix/include/rtems/posix/mqueueimpl.h    | 21 +++++----
 cpukit/posix/include/rtems/posix/posixapi.h      | 31 +++++--------
 cpukit/posix/include/rtems/posix/semaphoreimpl.h | 20 +++++----
 cpukit/posix/src/mqueueopen.c                    | 18 ++++----
 cpukit/posix/src/mqueueunlink.c                  | 35 ++++-----------
 cpukit/posix/src/psxnametoid.c                   | 44 +++---------------
 cpukit/posix/src/semopen.c                       | 18 ++++----
 cpukit/posix/src/semunlink.c                     | 28 +++---------
 cpukit/score/include/rtems/score/objectimpl.h    | 39 ++++++++++------
 cpukit/score/src/objectnametoidstring.c          | 57 ++++++++++++++----------
 testsuites/psxtests/psxobj01/init.c              | 48 ++++++++++----------
 testsuites/psxtests/psxobj01/psxobj01.scn        | 11 +++--
 12 files changed, 156 insertions(+), 214 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/mqueueimpl.h b/cpukit/posix/include/rtems/posix/mqueueimpl.h
index 6646fa2..cf0f76a 100644
--- a/cpukit/posix/include/rtems/posix/mqueueimpl.h
+++ b/cpukit/posix/include/rtems/posix/mqueueimpl.h
@@ -246,17 +246,20 @@ _POSIX_Message_queue_Get_fd_interrupt_disable(
     lock_context
   );
 }
- 
-/**
- * @see _POSIX_Name_to_id().
- */
-RTEMS_INLINE_ROUTINE int _POSIX_Message_queue_Name_to_id(
-  const char          *name,
-  Objects_Id          *id,
-  size_t              *len
+
+RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *
+_POSIX_Message_queue_Get_by_name(
+  const char                *name,
+  size_t                    *name_length_p,
+  Objects_Get_by_name_error *error
 )
 {
-  return _POSIX_Name_to_id( &_POSIX_Message_queue_Information, name, id, len );
+  return (POSIX_Message_queue_Control *) _Objects_Get_by_name(
+    &_POSIX_Message_queue_Information,
+    name,
+    name_length_p,
+    error
+  );
 }
 
 #ifdef __cplusplus
diff --git a/cpukit/posix/include/rtems/posix/posixapi.h b/cpukit/posix/include/rtems/posix/posixapi.h
index 8fee7a4..0348e28 100644
--- a/cpukit/posix/include/rtems/posix/posixapi.h
+++ b/cpukit/posix/include/rtems/posix/posixapi.h
@@ -20,6 +20,7 @@
 #define _RTEMS_POSIX_POSIXAPI_H
 
 #include <rtems/config.h>
+#include <rtems/score/assert.h>
 #include <rtems/score/objectimpl.h>
 
 /**
@@ -48,27 +49,15 @@ typedef enum {
  */
 void _POSIX_Fatal_error( POSIX_Fatal_domain domain, int eno );
 
-/**
- * @brief Queries the object identifier @a id for a @a name.
- *
- * @param[in] information Object information.
- * @param[in] name Zero terminated name string to look up.
- * @param[out] id Pointer for identifier.  The pointer must be valid.
- * @param[out] len Pointer for string length.  The pointer must be valid.
- *
- * @retval 0 Successful operation.
- * @retval EINVAL The @a name pointer is @c NULL or the @a name string has
- * zero length.
- * @retval ENAMETOOLONG The @a name string length is greater than or equal to
- * @c NAME_MAX.
- * @retval ENOENT Found no corresponding identifier.
- */
-int _POSIX_Name_to_id(
-  Objects_Information *information,
-  const char          *name,
-  Objects_Id          *id,
-  size_t              *len
-);
+extern const int _POSIX_Get_by_name_error_table[ 3 ];
+
+RTEMS_INLINE_ROUTINE int _POSIX_Get_by_name_error(
+  Objects_Get_by_name_error error
+)
+{
+  _Assert( (size_t) error < RTEMS_ARRAY_SIZE( _POSIX_Get_by_name_error_table ) );
+  return _POSIX_Get_by_name_error_table[ error ];
+}
 
 /** @} */
 
diff --git a/cpukit/posix/include/rtems/posix/semaphoreimpl.h b/cpukit/posix/include/rtems/posix/semaphoreimpl.h
index fe5ee44..8608e6f 100644
--- a/cpukit/posix/include/rtems/posix/semaphoreimpl.h
+++ b/cpukit/posix/include/rtems/posix/semaphoreimpl.h
@@ -163,17 +163,19 @@ RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Namespace_remove (
   _Objects_Namespace_remove( 
     &_POSIX_Semaphore_Information, &the_semaphore->Object );
 }
- 
-/**
- * @see _POSIX_Name_to_id().
- */
-RTEMS_INLINE_ROUTINE int _POSIX_Semaphore_Name_to_id(
-  const char *name,
-  Objects_Id *id,
-  size_t     *len
+
+RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get_by_name(
+  const char                *name,
+  size_t                    *name_length_p,
+  Objects_Get_by_name_error *error
 )
 {
-  return _POSIX_Name_to_id( &_POSIX_Semaphore_Information, name, id, len );
+  return (POSIX_Semaphore_Control *) _Objects_Get_by_name(
+    &_POSIX_Semaphore_Information,
+    name,
+    name_length_p,
+    error
+  );
 }
 
 #ifdef __cplusplus
diff --git a/cpukit/posix/src/mqueueopen.c b/cpukit/posix/src/mqueueopen.c
index 005de74..d327e13 100644
--- a/cpukit/posix/src/mqueueopen.c
+++ b/cpukit/posix/src/mqueueopen.c
@@ -67,11 +67,10 @@ mqd_t mq_open(
   va_list                         arg;
   struct mq_attr                 *attr = NULL;
   int                             status;
-  Objects_Id                      the_mq_id;
   POSIX_Message_queue_Control    *the_mq;
   POSIX_Message_queue_Control_fd *the_mq_fd;
-  Objects_Locations               location;
   size_t                          name_len;
+  Objects_Get_by_name_error       error;
 
   if ( oflag & O_CREAT ) {
     va_start(arg, oflag);
@@ -87,7 +86,7 @@ mqd_t mq_open(
   }
   the_mq_fd->oflag = oflag;
 
-  status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id, &name_len );
+  the_mq = _POSIX_Message_queue_Get_by_name( name, &name_len, &error );
 
   /*
    *  If the name to id translation worked, then the message queue exists
@@ -95,15 +94,18 @@ mqd_t mq_open(
    *  need to check to see if this is a "message queue does not exist"
    *  or some other miscellaneous error on the name.
    */
-  if ( status ) {
+  if ( the_mq == NULL ) {
     /*
      * Unless provided a valid name that did not already exist
      * and we are willing to create then it is an error.
      */
-    if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
+    if ( !( error == OBJECTS_GET_BY_NAME_NO_OBJECT && (oflag & O_CREAT) ) ) {
       _POSIX_Message_queue_Free_fd( the_mq_fd );
       _Objects_Allocator_unlock();
-      rtems_set_errno_and_return_value( status, MQ_OPEN_FAILED );
+      rtems_set_errno_and_return_value(
+        _POSIX_Get_by_name_error( error ),
+        MQ_OPEN_FAILED
+      );
     }
 
   } else {                /* name -> ID translation succeeded */
@@ -120,7 +122,6 @@ mqd_t mq_open(
      * In this case we need to do an ID->pointer conversion to
      * check the mode.
      */
-    the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
     the_mq->open_count += 1;
     the_mq_fd->Queue = the_mq;
     _Objects_Open_string(
@@ -128,7 +129,6 @@ mqd_t mq_open(
       &the_mq_fd->Object,
       NULL
     );
-    _Thread_Enable_dispatch();
     _Objects_Allocator_unlock();
     return the_mq_fd->Object.id;
 
@@ -149,7 +149,7 @@ mqd_t mq_open(
   /*
    * errno was set by Create_support, so don't set it again.
    */
-  if ( status == -1 ) {
+  if ( status != 0 ) {
     _POSIX_Message_queue_Free_fd( the_mq_fd );
     _Objects_Allocator_unlock();
     return MQ_OPEN_FAILED;
diff --git a/cpukit/posix/src/mqueueunlink.c b/cpukit/posix/src/mqueueunlink.c
index 2be096a..d5182d2 100644
--- a/cpukit/posix/src/mqueueunlink.c
+++ b/cpukit/posix/src/mqueueunlink.c
@@ -18,19 +18,10 @@
 #include "config.h"
 #endif
 
-#include <stdarg.h>
-
-#include <pthread.h>
-#include <limits.h>
-#include <errno.h>
-#include <fcntl.h>
 #include <mqueue.h>
 
-#include <rtems/system.h>
-#include <rtems/score/watchdog.h>
-#include <rtems/score/wkspace.h>
-#include <rtems/seterr.h>
 #include <rtems/posix/mqueueimpl.h>
+#include <rtems/seterr.h>
 
 /*
  *  15.2.2 Remove a Message Queue, P1003.1b-1993, p. 276
@@ -40,31 +31,21 @@ int mq_unlink(
   const char *name
 )
 {
-  int                                   status;
-  POSIX_Message_queue_Control          *the_mq;
-  Objects_Id                            the_mq_id;
-  size_t                                name_len;
+  POSIX_Message_queue_Control *the_mq;
+  Objects_Get_by_name_error    error;
 
   _Objects_Allocator_lock();
-  _Thread_Disable_dispatch();
 
-  status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id, &name_len );
-   if ( status != 0 ) {
-    _Thread_Enable_dispatch();
+  the_mq = _POSIX_Message_queue_Get_by_name( name, NULL, &error );
+  if ( the_mq == NULL ) {
     _Objects_Allocator_unlock();
-    rtems_set_errno_and_return_minus_one( status );
-   }
-
-  the_mq = (POSIX_Message_queue_Control *) _Objects_Get_local_object(
-    &_POSIX_Message_queue_Information,
-    _Objects_Get_index( the_mq_id )
-  );
+    rtems_set_errno_and_return_minus_one( _POSIX_Get_by_name_error( error ) );
+  }
 
   the_mq->linked = false;
   _POSIX_Message_queue_Namespace_remove( the_mq );
   _POSIX_Message_queue_Delete( the_mq );
 
-  _Thread_Enable_dispatch();
-   _Objects_Allocator_unlock();
+  _Objects_Allocator_unlock();
   return 0;
 }
diff --git a/cpukit/posix/src/psxnametoid.c b/cpukit/posix/src/psxnametoid.c
index 637de91..eac8e84 100644
--- a/cpukit/posix/src/psxnametoid.c
+++ b/cpukit/posix/src/psxnametoid.c
@@ -20,44 +20,10 @@
 
 #include <rtems/posix/posixapi.h>
 
-#include <string.h>
-#include <limits.h>
 #include <errno.h>
 
-/* pure ANSI mode does not have this prototype */
-size_t strnlen(const char *, size_t);
-
-int _POSIX_Name_to_id(
-  Objects_Information *information,
-  const char          *name,
-  Objects_Id          *id,
-  size_t              *len
-)
-{
-  int eno = EINVAL;
-  size_t n = 0;
-
-  if ( name != NULL && name [0] != '\0' ) {
-    n = strnlen( name, NAME_MAX );
-
-    if ( n < NAME_MAX ) {
-      Objects_Name_or_id_lookup_errors status = _Objects_Name_to_id_string(
-        information,
-        name,
-        id
-      );
-
-      if ( status == OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL ) {
-        eno = 0;
-      } else {
-        eno = ENOENT;
-      }
-    } else {
-      eno = ENAMETOOLONG;
-    }
-  }
-
-  *len = n;
-
-  return eno;
-}
+const int _POSIX_Get_by_name_error_table[ 3 ] = {
+  EINVAL,
+  ENAMETOOLONG,
+  ENOENT
+};
diff --git a/cpukit/posix/src/semopen.c b/cpukit/posix/src/semopen.c
index fe0dbeb..b844b08 100644
--- a/cpukit/posix/src/semopen.c
+++ b/cpukit/posix/src/semopen.c
@@ -60,10 +60,9 @@ sem_t *sem_open(
   va_list                    arg;
   unsigned int               value = 0;
   int                        status;
-  Objects_Id                 the_semaphore_id;
   POSIX_Semaphore_Control   *the_semaphore;
-  Objects_Locations          location;
   size_t                     name_len;
+  Objects_Get_by_name_error  error;
 
   if ( oflag & O_CREAT ) {
     va_start(arg, oflag);
@@ -73,7 +72,7 @@ sem_t *sem_open(
   }
 
   _Objects_Allocator_lock();
-  status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id, &name_len );
+  the_semaphore = _POSIX_Semaphore_Get_by_name( name, &name_len, &error );
 
   /*
    *  If the name to id translation worked, then the semaphore exists
@@ -82,16 +81,19 @@ sem_t *sem_open(
    *  or some other miscellaneous error on the name.
    */
 
-  if ( status ) {
+  if ( the_semaphore == NULL ) {
 
     /*
      * Unless provided a valid name that did not already exist
      * and we are willing to create then it is an error.
      */
 
-    if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
+    if ( !( error == OBJECTS_GET_BY_NAME_NO_OBJECT && (oflag & O_CREAT) ) ) {
       _Objects_Allocator_unlock();
-      rtems_set_errno_and_return_value( status, SEM_FAILED );
+      rtems_set_errno_and_return_value(
+        _POSIX_Get_by_name_error( error ),
+        SEM_FAILED
+      );
     }
   } else {
 
@@ -104,9 +106,7 @@ sem_t *sem_open(
       rtems_set_errno_and_return_value( EEXIST, SEM_FAILED );
     }
 
-    the_semaphore = _POSIX_Semaphore_Get( (sem_t *) &the_semaphore_id, &location );
     the_semaphore->open_count += 1;
-    _Thread_Enable_dispatch();
     _Objects_Allocator_unlock();
     goto return_id;
   }
@@ -130,7 +130,7 @@ sem_t *sem_open(
 
   _Objects_Allocator_unlock();
 
-  if ( status == -1 )
+  if ( status != 0 )
     return SEM_FAILED;
 
 return_id:
diff --git a/cpukit/posix/src/semunlink.c b/cpukit/posix/src/semunlink.c
index 863d258..b840618 100644
--- a/cpukit/posix/src/semunlink.c
+++ b/cpukit/posix/src/semunlink.c
@@ -18,15 +18,8 @@
 #include "config.h"
 #endif
 
-#include <stdarg.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
 #include <semaphore.h>
-#include <limits.h>
 
-#include <rtems/system.h>
 #include <rtems/posix/semaphoreimpl.h>
 #include <rtems/seterr.h>
 
@@ -34,32 +27,21 @@ int sem_unlink(
   const char *name
 )
 {
-  int                      status;
-  POSIX_Semaphore_Control *the_semaphore;
-  Objects_Id               the_semaphore_id;
-  size_t                   name_len;
+  POSIX_Semaphore_Control   *the_semaphore;
+  Objects_Get_by_name_error  error;
 
   _Objects_Allocator_lock();
-  _Thread_Disable_dispatch();
 
-  status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id, &name_len );
-  if ( status != 0 ) {
-    _Thread_Enable_dispatch();
+  the_semaphore = _POSIX_Semaphore_Get_by_name( name, NULL, &error );
+  if ( the_semaphore == NULL ) {
     _Objects_Allocator_unlock();
-    rtems_set_errno_and_return_minus_one( status );
+    rtems_set_errno_and_return_minus_one( _POSIX_Get_by_name_error( error ) );
   }
 
-  the_semaphore = (POSIX_Semaphore_Control *) _Objects_Get_local_object(
-    &_POSIX_Semaphore_Information,
-    _Objects_Get_index( the_semaphore_id )
-  );
-
   the_semaphore->linked = false;
   _POSIX_Semaphore_Namespace_remove( the_semaphore );
   _POSIX_Semaphore_Delete( the_semaphore );
 
-  _Thread_Enable_dispatch();
   _Objects_Allocator_unlock();
-
   return 0;
 }
diff --git a/cpukit/score/include/rtems/score/objectimpl.h b/cpukit/score/include/rtems/score/objectimpl.h
index fb2aca8..f75ae59 100644
--- a/cpukit/score/include/rtems/score/objectimpl.h
+++ b/cpukit/score/include/rtems/score/objectimpl.h
@@ -448,25 +448,31 @@ Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(
 );
 
 #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
+typedef enum {
+  OBJECTS_GET_BY_NAME_INVALID_NAME,
+  OBJECTS_GET_BY_NAME_NAME_TOO_LONG,
+  OBJECTS_GET_BY_NAME_NO_OBJECT
+} Objects_Get_by_name_error;
+
 /**
- *  @brief Converts an object name to an Id.
+ * @brief Gets an object control block identified by its name.
  *
- *  This method converts an object name to an Id.  It performs a look up
- *  using the object information block for this object class.
+ * The object information must use string names.
  *
- *  @param[in] information points to an object class information block.
- *  @param[in] name is the name of the object to find.
- *  @param[in] id will contain the Id if the search is successful.
+ * @param information The object information.  Must not be NULL.
+ * @param name The object name.
+ * @param name_length_p Optional parameter to return the name length.
+ * @param error The error indication in case of failure.  Must not be NULL.
  *
- *  @retval This method returns one of the values from the
- *          @ref Objects_Name_or_id_lookup_errors enumeration to indicate
- *          successful or failure.  On success @a id will contain the Id of
- *          the requested object.
+ * @retval NULL No object exists for this name or invalid parameters.
+ * @retval other The first object according to object index associated with
+ * this name.
  */
-Objects_Name_or_id_lookup_errors _Objects_Name_to_id_string(
-  Objects_Information *information,
-  const char          *name,
-  Objects_Id          *id
+Objects_Control *_Objects_Get_by_name(
+  const Objects_Information *information,
+  const char                *name,
+  size_t                    *name_length_p,
+  Objects_Get_by_name_error *error
 );
 #endif
 
@@ -1054,6 +1060,11 @@ RTEMS_INLINE_ROUTINE void _Objects_Allocator_unlock( void )
   _RTEMS_Unlock_allocator();
 }
 
+RTEMS_INLINE_ROUTINE bool _Objects_Allocator_is_owner( void )
+{
+  return _RTEMS_Allocator_is_owner();
+}
+
 /** @} */
 
 #ifdef __cplusplus
diff --git a/cpukit/score/src/objectnametoidstring.c b/cpukit/score/src/objectnametoidstring.c
index 00c84f0..dd0f203 100644
--- a/cpukit/score/src/objectnametoidstring.c
+++ b/cpukit/score/src/objectnametoidstring.c
@@ -23,40 +23,51 @@
 #include <string.h>
 
 #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
-Objects_Name_or_id_lookup_errors _Objects_Name_to_id_string(
-  Objects_Information *information,
-  const char          *name,
-  Objects_Id          *id
+Objects_Control *_Objects_Get_by_name(
+  const Objects_Information *information,
+  const char                *name,
+  size_t                    *name_length_p,
+  Objects_Get_by_name_error *error
 )
 {
-  Objects_Control           *the_object;
-  uint32_t                   index;
+  size_t   name_length;
+  uint32_t index;
 
-  /* ASSERT: information->is_string == true */
+  _Assert( information->is_string );
+  _Assert( _Objects_Allocator_is_owner() );
 
-  if ( !id )
-    return OBJECTS_INVALID_ADDRESS;
+  if ( name == NULL ) {
+    *error = OBJECTS_GET_BY_NAME_INVALID_NAME;
+    return NULL;
+  }
+
+  name_length = strnlen( name, information->name_length + 1 );
+  if ( name_length > information->name_length ) {
+    *error = OBJECTS_GET_BY_NAME_NAME_TOO_LONG;
+    return NULL;
+  }
+
+  if ( name_length_p != NULL ) {
+    *name_length_p = name_length;
+  }
 
-  if ( !name )
-    return OBJECTS_INVALID_NAME;
+  for ( index = 1; index <= information->maximum; index++ ) {
+    Objects_Control *the_object;
 
-  if ( information->maximum != 0 ) {
+    the_object = information->local_table[ index ];
 
-    for ( index = 1; index <= information->maximum; index++ ) {
-      the_object = information->local_table[ index ];
-      if ( !the_object )
-        continue;
+    if ( the_object == NULL )
+      continue;
 
-      if ( !the_object->name.name_p )
-        continue;
+    if ( the_object->name.name_p == NULL )
+      continue;
 
-      if (!strncmp( name, the_object->name.name_p, information->name_length)) {
-        *id = the_object->id;
-        return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
-      }
+    if ( strncmp( name, the_object->name.name_p, name_length ) == 0 ) {
+      return the_object;
     }
   }
 
-  return OBJECTS_INVALID_NAME;
+  *error = OBJECTS_GET_BY_NAME_NO_OBJECT;
+  return NULL;
 }
 #endif
diff --git a/testsuites/psxtests/psxobj01/init.c b/testsuites/psxtests/psxobj01/init.c
index 27d32b3..16b703b 100644
--- a/testsuites/psxtests/psxobj01/init.c
+++ b/testsuites/psxtests/psxobj01/init.c
@@ -29,11 +29,12 @@ rtems_task Init(
   rtems_task_argument ignored
 )
 {
-  Objects_Name_or_id_lookup_errors namerc;
-  Objects_Information              TestClass;
-  Objects_Id                       id;
-  char                             name[64];
-  bool                             bc;
+  Objects_Get_by_name_error  error;
+  Objects_Information        TestClass;
+  Objects_Control           *the_object;
+  char                       name[64];
+  size_t                     name_len;
+  bool                       bc;
 
   TEST_BEGIN();
 
@@ -53,27 +54,24 @@ rtems_task Init(
     #endif
   );
 
-  puts( "INIT - _Objects_Name_to_id_string - NULL name" );
-  namerc = _Objects_Name_to_id_string( &TestClass, NULL, &id );
-  if ( namerc != OBJECTS_INVALID_NAME ) {
-    printf( "ERROR - Status = %d\n", namerc );
-    rtems_test_exit(0);
-  }
-
-  puts( "INIT - _Objects_Name_to_id_string - NULL ID" );
-  namerc = _Objects_Name_to_id_string( &TestClass, name, NULL );
-  if ( namerc != OBJECTS_INVALID_ADDRESS ) {
-    printf( "ERROR - Status = %d\n", namerc );
-    rtems_test_exit(0);
-  }
-
-  puts( "INIT - _Objects_Name_to_id_string - name of non-existent object" );
+  puts( "INIT - _Objects_Get_by_name - NULL name" );
+  the_object = _Objects_Get_by_name( &TestClass, NULL, NULL, &error );
+  rtems_test_assert( the_object == NULL );
+  rtems_test_assert( error == OBJECTS_GET_BY_NAME_INVALID_NAME );
+
+  puts( "INIT - _Objects_Get_by_name - name too long" );
+  strcpy( name, "TOOOOOOOOOOOOOOOOOO LONG" );
+  the_object = _Objects_Get_by_name( &TestClass, name, NULL, &error );
+  rtems_test_assert( the_object == NULL );
+  rtems_test_assert( error == OBJECTS_GET_BY_NAME_NAME_TOO_LONG );
+
+  puts( "INIT - _Objects_Get_by_name - name of non-existent object" );
   strcpy( name, "NOT FOUND" );
-  namerc = _Objects_Name_to_id_string( &TestClass, name, &id );
-  if ( namerc != OBJECTS_INVALID_NAME ) {
-    printf( "ERROR - Status = %d\n", namerc );
-    rtems_test_exit(0);
-  }
+  name_len = 123;
+  the_object = _Objects_Get_by_name( &TestClass, name, &name_len, &error );
+  rtems_test_assert( the_object == NULL );
+  rtems_test_assert( error == OBJECTS_GET_BY_NAME_NO_OBJECT );
+  rtems_test_assert( name_len == 9 );
 
   /* out of memory error ONLY when POSIX is enabled */
   puts( "INIT - _Objects_Set_name fails - out of memory" );
diff --git a/testsuites/psxtests/psxobj01/psxobj01.scn b/testsuites/psxtests/psxobj01/psxobj01.scn
index 809d028..344820f 100644
--- a/testsuites/psxtests/psxobj01/psxobj01.scn
+++ b/testsuites/psxtests/psxobj01/psxobj01.scn
@@ -1,7 +1,6 @@
-*** POSIX OBJECT TEST 1 ***
-INIT - _Objects_Name_to_id_string - NULL name
-INIT - _Objects_Name_to_id_string - NULL ID
-INIT - _Objects_Name_to_id_string - name of non-existent object
+*** BEGIN OF TEST PSXOBJ 1 ***
+INIT - _Objects_Get_by_name - NULL name
+INIT - _Objects_Get_by_name - name too long
+INIT - _Objects_Get_by_name - name of non-existent object
 INIT - _Objects_Set_name fails - out of memory
-Allocate_majority_of_workspace: 
-*** END OF POSIX OBJECT TEST 1 ***
+*** END OF TEST PSXOBJ 1 ***
-- 
1.8.4.5



More information about the devel mailing list