source: rtems/testsuites/libtests/rtems++/Task1.cc @ 1fcff14

4.104.115
Last change on this file since 1fcff14 was 1fcff14, checked in by Ralf Corsepius <ralf.corsepius@…>, on Nov 14, 2009 at 9:09:34 PM

2009-11-14 Ralf Corsépius <ralf.corsepius@…>

  • rtems++/Task1.cc, rtems++/Task2.cc: Spray PRI* macros to eliminate several dozens of warnings.
  • Property mode set to 100644
File size: 22.3 KB
Line 
1/*  Task1
2 *
3 *  This task is the main line for the test. It creates other
4 *  tasks which can create
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1997
12 *  Objective Design Systems Ltd Pty (ODS)
13 *  All rights reserved (R) Objective Design Systems Ltd Pty
14 *
15 *  COPYRIGHT (c) 1989-2007.
16 *  On-Line Applications Research Corporation (OAR).
17 *
18 *  The license and distribution terms for this file may be
19 *  found in the file LICENSE in this distribution or at
20 *  http://www.rtems.com/license/LICENSE.
21 *
22 *  $Id$
23 */
24
25#include <stdlib.h>
26#include <string.h>
27#include "System.h"
28
29/* c.f. cpukit/score/include/rtems/score/priority.h */
30#define PRIiPriority_Control PRIi32
31/* rtems_task_priority is a typedef to Priority_Control */
32#define PRIirtems_task_priority PRIiPriority_Control
33
34/* c.f. cpukit/rtems/include/rtems/rtems/modes.h */
35#define PRIXModes_Control PRIX32
36/* rtems_mode is a typedef to Modes_Control */
37#define PRIXrtems_mode PRIXModes_Control
38
39void Task1::body(rtems_task_argument argument)
40{
41  rtems_test_pause_and_screen_number(1);
42 
43  printf(" * START Task Class test *\n");
44 
45  printf("%s - test argument - ", name_string());
46  if (argument != 0xDEADDEAD)
47    printf("argument is not 0xDEADDEAD\n");
48  else
49    printf("argument matched\n");
50 
51  screen1();
52  rtems_test_pause_and_screen_number(2);
53
54  screen2();
55  rtems_test_pause_and_screen_number(3);
56 
57  screen3();
58  rtems_test_pause_and_screen_number(4);
59 
60  screen4();
61  rtems_test_pause_and_screen_number(5);
62 
63  screen5();
64  rtems_test_pause_and_screen_number(6);
65 
66  screen6();
67
68  // do not call exit(0) from this thread as this object is static
69  // the static destructor call delete the task which is calling exit
70  // so exit never completes
71 
72  EndTask end_task("ENDT", (rtems_task_priority) 1, RTEMS_MINIMUM_STACK_SIZE * 6);
73  end_task.start(0);
74
75  rtemsEvent block_me;
76  rtems_event_set out;
77 
78  block_me.receive(RTEMS_SIGNAL_0, out);
79
80  printf("**** TASK 1 did not block ????\n");
81}
82
83void Task1::screen1(void)
84{
85  // create two local task objects to connect to this task
86  rtemsTask local_task_1 = *this;
87  rtemsTask local_task_2;
88
89  local_task_2 = *this;
90 
91  // check the copy constructor works
92  printf("%s - copy constructor - ", name_string());
93  if (local_task_1.id_is() == id_is())
94    printf("local and this id's match\n");
95  else
96    printf("local and this id's do not match\n");
97
98  printf("%s - copy constructor - ", name_string());
99  if (local_task_1.name_is() == name_is())
100    printf("local and this name's match\n");
101  else
102    printf("local and this name's do not match\n");
103
104  // check the copy operator works
105  printf("%s - copy operator - ", name_string());
106  if (local_task_2.id_is() == id_is())
107    printf("local and this id's match\n");
108  else
109    printf("local and this id's do not match\n");
110  printf("%s - copy operator - ", name_string());
111  if (local_task_2.name_is() == name_is())
112    printf("local and this name's match\n");
113  else
114    printf("local and this name's do not match\n");
115 
116  // check that the owner of the id cannot delete this task
117  printf("%s - not owner destroy's task - ", local_task_1.name_string());
118  local_task_1.destroy();
119  printf("%s\n", local_task_1.last_status_string());
120 
121  // connect to a valid task
122  printf("%s - connect to a local valid task name - ", local_task_2.name_string());
123  local_task_2.connect("TA1 ", RTEMS_SEARCH_ALL_NODES);
124  printf("%s\n", local_task_2.last_status_string());
125 
126  // connect to an invalid task
127  printf("%s - connect to an invalid task name - ", local_task_2.name_string());
128  local_task_2.connect("BADT", RTEMS_SEARCH_ALL_NODES);
129  printf("%s\n", local_task_2.last_status_string());
130 
131  // connect to a task an invalid node
132  printf("%s - connect to a task on an invalid node - ", local_task_2.name_string());
133  local_task_2.connect("BADT", 10);
134  printf("%s\n", local_task_2.last_status_string());
135 
136  // restart this task
137  printf("%s - restart from a non-owner - ", name_string());
138  local_task_1.restart(0);
139  printf("%s\n", local_task_1.last_status_string());
140}
141
142void Task1::screen2(void)
143{
144  // wake after using this object
145 
146  printf("%s - wake after 0 secs - ", name_string());
147  wake_after(0);
148  printf("%s\n", last_status_string());
149 
150  printf("%s - wake after 500 msecs - ", name_string());
151  wake_after(500000);
152  printf("%s\n", last_status_string());
153 
154  printf("%s - wake after 5 secs - ", name_string());
155  wake_after(5000000);
156  printf("%s\n", last_status_string());
157
158  printf("%s - wake when - to do\n", name_string());
159
160  rtemsTask task_1 = *this;
161 
162  // wake after using a connected object
163 
164  printf("%s - connected object wake after 0 secs - ", task_1.name_string());
165  task_1.wake_after(0);
166  printf("%s\n", task_1.last_status_string());
167 
168  printf("%s - connected object wake after 500 msecs - ", task_1.name_string());
169  task_1.wake_after(500000);
170  printf("%s\n", task_1.last_status_string());
171 
172  printf("%s - connected object wake after 5 secs - ", task_1.name_string());
173  task_1.wake_after(5000000);
174  printf("%s\n", task_1.last_status_string());
175
176  printf("%s - connected object wake when - to do\n", task_1.name_string());
177
178  rtemsTask task_2;
179 
180  // wake after using a self object
181 
182  printf("%s - self object wake after 0 secs - ", task_2.name_string());
183  task_2.wake_after(0);
184  printf("%s\n", task_2.last_status_string());
185 
186  printf("%s - self object wake after 500 msecs - ", task_2.name_string());
187  task_2.wake_after(500000);
188  printf("%s\n", task_2.last_status_string());
189 
190  printf("%s - self object wake after 5 secs - ", task_2.name_string());
191  task_2.wake_after(5000000);
192  printf("%s\n", task_2.last_status_string());
193
194  printf("%s - self object wake when - to do\n", task_2.name_string());
195
196  rtems_task_priority current_priority;
197  rtems_task_priority priority;
198
199  // priorities with this object
200 
201  printf("%s - get priority - ", name_string());
202  get_priority(current_priority);
203  printf("%s, priority is %" PRIirtems_task_priority "\n", last_status_string(), current_priority);
204
205  printf("%s - set priority to 512 - ", name_string());
206  set_priority(512);
207  printf("%s\n", last_status_string());
208
209  printf("%s - set priority to 25 - ", name_string());
210  set_priority(25);
211  printf("%s\n", last_status_string());
212
213  printf("%s - set priority to original - ", name_string());
214  set_priority(current_priority, priority);
215  printf("%s, priority was %" PRIirtems_task_priority "\n", last_status_string(), priority);
216
217  // priorities with connected object
218   
219  printf("%s - connected object get priority - ", task_1.name_string());
220  task_1.get_priority(current_priority);
221  printf("%s, priority is %" PRIirtems_task_priority "\n", task_1.last_status_string(), current_priority);
222
223  printf("%s - connected object set priority to 512 - ", task_1.name_string());
224  task_1.set_priority(512);
225  printf("%s\n", task_1.last_status_string());
226
227  printf("%s - connected object set priority to 25 - ", task_1.name_string());
228  task_1.set_priority(25);
229  printf("%s\n", task_1.last_status_string());
230
231  printf("%s - connected object set priority to original - ", task_1.name_string());
232  task_1.set_priority(current_priority, priority);
233  printf("%s, priority was %" PRIirtems_task_priority "\n", task_1.last_status_string(), priority); 
234
235  // priorities with self object
236   
237  printf("%s - self object get priority - ", task_2.name_string());
238  task_2.get_priority(current_priority);
239  printf("%s, priority is %" PRIirtems_task_priority "\n", task_2.last_status_string(), current_priority);
240
241  printf("%s - self object set priority to 512 - ", task_2.name_string());
242  task_2.set_priority(512);
243  printf("%s\n", task_2.last_status_string());
244
245  printf("%s - self object set priority to 25 - ", task_2.name_string());
246  task_2.set_priority(25);
247  printf("%s\n", task_2.last_status_string());
248
249  printf("%s - self object set priority to original - ", task_2.name_string());
250  task_2.set_priority(current_priority, priority);
251  printf("%s, priority was %" PRIirtems_task_priority "\n", task_2.last_status_string(), priority);
252
253  uint32_t   current_note;
254  uint32_t   note;
255 
256  // notepad registers for this object
257
258  printf("%s - get note - ", name_string());
259  get_note(0, current_note);
260  printf("%s, note is %" PRIi32 "\n", last_status_string(), current_note);
261
262  printf("%s - get with bad notepad number - ", name_string());
263  get_note(100, current_note);
264  printf("%s, note is %" PRIi32 "\n", last_status_string(), current_note);
265
266  printf("%s - set note to 0xDEADBEEF - ", name_string());
267  set_note(0, 0xDEADBEEF);
268  printf("%s\n", last_status_string());
269
270  printf("%s - get note - ", name_string());
271  get_note(0, note);
272  printf("%s, note is 0x%08" PRIX32 "\n", last_status_string(), note);
273
274  printf("%s - set note to original value - ", name_string());
275  set_note(0, current_note);
276  printf("%s\n", last_status_string());
277
278  // notepad registers for connected object
279
280  printf("%s - connected object get note - ", task_1.name_string());
281  task_1.get_note(0, current_note);
282  printf("%s, notepad is %" PRIi32 "\n", task_1.last_status_string(), current_note);
283
284  printf("%s - connected object get with bad notepad number - ", task_1.name_string());
285  task_1.get_note(100, current_note);
286  printf("%s, note is %" PRIi32 "\n", task_1.last_status_string(), current_note);
287
288  printf("%s - connected object set note to 0xDEADBEEF - ", task_1.name_string());
289  task_1.set_note(0, 0xDEADBEEF);
290  printf("%s\n", task_1.last_status_string());
291
292  printf("%s - connected object get note - ", task_1.name_string());
293  task_1.get_note(0, note);
294  printf("%s, note is 0x%08" PRIX32 "\n", task_1.last_status_string(), note);
295
296  printf("%s - connected object set note to original value - ", task_1.name_string());
297  task_1.set_note(0, current_note);
298  printf("%s\n", task_1.last_status_string());
299
300  // notepad registers for self object
301
302  printf("%s - self object get note - ", task_2.name_string());
303  task_2.get_note(0, current_note);
304  printf("%s, note is %" PRIi32 "\n", task_2.last_status_string(), current_note);
305
306  printf("%s - self object get with bad notepad number - ", task_2.name_string());
307  task_2.get_note(100, current_note);
308  printf("%s, note is %" PRIi32 "\n", task_2.last_status_string(), current_note);
309
310  printf("%s - self object set note to 0xDEADBEEF - ", task_2.name_string());
311  task_2.set_note(0, 0xDEADBEEF);
312  printf("%s\n", task_2.last_status_string());
313
314  printf("%s - self object get note - ", task_2.name_string());
315  task_2.get_note(0, note);
316  printf("%s, notepad is 0x%08" PRIX32 "\n", task_2.last_status_string(), note);
317
318  printf("%s - self object set note to original value - ", task_2.name_string());
319  task_2.set_note(0, current_note);
320  printf("%s\n", task_2.last_status_string());
321
322  printf(" * END Task Class test *\n");
323}
324
325#define RTEMS_ALL_MODES (RTEMS_PREEMPT_MASK | \
326                         RTEMS_TIMESLICE_MASK | \
327                         RTEMS_ASR_MASK | \
328                         RTEMS_INTERRUPT_MASK)
329
330void Task1::screen3(void)
331{
332  printf(" * START TaskMode Class test *\n");
333
334  rtemsTask self;
335  rtemsTaskMode task_mode;
336  rtems_mode current_mode;
337  rtems_mode mode;
338
339  printf("%s - get mode - ", self.name_string());
340  task_mode.get_mode(current_mode);
341  printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), current_mode);
342  print_mode(current_mode, RTEMS_ALL_MODES);
343  printf("\n");
344
345  // PREEMPTION mode control
346 
347  printf("%s - get preemption state - ", self.name_string());
348  task_mode.get_preemption_state(mode);
349  printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
350  print_mode(mode, RTEMS_PREEMPT_MASK);
351  printf("\n");
352 
353  printf("%s - set preemption state to RTEMS_PREEMPT - ", self.name_string());
354  task_mode.set_preemption_state(RTEMS_PREEMPT);
355  task_mode.get_mode(mode);
356  printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
357  print_mode(mode, RTEMS_ALL_MODES);
358  printf("\n");
359 
360  printf("%s - set preemption state to RTEMS_NO_PREEMPT - ", self.name_string());
361  task_mode.set_preemption_state(RTEMS_NO_PREEMPT);
362  task_mode.get_mode(mode);
363  printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
364  print_mode(mode, RTEMS_ALL_MODES);
365  printf("\n");
366
367  // TIMESLICE mode control
368 
369  printf("%s - get timeslice state - ", self.name_string());
370  task_mode.get_timeslice_state(mode);
371  printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
372  print_mode(mode, RTEMS_TIMESLICE_MASK);
373  printf("\n");
374 
375  printf("%s - set timeslice state to RTEMS_TIMESLICE - ", self.name_string());
376  task_mode.set_timeslice_state(RTEMS_TIMESLICE);
377  task_mode.get_mode(mode);
378  printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
379  print_mode(mode, RTEMS_ALL_MODES);
380  printf("\n");
381 
382  printf("%s - set timeslice state to RTEMS_NO_TIMESLICE - ", self.name_string());
383  task_mode.set_timeslice_state(RTEMS_NO_TIMESLICE);
384  task_mode.get_mode(mode);
385  printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
386  print_mode(mode, RTEMS_ALL_MODES);
387  printf("\n");
388
389  // ASR mode control
390 
391  printf("%s - get asr state - ", self.name_string());
392  task_mode.get_asr_state(mode);
393  printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
394  print_mode(mode, RTEMS_ASR_MASK);
395  printf("\n");
396 
397  printf("%s - set asr state to RTEMS_ASR - ", self.name_string());
398  task_mode.set_asr_state(RTEMS_ASR);
399  task_mode.get_mode(mode);
400  printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
401  print_mode(mode, RTEMS_ALL_MODES);
402  printf("\n");
403 
404  printf("%s - set asr state to RTEMS_NO_ASR - ", self.name_string());
405  task_mode.set_asr_state(RTEMS_NO_ASR);
406  task_mode.get_mode(mode);
407  printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
408  print_mode(mode, RTEMS_ALL_MODES);
409  printf("\n");
410
411  // interrupt level control
412 
413  rtems_interrupt_level current_level;
414  rtems_interrupt_level level;
415
416  printf("%s - get current interrupt level - ", self.name_string());
417  task_mode.get_interrupt_level(current_level);
418  printf("%s, level is %i\n", task_mode.last_status_string(), current_level);
419
420  printf("%s - set interrupt level to 102 - ", self.name_string());
421  task_mode.set_interrupt_level(102);
422  printf("%s\n", task_mode.last_status_string());
423 
424  printf("%s - set interrupt level to original level - ", self.name_string());
425  task_mode.set_interrupt_level(current_level, level);
426  printf("%s, level was %i\n", task_mode.last_status_string(), level);
427
428  printf("%s - set mode to original mode - ", self.name_string());
429  task_mode.set_mode(current_mode,
430                     RTEMS_PREEMPT_MASK | RTEMS_TIMESLICE_MASK |
431                     RTEMS_ASR_MASK | RTEMS_INTERRUPT_MASK);
432  task_mode.get_mode(mode);
433  printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
434  print_mode(mode, RTEMS_ALL_MODES);
435  printf("\n");
436 
437  printf(" * END TaskMode Class test *\n"); 
438}
439
440void Task1::screen4(void)
441{
442  printf(" * START Event Class test *\n");
443
444  printf("%s - create task 2 - ", name_string());
445  Task2 task_2("TA2", (rtems_task_priority) 9, RTEMS_MINIMUM_STACK_SIZE * 6);
446  printf("%s\n", task_2.last_status_string());
447
448  printf("%s - start task 2 - ", name_string());
449  task_2.start(0);
450  printf("%s\n", task_2.last_status_string());
451 
452  printf("%s - construct event connecting to task 2 - ", name_string());
453  rtemsEvent event_2("TA2 ");
454  printf("%s\n", event_2.last_status_string());
455
456  // wait for task 2 to complete its timeout tests
457  wake_after(7000000);
458
459  printf("%s - send event signal 0 using the task id - ", name_string());
460  event_2.send(task_2.id_is(), RTEMS_SIGNAL_0);
461  printf("%s\n", event_2.last_status_string());
462 
463  wake_after(1000000);
464
465  printf("%s - send event signal 0 using the task object reference - ", name_string());
466  event_2.send(task_2, RTEMS_SIGNAL_0);
467  printf("%s\n", event_2.last_status_string());
468 
469  wake_after(1000000);
470
471  printf("%s - send event signal 31 using connected id - ", name_string());
472  event_2.send(RTEMS_SIGNAL_31);
473  printf("%s\n", event_2.last_status_string());
474 
475  wake_after(1000000);
476
477  rtemsEvent event_2_2;
478
479  event_2_2.connect("TA2");
480 
481  printf("%s - send event signal 0 and 31 - ", name_string());
482  event_2_2.send(task_2, RTEMS_SIGNAL_0 | RTEMS_SIGNAL_31);
483  printf("%s\n", event_2_2.last_status_string());
484 
485  printf("%s - waiting 5 secs for TA2 to finish\n", name_string());
486  wake_after(500000);
487 
488  printf(" * END Event Class test *\n"); 
489}
490
491void Task1::screen5(void)
492{
493  printf(" * START Interrupt Class test *\n");
494
495  printf(" do not know a portable BSP type interrupt test\n");
496
497  printf(" * END Interrupt Class test *\n"); 
498}
499
500void Task1::screen6(void)
501{
502  printf(" * START MessageQueue Class test *\n");
503
504  printf("%s - construct message queue 1 with no memory error - ", name_string());
505  rtemsMessageQueue mq_1("MQ1", 1000000, 1000);
506  printf("%s\n", mq_1.last_status_string());
507
508  printf("%s - construct/create message queue 2 - ", name_string());
509  rtemsMessageQueue mq_2("MQ2", 4, 50);
510  printf("%s\n", mq_2.last_status_string());
511
512  const char *u1 = "normal send";
513  const char *u2 = "urgent send";
514  char in[100];
515  size_t  size;
516  uint32_t count;
517 
518  printf("%s - send u1 to mq_2 - ", name_string());
519  mq_2.send(u1, strlen(u1) + 1);
520  printf("%s\n", mq_2.last_status_string());
521 
522  printf("%s - urgent send u2 to mq_2 - ", name_string());
523  mq_2.urgent(u2, strlen(u2) + 1);
524  printf("%s\n", mq_2.last_status_string());
525 
526  printf("%s - create task 3_1 - ", name_string());
527  Task3 task_3_1("TA31", 9, RTEMS_MINIMUM_STACK_SIZE * 6);
528  printf("%s\n", task_3_1.last_status_string());
529
530  printf("%s - start task 3_1 - ", name_string());
531  task_3_1.start(0);
532  printf("%s\n", task_3_1.last_status_string());
533 
534  printf("%s - create task 3_2 - ", name_string());
535  Task3 task_3_2("TA32", 9, RTEMS_MINIMUM_STACK_SIZE * 6);
536  printf("%s\n", task_3_2.last_status_string());
537
538  printf("%s - start task 3_2 - ", name_string());
539  task_3_2.start(0);
540  printf("%s\n", task_3_1.last_status_string());
541 
542  wake_after(1000000);
543 
544  printf("%s - receive u2 on mq_2 ...\n", name_string()); fflush(stdout);
545  mq_2.receive(in, size, 5000000);
546  printf("%s - %s\n", name_string(), mq_2.last_status_string());
547
548  if (size == (strlen(u2) + 5))
549  {
550    if ((strncmp(in, task_3_1.name_string(), 4) == 0) &&
551        (strcmp(in + 4, u2) == 0))
552    {
553      printf("%s - message u2 received correctly\n", name_string());
554    }
555    else
556    {
557      printf("%s - message u2 received incorrectly, message='%s', size=%i\n",
558             name_string(), in, size);
559    }
560  }
561  else
562    printf("%s - message u2 size incorrect, size=%i\n", name_string(), size);
563
564  printf("%s - receive u1 on mq_2 ...\n", name_string()); fflush(stdout);
565  mq_2.receive(in, size, 5000000);
566  printf("%s - %s\n", name_string(), mq_2.last_status_string());
567
568  if (size == (strlen(u1) + 5))
569  {
570    if ((strncmp(in, task_3_2.name_string(), 4) == 0) &&
571        (strcmp(in + 4, u1) == 0))
572    {
573      printf("%s - message u1 received correctly\n", name_string());
574    }
575    else
576    {
577      printf("%s - message u1 received incorrectly, message='%s', size=%i\n",
578             name_string(), in, size);
579    }
580  }
581  else
582    printf("%s - message u1 size incorrect, size=%i\n", name_string(), size);
583
584  wake_after(3000000);
585 
586  const char *b1 = "broadcast message";
587 
588  printf("%s - broadcast send b1 ...\n", name_string());
589  mq_2.broadcast(b1, strlen(b1) + 1, count);
590  printf("%s - mq_2 broadcast send - %s, count=%" PRIi32 "\n",
591         name_string(), mq_2.last_status_string(), count);
592
593  wake_after(1000000);
594 
595  printf("%s - receive message b1 on mq_2 from %s...\n",
596         name_string(), task_3_1.name_string()); fflush(stdout);
597  mq_2.receive(in, size, 5000000);
598  printf("%s - %s\n", name_string(), mq_2.last_status_string());
599
600  if (size == (strlen(b1) + 5))
601  {
602    if ((strncmp(in, task_3_1.name_string(), 4) == 0) &&
603        (strcmp(in + 4, b1) == 0))
604    {
605      printf("%s - message b1 received correctly\n", name_string());
606    }
607    else
608    {
609      printf("%s - message b1 received incorrectly, message='%s'\n",
610             name_string(), in);
611    }
612  }
613  else
614    printf("%s - message b1 size incorrect, size=%i\n", name_string(), size);
615
616  printf("%s - receive message b1 on mq_2 from %s...\n",
617         name_string(), task_3_1.name_string()); fflush(stdout);
618  mq_2.receive(in, size, 5000000);
619  printf("%s - %s\n", name_string(), mq_2.last_status_string());
620
621  if (size == (strlen(b1) + 5))
622  {
623    if ((strncmp(in, task_3_2.name_string(), 4) == 0) &&
624        (strcmp(in + 4, b1) == 0))
625    {
626      printf("%s - message b1 received correctly\n", name_string());
627    }
628    else
629    {
630      printf("%s - message b1 received incorrectly, message='%s', size=%i\n",
631             name_string(), in, size);
632    }
633  }
634  else
635    printf("%s - message b1 size incorrect, size=%i\n", name_string(), size);
636
637  // wait for task 3_1, and 3_2 to complete their timeout tests, will
638  // start these after getting the broadcast message
639  wake_after(7000000); 
640
641  const char *f1 = "flush message";
642 
643  printf("%s - send f1 to mq_2 - ", name_string());
644  mq_2.send(f1, strlen(f1) + 1);
645  printf("%s\n", mq_2.last_status_string());
646 
647  printf("%s - send f1 to mq_2 - ", name_string());
648  mq_2.send(f1, strlen(f1) + 1);
649  printf("%s\n", mq_2.last_status_string());
650 
651  printf("%s - send f1 to mq_2 - ", name_string());
652  mq_2.send(f1, strlen(f1) + 1);
653  printf("%s\n", mq_2.last_status_string());
654
655  printf("%s - flush mq_2 - ", name_string());
656  mq_2.flush(count);
657  printf("%s, flushed=%" PRIi32 "\n", mq_2.last_status_string(), count);
658 
659  printf(" * END MessageQueue Class test *\n"); 
660}
661
662void Task1::print_mode(rtems_mode mode, rtems_mode mask)
663{
664  rtemsTaskMode task_mode;
665  if (mask & RTEMS_PREEMPT_MASK)
666    printf("RTEMS_%sPREEMPT ",
667           task_mode.preemption_set(mode) ? "" : "NO_");
668  if (mask & RTEMS_TIMESLICE_MASK)
669    printf("RTEMS_%sTIMESLICE ",
670           task_mode.preemption_set(mode) ? "" : "NO_");
671  if (mask & RTEMS_ASR_MASK)
672    printf("RTEMS_%sASR ",
673           task_mode.asr_set(mode) ? "" : "NO_");
674  if (mask & RTEMS_INTERRUPT_MASK)
675    printf("INTMASK=%i",
676           mode & RTEMS_INTERRUPT_MASK);
677}
678
679EndTask::EndTask(const char* name,
680                 const rtems_task_priority initial_priority,
681                 const uint32_t   stack_size)
682  : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT)
683{
684}
685 
686void EndTask::body(rtems_task_argument)
687{
688 printf("*** END OF RTEMS++ TEST ***\n");
689 exit(0);
690}
691
Note: See TracBrowser for help on using the repository browser.