source: rtems/testsuites/libtests/rtems++/Task1.cc @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

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