Changeset 99e7ab89 in rtems


Ignore:
Timestamp:
Jan 5, 2000, 5:21:12 PM (20 years ago)
Author:
Jennifer Averett <Jennifer.Averett@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
f388d36
Parents:
b302d527
Message:

+ Added tests for open, close, unlink, and send.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/tests/psxtests/psxmsgq01/init.c

    rb302d527 r99e7ab89  
    3636}
    3737
     38typedef enum {
     39  DEFAULT_SIZE_TYPE,
     40  TEST_SIZE_TYPE,
     41  MAX_SIZE,
     42  TYPES_OF_TEST_SIZES
     43} TEST_MQ_SIZE_TYPES;
     44
     45
    3846/*
    3947 * Opens CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES then leaves size queues
     
    6674  attr.mq_maxmsg = -1;
    6775  puts( "mq_open - Create with maxmsg (-1) (EINVAL)" );
    68   n_mq2 = mq_open("mq2", O_CREAT, O_RDONLY, &attr);
     76  n_mq2 = mq_open("mq2", O_CREAT | O_RDONLY, 0x777, &attr);
    6977  fatal_directive_status(
    7078    (int) n_mq2, (int ) (-1), "mq_open error return status" );
     
    7381  attr.mq_msgsize = -1;
    7482  puts( "mq_open - Create with msgsize (-1) (EINVAL)" );
    75   n_mq2 = mq_open("mq2", O_CREAT, O_RDONLY, &attr);
     83  n_mq2 = mq_open("mq2", O_CREAT | O_RDONLY, 0x777, &attr);
    7684  fatal_directive_status(
    7785    (int) n_mq2, (int ) (-1), "mq_open error return status" );
    7886  fatal_directive_status( errno, EINVAL,  "mq_open errno EINVAL");
    7987
    80 
    8188  puts( "mq_open - Open new mq without create flag (ENOENT)" );
    82   n_mq2 = mq_open("mq3", O_EXCL, O_RDONLY, NULL);
     89  n_mq2 = mq_open("mq3", O_EXCL | O_RDONLY, 0x777, NULL);
    8390  fatal_directive_status(
    8491    (int) n_mq2, (int ) (-1), "mq_open error return status" );
     
    95102
    96103  puts( "mq_open - Open with too long of a name (ENAMETOOLONG)" );
    97   n_mq2 = mq_open( Get_Too_Long_Name(), O_CREAT, O_RDONLY, NULL );
     104  n_mq2 = mq_open( Get_Too_Long_Name(), O_CREAT | O_RDONLY, 0x777, NULL );
    98105  fatal_directive_status(
    99106    (int) n_mq2, (int ) (-1), "mq_open error return status" );
     
    106113  puts( "mq_open - SUCCESSFUL" );
    107114  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES; i++) {
    108     mqs[i] = mq_open( Get_Queue_Name(i), O_CREAT, O_RDONLY, NULL );
     115    mqs[i] = mq_open( Get_Queue_Name(i), O_CREAT | O_RDWR, 0x777, NULL );
    109116    assert( mqs[i] != (-1) );
    110117    /*XXX - Isn't there a more general check */
     
    126133   * XXX EACCES - queue exists permissions specified by o_flag are denied.
    127134  puts( "mq_open - open mq as write (EACCES)" );
    128   n_mq2 = mq_open("mq1", O_CREAT, O_WRONLY, NULL);
     135  n_mq2 = mq_open("mq1", O_CREAT | O_WRONLY, 0x777, NULL);
    129136  fatal_directive_status(
    130137    (int) n_mq2, (int ) (-1), "mq_open error return status" );
     
    133140
    134141  puts( "mq_open - Create an Existing mq (EEXIST)" );
    135   n_mq2 = mq_open("mq1", O_CREAT | O_EXCL, O_RDONLY, NULL);
     142  n_mq2 = mq_open("mq1", O_CREAT | O_EXCL | O_RDONLY, 0x777, NULL);
    136143  fatal_directive_status(
    137144    (int) n_mq2, (int ) (-1), "mq_open error return status" );
     
    144151
    145152  puts( "mq_open - system is out of resources (ENFILE)" );
    146   n_mq2 = mq_open( Get_Queue_Name(i), O_CREAT, O_RDONLY, NULL );
     153  n_mq2 = mq_open( Get_Queue_Name(i), O_CREAT | O_RDONLY, 0x777, NULL );
    147154  fatal_directive_status(
    148155    (int) n_mq2, (int ) (-1), "mq_open error return status" );
     
    165172
    166173void validate_mq_unlink_error_codes(
    167   mqd_t   *mqs,      /* Must be large enough for Maximum to be opened. */
    168   int      size      /* Number still open */
     174  mqd_t   *mqs,     
     175  int      size      /* Number still open in mqs */
    169176)
    170177{
     
    178185   * XXX ENAMETOOLONG - Not checked in either sem_unlink or mq_unlink is
    179186   *                    this an error?
    180   for ( i=0; i< PATH_MAX+1; i++ )
    181     name[i] = 'N';
    182   puts( "mq_open - Open with too long of a name (ENAMETOOLONG)" );
    183   n_mq2 = mq_open( Get_Too_Long_Name(), O_CREAT, O_RDONLY, NULL );
    184   fatal_directive_status(
    185     (int) n_mq2, (int ) (-1), "mq_open error return status" );
    186   fatal_directive_status( errno, ENAMETOOLONG,  "mq_open errno ENAMETOOLONG");
    187   */
     187   */
     188
     189  puts( "mq_unlink - mq_unlink with too long of a name (ENAMETOOLONG)" );
     190  status = mq_unlink( Get_Too_Long_Name() );
     191  fatal_directive_status( status, -1, "mq_unlink error return status");
     192  fatal_directive_status( errno, ENAMETOOLONG, "mq_unlink errno ENAMETOOLONG");
    188193 
    189194  puts( "mq_unlink - UNSUCCESSFUL (ENOENT)" );
     
    191196  fatal_directive_status( status, -1, "mq_unlink error return status");
    192197  fatal_directive_status( errno, ENOENT, "mq_unlink errno ENOENT");
     198
     199  /*
     200   * XXX - These errors are not in the POSIX manual but may occur.
     201   */
     202
     203  puts( "mq_unlink (NULL) - EINVAL" );
     204  status = mq_unlink( NULL );
     205  fatal_directive_status( status, -1, "mq_unlink error return status");
     206  fatal_directive_status( errno, EINVAL, "mq_unlink errno value");
     207
     208  puts( "mq_unlink (\"\") - EINVAL" );
     209  status = mq_unlink( "" );
     210  fatal_directive_status( status, -1, "mq_unlink error return status");
     211  fatal_directive_status( errno, EINVAL, "mq_unlink errno value");
    193212}
    194213
    195214void validate_mq_close_error_codes(
    196   mqd_t   *mqs,      /* Must be large enough for Maximum to be opened. */
    197   int      size      /* Number still open */
     215  mqd_t   *mqs,     
     216  int      size      /* Number still open in mqs */
    198217)
    199218{
     
    204223  fatal_directive_status( status, -1, "mq_close error return status");
    205224  fatal_directive_status( errno, EBADF, "mq_close errno EBADF");
    206 
     225}
     226 
     227/*
     228 * Returns the number of messages queued after the test on the
     229 * first queue.
     230 */
     231
     232int validate_mq_send_error_codes(
     233  mqd_t   *mqs,
     234  int      size      /* Number still open in mqs */
     235)
     236{
     237  int             status;
     238  int             i;
     239  mqd_t           n_mq1;
     240  struct mq_attr  attr;
     241
     242  attr.mq_maxmsg  = 3;
     243  attr.mq_msgsize = 8;
     244
     245  /*
     246   * XXX - EBADF  Not a valid message descriptor.
     247   *       Write to a invalid message descriptor
     248   * XXX - Write to a read only queue
     249   */
     250
     251  puts( "mq_send - Closed message queue (EBADF)" );
     252  status = mq_send( mqs[size], "", 1, 0 );
     253  fatal_directive_status( status, -1, "mq_send error return status");
     254  fatal_directive_status( errno, EBADF, "mq_send errno EBADF");
     255
     256  puts( "mq_open - Open a read only queue" );
     257  n_mq1 = mq_open("read_only", O_CREAT | O_RDONLY, 0x777, &attr);
     258  assert( n_mq1 != (-1) );
     259  /*XXX - Isn't there a more general check */
     260
     261  puts( "mq_send - Read only message queue (EBADF)" );
     262  status = mq_send( n_mq1, "", 1, 0 );
     263  fatal_directive_status( status, -1, "mq_send error return status");
     264  fatal_directive_status( errno, EBADF, "mq_send errno EBADF");
     265
     266  status = mq_close( n_mq1 );
     267  fatal_directive_status( status, 0, "mq_close message queue");
     268
     269  status = mq_unlink( "read_only" );
     270  fatal_directive_status( status, 0, "mq_unlink message queue");
     271
     272  /*
     273   * XXX - EINTR
     274   *       Signal interrupted the call.
     275
     276  puts( "mq_send - UNSUCCESSFUL (EINTR)" );
     277  status = mq_send( mqs, "", 0xffff, 0 );
     278  fatal_directive_status( status, -1, "mq_send error return status");
     279  fatal_directive_status( errno, E, "mq_send errno E");
     280   */
     281
     282  /*
     283   * XXX - EINVAL priority is out of range.
     284   */
     285
     286  puts( "mq_send - Priority out of range (EINVAL)" );
     287  status = mq_send( mqs[0], "", 1, MQ_PRIO_MAX + 1 );
     288  fatal_directive_status( status, -1, "mq_send error return status");
     289  fatal_directive_status( errno, EINVAL, "mq_send errno EINVAL");
     290
     291  /*
     292   * XXX - EMSGSIZE - Message size larger than msg_len
     293   */
     294
     295  puts( "mq_send - Message longer than msg_len (EMSGSIZE)" );
     296  status = mq_send( mqs[0], "", 0xffff, 0 );
     297  fatal_directive_status( status, -1, "mq_send error return status");
     298  fatal_directive_status( errno, EMSGSIZE, "mq_send errno EMSGSIZE");
     299
     300  /*
     301   * ENOSYS - send is supported should never happen.
     302   */
     303
     304
     305  /*
     306   * XXX - EAGAIN
     307   *       O_NONBLOCK and message queue is full.
     308   *       This is validated in the read/write test.
     309   */
     310
     311  i=0;
     312  do {
     313    status = mq_send( mqs[0], "", 1, 0 );
     314    i++;
     315  } while (status == 0);
     316  fatal_directive_status( status, -1, "mq_send error return status");
     317  fatal_directive_status( errno, EAGAIN, "mq_send errno EAGAIN");
     318
     319  return i-1;
     320}
     321
     322void validate_mq_receive_error_codes(
     323  mqd_t   *mqs,     
     324  int      size      /* Number still open in mqs */
     325)
     326{
     327  int             status;
     328
     329  /*
     330   * EAGAIN -
     331   */
     332
     333  /*
     334   * EBADF -
     335   */
     336
     337  /*
     338   * EMSGSIZE -
     339   */
     340
     341  /*
     342   * EINTR -
     343   */
     344
     345  /*
     346   * EBADMSG - a data corruption problem.
     347   *  XXX - Can not cause.
     348   */
     349
     350  /*
     351  puts( "mq_ - UNSUCCESSFUL ()" );
     352  status = mq_(  );
     353  fatal_directive_status( status, -1, "mq_ error return status");
     354  fatal_directive_status( errno, E, "mq_c errno E");
     355
     356  */
     357  /*
     358   * ENOSYS -
     359   */
     360
     361}
     362
     363void non_blocking_mq_read_write(
     364  mqd_t   *mqs,     
     365  int      size      /* Number still open in mqs */
     366)
     367{
     368  /*
     369  int         status;
     370  char       *messages[] = {
     371    "Msg 1",
     372    "Test 2",
     373    "12345678901234567890"
     374  };
     375
     376  status = mq_send( mqs[0], messages[0], strlen( messages[0] ), 0 );
     377  fatal_directive_status( status, 0, "mq_send error return status" );
     378   
     379  puts( "mq_send - UNSUCCESSFUL ()" );
     380  do {
     381    status = mq_send(  );
     382  fatal_directive_status( status, -1, "mq_send error return status");
     383  fatal_directive_status( errno, E, "mq_send errno E");
     384  }
     385  */
    207386}
    208387
     
    212391{
    213392  int             status;
    214   int             value;
    215   int             i;
    216393  mqd_t           mqs[CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES];
    217   mqd_t           mq2;
    218394  mqd_t           n_mq1;
    219395  mqd_t           n_mq2;
    220   struct timespec waittime;
    221   char            failure_msg[80];
    222   struct mq_attr  attr;
     396  char           *messages[] = {
     397    "Msg 1",
     398    "Test 2",
     399    "12345678901234567890"
     400  };
    223401
    224402  puts( "\n\n*** POSIX MESSAGE QUEUE TEST ***" );
     
    228406  validate_mq_close_error_codes( mqs, 2 );
    229407
     408  validate_mq_send_error_codes( mqs, 2 );
     409  validate_mq_receive_error_codes( mqs, 2 );
     410
     411
    230412  /*
    231413   * Validate a second open returns the same message queue.
     
    233415
    234416  puts( "mq_open - Open an existing mq ( same id )" );
    235   n_mq2 = mq_open("mq1", 0 );
    236   fatal_directive_status(
    237     (int) n_mq2, (int ) mqs[0], "mq_open error return status" );
     417  n_mq1 = mq_open("mq1", 0 );
     418  fatal_directive_status(
     419    (int) n_mq1, (int ) mqs[0], "mq_open error return status" );
    238420 
    239421  /*
     
    252434
    253435  /*
    254    * Validate it n_mq2 (the last open for mq1 name can be
    255    * correctly closed and unlinked.
    256    */
    257 
    258   puts( "Init: mq_unlink - mq1 (2) SUCCESSFUL" );
     436   * Validate it "mq1" can be closed and unlinked.
     437   */
     438
     439  puts( "mq_unlink - mq1 SUCCESSFUL" );
    259440  status = mq_unlink( "mq1" );
    260441  fatal_directive_status( status, 0, "mq_unlink locked message queue");
    261442
    262   puts( "Init: mq_close (2) - SUCCESSFUL" );
     443  puts( "mq_close mq1 - SUCCESSFUL" );
    263444  status = mq_close( n_mq2 );
    264445  fatal_directive_status( status, 0, "mq_close message queue");
    265 
    266 
    267   puts( "Init: mq_unlink - UNSUCCESSFUL (ENOENT)" );
     446  status = mq_close( n_mq1 );
     447  fatal_directive_status( status, 0, "mq_close message queue");
     448  status = mq_close( mqs[0] );
     449  fatal_directive_status( status, 0, "mq_close message queue");
     450
     451  puts( "mq_unlink - UNSUCCESSFUL (ENOENT)" );
    268452  status = mq_unlink("mq1");
    269453  fatal_directive_status( status, -1, "mq_unlink error return status");
    270454  fatal_directive_status( errno, ENOENT, "mq_close errno EINVAL");
    271 
    272 
    273   /*
    274    * Validate we can unlink (2)
    275    */
    276 
    277   puts( "Init: mq_unlink (NULL) - EINVAL" );
    278   status = mq_unlink( NULL );
    279   fatal_directive_status( status, -1, "mq_unlink error return status");
    280   fatal_directive_status( errno, EINVAL, "mq_unlink errno value");
    281 
    282   puts( "Init: mq_unlink (\"\") - EINVAL" );
    283   status = mq_unlink( "" );
    284   fatal_directive_status( status, -1, "mq_unlink error return status");
    285   fatal_directive_status( errno, EINVAL, "mq_unlink errno value");
    286455
    287456  /*
    288457   * XXX - Cant' create location OBJECTS_ERROR or OBJECTS_REMOTE.
    289458   *       mq_close and mq_unlink.
    290    */
    291 
     459   * XXX - Don't think we need this save until yellow line tested.
    292460  puts( "Init: mq_unlink - UNSUCCESSFUL (ENOENT)" );
    293461  status = mq_unlink("mq3");
     
    295463  fatal_directive_status( errno, ENOENT, "mq_unlink errno ENOENT");
    296464  assert( (status == -1) && (errno == ENOENT) );
    297 
     465  */
    298466
    299467
     
    313481  return NULL; /* just so the compiler thinks we returned something */
    314482}
     483
     484
  • testsuites/psxtests/psxmsgq01/init.c

    rb302d527 r99e7ab89  
    3636}
    3737
     38typedef enum {
     39  DEFAULT_SIZE_TYPE,
     40  TEST_SIZE_TYPE,
     41  MAX_SIZE,
     42  TYPES_OF_TEST_SIZES
     43} TEST_MQ_SIZE_TYPES;
     44
     45
    3846/*
    3947 * Opens CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES then leaves size queues
     
    6674  attr.mq_maxmsg = -1;
    6775  puts( "mq_open - Create with maxmsg (-1) (EINVAL)" );
    68   n_mq2 = mq_open("mq2", O_CREAT, O_RDONLY, &attr);
     76  n_mq2 = mq_open("mq2", O_CREAT | O_RDONLY, 0x777, &attr);
    6977  fatal_directive_status(
    7078    (int) n_mq2, (int ) (-1), "mq_open error return status" );
     
    7381  attr.mq_msgsize = -1;
    7482  puts( "mq_open - Create with msgsize (-1) (EINVAL)" );
    75   n_mq2 = mq_open("mq2", O_CREAT, O_RDONLY, &attr);
     83  n_mq2 = mq_open("mq2", O_CREAT | O_RDONLY, 0x777, &attr);
    7684  fatal_directive_status(
    7785    (int) n_mq2, (int ) (-1), "mq_open error return status" );
    7886  fatal_directive_status( errno, EINVAL,  "mq_open errno EINVAL");
    7987
    80 
    8188  puts( "mq_open - Open new mq without create flag (ENOENT)" );
    82   n_mq2 = mq_open("mq3", O_EXCL, O_RDONLY, NULL);
     89  n_mq2 = mq_open("mq3", O_EXCL | O_RDONLY, 0x777, NULL);
    8390  fatal_directive_status(
    8491    (int) n_mq2, (int ) (-1), "mq_open error return status" );
     
    95102
    96103  puts( "mq_open - Open with too long of a name (ENAMETOOLONG)" );
    97   n_mq2 = mq_open( Get_Too_Long_Name(), O_CREAT, O_RDONLY, NULL );
     104  n_mq2 = mq_open( Get_Too_Long_Name(), O_CREAT | O_RDONLY, 0x777, NULL );
    98105  fatal_directive_status(
    99106    (int) n_mq2, (int ) (-1), "mq_open error return status" );
     
    106113  puts( "mq_open - SUCCESSFUL" );
    107114  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES; i++) {
    108     mqs[i] = mq_open( Get_Queue_Name(i), O_CREAT, O_RDONLY, NULL );
     115    mqs[i] = mq_open( Get_Queue_Name(i), O_CREAT | O_RDWR, 0x777, NULL );
    109116    assert( mqs[i] != (-1) );
    110117    /*XXX - Isn't there a more general check */
     
    126133   * XXX EACCES - queue exists permissions specified by o_flag are denied.
    127134  puts( "mq_open - open mq as write (EACCES)" );
    128   n_mq2 = mq_open("mq1", O_CREAT, O_WRONLY, NULL);
     135  n_mq2 = mq_open("mq1", O_CREAT | O_WRONLY, 0x777, NULL);
    129136  fatal_directive_status(
    130137    (int) n_mq2, (int ) (-1), "mq_open error return status" );
     
    133140
    134141  puts( "mq_open - Create an Existing mq (EEXIST)" );
    135   n_mq2 = mq_open("mq1", O_CREAT | O_EXCL, O_RDONLY, NULL);
     142  n_mq2 = mq_open("mq1", O_CREAT | O_EXCL | O_RDONLY, 0x777, NULL);
    136143  fatal_directive_status(
    137144    (int) n_mq2, (int ) (-1), "mq_open error return status" );
     
    144151
    145152  puts( "mq_open - system is out of resources (ENFILE)" );
    146   n_mq2 = mq_open( Get_Queue_Name(i), O_CREAT, O_RDONLY, NULL );
     153  n_mq2 = mq_open( Get_Queue_Name(i), O_CREAT | O_RDONLY, 0x777, NULL );
    147154  fatal_directive_status(
    148155    (int) n_mq2, (int ) (-1), "mq_open error return status" );
     
    165172
    166173void validate_mq_unlink_error_codes(
    167   mqd_t   *mqs,      /* Must be large enough for Maximum to be opened. */
    168   int      size      /* Number still open */
     174  mqd_t   *mqs,     
     175  int      size      /* Number still open in mqs */
    169176)
    170177{
     
    178185   * XXX ENAMETOOLONG - Not checked in either sem_unlink or mq_unlink is
    179186   *                    this an error?
    180   for ( i=0; i< PATH_MAX+1; i++ )
    181     name[i] = 'N';
    182   puts( "mq_open - Open with too long of a name (ENAMETOOLONG)" );
    183   n_mq2 = mq_open( Get_Too_Long_Name(), O_CREAT, O_RDONLY, NULL );
    184   fatal_directive_status(
    185     (int) n_mq2, (int ) (-1), "mq_open error return status" );
    186   fatal_directive_status( errno, ENAMETOOLONG,  "mq_open errno ENAMETOOLONG");
    187   */
     187   */
     188
     189  puts( "mq_unlink - mq_unlink with too long of a name (ENAMETOOLONG)" );
     190  status = mq_unlink( Get_Too_Long_Name() );
     191  fatal_directive_status( status, -1, "mq_unlink error return status");
     192  fatal_directive_status( errno, ENAMETOOLONG, "mq_unlink errno ENAMETOOLONG");
    188193 
    189194  puts( "mq_unlink - UNSUCCESSFUL (ENOENT)" );
     
    191196  fatal_directive_status( status, -1, "mq_unlink error return status");
    192197  fatal_directive_status( errno, ENOENT, "mq_unlink errno ENOENT");
     198
     199  /*
     200   * XXX - These errors are not in the POSIX manual but may occur.
     201   */
     202
     203  puts( "mq_unlink (NULL) - EINVAL" );
     204  status = mq_unlink( NULL );
     205  fatal_directive_status( status, -1, "mq_unlink error return status");
     206  fatal_directive_status( errno, EINVAL, "mq_unlink errno value");
     207
     208  puts( "mq_unlink (\"\") - EINVAL" );
     209  status = mq_unlink( "" );
     210  fatal_directive_status( status, -1, "mq_unlink error return status");
     211  fatal_directive_status( errno, EINVAL, "mq_unlink errno value");
    193212}
    194213
    195214void validate_mq_close_error_codes(
    196   mqd_t   *mqs,      /* Must be large enough for Maximum to be opened. */
    197   int      size      /* Number still open */
     215  mqd_t   *mqs,     
     216  int      size      /* Number still open in mqs */
    198217)
    199218{
     
    204223  fatal_directive_status( status, -1, "mq_close error return status");
    205224  fatal_directive_status( errno, EBADF, "mq_close errno EBADF");
    206 
     225}
     226 
     227/*
     228 * Returns the number of messages queued after the test on the
     229 * first queue.
     230 */
     231
     232int validate_mq_send_error_codes(
     233  mqd_t   *mqs,
     234  int      size      /* Number still open in mqs */
     235)
     236{
     237  int             status;
     238  int             i;
     239  mqd_t           n_mq1;
     240  struct mq_attr  attr;
     241
     242  attr.mq_maxmsg  = 3;
     243  attr.mq_msgsize = 8;
     244
     245  /*
     246   * XXX - EBADF  Not a valid message descriptor.
     247   *       Write to a invalid message descriptor
     248   * XXX - Write to a read only queue
     249   */
     250
     251  puts( "mq_send - Closed message queue (EBADF)" );
     252  status = mq_send( mqs[size], "", 1, 0 );
     253  fatal_directive_status( status, -1, "mq_send error return status");
     254  fatal_directive_status( errno, EBADF, "mq_send errno EBADF");
     255
     256  puts( "mq_open - Open a read only queue" );
     257  n_mq1 = mq_open("read_only", O_CREAT | O_RDONLY, 0x777, &attr);
     258  assert( n_mq1 != (-1) );
     259  /*XXX - Isn't there a more general check */
     260
     261  puts( "mq_send - Read only message queue (EBADF)" );
     262  status = mq_send( n_mq1, "", 1, 0 );
     263  fatal_directive_status( status, -1, "mq_send error return status");
     264  fatal_directive_status( errno, EBADF, "mq_send errno EBADF");
     265
     266  status = mq_close( n_mq1 );
     267  fatal_directive_status( status, 0, "mq_close message queue");
     268
     269  status = mq_unlink( "read_only" );
     270  fatal_directive_status( status, 0, "mq_unlink message queue");
     271
     272  /*
     273   * XXX - EINTR
     274   *       Signal interrupted the call.
     275
     276  puts( "mq_send - UNSUCCESSFUL (EINTR)" );
     277  status = mq_send( mqs, "", 0xffff, 0 );
     278  fatal_directive_status( status, -1, "mq_send error return status");
     279  fatal_directive_status( errno, E, "mq_send errno E");
     280   */
     281
     282  /*
     283   * XXX - EINVAL priority is out of range.
     284   */
     285
     286  puts( "mq_send - Priority out of range (EINVAL)" );
     287  status = mq_send( mqs[0], "", 1, MQ_PRIO_MAX + 1 );
     288  fatal_directive_status( status, -1, "mq_send error return status");
     289  fatal_directive_status( errno, EINVAL, "mq_send errno EINVAL");
     290
     291  /*
     292   * XXX - EMSGSIZE - Message size larger than msg_len
     293   */
     294
     295  puts( "mq_send - Message longer than msg_len (EMSGSIZE)" );
     296  status = mq_send( mqs[0], "", 0xffff, 0 );
     297  fatal_directive_status( status, -1, "mq_send error return status");
     298  fatal_directive_status( errno, EMSGSIZE, "mq_send errno EMSGSIZE");
     299
     300  /*
     301   * ENOSYS - send is supported should never happen.
     302   */
     303
     304
     305  /*
     306   * XXX - EAGAIN
     307   *       O_NONBLOCK and message queue is full.
     308   *       This is validated in the read/write test.
     309   */
     310
     311  i=0;
     312  do {
     313    status = mq_send( mqs[0], "", 1, 0 );
     314    i++;
     315  } while (status == 0);
     316  fatal_directive_status( status, -1, "mq_send error return status");
     317  fatal_directive_status( errno, EAGAIN, "mq_send errno EAGAIN");
     318
     319  return i-1;
     320}
     321
     322void validate_mq_receive_error_codes(
     323  mqd_t   *mqs,     
     324  int      size      /* Number still open in mqs */
     325)
     326{
     327  int             status;
     328
     329  /*
     330   * EAGAIN -
     331   */
     332
     333  /*
     334   * EBADF -
     335   */
     336
     337  /*
     338   * EMSGSIZE -
     339   */
     340
     341  /*
     342   * EINTR -
     343   */
     344
     345  /*
     346   * EBADMSG - a data corruption problem.
     347   *  XXX - Can not cause.
     348   */
     349
     350  /*
     351  puts( "mq_ - UNSUCCESSFUL ()" );
     352  status = mq_(  );
     353  fatal_directive_status( status, -1, "mq_ error return status");
     354  fatal_directive_status( errno, E, "mq_c errno E");
     355
     356  */
     357  /*
     358   * ENOSYS -
     359   */
     360
     361}
     362
     363void non_blocking_mq_read_write(
     364  mqd_t   *mqs,     
     365  int      size      /* Number still open in mqs */
     366)
     367{
     368  /*
     369  int         status;
     370  char       *messages[] = {
     371    "Msg 1",
     372    "Test 2",
     373    "12345678901234567890"
     374  };
     375
     376  status = mq_send( mqs[0], messages[0], strlen( messages[0] ), 0 );
     377  fatal_directive_status( status, 0, "mq_send error return status" );
     378   
     379  puts( "mq_send - UNSUCCESSFUL ()" );
     380  do {
     381    status = mq_send(  );
     382  fatal_directive_status( status, -1, "mq_send error return status");
     383  fatal_directive_status( errno, E, "mq_send errno E");
     384  }
     385  */
    207386}
    208387
     
    212391{
    213392  int             status;
    214   int             value;
    215   int             i;
    216393  mqd_t           mqs[CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES];
    217   mqd_t           mq2;
    218394  mqd_t           n_mq1;
    219395  mqd_t           n_mq2;
    220   struct timespec waittime;
    221   char            failure_msg[80];
    222   struct mq_attr  attr;
     396  char           *messages[] = {
     397    "Msg 1",
     398    "Test 2",
     399    "12345678901234567890"
     400  };
    223401
    224402  puts( "\n\n*** POSIX MESSAGE QUEUE TEST ***" );
     
    228406  validate_mq_close_error_codes( mqs, 2 );
    229407
     408  validate_mq_send_error_codes( mqs, 2 );
     409  validate_mq_receive_error_codes( mqs, 2 );
     410
     411
    230412  /*
    231413   * Validate a second open returns the same message queue.
     
    233415
    234416  puts( "mq_open - Open an existing mq ( same id )" );
    235   n_mq2 = mq_open("mq1", 0 );
    236   fatal_directive_status(
    237     (int) n_mq2, (int ) mqs[0], "mq_open error return status" );
     417  n_mq1 = mq_open("mq1", 0 );
     418  fatal_directive_status(
     419    (int) n_mq1, (int ) mqs[0], "mq_open error return status" );
    238420 
    239421  /*
     
    252434
    253435  /*
    254    * Validate it n_mq2 (the last open for mq1 name can be
    255    * correctly closed and unlinked.
    256    */
    257 
    258   puts( "Init: mq_unlink - mq1 (2) SUCCESSFUL" );
     436   * Validate it "mq1" can be closed and unlinked.
     437   */
     438
     439  puts( "mq_unlink - mq1 SUCCESSFUL" );
    259440  status = mq_unlink( "mq1" );
    260441  fatal_directive_status( status, 0, "mq_unlink locked message queue");
    261442
    262   puts( "Init: mq_close (2) - SUCCESSFUL" );
     443  puts( "mq_close mq1 - SUCCESSFUL" );
    263444  status = mq_close( n_mq2 );
    264445  fatal_directive_status( status, 0, "mq_close message queue");
    265 
    266 
    267   puts( "Init: mq_unlink - UNSUCCESSFUL (ENOENT)" );
     446  status = mq_close( n_mq1 );
     447  fatal_directive_status( status, 0, "mq_close message queue");
     448  status = mq_close( mqs[0] );
     449  fatal_directive_status( status, 0, "mq_close message queue");
     450
     451  puts( "mq_unlink - UNSUCCESSFUL (ENOENT)" );
    268452  status = mq_unlink("mq1");
    269453  fatal_directive_status( status, -1, "mq_unlink error return status");
    270454  fatal_directive_status( errno, ENOENT, "mq_close errno EINVAL");
    271 
    272 
    273   /*
    274    * Validate we can unlink (2)
    275    */
    276 
    277   puts( "Init: mq_unlink (NULL) - EINVAL" );
    278   status = mq_unlink( NULL );
    279   fatal_directive_status( status, -1, "mq_unlink error return status");
    280   fatal_directive_status( errno, EINVAL, "mq_unlink errno value");
    281 
    282   puts( "Init: mq_unlink (\"\") - EINVAL" );
    283   status = mq_unlink( "" );
    284   fatal_directive_status( status, -1, "mq_unlink error return status");
    285   fatal_directive_status( errno, EINVAL, "mq_unlink errno value");
    286455
    287456  /*
    288457   * XXX - Cant' create location OBJECTS_ERROR or OBJECTS_REMOTE.
    289458   *       mq_close and mq_unlink.
    290    */
    291 
     459   * XXX - Don't think we need this save until yellow line tested.
    292460  puts( "Init: mq_unlink - UNSUCCESSFUL (ENOENT)" );
    293461  status = mq_unlink("mq3");
     
    295463  fatal_directive_status( errno, ENOENT, "mq_unlink errno ENOENT");
    296464  assert( (status == -1) && (errno == ENOENT) );
    297 
     465  */
    298466
    299467
     
    313481  return NULL; /* just so the compiler thinks we returned something */
    314482}
     483
     484
Note: See TracChangeset for help on using the changeset viewer.