source: rtems/testsuites/psxtests/psxmsgq01/init.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 36.8 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define CONFIGURE_INIT
15#include "system.h"
16#include <sched.h>
17#include <fcntl.h>
18#include <time.h>
19#include <tmacros.h>
20#include <signal.h>   /* signal facilities */
21#include "test_support.h"
22
23#define fatal_posix_mqd( _ptr, _msg ) \
24  if ( (_ptr != (mqd_t) -1) ) { \
25    check_dispatch_disable_level( 0 ); \
26    printf( "\n%s FAILED -- expected (-1) got (%" PRId32 " - %d/%s)\n", \
27            (_msg), _ptr, errno, strerror(errno) ); \
28    FLUSH_OUTPUT(); \
29    rtems_test_exit( -1 ); \
30  }
31
32
33typedef struct {
34  char         msg[ 50 ];
35  int          size;
36  unsigned int priority;
37}Test_Message_t;
38Test_Message_t Predefined_Msgs[MAXMSG+1];
39Test_Message_t Predefined_Msgs[MAXMSG+1] = {
40  { "12345678",   9, MQ_PRIO_MAX-1 },  /* Max Length Message med  */
41  { "",           1, 1             },  /* NULL  Message      low  */
42  { "Last",       5, MQ_PRIO_MAX   },  /* Queue Full Message hi   */
43  { "No Message", 0, MQ_PRIO_MAX-1 },  /* 0 length Message   med  */
44  { "1",          2, 0             },  /* Cause Overflow Behavior */
45};
46int Priority_Order[MAXMSG+1] = { 2, 0, 3, 1, MAXMSG };
47
48
49typedef struct {
50  mqd_t              mq;
51  Test_Queue_Types   index;
52  char              *name;
53  int                oflag;
54  int                maxmsg;
55  int                msgsize;
56  int                count;
57} Test_queue_type;
58
59Test_queue_type Test_q[ NUMBER_OF_TEST_QUEUES + 1 ] =
60{
61  { 0, 0, "Qread",    ( O_CREAT | O_RDONLY | O_NONBLOCK ), MAXMSG, MSGSIZE, 0 },
62  { 0, 1, "Qwrite",   ( O_CREAT | O_WRONLY | O_NONBLOCK ), MAXMSG, MSGSIZE, 0 },
63  { 0, 2, "Qnoblock", ( O_CREAT | O_RDWR   | O_NONBLOCK ), MAXMSG, MSGSIZE, 0 },
64  { 0, 3, "Qblock",   ( O_CREAT | O_RDWR )               , MAXMSG, MSGSIZE, 0 },
65  { 0, 4, "Qdefault", ( O_CREAT | O_RDWR )               , 10,     16,      0 },
66  { 0, 5, "mq6",      ( O_CREAT | O_WRONLY | O_NONBLOCK ), MAXMSG, MSGSIZE, 0 },
67  { 0, 6, "Qblock",   (           O_RDWR )               , MAXMSG, MSGSIZE, 0 },
68};
69
70#define RW_NAME             Test_q[ RW_QUEUE ].name
71#define DEFAULT_NAME        Test_q[ DEFAULT_RW ].name
72#define RD_NAME             Test_q[ RD_QUEUE ].name
73#define WR_NAME             Test_q[ WR_QUEUE ].name
74#define BLOCKING_NAME       Test_q[ BLOCKING ].name
75#define CLOSED_NAME         Test_q[ CLOSED ].name
76
77#define RW_ATTR         Test_q[ RW_QUEUE ].oflag
78#define DEFAULT_ATTR    Test_q[ DEFAULT_RW ].oflag
79#define RD_ATTR         Test_q[ RD_QUEUE ].oflag
80#define WR_ATTR         Test_q[ WR_QUEUE ].oflag
81#define BLOCK_ATTR      Test_q[ BLOCKING ].oflag
82#define CLOSED_ATTR     Test_q[ CLOSED ].oflag
83
84/*
85 * Outputs a header at each test section.
86 */
87void Start_Test(
88  char *description
89)
90{
91  printf( "_______________%s\n", description );
92}
93
94
95void Validate_attributes(
96    mqd_t  mq,
97    int    oflag,
98    int    msg_count
99)
100{
101  int             status;
102  struct mq_attr  attr;
103
104  status = mq_getattr( mq, &attr );
105  fatal_posix_service_status( status, 0, "mq_getattr valid return status");
106
107  if ( mq != Test_q[ DEFAULT_RW ].mq ){
108    fatal_int_service_status((int)attr.mq_maxmsg, MAXMSG, "maxmsg attribute" );
109    fatal_int_service_status((int)attr.mq_msgsize,MSGSIZE,"msgsize attribute");
110  }
111
112  fatal_int_service_status((int)attr.mq_curmsgs, msg_count, "count attribute" );
113  fatal_int_service_status((int)attr.mq_flags, oflag, "flag attribute" );
114}
115
116#define Get_Queue_Name( i )  Test_q[i].name
117char *Build_Queue_Name( int i ) {
118
119  static char Queue_Name[PATH_MAX + 2];
120
121  sprintf(Queue_Name,"mq%d", i+1 );
122  return Queue_Name;
123}
124
125void open_test_queues(void)
126{
127  struct mq_attr   attr;
128  int              status;
129  Test_queue_type *tq;
130  int              que;
131
132  attr.mq_maxmsg  = MAXMSG;
133  attr.mq_msgsize = MSGSIZE;
134
135  puts( "Init: Open Test Queues" );
136
137  for( que = 0; que < NUMBER_OF_TEST_QUEUES+1; que++ ) {
138
139    tq = &Test_q[ que ];
140    if ( que == DEFAULT_RW)
141      Test_q[que].mq = mq_open( tq->name, tq->oflag, 0x777, NULL );
142    else
143      Test_q[que].mq = mq_open( tq->name, tq->oflag, 0x777, &attr );
144
145    rtems_test_assert( Test_q[que].mq != (-1) );
146  }
147
148  status = mq_close( Test_q[NUMBER_OF_TEST_QUEUES].mq );
149  fatal_posix_service_status( status, 0, "mq_close duplicate message queue");
150  status = mq_close( Test_q[CLOSED].mq );
151  fatal_posix_service_status( status, 0, "mq_close message queue");
152  status = mq_unlink( CLOSED_NAME );
153  fatal_posix_service_status( status, 0, "mq_unlink message queue");
154}
155
156/*
157 * Opens CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES then leaves size queues
158 * opened but closes the rest.
159 */
160
161void validate_mq_open_error_codes(void)
162{
163  int             i;
164  mqd_t           n_mq2;
165  struct mq_attr  attr;
166  int             status;
167  mqd_t           open_mq[CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES + 1];
168
169  attr.mq_maxmsg  = MAXMSG;
170  attr.mq_msgsize = MSGSIZE;
171
172  Start_Test( "mq_open errors" );
173
174  /*
175   * XXX EINVAL - inappropriate name was given for the message queue
176   */
177
178  /*
179   * EINVAL - Create with negative maxmsg.
180   */
181
182  attr.mq_maxmsg = -1;
183  puts( "Init: mq_open - Create with maxmsg (-1) (EINVAL)" );
184  n_mq2 = mq_open( "mq2", O_CREAT | O_RDONLY, 0x777, &attr);
185  fatal_posix_mqd( n_mq2, "mq_open error return status" );
186  fatal_posix_service_status( errno, EINVAL,  "mq_open errno EINVAL");
187  attr.mq_maxmsg  = MAXMSG;
188
189  /*
190   * EINVAL - Create withnegative msgsize.
191   */
192
193  attr.mq_msgsize = -1;
194  puts( "Init: mq_open - Create with msgsize (-1) (EINVAL)" );
195  n_mq2 = mq_open( "mq2", O_CREAT | O_RDONLY, 0x777, &attr);
196  fatal_posix_mqd( n_mq2, "mq_open error return status" );
197  fatal_posix_service_status( errno, EINVAL,  "mq_open errno EINVAL");
198  attr.mq_msgsize = MSGSIZE;
199
200  /*
201   * ENOENT - Open a non-created file.
202   */
203
204  puts( "Init: mq_open - Open new mq without create flag (ENOENT)" );
205  n_mq2 = mq_open( "mq3", O_EXCL | O_RDONLY, 0x777, NULL);
206  fatal_posix_mqd( n_mq2, "mq_open error return status" );
207  fatal_posix_service_status( errno, ENOENT,  "mq_open errno ENOENT");
208
209  /*
210   * XXX EINTR  - call was interrupted by a signal
211   */
212
213  /*
214   * ENAMETOOLONG - Give a name greater than PATH_MAX.
215   */
216
217  puts( "Init: mq_open - Open with too long of a name (ENAMETOOLONG)" );
218  n_mq2 = mq_open( Get_Too_Long_Name(), O_CREAT | O_RDONLY, 0x777, NULL );
219  fatal_posix_mqd( n_mq2, "mq_open error return status" );
220  fatal_posix_service_status( errno, ENAMETOOLONG, "mq_open errno ENAMETOOLONG");
221
222  /*
223   * XXX - ENAMETOOLONG - Give a name greater than NAME_MAX
224   *       Per implementation not possible.
225   */
226
227  /*
228   * EEXIST - Create an existing queue.
229   */
230
231  puts( "Init: mq_open - Create an Existing mq (EEXIST)" );
232  open_mq[0] = mq_open(
233    Build_Queue_Name(0), O_CREAT | O_RDWR | O_NONBLOCK, 0x777, NULL );
234  rtems_test_assert( open_mq[0] != (-1) );
235
236  n_mq2 = mq_open(
237    Build_Queue_Name(0), O_CREAT | O_EXCL | O_RDONLY, 0x777, NULL);
238  fatal_posix_mqd( n_mq2, "mq_open error return status" );
239  fatal_posix_service_status( errno, EEXIST,  "mq_open errno EEXIST");
240
241  status = mq_unlink( Build_Queue_Name(0) );
242  fatal_posix_service_status( status, 0, "mq_unlink message queue");
243
244  status = mq_close( open_mq[0]);
245  fatal_posix_service_status( status, 0, "mq_close message queue");
246
247  /*
248   * Open maximum number of message queues
249   */
250
251  puts( "Init: mq_open - SUCCESSFUL" );
252  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES; i++) {
253    open_mq[i] = mq_open(
254      Build_Queue_Name(i), O_CREAT | O_RDWR | O_NONBLOCK, 0x777, NULL );
255    rtems_test_assert( open_mq[i] != (-1) );
256    rtems_test_assert( open_mq[i] );
257    /*XXX - Isn't there a more general check */
258/* JRS     printf( "mq_open 0x%x %s\n", open_mq[i], Build_Queue_Name(i) ); */
259  }
260
261  /*
262   * XXX EACCES - permission to create is denied.
263   */
264
265  /*
266   * XXX EACCES - queue exists permissions specified by o_flag are denied.
267   */
268
269  /*
270   * XXX EMFILE  - Too many message queues in use by the process
271   */
272
273  /*
274   * ENFILE -  Too many message queues open in the system
275   */
276
277  puts( "Init: mq_open - system is out of resources (ENFILE)" );
278  n_mq2 = mq_open( Build_Queue_Name(i), O_CREAT | O_RDONLY, 0x777, NULL );
279  fatal_posix_mqd( n_mq2, "mq_open error return status" );
280  fatal_posix_service_status( errno, ENFILE,  "mq_open errno ENFILE");
281
282  /*
283   * Unlink and Close all queues.
284   */
285
286  puts( "Init: mq_close and mq_unlink (mq3...mqn) - SUCCESSFUL" );
287  for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES; i++) {
288
289    status = mq_close( open_mq[i]);
290    fatal_posix_service_status( status, 0, "mq_close message queue");
291
292    status = mq_unlink( Build_Queue_Name(i) );
293    if ( status == -1 )
294      perror( "mq_unlink" );
295    fatal_posix_service_status( status, 0, "mq_unlink message queue");
296    /* JRS printf( "mq_close/mq_unlink 0x%x %s\n", open_mq[i], Build_Queue_Name(i) ); */
297  }
298}
299
300void validate_mq_unlink_error_codes(void)
301{
302  int             status;
303
304  Start_Test( "mq_unlink errors" );
305
306  /*
307   * XXX - EACCES Permission Denied
308   */
309
310  /*
311   * ENAMETOOLONG - Give a name greater than PATH_MAX.
312   */
313
314  puts( "Init: mq_unlink - mq_unlink with too long of a name (ENAMETOOLONG)" );
315  status = mq_unlink( Get_Too_Long_Name() );
316  fatal_posix_service_status( status, -1, "mq_unlink error return status");
317  fatal_posix_service_status( errno, ENAMETOOLONG, "mq_unlink errno ENAMETOOLONG");
318
319  /*
320   * XXX - ENAMETOOLONG - Give a name greater than NAME_MAX
321   *       Per implementation not possible.
322   */
323
324  /*
325   *  ENOENT - Unlink an unopened queue
326   */
327
328  puts( "Init: mq_unlink - A Queue not opened  (ENOENT)" );
329  status = mq_unlink( CLOSED_NAME );
330  fatal_posix_service_status( status, -1, "mq_unlink error return status");
331  fatal_posix_service_status( errno, ENOENT, "mq_unlink errno ENOENT");
332
333  /*
334   * XXX - The following were not listed in the POSIX document as
335   *       possible errors.  Under other commands the EINVAL is
336   *       given for these conditions.
337   */
338
339  /*
340   *  EINVAL - Unlink a queue with no name
341   */
342
343  puts( "Init: mq_unlink (NULL) - EINVAL" );
344  status = mq_unlink( NULL );
345  fatal_posix_service_status( status, -1, "mq_unlink error return status");
346  fatal_posix_service_status( errno, EINVAL, "mq_unlink errno value");
347
348  /*
349   *  EINVAL - Unlink a queue with a null name
350   */
351
352  puts( "Init: mq_unlink (\"\") - EINVAL" );
353  status = mq_unlink( "" );
354  fatal_posix_service_status( status, -1, "mq_unlink error return status");
355  fatal_posix_service_status( errno, EINVAL, "mq_unlink errno value");
356}
357
358void validate_mq_close_error_codes(void)
359{
360  int             status;
361
362  Start_Test( "mq_close errors" );
363
364  /*
365   * EBADF - Close a queue that is not open.
366   */
367
368  puts( "Init: mq_close - unopened queue (EBADF)" );
369  status = mq_close( Test_q[CLOSED].mq );
370  fatal_posix_service_status( status, -1, "mq_close error return status");
371  fatal_posix_service_status( errno, EBADF, "mq_close errno EBADF");
372}
373
374
375void validate_mq_getattr_error_codes(void)
376{
377  struct mq_attr  attr;
378  int             status;
379
380  Start_Test( "mq_getattr errors" );
381
382  /*
383   * EBADF - Get the attributes from a closed queue.
384   */
385
386  puts( "Init: mq_getattr - unopened queue (EBADF)" );
387  status = mq_getattr( Test_q[CLOSED].mq, &attr );
388  fatal_posix_service_status( status, -1, "mq_close error return status");
389  fatal_posix_service_status( errno, EBADF, "mq_close errno EBADF");
390
391  /*
392   * XXX - The following are not listed in the POSIX manual but
393   *       may occur.
394   */
395
396  /*
397   * EINVAL - NULL attributes
398   */
399
400  puts( "Init: mq_getattr - NULL attributes (EINVAL)" );
401  status = mq_getattr( Test_q[RW_QUEUE].mq, NULL );
402  fatal_posix_service_status( status, -1, "mq_close error return status");
403  fatal_posix_service_status( errno, EINVAL, "mq_close errno EINVAL");
404
405}
406
407
408void Send_msg_to_que(
409  int que,
410  int msg
411)
412{
413  Test_Message_t *ptr = &Predefined_Msgs[msg];
414  int             status;
415
416  status = mq_send( Test_q[que].mq, ptr->msg, ptr->size , ptr->priority );
417  fatal_posix_service_status( status, 0, "mq_send valid return status");
418  Test_q[que].count++;
419}
420
421void Show_send_msg_to_que(
422  char *task_name,
423  int   que,
424  int   msg
425)
426{
427  Test_Message_t *ptr = &Predefined_Msgs[msg];
428  printf( "%s mq_send -  to %s msg: %s priority %d\n",
429    task_name, Test_q[que].name, ptr->msg, ptr->priority);
430  Send_msg_to_que( que, msg );
431}
432
433void verify_queues_full(
434  char *task_name
435)
436{
437  int          que;
438
439  /*
440   * Validate that the queues are full.
441   */
442
443  printf( "%s Verify Queues are full\n", task_name );
444  for( que = RW_QUEUE; que < CLOSED; que++ )
445    Validate_attributes( Test_q[que].mq, Test_q[que].oflag, Test_q[que].count );
446
447}
448void verify_queues_empty(
449  char *task_name
450)
451{
452  int             que;
453
454  printf( "%s Verify Queues are empty\n", task_name );
455  for( que = RW_QUEUE; que < CLOSED; que++ )
456    Validate_attributes( Test_q[que].mq, Test_q[que].oflag, 0 );
457}
458
459int fill_message_queues(
460  char *task_name
461)
462{
463  int             msg;
464  int             que;
465
466
467  verify_queues_empty( task_name );
468
469  /*
470   * Fill Queue with predefined messages.
471   */
472
473  printf( "%s Fill Queues with messages\n", task_name );
474  for(msg=0; msg<MAXMSG; msg++){
475    for( que = RW_QUEUE; que < CLOSED; que++ ) {
476      Send_msg_to_que( que, msg );
477    }
478  }
479
480  verify_queues_full( "Init:" );
481  return msg;
482}
483
484
485void Read_msg_from_que(
486  int que,
487  int msg
488)
489{
490  unsigned int    priority;
491  Test_Message_t *ptr;
492  int             status;
493  char            message[100];
494  char            err_msg[100];
495
496  ptr = &Predefined_Msgs[msg];
497  status = mq_receive(Test_q[ que ].mq, message, 100, &priority );
498  Test_q[que].count--;
499
500  sprintf( err_msg, "%s msg %s size failure", Test_q[ que ].name, ptr->msg );
501  fatal_int_service_status( status, ptr->size, err_msg );
502
503  rtems_test_assert( !strcmp( message, ptr->msg ) );
504  strcpy( message, "No Message" );
505
506  sprintf( err_msg,"%s msg %s size failure", Test_q[ que ].name, ptr->msg );
507  fatal_int_service_status(priority, ptr->priority, err_msg );
508}
509
510int empty_message_queues(
511  char *task_name
512)
513{
514  int que;
515  int i;
516
517  printf( "%s Empty all Queues\n", task_name );
518  for( que = RW_QUEUE; que < CLOSED; que++ ) {
519    for(i=0; Test_q[que].count != 0; i++ )
520      Read_msg_from_que( que,  Priority_Order[i] );
521
522    Validate_attributes( Test_q[ que].mq, Test_q[ que ].oflag, 0 );
523  }
524  return 0;
525}
526
527/*
528 * Returns the number of messages queued after the test on the
529 * first queue.
530 */
531
532int validate_mq_send_error_codes(void)
533{
534  int             status;
535  int             i;
536  char           *str;
537
538  Start_Test( "mq_send errors" );
539
540  /*
541   * EBADF - Write to a closed queue.
542   */
543
544  puts( "Init: mq_send - Closed message queue (EBADF)" );
545  status = mq_send( Test_q[CLOSED].mq, "", 1, 0 );
546  fatal_posix_service_status( status, -1, "mq_send error return status");
547  fatal_posix_service_status( errno, EBADF, "mq_send errno EBADF");
548
549  /*
550   * EBADF - Write to a read only  queue.
551   */
552
553  puts( "Init: mq_send - Read only message queue (EBADF)" );
554  status = mq_send( Test_q[ RD_QUEUE ].mq, "", 1, 0 );
555  fatal_posix_service_status( status, -1, "mq_send error return status");
556  fatal_posix_service_status( errno, EBADF, "mq_send errno EBADF");
557
558  /*
559   * XXX - EINTR      Signal interrupted the call.
560   *
561  puts( "Init: mq_send - UNSUCCESSFUL (EINTR)" );
562  status = mq_send( Test_q, "", 0xffff, 0 );
563  fatal_posix_service_status( status, -1, "mq_send error return status");
564  fatal_posix_service_status( errno, E, "mq_send errno E");
565   */
566
567  /*
568   * EINVAL priority is out of range.
569   */
570
571  puts( "Init: mq_send - Priority out of range (EINVAL)" );
572  status = mq_send( Test_q[ RW_QUEUE ].mq, "", 1, MQ_PRIO_MAX + 1 );
573  fatal_posix_service_status( status, -1, "mq_send error return status");
574  fatal_posix_service_status( errno, EINVAL, "mq_send errno EINVAL");
575
576  /*
577   *  EMSGSIZE - Message size larger than msg_len
578   *             Validates that msgsize is stored correctly.
579   */
580
581  puts( "Init: mq_send - Message longer than msg_len (EMSGSIZE)" );
582  status = mq_send( Test_q[ RW_QUEUE ].mq, "", MSGSIZE+1, 0 );
583  fatal_posix_service_status( status, -1, "mq_send error return status");
584  fatal_posix_service_status( errno, EMSGSIZE, "mq_send errno EMSGSIZE");
585
586  i = fill_message_queues( "Init:" );
587
588  /*
589   * ENOSYS - send not supported
590  puts( "Init: mq_send - Blocking Queue overflow (ENOSYS)" );
591  status = mq_send( n_mq1, Predefined_Msgs[i], 0, 0 );
592  fatal_posix_service_status( status, -1, "mq_send error return status");
593  fatal_posix_service_status( errno, EBADF, "mq_send errno EBADF");
594
595  status = mq_close( n_mq1 );
596  fatal_posix_service_status( status, 0, "mq_close message queue");
597
598  status = mq_unlink( "read_only" );
599  fatal_posix_service_status( status, 0, "mq_unlink message queue");
600   */
601
602  /*
603   * EAGAIN - O_NONBLOCK and message queue is full.
604   */
605
606  puts( "Init: mq_send - on a FULL non-blocking queue with (EAGAIN)" );
607  str = Predefined_Msgs[i].msg;
608  status = mq_send(Test_q[RW_QUEUE].mq, str, 0, 0 );
609  fatal_posix_service_status( status, -1, "mq_send error return status");
610  fatal_posix_service_status( errno, EAGAIN, "mq_send errno EAGAIN");
611
612  return i-1;
613}
614
615void validate_mq_receive_error_codes(void)
616{
617  int            status;
618  char           message[100];
619  unsigned int   priority;
620
621  Start_Test( "mq_receive errors"  );
622
623  /*
624   * EBADF - Not A Valid Message Queue
625   */
626
627  puts( "Init: mq_receive - Unopened message queue (EBADF)" );
628  status = mq_receive( Test_q[CLOSED].mq, message, 100, &priority );
629  fatal_posix_service_status( status, -1, "mq_ error return status");
630  fatal_posix_service_status( errno, EBADF, "mq_receive errno EBADF");
631
632  /*
633   * EBADF - Queue not opened to read
634   */
635
636  puts( "Init: mq_receive - Write only queue (EBADF)" );
637  status = mq_receive( Test_q[WR_QUEUE].mq, message, 100, &priority  );
638  fatal_posix_service_status( status, -1, "mq_ error return status");
639  fatal_posix_service_status( errno, EBADF, "mq_receive errno EBADF");
640
641  /*
642   * EMSGSIZE - Size is less than the message size attribute
643   */
644
645  puts( "Init: mq_receive - Size is less than the message (EMSGSIZE)" );
646  status = mq_receive(
647    Test_q[RW_QUEUE].mq, message, Predefined_Msgs[0].size-1, &priority );
648  fatal_posix_service_status( status, -1, "mq_ error return status");
649  fatal_posix_service_status( errno, EMSGSIZE, "mq_receive errno EMSGSIZE");
650
651
652  /*
653   * EAGAIN - O_NONBLOCK and Queue is empty
654   */
655  verify_queues_full( "Init:" );
656  empty_message_queues( "Init:" );
657
658  puts( "Init: mq_receive - Queue is empty (EAGAIN)" );
659  status = mq_receive( Test_q[RW_QUEUE].mq, message, 100, &priority );
660  fatal_posix_service_status( status, -1, "mq_ error return status");
661  fatal_posix_service_status( errno, EAGAIN, "mq_receive errno EAGAIN");
662
663  /*
664   * XXX - EINTR - Interrupted by a signal
665   */
666
667  /*
668   * XXX - EBADMSG - a data corruption problem.
669   */
670
671  /*
672   * XXX - ENOSYS - mq_receive not supported
673   */
674}
675
676void verify_open_functionality(void)
677{
678#if 0
679  mqd_t           n_mq;
680#endif
681
682  Start_Test( "mq_open functionality" );
683
684  /*
685   * Validate a second open returns the same message queue.
686   */
687
688#if 0
689  puts( "Init: mq_open - Open an existing mq ( same id )" );
690  n_mq = mq_open( RD_NAME, 0 );
691  fatal_posix_service_status(
692  rtems_test_assert( n_mq == Test_q[RD_QUEUE].mq );
693#endif
694}
695
696void verify_unlink_functionality(void)
697{
698  mqd_t           n_mq;
699  int             status;
700
701  Start_Test( "mq_unlink functionality" );
702
703  /*
704   * Unlink the message queue, then verify an open of the same name produces a
705   * different message queue.
706   */
707
708  puts( "Init: Unlink and Open without closing SUCCESSFUL" );
709  status = mq_unlink( DEFAULT_NAME );
710  fatal_posix_service_status( status, 0, "mq_unlink locked message queue");
711
712  n_mq = mq_open( DEFAULT_NAME, DEFAULT_ATTR, 0x777, NULL );
713  rtems_test_assert( n_mq != (-1) );
714  rtems_test_assert( n_mq != Test_q[ DEFAULT_RW ].mq );
715
716
717  status = mq_unlink( DEFAULT_NAME );
718  fatal_posix_service_status( status, 0, "mq_unlink locked message queue");
719  status = mq_close( Test_q[ DEFAULT_RW ].mq );
720  fatal_posix_service_status( status, 0, "mq_close message queue");
721
722  Test_q[ DEFAULT_RW ].mq = n_mq;
723}
724
725void verify_close_functionality(void)
726{
727  int i;
728  int status;
729  Start_Test( "Unlink and Close All Files"  );
730  for (i=0; i<DEFAULT_RW; i++) {
731
732    status = mq_unlink( Get_Queue_Name(i) );
733    fatal_posix_service_status( status, 0, "mq_unlink message queue");
734
735    status = mq_close( Test_q[i].mq );
736    fatal_posix_service_status( status, 0, "mq_close message queue");
737  }
738}
739
740
741void verify_timed_send_queue(
742  int  que,
743  int  is_blocking
744)
745{
746  struct timespec timeout;
747  struct timeval  tv1, tv2, tv3;
748  struct timezone tz1, tz2;
749  int              len;
750  int              status;
751  char            *msg;
752
753  printf( "Init: mq_timedsend - on queue %s ", Test_q[que].name);
754  len = Predefined_Msgs[MAXMSG].size;
755  msg = Predefined_Msgs[MAXMSG].msg;
756
757  gettimeofday( &tv1, &tz1 );
758  timeout.tv_sec  = tv1.tv_sec + 1;
759  timeout.tv_nsec = tv1.tv_usec * 1000;
760
761  status = mq_timedsend( Test_q[que].mq, msg, len , 0, &timeout );
762
763  gettimeofday( &tv2, &tz2 );
764  tv3.tv_sec  = tv2.tv_sec - tv1.tv_sec;
765  tv3.tv_usec = tv2.tv_usec - tv1.tv_usec;
766
767  if ( is_blocking ) { /* Don't verify the non-blocking queue */
768    fatal_int_service_status( status, -1, "mq_timedsend status" );
769    fatal_posix_service_status( errno, ETIMEDOUT,  "errno ETIMEDOUT" );
770  }
771
772  printf( "Init: %ld sec %ld us\n", (long)tv3.tv_sec, (long)tv3.tv_usec );
773
774  if ( que == DEFAULT_RW )
775    Test_q[que].count++;
776}
777
778void verify_timed_send(void)
779{
780  int              que;
781
782  Start_Test( "mq_timedsend"  );
783
784  for( que = RW_QUEUE; que < CLOSED; que++ ) {
785    if ( que == BLOCKING )
786      verify_timed_send_queue( que, 1 );
787    else
788      verify_timed_send_queue( que, 0 );
789  }
790}
791
792void verify_timed_receive_queue(
793  char *task_name,
794  int   que,
795  int   is_blocking
796)
797{
798  char message[ 100 ];
799  unsigned int priority;
800  struct timespec tm;
801  struct timeval  tv1, tv2, tv3;
802  struct timezone tz1, tz2;
803  int              status;
804
805  printf(
806    "Init: %s mq_timedreceive - on queue %s ",
807    task_name,
808    Test_q[que].name
809  );
810
811  gettimeofday( &tv1, &tz1 );
812  tm.tv_sec  = tv1.tv_sec + 1;
813  tm.tv_nsec = tv1.tv_usec * 1000;
814
815  status = mq_timedreceive( Test_q[ que ].mq, message, 100, &priority, &tm );
816
817  gettimeofday( &tv2, &tz2 );
818  tv3.tv_sec  = tv2.tv_sec - tv1.tv_sec;
819  tv3.tv_usec = tv2.tv_usec - tv1.tv_usec;
820
821  fatal_int_service_status( status, -1, "mq_timedreceive status");
822  if ( is_blocking )
823    fatal_posix_service_status( errno, ETIMEDOUT,  "errno ETIMEDOUT");
824  printf( "Init: %ld sec %ld us\n", (long)tv3.tv_sec, (long)tv3.tv_usec );
825
826}
827
828void verify_timed_receive(void)
829{
830  int  que;
831
832  Start_Test( "mq_timedreceive"  );
833
834  for( que = RW_QUEUE; que < CLOSED; que++ ) {
835    if (( que == BLOCKING ) || ( que == DEFAULT_RW ))
836      verify_timed_receive_queue( "Init:", que, 1 );
837    else
838      verify_timed_receive_queue( "Init:", que, 0 );
839  }
840}
841
842#if (0)
843void verify_set_attr(void)
844{
845  struct mq_attr save_attr[ NUMBER_OF_TEST_QUEUES ];
846  struct mq_attr attr;
847  int            i;
848  int            status;
849
850  attr.mq_maxmsg  = 0;
851  attr.mq_msgsize = 0;
852
853  Start_Test( "mq_setattr"  );
854
855  puts( "Init: set_attr all queues to blocking" );
856  for(i=0; i<CLOSED; i++) {
857    attr.mq_flags =  Test_q[i].oflag & (~O_NONBLOCK );
858    status = mq_setattr( Test_q[i].mq, &attr, &save_attr[i] );
859    fatal_int_service_status( status, 0, "mq_setattr valid return status");
860
861    Validate_attributes( Test_q[i].mq, attr.mq_flags, 0 );
862  }
863
864  for( i = RW_QUEUE; i < CLOSED; i++ ) {
865    verify_timed_receive_queue( "Init:", i, 1 );
866  }
867
868  for(i=0; i<CLOSED; i++) {
869    attr.mq_flags =  Test_q[i].oflag & (~O_NONBLOCK );
870    status = mq_setattr( Test_q[i].mq, &save_attr[i], NULL );
871    fatal_int_service_status( status, 0, "mq_setattr valid return status");
872
873    Validate_attributes( Test_q[i].mq, Test_q[i].oflag, 0 );
874  }
875}
876#endif
877
878void wait_for_signal(
879  sigset_t     *waitset,
880  int           sec,
881  int           expect_signal
882)
883{
884  siginfo_t         siginfo;
885  int               status;
886  struct timespec   timeout;
887  int               signo;
888
889  siginfo.si_code = -1;
890  siginfo.si_signo = -1;
891  siginfo.si_value.sival_int = -1;
892
893  timeout.tv_sec = sec;
894  timeout.tv_nsec = 0;
895
896  status = sigemptyset( waitset );
897  rtems_test_assert( !status );
898
899  status = sigaddset( waitset, SIGUSR1 );
900  rtems_test_assert( !status );
901
902  printf( "waiting on any signal for %d seconds.\n", sec );
903  signo = sigtimedwait( waitset, &siginfo, &timeout );
904  if (expect_signal) {
905    fatal_int_service_status( signo, SIGUSR1, "got SISUSR1" );
906  } else {
907    fatal_int_service_status( signo, -1, "error return status");
908    fatal_posix_service_status( errno, EAGAIN, "errno EAGAIN");
909  }
910}
911
912void verify_notify(void)
913{
914  struct sigevent event;
915  int             status;
916  timer_t         timer_id;
917  sigset_t        set;
918
919  Start_Test( "mq_notify"  );
920
921  /* timer create */
922  event.sigev_notify = SIGEV_SIGNAL;
923  event.sigev_signo  = SIGUSR1;
924  if (timer_create (CLOCK_REALTIME, &event, &timer_id) == -1)
925    fatal_posix_service_status( errno, 0,  "errno ETIMEDOUT");
926
927  /* block the timer signal */
928  sigemptyset( &set );
929  sigaddset( &set, SIGUSR1 );
930  pthread_sigmask( SIG_BLOCK, &set, NULL );
931
932  /*
933   * EBADF - Not A Valid Message Queue
934   */
935
936  puts( "Init: mq_notify - Unopened message queue (EBADF)" );
937  status = mq_notify( Test_q[CLOSED].mq, NULL );
938  fatal_posix_service_status( status, -1, "mq_ error return status");
939  fatal_posix_service_status( errno, EBADF, "mq_receive errno EBADF");
940
941  /*
942   * Create ...
943   */
944
945  /*
946   * XXX setup notification
947   */
948  printf( "_____mq_notify - notify when %s gets a message\n",RW_NAME);
949  status = mq_notify( Test_q[RW_QUEUE].mq, &event );
950  fatal_posix_service_status( status, 0, "mq_notify valid status");
951  wait_for_signal( &set, 3, 0 );
952
953  /*
954   * Send and verify signal occurs and registration is removed.
955   */
956
957  puts( "Init: Verify Signal when send" );
958  Show_send_msg_to_que( "Init:", RW_QUEUE, 0 );
959  wait_for_signal( &set, 3, 1 );
960  Read_msg_from_que( RW_QUEUE, 0 );
961
962  puts( "Init: Verify No Signal when send" );
963  Show_send_msg_to_que( "Init:", RW_QUEUE, 0 );
964  wait_for_signal( &set, 3, 0 );
965  Read_msg_from_que( RW_QUEUE, 0 );
966
967  /*
968   * EBUSY - Already Registered
969   */
970
971  printf( "____mq_notify - notify when %s gets a message\n",RD_NAME);
972  status = mq_notify( Test_q[RW_QUEUE].mq, &event );
973  fatal_posix_service_status( status, 0, "mq_notify valid status");
974  wait_for_signal( &set, 3, 0 );
975
976  puts( "Init: mq_notify -  (EBUSY)" );
977  status = mq_notify( Test_q[RW_QUEUE].mq, &event );
978  fatal_posix_service_status( status, -1, "mq_notify error return status");
979  fatal_posix_service_status( errno, EBUSY, "mq_notify errno EBUSY");
980
981  /*
982   * Verify NULL removes registration.
983   */
984
985  puts( "Init: mq_notify - Remove notification with null" );
986  status = mq_notify( Test_q[RW_QUEUE].mq, NULL );
987  fatal_posix_service_status( status, 0, "mq_notify valid status");
988
989  puts( "Init: Verify No Signal when send" );
990  Show_send_msg_to_que( "Init:", RW_QUEUE, 0 );
991  wait_for_signal( &set, 3, 0 );
992  Read_msg_from_que( RW_QUEUE, 0 );
993
994}
995
996void verify_with_threads(void)
997{
998  int               status;
999  pthread_t         id;
1000  Test_Message_t   *ptr;
1001#if 0
1002  unsigned int      priority;
1003  char              message[100];
1004#endif
1005
1006
1007#if 0
1008  /*
1009   * Create a task then block until the task sends the message.
1010   * Task tests set attributes so one queue will have a thread
1011   * blocked while attributes are changed.
1012   */
1013
1014  Start_Test( "multi-thread Task 4 Receive Test"  );
1015  status = pthread_create( &id, NULL, Task_4, NULL );
1016  rtems_test_assert( !status );
1017  puts( "Init: mq_receive - Empty queue changes to non-blocking (EAGAIN)" );
1018  status = mq_receive( Test_q[BLOCKING].mq, message, 100, &priority );
1019  fatal_int_service_status( status, -1, "mq_receive error return status");
1020  fatal_posix_service_status( errno, EAGAIN, "mq_receive errno EAGAIN");
1021  print_current_time( "Init: ", "" );
1022#endif
1023  /*
1024   * Create a task then block until the task sends the message.
1025   * Task tests set attributes so one queue will have a thread
1026   * blocked while attributes are changed.
1027   */
1028
1029  Start_Test( "multi-thread Task 1 Test"  );
1030  status = pthread_create( &id, NULL, Task_1, NULL );
1031  rtems_test_assert( !status );
1032  Read_msg_from_que(  BLOCKING, 0 ); /* Block until init writes */
1033  print_current_time( "Init: ", "" );
1034
1035#if 0
1036  /*
1037   * Fill the queue then create a task then block until the task receives a message.
1038   * Task tests set attributes so one queue will have a thread
1039   * blocked while attributes are changed.
1040   */
1041
1042  Start_Test( "multi-thread Task 4 Send Test"  );
1043  fill_message_queues( "Init:" );
1044  status = pthread_create( &id, NULL, Task_4, NULL );
1045  rtems_test_assert( !status );
1046  puts( "Init: mq_send - Full queue changes to non-blocking (EAGAIN)" );
1047  status = mq_send(Test_q[BLOCKING].mq, message, 0, 0 );
1048  fatal_posix_service_status( status, -1, "mq_send error return status");
1049  fatal_posix_service_status( errno, EAGAIN, "mq_send errno EAGAIN");
1050  verify_queues_full( "Init:" );
1051  empty_message_queues( "Init:" );
1052#endif
1053  /*
1054   * Create a task then block until the task reads a message.
1055   */
1056
1057  Start_Test( "multi-thread Task 2 Test"  );
1058  fill_message_queues( "Init:" );
1059  status = pthread_create( &id, NULL, Task_2, NULL );
1060  rtems_test_assert( !status );
1061  Show_send_msg_to_que( "Init:", BLOCKING, Priority_Order[0] );
1062  print_current_time( "Init: ", "" );
1063  verify_queues_full( "Init:" );
1064  empty_message_queues( "Init:" );
1065
1066  /*
1067   * Create a task then block until it deletes and closes all queues.
1068   *     EBADF - Queue unlinked and closed while blocked
1069   */
1070
1071  Start_Test( "multi-thread Task 3 Test"  );
1072  fill_message_queues( "Init:" );
1073  status = pthread_create( &id, NULL, Task_3, NULL );
1074  rtems_test_assert( !status );
1075  puts( "Init: mq_send - Block while thread deletes queue (EBADF)" );
1076  ptr = &Predefined_Msgs[0];
1077  status = mq_send( Test_q[BLOCKING].mq, ptr->msg, ptr->size , ptr->priority );
1078  fatal_posix_service_status( status, -1, "mq_send error return status");
1079  fatal_posix_service_status( errno, EBADF, "mq_send errno EBADF");
1080
1081}
1082
1083void validate_mq_setattr(void)
1084{
1085  struct mq_attr  attr;
1086  struct mq_attr  save_attr[ NUMBER_OF_TEST_QUEUES ];
1087  int             status;
1088  int            i;
1089
1090  /*
1091   * EBADF - Get the attributes from a closed queue.
1092   */
1093
1094  puts( "Task1:mq_setattr - unopened queue (EBADF)" );
1095  status = mq_setattr( Test_q[CLOSED].mq, &attr, NULL );
1096  fatal_posix_service_status( status, -1, "mq_setattr error return status");
1097  fatal_posix_service_status( errno, EBADF, "mq_setattr errno EBADF");
1098
1099  /*
1100   * XXX - The following are not listed in the POSIX manual but
1101   *       may occur.
1102   */
1103
1104  /*
1105   * EINVAL - NULL attributes
1106   */
1107
1108  puts( "Task1:mq_setattr - NULL attributes (EINVAL)" );
1109  status = mq_setattr( Test_q[RW_QUEUE].mq, NULL, NULL );
1110  fatal_posix_service_status( status, -1, "mq_setattr error return status");
1111  fatal_posix_service_status( errno, EINVAL, "mq_setattr errno EINVAL");
1112
1113  /*
1114   * Verify change queues to blocking, by verifying all queues block
1115   * for a timed receive.
1116   */
1117
1118  puts( "Init: set_attr all queues to blocking" );
1119  for(i=0; i<CLOSED; i++) {
1120    attr.mq_flags =  Test_q[i].oflag & (~O_NONBLOCK );
1121    status = mq_setattr( Test_q[i].mq, &attr, &save_attr[i] );
1122    fatal_int_service_status( status, 0, "mq_setattr valid return status");
1123    Validate_attributes( Test_q[i].mq, attr.mq_flags, 0 );
1124  }
1125  for( i = RW_QUEUE; i < CLOSED; i++ ) {
1126    verify_timed_receive_queue( "Init:", i, 1 );
1127  }
1128
1129  /*
1130   * Restore restore all queues to their old attribute.
1131   */
1132
1133  for(i=0; i<CLOSED; i++) {
1134    status = mq_setattr( Test_q[i].mq, &save_attr[i], NULL );
1135    fatal_int_service_status( status, 0, "mq_setattr valid return status");
1136    Validate_attributes( Test_q[i].mq, Test_q[i].oflag, 0 );
1137  }
1138}
1139
1140void verify_timedout_mq_timedreceive(
1141  char *task_name,
1142  int   que,
1143  int   is_blocking
1144)
1145{
1146  char             message[ 100 ];
1147  struct timespec  tm;
1148  struct timeval   tv1, tv2, tv3;
1149  struct timezone  tz1, tz2;
1150  int              status;
1151
1152  printf(
1153    "Init: %s verify_timedout_mq_timedreceive - on queue %s ",
1154    task_name,
1155    Test_q[que].name
1156  );
1157
1158  gettimeofday( &tv1, &tz1 );
1159  tm.tv_sec  = tv1.tv_sec - 1;
1160  tm.tv_nsec = tv1.tv_usec * 1000;
1161
1162  status = mq_timedreceive( Test_q[ que ].mq, message, 100, NULL, &tm );
1163
1164  gettimeofday( &tv2, &tz2 );
1165  tv3.tv_sec  = tv2.tv_sec - tv1.tv_sec;
1166  tv3.tv_usec = tv2.tv_usec - tv1.tv_usec;
1167
1168  fatal_int_service_status( status, -1, "mq_timedreceive status");
1169
1170/* FIXME: This is wrong. */
1171  printf( "Init: %ld sec %ld us\n", (long)tv3.tv_sec, (long)tv3.tv_usec );
1172}
1173
1174void verify_mq_receive(void)
1175{
1176  int  que;
1177
1178  Start_Test( "mq_timedout_receive"  );
1179
1180  for( que = RW_QUEUE; que < CLOSED; que++ ) {
1181    if (( que == BLOCKING ) || ( que == DEFAULT_RW ))
1182      break;
1183    else
1184      verify_timedout_mq_timedreceive( "Init:", que, 0 );
1185  }
1186}
1187
1188void verify_timedout_mq_timedsend(
1189  int  que,
1190  int  is_blocking
1191)
1192{
1193  struct timespec timeout;
1194  struct timeval  tv1, tv2, tv3;
1195  struct timezone tz1, tz2;
1196  int              len;
1197  char            *msg;
1198
1199  printf( "Init: verify_timedout_mq_timedsend - on queue %s ", Test_q[que].name);
1200  len = Predefined_Msgs[MAXMSG].size;
1201  msg = Predefined_Msgs[MAXMSG].msg;
1202
1203  gettimeofday( &tv1, &tz1 );
1204  timeout.tv_sec  = tv1.tv_sec - 1;
1205  timeout.tv_nsec = tv1.tv_usec * 1000;
1206
1207  (void) mq_timedsend( Test_q[que].mq, msg, len , 0, &timeout );
1208
1209  gettimeofday( &tv2, &tz2 );
1210  tv3.tv_sec  = tv2.tv_sec - tv1.tv_sec;
1211  tv3.tv_usec = tv2.tv_usec - tv1.tv_usec;
1212
1213  printf( "Init: %ld sec %ld us\n", (long)tv3.tv_sec, (long)tv3.tv_usec );
1214
1215  if ( que == DEFAULT_RW )
1216    Test_q[que].count++;
1217}
1218
1219void verify_mq_send(void)
1220{
1221  int              que;
1222
1223  Start_Test( "verify_timedout_mq_timedsend"  );
1224
1225  for( que = RW_QUEUE; que < CLOSED; que++ ) {
1226    if ( que == BLOCKING )
1227      verify_timedout_mq_timedsend( que, 1 );
1228    else
1229      verify_timedout_mq_timedsend( que, 0 );
1230  }
1231}
1232
1233void *POSIX_Init(
1234  void *argument
1235)
1236{
1237  puts( "\n\n*** POSIX MESSAGE QUEUE TEST ***" );
1238
1239  validate_mq_open_error_codes( );
1240  open_test_queues();
1241  validate_mq_unlink_error_codes();
1242  validate_mq_close_error_codes();
1243  verify_unlink_functionality();
1244  validate_mq_setattr( );
1245  validate_mq_send_error_codes();
1246  validate_mq_getattr_error_codes();
1247  verify_timed_send();
1248  validate_mq_receive_error_codes();
1249  verify_timed_receive();
1250  verify_open_functionality();
1251  verify_notify();
1252  verify_with_threads();
1253  verify_mq_receive();
1254  verify_mq_send();
1255
1256  puts( "*** END OF POSIX MESSAGE QUEUE TEST ***" );
1257  rtems_test_exit( 0 );
1258
1259  return NULL; /* just so the compiler thinks we returned something */
1260}
1261
1262
1263void *Task_1 (
1264  void *argument
1265)
1266{
1267  /* Block Waiting for a message */
1268
1269  print_current_time( "Task_1: ", "" );
1270
1271  Show_send_msg_to_que( "Task_1:", BLOCKING, 0 );
1272
1273  puts( "Task_1: pthread_exit" );
1274  pthread_exit( NULL );
1275
1276  /* switch to Init */
1277
1278  rtems_test_assert( 0 );
1279  return NULL; /* just so the compiler thinks we returned something */
1280}
1281
1282void *Task_2(
1283  void *argument
1284)
1285{
1286  print_current_time( "Task_2: ", "" );
1287
1288
1289  /* Block waiting to send a message */
1290
1291  verify_queues_full( "Task_2:" );
1292  Read_msg_from_que( BLOCKING, Priority_Order[0] ); /* Cause context switch */
1293
1294  puts( "Task_2: pthread_exit" );
1295  pthread_exit( NULL );
1296
1297     /* switch to Init */
1298
1299  return NULL; /* just so the compiler thinks we returned something */
1300}
1301
1302void *Task_3 (
1303  void *argument
1304)
1305{
1306
1307  print_current_time( "Task_3: ", "" );
1308
1309  /*
1310   * close and unlink all queues.
1311   */
1312
1313  verify_close_functionality();
1314  puts( "Task_3: pthread_exit" );
1315  pthread_exit( NULL );
1316
1317     /* switch to Init */
1318
1319  return NULL; /* just so the compiler thinks we returned something */
1320
1321}
1322
1323void *Task_4 (
1324  void *argument
1325)
1326{
1327  struct mq_attr  attr;
1328  int             status;
1329  int             count;
1330
1331  print_current_time( "Task_4: ", "" );
1332
1333  /*
1334   * Set the count to the number of messages in the queue.
1335   */
1336
1337  status = mq_getattr( Test_q[BLOCKING].mq, &attr );
1338  fatal_posix_service_status( status, 0, "mq_getattr valid return status");
1339  count = attr.mq_curmsgs;
1340
1341  puts("Task_4: Set queue to non-blocking");
1342  attr.mq_flags =  Test_q[BLOCKING].oflag | O_NONBLOCK;
1343  status = mq_setattr( Test_q[BLOCKING].mq, &attr, NULL );
1344  fatal_int_service_status( status, 0, "mq_setattr valid return status");
1345  Validate_attributes( Test_q[BLOCKING].mq, attr.mq_flags, count );
1346
1347  puts("Task_4: Return queue to blocking");
1348  attr.mq_flags =  Test_q[BLOCKING].oflag;
1349  status = mq_setattr( Test_q[BLOCKING].mq, &attr, NULL );
1350  fatal_int_service_status( status, 0, "mq_setattr valid return status");
1351  Validate_attributes( Test_q[BLOCKING].mq, attr.mq_flags, count );
1352
1353  puts( "Task_4: pthread_exit" );
1354  pthread_exit( NULL );
1355
1356     /* switch to Init */
1357
1358  return NULL; /* just so the compiler thinks we returned something */
1359
1360}
1361
1362void *Task_5 (
1363  void *argument
1364)
1365{
1366
1367  print_current_time( "Task_5: ", "" );
1368
1369  puts( "Task_5: pthread_exit" );
1370  pthread_exit( NULL );
1371
1372     /* switch to Init */
1373
1374  return NULL; /* just so the compiler thinks we returned something */
1375
1376}
1377
1378void *Task_ (
1379  void *argument
1380)
1381{
1382
1383  print_current_time( "Task_: ", "" );
1384
1385  puts( "Task_: pthread_exit" );
1386  pthread_exit( NULL );
1387
1388     /* switch to Init */
1389
1390  return NULL; /* just so the compiler thinks we returned something */
1391
1392}
Note: See TracBrowser for help on using the repository browser.