1 | /* Test_task |
---|
2 | * |
---|
3 | * This task tests the rtems_task_set_note directive on a remote task and that |
---|
4 | * errors are returned when attempting to delete, start, or restart |
---|
5 | * a remote task. |
---|
6 | * |
---|
7 | * Input parameters: |
---|
8 | * argument - task argument |
---|
9 | * |
---|
10 | * Output parameters: NONE |
---|
11 | * |
---|
12 | * COPYRIGHT (c) 1989-2009. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
14 | * |
---|
15 | * The license and distribution terms for this file may be |
---|
16 | * found in the file LICENSE in this distribution or at |
---|
17 | * http://www.rtems.com/license/LICENSE. |
---|
18 | * |
---|
19 | * $Id$ |
---|
20 | */ |
---|
21 | |
---|
22 | #ifdef HAVE_CONFIG_H |
---|
23 | #include "config.h" |
---|
24 | #endif |
---|
25 | |
---|
26 | #include "system.h" |
---|
27 | |
---|
28 | extern rtems_multiprocessing_table Multiprocessing_configuration; |
---|
29 | |
---|
30 | rtems_task Test_task( |
---|
31 | rtems_task_argument argument |
---|
32 | ) |
---|
33 | { |
---|
34 | rtems_id tid; |
---|
35 | rtems_status_code status; |
---|
36 | uint32_t remote_node; |
---|
37 | rtems_id remote_tid; |
---|
38 | rtems_id test_tid; |
---|
39 | uint32_t note; |
---|
40 | uint32_t tmpNode; |
---|
41 | |
---|
42 | status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); |
---|
43 | |
---|
44 | remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1; |
---|
45 | printf( "Remote task's name is : " ); |
---|
46 | put_name( Task_name[ remote_node ], TRUE ); |
---|
47 | |
---|
48 | puts( "Getting TID of remote task (all nodes)" ); |
---|
49 | do { |
---|
50 | status = rtems_task_ident( |
---|
51 | Task_name[ remote_node ], |
---|
52 | RTEMS_SEARCH_ALL_NODES, |
---|
53 | &remote_tid |
---|
54 | ); |
---|
55 | } while ( status != RTEMS_SUCCESSFUL ); |
---|
56 | |
---|
57 | directive_failed( status, "rtems_task_ident" ); |
---|
58 | |
---|
59 | puts( "Getting TID of remote task (1 node)" ); |
---|
60 | status = rtems_task_ident( Task_name[ remote_node ], remote_node, &test_tid ); |
---|
61 | directive_failed( status, "rtems_task_ident" ); |
---|
62 | |
---|
63 | if ( test_tid != remote_tid ) { |
---|
64 | puts( "rtems_task_ident tid's do not match!!" ); |
---|
65 | rtems_fatal_error_occurred( status ); |
---|
66 | } |
---|
67 | |
---|
68 | status = rtems_task_delete( remote_tid ); |
---|
69 | fatal_directive_status( |
---|
70 | status, |
---|
71 | RTEMS_ILLEGAL_ON_REMOTE_OBJECT, |
---|
72 | "rtems_task_delete of remote task" |
---|
73 | ); |
---|
74 | puts( "rtems_task_delete of remote task returned the correct error" ); |
---|
75 | |
---|
76 | status = rtems_task_start( remote_tid, Test_task, 0 ); |
---|
77 | fatal_directive_status( |
---|
78 | status, |
---|
79 | RTEMS_ILLEGAL_ON_REMOTE_OBJECT, |
---|
80 | "rtems_task_start of remote task" |
---|
81 | ); |
---|
82 | puts( "rtems_task_start of remote task returned the correct error" ); |
---|
83 | |
---|
84 | status = rtems_task_restart( remote_tid, 0 ); |
---|
85 | fatal_directive_status( |
---|
86 | status, |
---|
87 | RTEMS_ILLEGAL_ON_REMOTE_OBJECT, |
---|
88 | "rtems_task_restart of remote task" |
---|
89 | ); |
---|
90 | puts( "rtems_task_restart of remote task returned the correct error" ); |
---|
91 | |
---|
92 | tmpNode = rtems_object_id_get_node(tid); |
---|
93 | printf( "Setting notepad %" PRId32 " of the remote task to %" PRId32 "\n", tmpNode, tmpNode ); |
---|
94 | status = rtems_task_set_note( remote_tid, tmpNode, tmpNode ); |
---|
95 | directive_failed( status, "rtems_task_set_note" ); |
---|
96 | |
---|
97 | puts( "Getting a notepad of the remote task" ); |
---|
98 | status = rtems_task_get_note( remote_tid, tmpNode, ¬e ); |
---|
99 | directive_failed( status, "rtems_task_get_note" ); |
---|
100 | |
---|
101 | if ( note == tmpNode ) |
---|
102 | puts( "Remote notepad set and read correctly" ); |
---|
103 | else |
---|
104 | printf( |
---|
105 | "FAILURE!! Remote notepad was not set and read correctly (%" PRId32 ", %" PRId32 ")\n", |
---|
106 | note, |
---|
107 | tmpNode |
---|
108 | ); |
---|
109 | |
---|
110 | status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() ); |
---|
111 | directive_failed( status, "rtems_task_wake_after" ); |
---|
112 | |
---|
113 | puts( "*** END OF TEST 2 ***" ); |
---|
114 | rtems_test_exit( 0 ); |
---|
115 | } |
---|