source: rtems/testsuites/psxtests/psxmsgq03/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: 2.5 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
17#include <fcntl.h>           /* For O_* constants */
18#include <sys/stat.h>        /* For mode constants */
19#include <mqueue.h>
20
21#include "test_support.h"
22
23mqd_t Queue;
24volatile bool tsr_fired;
25volatile int  tsr_status;
26volatile int  tsr_errno;
27
28rtems_timer_service_routine mq_send_timer(
29  rtems_id  timer,
30  void     *arg
31)
32{
33  int msg = 4;
34
35  tsr_fired = true;
36
37  tsr_status = mq_send( Queue, (const char *)&msg, sizeof(int), 1 );
38  tsr_errno = errno;
39}
40
41void *POSIX_Init(
42  void *argument
43)
44{
45  struct mq_attr     attr;
46  int                status;
47  rtems_id           timer;
48  rtems_status_code  rc;
49
50  puts( "\n\n*** POSIX MESSAGE QUEUE TEST 3 ***" );
51
52  attr.mq_maxmsg  = 1;
53  attr.mq_msgsize = sizeof(int);
54
55  puts( "Init - Open message queue" );
56  Queue = mq_open( "Qsend", O_CREAT | O_RDWR, 0x777, &attr );
57  if ( Queue == (-1) ) {
58    perror( "mq_open failed" );
59  }
60  rtems_test_assert( Queue != (-1) );
61
62  puts( "Init - send to message queue" );
63  status = mq_send( Queue, (const char *)&status, sizeof(int), 1 );
64  if ( status == (-1) ) {
65    perror( "mq_status failed" );
66  }
67  rtems_test_assert( status != (-1) );
68
69  /*
70   * Now create the timer we will send to a full queue from.
71   */
72  puts( "Init - Create Classic API Timer" );
73  rc = rtems_timer_create( 1, &timer );
74  directive_failed( rc, "rtems_timer_create" );
75
76  puts( "Init - Fire After Classic API Timer" );
77  tsr_fired = false;
78
79  rc = rtems_timer_fire_after(
80    timer,
81    rtems_clock_get_ticks_per_second(),
82    mq_send_timer,
83    NULL
84  );
85  directive_failed( rc, "rtems_timer_fire_after" );
86
87  sleep(2);
88
89  if ( tsr_fired == false ) {
90    puts( "ERROR -- TSR DID NOT FIRE" );
91    rtems_test_exit( 0 );
92  }
93  if ( (tsr_status != -1) || (tsr_errno != ENOMEM) ) {
94    puts( "ERROR -- TSR DID NOT RETURN CORRECT STATUS" );
95    printf(
96      "status=%d errno=%d --> %s\n",
97      tsr_status,
98      tsr_errno,
99      strerror(tsr_errno)
100    );
101    rtems_test_exit( 0 );
102  }
103
104  puts( "Init - mq_send from ISR returned correct status" );
105
106  puts( "*** END OF POSIX MESSAGE QUEUE TEST 3 ***" );
107  rtems_test_exit( 0 );
108
109  return NULL; /* just so the compiler thinks we returned something */
110}
Note: See TracBrowser for help on using the repository browser.