1 | /* |
---|
2 | * COPYRIGHT (c) 2014. |
---|
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.org/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 | const char rtems_test_name[] = "SP TASK ERROR 03"; |
---|
18 | |
---|
19 | rtems_task Init( |
---|
20 | rtems_task_argument argument |
---|
21 | ) |
---|
22 | { |
---|
23 | rtems_name task_name; |
---|
24 | rtems_status_code status; |
---|
25 | bool skipUnsatisfied; |
---|
26 | |
---|
27 | TEST_BEGIN(); |
---|
28 | |
---|
29 | Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); |
---|
30 | Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); |
---|
31 | Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' ); |
---|
32 | Task_name[ 4 ] = rtems_build_name( 'T', 'A', '4', ' ' ); |
---|
33 | Task_name[ 5 ] = rtems_build_name( 'T', 'A', '5', ' ' ); |
---|
34 | Task_name[ 6 ] = rtems_build_name( 'T', 'A', '6', ' ' ); |
---|
35 | Task_name[ 7 ] = rtems_build_name( 'T', 'A', '7', ' ' ); |
---|
36 | Task_name[ 8 ] = rtems_build_name( 'T', 'A', '8', ' ' ); |
---|
37 | Task_name[ 9 ] = rtems_build_name( 'T', 'A', '9', ' ' ); |
---|
38 | Task_name[ 10 ] = rtems_build_name( 'T', 'A', 'A', ' ' ); |
---|
39 | |
---|
40 | /* task create bad name */ |
---|
41 | task_name = 1; |
---|
42 | status = rtems_task_create( |
---|
43 | 0, |
---|
44 | 1, |
---|
45 | RTEMS_MINIMUM_STACK_SIZE, |
---|
46 | RTEMS_DEFAULT_MODES, |
---|
47 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
48 | &Junk_id |
---|
49 | ); |
---|
50 | fatal_directive_status( |
---|
51 | status, |
---|
52 | RTEMS_INVALID_NAME, |
---|
53 | "rtems_task_create with illegal name" |
---|
54 | ); |
---|
55 | puts( "TA1 - rtems_task_create - RTEMS_INVALID_NAME" ); |
---|
56 | |
---|
57 | /* null ID */ |
---|
58 | status = rtems_task_create( |
---|
59 | Task_name[ 1 ], |
---|
60 | 4, |
---|
61 | RTEMS_MINIMUM_STACK_SIZE, |
---|
62 | RTEMS_DEFAULT_MODES, |
---|
63 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
64 | NULL |
---|
65 | ); |
---|
66 | fatal_directive_status( |
---|
67 | status, |
---|
68 | RTEMS_INVALID_ADDRESS, |
---|
69 | "rtems_task_create with NULL ID param" |
---|
70 | ); |
---|
71 | puts( "TA1 - rtems_task_create - RTEMS_INVALID_ADDRESS" ); |
---|
72 | |
---|
73 | /* |
---|
74 | * If the bsp provides its own stack allocator, then |
---|
75 | * skip the test that tries to allocate a stack that is too big. |
---|
76 | * |
---|
77 | * If on the m32c, we can't even ask for enough memory to trip this |
---|
78 | * error. |
---|
79 | */ |
---|
80 | |
---|
81 | skipUnsatisfied = false; |
---|
82 | if (rtems_configuration_get_stack_allocate_hook()) |
---|
83 | skipUnsatisfied = true; |
---|
84 | #if defined(__m32c__) |
---|
85 | skipUnsatisfied = true; |
---|
86 | #endif |
---|
87 | |
---|
88 | if ( skipUnsatisfied ) { |
---|
89 | puts( |
---|
90 | "TA1 - rtems_task_create - stack size - RTEMS_UNSATISFIED -- SKIPPED" |
---|
91 | ); |
---|
92 | } else { |
---|
93 | status = rtems_task_create( |
---|
94 | task_name, |
---|
95 | 1, |
---|
96 | rtems_configuration_get_work_space_size(), |
---|
97 | RTEMS_DEFAULT_MODES, |
---|
98 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
99 | &Junk_id |
---|
100 | ); |
---|
101 | fatal_directive_status( |
---|
102 | status, |
---|
103 | RTEMS_UNSATISFIED, |
---|
104 | "rtems_task_create with a stack size larger than the workspace" |
---|
105 | ); |
---|
106 | puts( "TA1 - rtems_task_create - stack size - RTEMS_UNSATISFIED" ); |
---|
107 | } |
---|
108 | status = rtems_task_create( |
---|
109 | Task_name[ 1 ], |
---|
110 | 4, |
---|
111 | RTEMS_MINIMUM_STACK_SIZE * 3, |
---|
112 | RTEMS_DEFAULT_MODES, |
---|
113 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
114 | &Task_id[ 1 ] |
---|
115 | ); |
---|
116 | directive_failed( status, "rtems_task_create of TA1" ); |
---|
117 | |
---|
118 | status = rtems_task_create( |
---|
119 | Task_name[ 2 ], |
---|
120 | 4, |
---|
121 | RTEMS_MINIMUM_STACK_SIZE, |
---|
122 | RTEMS_DEFAULT_MODES, |
---|
123 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
124 | &Task_id[ 2 ] |
---|
125 | ); |
---|
126 | directive_failed( status, "rtems_task_create of TA2" ); |
---|
127 | puts( "TA1 - rtems_task_create - TA2 created - RTEMS_SUCCESSFUL" ); |
---|
128 | |
---|
129 | status = rtems_task_suspend( Task_id[ 2 ] ); |
---|
130 | directive_failed( status, "rtems_task_suspend of TA2" ); |
---|
131 | puts( "TA1 - rtems_task_suspend - suspend TA2 - RTEMS_SUCCESSFUL" ); |
---|
132 | |
---|
133 | status = rtems_task_suspend( Task_id[ 2 ] ); |
---|
134 | fatal_directive_status( |
---|
135 | status, |
---|
136 | RTEMS_ALREADY_SUSPENDED, |
---|
137 | "rtems_task_suspend of suspended TA2" |
---|
138 | ); |
---|
139 | puts( "TA1 - rtems_task_suspend - suspend TA2 - RTEMS_ALREADY_SUSPENDED" ); |
---|
140 | |
---|
141 | status = rtems_task_resume( Task_id[ 2 ] ); |
---|
142 | directive_failed( status, "rtems_task_resume of TA2" ); |
---|
143 | puts( "TA1 - rtems_task_resume - TA2 resumed - RTEMS_SUCCESSFUL" ); |
---|
144 | |
---|
145 | status = rtems_task_create( |
---|
146 | Task_name[ 3 ], |
---|
147 | 4, |
---|
148 | RTEMS_MINIMUM_STACK_SIZE, |
---|
149 | RTEMS_DEFAULT_MODES, |
---|
150 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
151 | &Task_id[ 3 ] |
---|
152 | ); |
---|
153 | directive_failed( status, "rtems_task_create of TA3" ); |
---|
154 | puts( "TA1 - rtems_task_create - TA3 created - RTEMS_SUCCESSFUL" ); |
---|
155 | |
---|
156 | status = rtems_task_create( |
---|
157 | Task_name[ 5 ], |
---|
158 | 4, |
---|
159 | RTEMS_MINIMUM_STACK_SIZE, |
---|
160 | RTEMS_DEFAULT_MODES, |
---|
161 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
162 | &Task_id[ 5 ] |
---|
163 | ); |
---|
164 | directive_failed( status, "rtems_task_create of TA5" ); |
---|
165 | puts( "TA1 - rtems_task_create - 5 created - RTEMS_SUCCESSFUL" ); |
---|
166 | |
---|
167 | status = rtems_task_create( |
---|
168 | Task_name[ 6 ], |
---|
169 | 4, |
---|
170 | RTEMS_MINIMUM_STACK_SIZE, |
---|
171 | RTEMS_DEFAULT_MODES, |
---|
172 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
173 | &Task_id[ 6 ] |
---|
174 | ); |
---|
175 | directive_failed( status, "rtems_task_create of TA6" ); |
---|
176 | puts( "TA1 - rtems_task_create - 6 created - RTEMS_SUCCESSFUL" ); |
---|
177 | |
---|
178 | status = rtems_task_create( |
---|
179 | Task_name[ 7 ], |
---|
180 | 4, |
---|
181 | RTEMS_MINIMUM_STACK_SIZE, |
---|
182 | RTEMS_DEFAULT_MODES, |
---|
183 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
184 | &Task_id[ 7 ] |
---|
185 | ); |
---|
186 | directive_failed( status, "rtems_task_create of TA7" ); |
---|
187 | puts( "TA1 - rtems_task_create - 7 created - RTEMS_SUCCESSFUL" ); |
---|
188 | |
---|
189 | status = rtems_task_create( |
---|
190 | Task_name[ 8 ], |
---|
191 | 4, |
---|
192 | RTEMS_MINIMUM_STACK_SIZE, |
---|
193 | RTEMS_DEFAULT_MODES, |
---|
194 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
195 | &Task_id[ 8 ] |
---|
196 | ); |
---|
197 | directive_failed( status, "rtems_task_create of TA8" ); |
---|
198 | puts( "TA1 - rtems_task_create - 8 created - RTEMS_SUCCESSFUL" ); |
---|
199 | |
---|
200 | status = rtems_task_create( |
---|
201 | Task_name[ 9 ], |
---|
202 | 4, |
---|
203 | RTEMS_MINIMUM_STACK_SIZE, |
---|
204 | RTEMS_DEFAULT_MODES, |
---|
205 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
206 | &Task_id[ 9 ] |
---|
207 | ); |
---|
208 | directive_failed( status, "rtems_task_create of TA9" ); |
---|
209 | puts( "TA1 - rtems_task_create - 9 created - RTEMS_SUCCESSFUL" ); |
---|
210 | |
---|
211 | status = rtems_task_create( |
---|
212 | Task_name[ 10 ], |
---|
213 | 4, |
---|
214 | RTEMS_MINIMUM_STACK_SIZE, |
---|
215 | RTEMS_DEFAULT_MODES, |
---|
216 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
217 | &Task_id[ 10 ] |
---|
218 | ); |
---|
219 | directive_failed( status, "rtems_task_create of TA10" ); |
---|
220 | puts( "TA1 - rtems_task_create - 10 created - RTEMS_SUCCESSFUL" ); |
---|
221 | |
---|
222 | status = rtems_task_create( |
---|
223 | task_name, |
---|
224 | 4, |
---|
225 | RTEMS_MINIMUM_STACK_SIZE, |
---|
226 | RTEMS_DEFAULT_MODES, |
---|
227 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
228 | &Junk_id |
---|
229 | ); |
---|
230 | fatal_directive_status( |
---|
231 | status, |
---|
232 | RTEMS_TOO_MANY, |
---|
233 | "rtems_task_create for too many tasks" |
---|
234 | ); |
---|
235 | puts( "TA1 - rtems_task_create - 11 - RTEMS_TOO_MANY" ); |
---|
236 | |
---|
237 | /* |
---|
238 | * The check for an object being global is only made if |
---|
239 | * multiprocessing is enabled. |
---|
240 | */ |
---|
241 | |
---|
242 | #if defined(RTEMS_MULTIPROCESSING) |
---|
243 | status = rtems_task_create( |
---|
244 | task_name, |
---|
245 | 4, |
---|
246 | RTEMS_MINIMUM_STACK_SIZE, |
---|
247 | RTEMS_DEFAULT_MODES, |
---|
248 | RTEMS_GLOBAL, |
---|
249 | &Junk_id |
---|
250 | ); |
---|
251 | fatal_directive_status( |
---|
252 | status, |
---|
253 | RTEMS_MP_NOT_CONFIGURED, |
---|
254 | "rtems_task_create of global task in a single cpu system" |
---|
255 | ); |
---|
256 | #endif |
---|
257 | puts( "TA1 - rtems_task_create - RTEMS_MP_NOT_CONFIGURED" ); |
---|
258 | |
---|
259 | TEST_END(); |
---|
260 | } |
---|