Changeset c904df5 in rtems


Ignore:
Timestamp:
Mar 18, 2016, 6:25:23 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
5a5fb3b
Parents:
1f0e652a
git-author:
Sebastian Huber <sebastian.huber@…> (03/18/16 06:25:23)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/18/16 14:36:58)
Message:

score: Add _Objects_Get_by_name()

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.

Files:
16 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/include/rtems/posix/mqueueimpl.h

    r1f0e652a rc904df5  
    247247  );
    248248}
    249  
    250 /**
    251  * @see _POSIX_Name_to_id().
    252  */
    253 RTEMS_INLINE_ROUTINE int _POSIX_Message_queue_Name_to_id(
    254   const char          *name,
    255   Objects_Id          *id,
    256   size_t              *len
    257 )
    258 {
    259   return _POSIX_Name_to_id( &_POSIX_Message_queue_Information, name, id, len );
     249
     250RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *
     251_POSIX_Message_queue_Get_by_name(
     252  const char                *name,
     253  size_t                    *name_length_p,
     254  Objects_Get_by_name_error *error
     255)
     256{
     257  return (POSIX_Message_queue_Control *) _Objects_Get_by_name(
     258    &_POSIX_Message_queue_Information,
     259    name,
     260    name_length_p,
     261    error
     262  );
    260263}
    261264
  • cpukit/posix/include/rtems/posix/posixapi.h

    r1f0e652a rc904df5  
    2121
    2222#include <rtems/config.h>
     23#include <rtems/score/assert.h>
    2324#include <rtems/score/objectimpl.h>
    2425
     
    4950void _POSIX_Fatal_error( POSIX_Fatal_domain domain, int eno );
    5051
    51 /**
    52  * @brief Queries the object identifier @a id for a @a name.
    53  *
    54  * @param[in] information Object information.
    55  * @param[in] name Zero terminated name string to look up.
    56  * @param[out] id Pointer for identifier.  The pointer must be valid.
    57  * @param[out] len Pointer for string length.  The pointer must be valid.
    58  *
    59  * @retval 0 Successful operation.
    60  * @retval EINVAL The @a name pointer is @c NULL or the @a name string has
    61  * zero length.
    62  * @retval ENAMETOOLONG The @a name string length is greater than or equal to
    63  * @c NAME_MAX.
    64  * @retval ENOENT Found no corresponding identifier.
    65  */
    66 int _POSIX_Name_to_id(
    67   Objects_Information *information,
    68   const char          *name,
    69   Objects_Id          *id,
    70   size_t              *len
    71 );
     52extern const int _POSIX_Get_by_name_error_table[ 3 ];
     53
     54RTEMS_INLINE_ROUTINE int _POSIX_Get_by_name_error(
     55  Objects_Get_by_name_error error
     56)
     57{
     58  _Assert( (size_t) error < RTEMS_ARRAY_SIZE( _POSIX_Get_by_name_error_table ) );
     59  return _POSIX_Get_by_name_error_table[ error ];
     60}
    7261
    7362/** @} */
  • cpukit/posix/include/rtems/posix/semaphoreimpl.h

    r1f0e652a rc904df5  
    164164    &_POSIX_Semaphore_Information, &the_semaphore->Object );
    165165}
    166  
    167 /**
    168  * @see _POSIX_Name_to_id().
    169  */
    170 RTEMS_INLINE_ROUTINE int _POSIX_Semaphore_Name_to_id(
    171   const char *name,
    172   Objects_Id *id,
    173   size_t     *len
     166
     167RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get_by_name(
     168  const char                *name,
     169  size_t                    *name_length_p,
     170  Objects_Get_by_name_error *error
    174171)
    175172{
    176   return _POSIX_Name_to_id( &_POSIX_Semaphore_Information, name, id, len );
     173  return (POSIX_Semaphore_Control *) _Objects_Get_by_name(
     174    &_POSIX_Semaphore_Information,
     175    name,
     176    name_length_p,
     177    error
     178  );
    177179}
    178180
  • cpukit/posix/src/mqueueopen.c

    r1f0e652a rc904df5  
    6868  struct mq_attr                 *attr = NULL;
    6969  int                             status;
    70   Objects_Id                      the_mq_id;
    7170  POSIX_Message_queue_Control    *the_mq;
    7271  POSIX_Message_queue_Control_fd *the_mq_fd;
    73   Objects_Locations               location;
    7472  size_t                          name_len;
     73  Objects_Get_by_name_error       error;
    7574
    7675  if ( oflag & O_CREAT ) {
     
    8887  the_mq_fd->oflag = oflag;
    8988
    90   status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id, &name_len );
     89  the_mq = _POSIX_Message_queue_Get_by_name( name, &name_len, &error );
    9190
    9291  /*
     
    9695   *  or some other miscellaneous error on the name.
    9796   */
    98   if ( status ) {
     97  if ( the_mq == NULL ) {
    9998    /*
    10099     * Unless provided a valid name that did not already exist
    101100     * and we are willing to create then it is an error.
    102101     */
    103     if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
     102    if ( !( error == OBJECTS_GET_BY_NAME_NO_OBJECT && (oflag & O_CREAT) ) ) {
    104103      _POSIX_Message_queue_Free_fd( the_mq_fd );
    105104      _Objects_Allocator_unlock();
    106       rtems_set_errno_and_return_value( status, MQ_OPEN_FAILED );
     105      rtems_set_errno_and_return_value(
     106        _POSIX_Get_by_name_error( error ),
     107        MQ_OPEN_FAILED
     108      );
    107109    }
    108110
     
    121123     * check the mode.
    122124     */
    123     the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
    124125    the_mq->open_count += 1;
    125126    the_mq_fd->Queue = the_mq;
     
    129130      NULL
    130131    );
    131     _Thread_Enable_dispatch();
    132132    _Objects_Allocator_unlock();
    133133    return the_mq_fd->Object.id;
     
    150150   * errno was set by Create_support, so don't set it again.
    151151   */
    152   if ( status == -1 ) {
     152  if ( status != 0 ) {
    153153    _POSIX_Message_queue_Free_fd( the_mq_fd );
    154154    _Objects_Allocator_unlock();
  • cpukit/posix/src/mqueueunlink.c

    r1f0e652a rc904df5  
    1919#endif
    2020
    21 #include <stdarg.h>
    22 
    23 #include <pthread.h>
    24 #include <limits.h>
    25 #include <errno.h>
    26 #include <fcntl.h>
    2721#include <mqueue.h>
    2822
    29 #include <rtems/system.h>
    30 #include <rtems/score/watchdog.h>
    31 #include <rtems/score/wkspace.h>
     23#include <rtems/posix/mqueueimpl.h>
    3224#include <rtems/seterr.h>
    33 #include <rtems/posix/mqueueimpl.h>
    3425
    3526/*
     
    4132)
    4233{
    43   int                                   status;
    44   POSIX_Message_queue_Control          *the_mq;
    45   Objects_Id                            the_mq_id;
    46   size_t                                name_len;
     34  POSIX_Message_queue_Control *the_mq;
     35  Objects_Get_by_name_error    error;
    4736
    4837  _Objects_Allocator_lock();
    49   _Thread_Disable_dispatch();
    5038
    51   status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id, &name_len );
    52    if ( status != 0 ) {
    53     _Thread_Enable_dispatch();
     39  the_mq = _POSIX_Message_queue_Get_by_name( name, NULL, &error );
     40  if ( the_mq == NULL ) {
    5441    _Objects_Allocator_unlock();
    55     rtems_set_errno_and_return_minus_one( status );
    56    }
    57 
    58   the_mq = (POSIX_Message_queue_Control *) _Objects_Get_local_object(
    59     &_POSIX_Message_queue_Information,
    60     _Objects_Get_index( the_mq_id )
    61   );
     42    rtems_set_errno_and_return_minus_one( _POSIX_Get_by_name_error( error ) );
     43  }
    6244
    6345  the_mq->linked = false;
     
    6547  _POSIX_Message_queue_Delete( the_mq );
    6648
    67   _Thread_Enable_dispatch();
    68    _Objects_Allocator_unlock();
     49  _Objects_Allocator_unlock();
    6950  return 0;
    7051}
  • cpukit/posix/src/psxnametoid.c

    r1f0e652a rc904df5  
    2121#include <rtems/posix/posixapi.h>
    2222
    23 #include <string.h>
    24 #include <limits.h>
    2523#include <errno.h>
    2624
    27 /* pure ANSI mode does not have this prototype */
    28 size_t strnlen(const char *, size_t);
    29 
    30 int _POSIX_Name_to_id(
    31   Objects_Information *information,
    32   const char          *name,
    33   Objects_Id          *id,
    34   size_t              *len
    35 )
    36 {
    37   int eno = EINVAL;
    38   size_t n = 0;
    39 
    40   if ( name != NULL && name [0] != '\0' ) {
    41     n = strnlen( name, NAME_MAX );
    42 
    43     if ( n < NAME_MAX ) {
    44       Objects_Name_or_id_lookup_errors status = _Objects_Name_to_id_string(
    45         information,
    46         name,
    47         id
    48       );
    49 
    50       if ( status == OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL ) {
    51         eno = 0;
    52       } else {
    53         eno = ENOENT;
    54       }
    55     } else {
    56       eno = ENAMETOOLONG;
    57     }
    58   }
    59 
    60   *len = n;
    61 
    62   return eno;
    63 }
     25const int _POSIX_Get_by_name_error_table[ 3 ] = {
     26  EINVAL,
     27  ENAMETOOLONG,
     28  ENOENT
     29};
  • cpukit/posix/src/semopen.c

    r1f0e652a rc904df5  
    6161  unsigned int               value = 0;
    6262  int                        status;
    63   Objects_Id                 the_semaphore_id;
    6463  POSIX_Semaphore_Control   *the_semaphore;
    65   Objects_Locations          location;
    6664  size_t                     name_len;
     65  Objects_Get_by_name_error  error;
    6766
    6867  if ( oflag & O_CREAT ) {
     
    7473
    7574  _Objects_Allocator_lock();
    76   status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id, &name_len );
     75  the_semaphore = _POSIX_Semaphore_Get_by_name( name, &name_len, &error );
    7776
    7877  /*
     
    8382   */
    8483
    85   if ( status ) {
     84  if ( the_semaphore == NULL ) {
    8685
    8786    /*
     
    9089     */
    9190
    92     if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
     91    if ( !( error == OBJECTS_GET_BY_NAME_NO_OBJECT && (oflag & O_CREAT) ) ) {
    9392      _Objects_Allocator_unlock();
    94       rtems_set_errno_and_return_value( status, SEM_FAILED );
     93      rtems_set_errno_and_return_value(
     94        _POSIX_Get_by_name_error( error ),
     95        SEM_FAILED
     96      );
    9597    }
    9698  } else {
     
    105107    }
    106108
    107     the_semaphore = _POSIX_Semaphore_Get( (sem_t *) &the_semaphore_id, &location );
    108109    the_semaphore->open_count += 1;
    109     _Thread_Enable_dispatch();
    110110    _Objects_Allocator_unlock();
    111111    goto return_id;
     
    131131  _Objects_Allocator_unlock();
    132132
    133   if ( status == -1 )
     133  if ( status != 0 )
    134134    return SEM_FAILED;
    135135
  • cpukit/posix/src/semunlink.c

    r1f0e652a rc904df5  
    1919#endif
    2020
    21 #include <stdarg.h>
     21#include <semaphore.h>
    2222
    23 #include <errno.h>
    24 #include <fcntl.h>
    25 #include <pthread.h>
    26 #include <semaphore.h>
    27 #include <limits.h>
    28 
    29 #include <rtems/system.h>
    3023#include <rtems/posix/semaphoreimpl.h>
    3124#include <rtems/seterr.h>
     
    3528)
    3629{
    37   int                      status;
    38   POSIX_Semaphore_Control *the_semaphore;
    39   Objects_Id               the_semaphore_id;
    40   size_t                   name_len;
     30  POSIX_Semaphore_Control   *the_semaphore;
     31  Objects_Get_by_name_error  error;
    4132
    4233  _Objects_Allocator_lock();
    43   _Thread_Disable_dispatch();
    4434
    45   status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id, &name_len );
    46   if ( status != 0 ) {
    47     _Thread_Enable_dispatch();
     35  the_semaphore = _POSIX_Semaphore_Get_by_name( name, NULL, &error );
     36  if ( the_semaphore == NULL ) {
    4837    _Objects_Allocator_unlock();
    49     rtems_set_errno_and_return_minus_one( status );
     38    rtems_set_errno_and_return_minus_one( _POSIX_Get_by_name_error( error ) );
    5039  }
    51 
    52   the_semaphore = (POSIX_Semaphore_Control *) _Objects_Get_local_object(
    53     &_POSIX_Semaphore_Information,
    54     _Objects_Get_index( the_semaphore_id )
    55   );
    5640
    5741  the_semaphore->linked = false;
     
    5943  _POSIX_Semaphore_Delete( the_semaphore );
    6044
    61   _Thread_Enable_dispatch();
    6245  _Objects_Allocator_unlock();
    63 
    6446  return 0;
    6547}
  • cpukit/score/include/rtems/score/objectimpl.h

    r1f0e652a rc904df5  
    449449
    450450#if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    451 /**
    452  *  @brief Converts an object name to an Id.
    453  *
    454  *  This method converts an object name to an Id.  It performs a look up
    455  *  using the object information block for this object class.
    456  *
    457  *  @param[in] information points to an object class information block.
    458  *  @param[in] name is the name of the object to find.
    459  *  @param[in] id will contain the Id if the search is successful.
    460  *
    461  *  @retval This method returns one of the values from the
    462  *          @ref Objects_Name_or_id_lookup_errors enumeration to indicate
    463  *          successful or failure.  On success @a id will contain the Id of
    464  *          the requested object.
    465  */
    466 Objects_Name_or_id_lookup_errors _Objects_Name_to_id_string(
    467   Objects_Information *information,
    468   const char          *name,
    469   Objects_Id          *id
     451typedef enum {
     452  OBJECTS_GET_BY_NAME_INVALID_NAME,
     453  OBJECTS_GET_BY_NAME_NAME_TOO_LONG,
     454  OBJECTS_GET_BY_NAME_NO_OBJECT
     455} Objects_Get_by_name_error;
     456
     457/**
     458 * @brief Gets an object control block identified by its name.
     459 *
     460 * The object information must use string names.
     461 *
     462 * @param information The object information.  Must not be NULL.
     463 * @param name The object name.
     464 * @param name_length_p Optional parameter to return the name length.
     465 * @param error The error indication in case of failure.  Must not be NULL.
     466 *
     467 * @retval NULL No object exists for this name or invalid parameters.
     468 * @retval other The first object according to object index associated with
     469 * this name.
     470 */
     471Objects_Control *_Objects_Get_by_name(
     472  const Objects_Information *information,
     473  const char                *name,
     474  size_t                    *name_length_p,
     475  Objects_Get_by_name_error *error
    470476);
    471477#endif
     
    10551061}
    10561062
     1063RTEMS_INLINE_ROUTINE bool _Objects_Allocator_is_owner( void )
     1064{
     1065  return _RTEMS_Allocator_is_owner();
     1066}
     1067
    10571068/** @} */
    10581069
  • cpukit/score/src/objectnametoidstring.c

    r1f0e652a rc904df5  
    2424
    2525#if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    26 Objects_Name_or_id_lookup_errors _Objects_Name_to_id_string(
    27   Objects_Information *information,
    28   const char          *name,
    29   Objects_Id          *id
     26Objects_Control *_Objects_Get_by_name(
     27  const Objects_Information *information,
     28  const char                *name,
     29  size_t                    *name_length_p,
     30  Objects_Get_by_name_error *error
    3031)
    3132{
    32   Objects_Control           *the_object;
    33   uint32_t                   index;
     33  size_t   name_length;
     34  size_t   max_name_length;
     35  uint32_t index;
    3436
    35   /* ASSERT: information->is_string == true */
     37  _Assert( information->is_string );
     38  _Assert( _Objects_Allocator_is_owner() );
    3639
    37   if ( !id )
    38     return OBJECTS_INVALID_ADDRESS;
     40  if ( name == NULL ) {
     41    *error = OBJECTS_GET_BY_NAME_INVALID_NAME;
     42    return NULL;
     43  }
    3944
    40   if ( !name )
    41     return OBJECTS_INVALID_NAME;
     45  name_length = strnlen( name, information->name_length + 1 );
     46  max_name_length = information->name_length;
     47  if ( name_length > max_name_length ) {
     48    *error = OBJECTS_GET_BY_NAME_NAME_TOO_LONG;
     49    return NULL;
     50  }
    4251
    43   if ( information->maximum != 0 ) {
     52  if ( name_length_p != NULL ) {
     53    *name_length_p = name_length;
     54  }
    4455
    45     for ( index = 1; index <= information->maximum; index++ ) {
    46       the_object = information->local_table[ index ];
    47       if ( !the_object )
    48         continue;
     56  for ( index = 1; index <= information->maximum; index++ ) {
     57    Objects_Control *the_object;
    4958
    50       if ( !the_object->name.name_p )
    51         continue;
     59    the_object = information->local_table[ index ];
    5260
    53       if (!strncmp( name, the_object->name.name_p, information->name_length)) {
    54         *id = the_object->id;
    55         return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
    56       }
     61    if ( the_object == NULL )
     62      continue;
     63
     64    if ( the_object->name.name_p == NULL )
     65      continue;
     66
     67    if ( strncmp( name, the_object->name.name_p, max_name_length ) == 0 ) {
     68      return the_object;
    5769    }
    5870  }
    5971
    60   return OBJECTS_INVALID_NAME;
     72  *error = OBJECTS_GET_BY_NAME_NO_OBJECT;
     73  return NULL;
    6174}
    6275#endif
  • testsuites/psxtests/psxmsgq01/init.c

    r1f0e652a rc904df5  
    379379
    380380  /*
    381    *  EINVAL - Unlink a queue with a null name
    382    */
    383 
    384   puts( "Init: mq_unlink (\"\") - EINVAL" );
     381   *  ENOENT - Unlink a queue with a zero length name
     382   */
     383
     384  puts( "Init: mq_unlink (\"\") - ENOENT" );
    385385  status = mq_unlink( "" );
    386386  fatal_posix_service_status( status, -1, "mq_unlink error return status");
    387   fatal_posix_service_status( errno, EINVAL, "mq_unlink errno value");
     387  fatal_posix_service_status( errno, ENOENT, "mq_unlink errno value");
    388388}
    389389
  • testsuites/psxtests/psxmsgq01/psxmsgq01.scn

    r1f0e652a rc904df5  
    1 *** POSIX MESSAGE QUEUE TEST ***
     1*** BEGIN OF TEST PSXMSGQ 1 ***
    22_______________mq_open errors
    33Init: mq_open - Create with maxmsg (-1) (EINVAL)
     
    1414Init: mq_unlink - A Queue not opened  (ENOENT)
    1515Init: mq_unlink (NULL) - EINVAL
    16 Init: mq_unlink ("") - EINVAL
     16Init: mq_unlink ("") - ENOENT
    1717_______________mq_close errors
    1818Init: mq_close - unopened queue (EBADF)
     
    2222Task1:mq_setattr - NULL attributes (EINVAL)
    2323Init: set_attr all queues to blocking
    24 Init: Init: mq_timedreceive - on queue Qnoblock Init: 1 sec -12131 us
    25 Init: Init: mq_timedreceive - on queue Qblock Init: 1 sec -11843 us
    26 Init: Init: mq_timedreceive - on queue Qdefault Init: 0 sec 988133 us
     24Init: Init: mq_timedreceive - on queue Qnoblock Init: 1 sec -8622 us
     25Init: Init: mq_timedreceive - on queue Qblock Init: 1 sec -1872 us
     26Init: Init: mq_timedreceive - on queue Qdefault Init: 1 sec -1881 us
    2727_______________mq_send errors
    2828Init: mq_send - Closed message queue (EBADF)
     
    3838Init: mq_getattr - NULL attributes (EINVAL)
    3939_______________mq_timedsend
    40 Init: mq_timedsend - on queue Qnoblock Init: 0 sec 77 us
    41 Init: mq_timedsend - on queue Qblock Init: 0 sec 988482 us
    42 Init: mq_timedsend - on queue Qdefault Init: 0 sec 101 us
     40Init: mq_timedsend - on queue Qnoblock Init: 0 sec 127 us
     41Init: mq_timedsend - on queue Qblock Init: 1 sec -9245 us
     42Init: mq_timedsend - on queue Qdefault Init: 0 sec 130 us
    4343_______________mq_receive errors
    4444Init: mq_receive - Unopened message queue (EBADF)
     
    4949Init: mq_receive - Queue is empty (EAGAIN)
    5050_______________mq_timedreceive
    51 Init: Init: mq_timedreceive - on queue Qnoblock Init: 0 sec 83 us
    52 Init: Init: mq_timedreceive - on queue Qblock Init: 0 sec 986568 us
    53 Init: Init: mq_timedreceive - on queue Qdefault Init: 1 sec -11823 us
     51Init: Init: mq_timedreceive - on queue Qnoblock Init: 0 sec 128 us
     52Init: Init: mq_timedreceive - on queue Qblock Init: 1 sec -715 us
     53Init: Init: mq_timedreceive - on queue Qdefault Init: 1 sec -1836 us
    5454_______________mq_open functionality
    5555_______________mq_notify
     
    7171waiting on any signal for 3 seconds.
    7272_______________multi-thread Task 1 Test
    73 Task_1: Fri Jan  1 00:00:17 1988
     73Task_1: Fri Jan  1 00:00:18 1988
    7474Task_1: mq_send -  to Qblock msg: 12345678 priority 31
    7575Task_1: pthread_exit
    76 Init: Fri Jan  1 00:00:17 1988
     76Init: Fri Jan  1 00:00:18 1988
    7777_______________multi-thread Task 2 Test
    7878Init: Verify Queues are empty
     
    8080Init: Verify Queues are full
    8181Init: mq_send -  to Qblock msg: Last priority 32
    82 Task_2: Fri Jan  1 00:00:17 1988
     82Task_2: Fri Jan  1 00:00:18 1988
    8383Task_2: Verify Queues are full
    8484Task_2: pthread_exit
    85 Init: Fri Jan  1 00:00:17 1988
     85Init: Fri Jan  1 00:00:18 1988
    8686Init: Verify Queues are full
    8787Init: Empty all Queues
     
    9595Task_3: pthread_exit
    9696_______________mq_timedout_receive
    97 Init: Init: verify_timedout_mq_timedreceive - on queue Qnoblock Init: 0 sec 54 us
     97Init: Init: verify_timedout_mq_timedreceive - on queue Qnoblock Init: 0 sec 81 us
    9898_______________verify_timedout_mq_timedsend
    99 Init: verify_timedout_mq_timedsend - on queue Qnoblock Init: 0 sec 54 us
    100 Init: verify_timedout_mq_timedsend - on queue Qblock Init: 0 sec 55 us
    101 Init: verify_timedout_mq_timedsend - on queue Qdefault Init: 0 sec 78 us
    102 *** END OF POSIX MESSAGE QUEUE TEST ***
    103 
     99Init: verify_timedout_mq_timedsend - on queue Qnoblock Init: 0 sec 84 us
     100Init: verify_timedout_mq_timedsend - on queue Qblock Init: 0 sec 86 us
     101Init: verify_timedout_mq_timedsend - on queue Qdefault Init: 0 sec 104 us
     102*** END OF TEST PSXMSGQ 1 ***
  • testsuites/psxtests/psxobj01/init.c

    r1f0e652a rc904df5  
    3030)
    3131{
    32   Objects_Name_or_id_lookup_errors namerc;
    33   Objects_Information              TestClass;
    34   Objects_Id                       id;
    35   char                             name[64];
    36   bool                             bc;
     32  Objects_Get_by_name_error  error;
     33  Objects_Information        TestClass;
     34  Objects_Control           *the_object;
     35  char                       name[64];
     36  size_t                     name_len;
     37  bool                       bc;
    3738
    3839  TEST_BEGIN();
     
    5455  );
    5556
    56   puts( "INIT - _Objects_Name_to_id_string - NULL name" );
    57   namerc = _Objects_Name_to_id_string( &TestClass, NULL, &id );
    58   if ( namerc != OBJECTS_INVALID_NAME ) {
    59     printf( "ERROR - Status = %d\n", namerc );
    60     rtems_test_exit(0);
    61   }
     57  puts( "INIT - _Objects_Get_by_name - NULL name" );
     58  the_object = _Objects_Get_by_name( &TestClass, NULL, NULL, &error );
     59  rtems_test_assert( the_object == NULL );
     60  rtems_test_assert( error == OBJECTS_GET_BY_NAME_INVALID_NAME );
    6261
    63   puts( "INIT - _Objects_Name_to_id_string - NULL ID" );
    64   namerc = _Objects_Name_to_id_string( &TestClass, name, NULL );
    65   if ( namerc != OBJECTS_INVALID_ADDRESS ) {
    66     printf( "ERROR - Status = %d\n", namerc );
    67     rtems_test_exit(0);
    68   }
     62  puts( "INIT - _Objects_Get_by_name - name too long" );
     63  strcpy( name, "TOOOOOOOOOOOOOOOOOO LONG" );
     64  the_object = _Objects_Get_by_name( &TestClass, name, NULL, &error );
     65  rtems_test_assert( the_object == NULL );
     66  rtems_test_assert( error == OBJECTS_GET_BY_NAME_NAME_TOO_LONG );
    6967
    70   puts( "INIT - _Objects_Name_to_id_string - name of non-existent object" );
     68  puts( "INIT - _Objects_Get_by_name - name of non-existent object" );
    7169  strcpy( name, "NOT FOUND" );
    72   namerc = _Objects_Name_to_id_string( &TestClass, name, &id );
    73   if ( namerc != OBJECTS_INVALID_NAME ) {
    74     printf( "ERROR - Status = %d\n", namerc );
    75     rtems_test_exit(0);
    76   }
     70  name_len = 123;
     71  the_object = _Objects_Get_by_name( &TestClass, name, &name_len, &error );
     72  rtems_test_assert( the_object == NULL );
     73  rtems_test_assert( error == OBJECTS_GET_BY_NAME_NO_OBJECT );
     74  rtems_test_assert( name_len == 9 );
    7775
    7876  /* out of memory error ONLY when POSIX is enabled */
  • testsuites/psxtests/psxobj01/psxobj01.scn

    r1f0e652a rc904df5  
    1 *** POSIX OBJECT TEST 1 ***
    2 INIT - _Objects_Name_to_id_string - NULL name
    3 INIT - _Objects_Name_to_id_string - NULL ID
    4 INIT - _Objects_Name_to_id_string - name of non-existent object
     1*** BEGIN OF TEST PSXOBJ 1 ***
     2INIT - _Objects_Get_by_name - NULL name
     3INIT - _Objects_Get_by_name - name too long
     4INIT - _Objects_Get_by_name - name of non-existent object
    55INIT - _Objects_Set_name fails - out of memory
    6 Allocate_majority_of_workspace:
    7 *** END OF POSIX OBJECT TEST 1 ***
     6*** END OF TEST PSXOBJ 1 ***
  • testsuites/psxtests/psxsem01/init.c

    r1f0e652a rc904df5  
    280280  fatal_posix_service_status( errno, EINVAL, "sem_unlink errno value");
    281281
    282   puts( "Init: sem_unlink (\"\") - EINVAL" );
     282  puts( "Init: sem_unlink (\"\") - ENOENT" );
    283283  status = sem_unlink( "" );
    284284  fatal_posix_service_status( status, -1, "sem_unlink error return status");
    285   fatal_posix_service_status( errno, EINVAL, "sem_unlink errno value");
     285  fatal_posix_service_status( errno, ENOENT, "sem_unlink errno value");
    286286
    287287  /*
  • testsuites/psxtests/psxsem01/psxsem01.scn

    r1f0e652a rc904df5  
    1 *** POSIX SEMAPHORE MANAGER TEST 1 ***
     1*** BEGIN OF TEST PSXSEM 1 ***
    22Init: sem_init - UNSUCCESSFUL (EINVAL)
    33Init: sem_init - SUCCESSFUL
    44Init: sem_init - UNSUCCESSFUL (ENOSPC)
    55Init: sem_init - UNSUCCESSFUL (ENOSYS -- pshared not supported)
    6 Init: sem_getvalue - SUCCESSFUL
    7 Init: sem_getvalue - UNSUCCESSFUL
     6Init: sem_getvalue - SUCCESSFUL 
     7Init: sem_getvalue - UNSUCCESSFUL 
    88Init: sem_destroy - SUCCESSFUL
    99Init: sem_destroy - UNSUCCESSFUL (EINVAL)
     
    1414Init: sem_trywait - SUCCESSFUL
    1515Init: sem_trywait - UNSUCCESSFUL (EAGAIN)
    16 Init: sem_trywait - UNSUCCESSFUL (EINVAL) -- skipping
     16Init: sem_trywait - UNSUCCESSFUL (EINVAL)
    1717Init: sem_timedwait - SUCCESSFUL
    1818Init: sem_timedwait - UNSUCCESSFUL (ETIMEDOUT)
    19 Init: sem_timedwait - UNSUCCESSFUL (EINVAL)
     19Init: sem_timedwait - UNSUCCESSFUL (EINVAL) -- skipping
    2020Init: sem_post - UNSUCCESSFUL (EINVAL)
    2121Init: sem_destroy - SUCCESSFUL
     
    3535Init: sem_unlink - UNSUCCESSFUL (ENOENT)
    3636Init: sem_unlink (NULL) - EINVAL
    37 Init: sem_unlink ("") - EINVAL
     37Init: sem_unlink ("") - ENOENT
    3838Init: sem_unlink - UNSUCCESSFUL (ENOENT)
    39 *** END OF POSIX SEMAPHORE MANAGER TEST 1 ***
    40 
     39*** END OF TEST PSXSEM 1 ***
Note: See TracChangeset for help on using the changeset viewer.