source: rtems/testsuites/psxtests/psxmsgq03/init.c @ 2317457

4.104.115
Last change on this file since 2317457 was 2317457, checked in by Joel Sherrill <joel.sherrill@…>, on 12/08/09 at 17:52:53

2009-12-08 Joel Sherrill <joel.sherrill@…>

  • include/pmacros.h, psx01/task.c, psx02/init.c, psx02/task.c, psx03/init.c, psx03/task.c, psx04/init.c, psx04/task1.c, psx04/task2.c, psx04/task3.c, psx05/init.c, psx05/task.c, psx05/task2.c, psx05/task3.c, psx06/init.c, psx06/task.c, psx06/task2.c, psx07/init.c, psx08/init.c, psx08/task2.c, psx08/task3.c, psx09/init.c, psx10/init.c, psx10/task.c, psx10/task2.c, psx10/task3.c, psx11/init.c, psx11/task.c, psx12/init.c, psxalarm01/init.c, psxbarrier01/test.c, psxcancel01/init.c, psxchroot01/test.c, psxclock/init.c, psxfile01/test.c, psxfile01/test_cat.c, psxfile01/test_extend.c, psxfile01/test_write.c, psxitimer/init.c, psxkey01/task.c, psxkey02/init.c, psxkey03/init.c, psxmount/test.c, psxmsgq01/init.c, psxmsgq03/init.c, psxmsgq04/init.c, psxreaddir/test.c, psxrwlock01/test.c, psxsem01/init.c, psxsignal01/init.c, psxsignal01/task1.c, psxsignal02/init.c, psxsignal03/init.c, psxsignal05/init.c, psxspin01/test.c, psxspin02/test.c, psxstack01/init.c, psxstat/test.c, psxtime/test.c, psxualarm/init.c: Use rtems_test_assert() consistently instead of system assert(). rtems_test_assert() is designed to integrate into the RTEMS test suite infrastructure.
  • Property mode set to 100644
File size: 2.4 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 *  $Id$
10 */
11
12#define CONFIGURE_INIT
13#include "system.h"
14
15#include <fcntl.h>           /* For O_* constants */
16#include <sys/stat.h>        /* For mode constants */
17#include <mqueue.h>
18
19#include "test_support.h"
20
21mqd_t Queue;
22volatile bool tsr_fired;
23volatile int  tsr_status;
24volatile int  tsr_errno;
25
26rtems_timer_service_routine mq_send_timer(
27  rtems_id  timer,
28  void     *arg
29)
30{
31  int msg = 4;
32
33  tsr_fired = true;
34
35  tsr_status = mq_send( Queue, (const char *)&msg, sizeof(int), 1 );
36  tsr_errno = errno;
37}
38
39void *POSIX_Init(
40  void *argument
41)
42{
43  struct mq_attr     attr;
44  int                status;
45  rtems_id           timer;
46  rtems_status_code  rc;
47
48  puts( "\n\n*** POSIX MESSAGE QUEUE TEST 3 ***" );
49
50  attr.mq_maxmsg  = 1;
51  attr.mq_msgsize = sizeof(int);
52
53  puts( "Init - Open message queue" );
54  Queue = mq_open( "Qsend", O_CREAT | O_RDWR, 0x777, &attr );
55  if ( Queue == (-1) ) {
56    perror( "mq_open failed" );
57  }
58  rtems_test_assert(  Queue != (-1) );
59
60  puts( "Init - send to message queue" );
61  status = mq_send( Queue, (const char *)&status, sizeof(int), 1 );
62  if ( status == (-1) ) {
63    perror( "mq_status failed" );
64  }
65  rtems_test_assert(  status != (-1) );
66
67  /*
68   * Now create the timer we will send to a full queue from.
69   */
70  puts( "Init - Create Classic API Timer" );
71  rc = rtems_timer_create( 1, &timer );
72  directive_failed( rc, "rtems_timer_create" );
73
74  puts( "Init - Fire After Classic API Timer" );
75  tsr_fired = false;
76
77  rc = rtems_timer_fire_after(
78    timer,
79    rtems_clock_get_ticks_per_second(),
80    mq_send_timer,
81    NULL
82  );
83  directive_failed( rc, "rtems_timer_fire_after" );
84
85  sleep(2);
86
87  if ( tsr_fired == false ) {
88    puts( "ERROR -- TSR DID NOT FIRE" );
89    rtems_test_exit( 0 );
90  }
91  if ( (tsr_status != -1) || (tsr_errno != ENOMEM) ) {
92    puts( "ERROR -- TSR DID NOT RETURN CORRECT STATUS" );
93    printf(
94      "status=%d errno=%d --> %s\n",
95      tsr_status,
96      tsr_errno,
97      strerror(tsr_errno)
98    );
99    rtems_test_exit( 0 );
100  }
101
102  puts( "Init - mq_send from ISR returned correct status" );
103
104  puts( "*** END OF POSIX MESSAGE QUEUE TEST 3 ***" );
105  rtems_test_exit( 0 );
106
107  return NULL; /* just so the compiler thinks we returned something */
108}
Note: See TracBrowser for help on using the repository browser.