source: rtems/testsuites/mptests/mp09/task1.c @ 7d17145

4.104.114.9
Last change on this file since 7d17145 was d8e681e, checked in by Ralf Corsepius <ralf.corsepius@…>, on Mar 30, 2004 at 11:18:29 AM

2004-03-30 Ralf Corsepius <ralf_corsepius@…>

  • mp02/task1.c, mp03/system.h, mp03/task1.c, mp04/task1.c, mp05/system.h, mp06/task1.c, mp07/task1.c, mp08/task1.c, mp09/recvmsg.c, mp09/sendmsg.c, mp09/task1.c, mp10/task1.c, mp11/init.c, mp12/init.c, mp13/task1.c, mp14/evtask1.c, mp14/evtmtask.c, mp14/init.c, mp14/msgtask1.c, mp14/pttask1.c, mp14/smtask1.c, mp14/system.h: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*  Test_task
2 *
3 *  This task tests global message queue operations.  It also generates
4 *  an error condition.
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1989-1999.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22
23char buffer1[16] = "123456789012345";
24char buffer2[16] = "abcdefghijklmno";
25char buffer3[16] = "ABCDEFGHIJKLMNO";
26char buffer4[16] = "PQRSTUVWXYZ(){}";
27
28rtems_task Test_task(
29  rtems_task_argument argument
30)
31{
32  rtems_status_code status;
33  uint32_t    count;
34  uint32_t    size;
35  char              receive_buffer[16];
36
37  status = rtems_task_wake_after( TICKS_PER_SECOND );
38  directive_failed( status, "rtems_task_wake_after" );
39
40  puts( "Getting QID of message queue" );
41
42  do {
43    status = rtems_message_queue_ident(
44      Queue_name[ 1 ],
45      RTEMS_SEARCH_ALL_NODES,
46      &Queue_id[ 1 ]
47    );
48  } while ( !rtems_is_status_successful( status ) );
49
50  if ( Multiprocessing_configuration.node == 2 ) {
51    status = rtems_message_queue_delete( Queue_id[ 1 ] );
52    fatal_directive_status(
53      status,
54      RTEMS_ILLEGAL_ON_REMOTE_OBJECT,
55      "rtems_message_queue_delete"
56    );
57    puts(
58  "rtems_message_queue_delete correctly returned RTEMS_ILLEGAL_ON_REMOTE_OBJECT"
59    );
60
61    Send_messages();
62    Receive_messages();
63
64    puts( "Flushing remote empty queue" );
65    status = rtems_message_queue_flush( Queue_id[ 1 ], &count );
66    directive_failed( status, "rtems_message_queue_flush" );
67    printf( "%d messages were flushed on the remote queue\n", count );
68
69    puts( "Send messages to be flushed from remote queue" );
70    status = rtems_message_queue_send( Queue_id[ 1 ], (long (*)[4])buffer1, 16 );
71    directive_failed( status, "rtems_message_queue_send" );
72
73    puts( "Flushing remote queue" );
74    status = rtems_message_queue_flush( Queue_id[ 1 ], &count );
75    directive_failed( status, "rtems_message_queue_flush" );
76    printf( "%d messages were flushed on the remote queue\n", count );
77
78    puts( "Waiting for message queue to be deleted" );
79    status = rtems_message_queue_receive(
80      Queue_id[ 1 ],
81      (long (*)[4])receive_buffer,
82      &size,
83      RTEMS_DEFAULT_OPTIONS,
84      RTEMS_NO_TIMEOUT
85    );
86    fatal_directive_status(
87      status,
88      RTEMS_OBJECT_WAS_DELETED,
89      "rtems_message_queue_receive"
90    );
91    puts( "\nGlobal message queue deleted" );
92  }
93  else {                   /* node == 1 */
94    Receive_messages();
95    Send_messages();
96
97    puts( "Delaying for 5 seconds" );
98    status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
99    directive_failed( status, "rtems_task_wake_after" );
100
101    puts( "Deleting Message queue" );
102    status = rtems_message_queue_delete( Queue_id[ 1 ] );
103    directive_failed( status, "rtems_message_queue_delete" );
104  }
105
106  puts( "*** END OF TEST 9 ***" );
107  rtems_test_exit( 0 );
108}
Note: See TracBrowser for help on using the repository browser.