1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2013. |
---|
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 | #include <tmacros.h> |
---|
15 | #include "test_support.h" |
---|
16 | |
---|
17 | const char rtems_test_name[] = "SPTIMER_ERR 2"; |
---|
18 | |
---|
19 | /* forward declarations to avoid warnings */ |
---|
20 | rtems_task Init(rtems_task_argument argument); |
---|
21 | rtems_timer_service_routine Delayed_routine( |
---|
22 | rtems_id ignored_id, |
---|
23 | void *ignored_address |
---|
24 | ); |
---|
25 | |
---|
26 | rtems_task Init( |
---|
27 | rtems_task_argument argument |
---|
28 | ) |
---|
29 | { |
---|
30 | TEST_BEGIN(); |
---|
31 | |
---|
32 | rtems_status_code status; |
---|
33 | rtems_time_of_day time; |
---|
34 | rtems_id timer_id; |
---|
35 | rtems_name timer_name; |
---|
36 | bool skipUnsatisfied; |
---|
37 | |
---|
38 | /* Set System time */ |
---|
39 | build_time( &time, 12, 31, 1992, 9, 0, 0, 0 ); |
---|
40 | status = rtems_clock_set( &time ); |
---|
41 | directive_failed( status, "rtems_clock_set" ); |
---|
42 | |
---|
43 | timer_name = rtems_build_name( 'T', 'M', '1', ' ' ); |
---|
44 | |
---|
45 | /* OK */ |
---|
46 | status = rtems_timer_create( timer_name, &timer_id ); |
---|
47 | directive_failed( status, "rtems_timer_create" ); |
---|
48 | puts( "TA1 - rtems_timer_create - 1 - RTEMS_SUCCESSFUL" ); |
---|
49 | |
---|
50 | /* incorrect state */ |
---|
51 | status = rtems_timer_server_fire_after( 0, 5, NULL, NULL ); |
---|
52 | fatal_directive_status( |
---|
53 | status, |
---|
54 | RTEMS_INCORRECT_STATE, |
---|
55 | "rtems_timer_server_fire_after incorrect state" |
---|
56 | ); |
---|
57 | puts( "TA1 - rtems_timer_server_fire_after - RTEMS_INCORRECT_STATE" ); |
---|
58 | |
---|
59 | /* incorrect state */ |
---|
60 | status = rtems_timer_server_fire_when( 0, &time, NULL, NULL ); |
---|
61 | fatal_directive_status( |
---|
62 | status, |
---|
63 | RTEMS_INCORRECT_STATE, |
---|
64 | "rtems_timer_server_fire_when incorrect state" |
---|
65 | ); |
---|
66 | puts( "TA1 - rtems_timer_server_fire_when - RTEMS_INCORRECT_STATE" ); |
---|
67 | |
---|
68 | /* invalid priority */ |
---|
69 | status = rtems_timer_initiate_server( UINT32_MAX - 1, 0, 0 ); |
---|
70 | fatal_directive_status( |
---|
71 | status, |
---|
72 | RTEMS_INVALID_PRIORITY, |
---|
73 | "rtems_timer_initiate_server invalid priority" |
---|
74 | ); |
---|
75 | puts( "TA1 - rtems_timer_initiate_server - RTEMS_INVALID_PRIORITY" ); |
---|
76 | |
---|
77 | skipUnsatisfied = false; |
---|
78 | #if defined(__m32c__) |
---|
79 | skipUnsatisfied = true; |
---|
80 | #endif |
---|
81 | if (skipUnsatisfied) { |
---|
82 | puts( "TA1 - rtems_timer_initiate_server - RTEMS_UNSATISFIED -- SKIPPED" ); |
---|
83 | } else { |
---|
84 | status = rtems_timer_initiate_server( |
---|
85 | RTEMS_TIMER_SERVER_DEFAULT_PRIORITY, |
---|
86 | 0x10000000, |
---|
87 | 0 |
---|
88 | ); |
---|
89 | fatal_directive_status( |
---|
90 | status, |
---|
91 | RTEMS_UNSATISFIED, |
---|
92 | "rtems_timer_initiate_server too much stack " |
---|
93 | ); |
---|
94 | puts( "TA1 - rtems_timer_initiate_server - RTEMS_UNSATISFIED" ); |
---|
95 | } |
---|
96 | |
---|
97 | status = |
---|
98 | rtems_timer_initiate_server( RTEMS_TIMER_SERVER_DEFAULT_PRIORITY, 0, 0 ); |
---|
99 | directive_failed( status, "rtems_timer_initiate_server" ); |
---|
100 | puts( "TA1 - rtems_timer_initiate_server - SUCCESSFUL" ); |
---|
101 | |
---|
102 | /* NULL routine */ |
---|
103 | status = rtems_timer_server_fire_after( timer_id, 1, NULL, NULL ); |
---|
104 | fatal_directive_status( |
---|
105 | status, |
---|
106 | RTEMS_INVALID_ADDRESS, |
---|
107 | "rtems_timer_server_fire_after NULL routine" |
---|
108 | ); |
---|
109 | puts( "TA1 - rtems_timer_server_fire_after - RTEMS_INVALID_ADDRESS" ); |
---|
110 | |
---|
111 | /* bad Id */ |
---|
112 | status = rtems_timer_server_fire_after( |
---|
113 | rtems_build_id( 1, 1, 1, 256 ), |
---|
114 | 5 * rtems_clock_get_ticks_per_second(), |
---|
115 | Delayed_routine, |
---|
116 | NULL |
---|
117 | ); |
---|
118 | fatal_directive_status( |
---|
119 | status, |
---|
120 | RTEMS_INVALID_ID, |
---|
121 | "rtems_timer_server_fire_after illegal id" |
---|
122 | ); |
---|
123 | puts( "TA1 - rtems_timer_server_fire_after - RTEMS_INVALID_ID" ); |
---|
124 | |
---|
125 | /* bad id */ |
---|
126 | build_time( &time, 12, 31, 1994, 9, 0, 0, 0 ); |
---|
127 | status = rtems_timer_server_fire_when( |
---|
128 | rtems_build_id( 1, 1, 1, 256 ), |
---|
129 | &time, |
---|
130 | Delayed_routine, |
---|
131 | NULL |
---|
132 | ); |
---|
133 | fatal_directive_status( |
---|
134 | status, |
---|
135 | RTEMS_INVALID_ID, |
---|
136 | "rtems_timer_server_fire_when with illegal id" |
---|
137 | ); |
---|
138 | puts( "TA1 - rtems_timer_server_fire_when - RTEMS_INVALID_ID" ); |
---|
139 | |
---|
140 | /* NULL routine */ |
---|
141 | status = rtems_timer_server_fire_after( timer_id, 1, NULL, NULL ); |
---|
142 | fatal_directive_status( |
---|
143 | status, |
---|
144 | RTEMS_INVALID_ADDRESS, |
---|
145 | "rtems_timer_server_fire_after NULL routine" |
---|
146 | ); |
---|
147 | puts( "TA1 - rtems_timer_server_fire_after - RTEMS_INVALID_ADDRESS" ); |
---|
148 | |
---|
149 | /* 0 ticks */ |
---|
150 | status = rtems_timer_server_fire_after( |
---|
151 | timer_id, 0, Delayed_routine, NULL ); |
---|
152 | fatal_directive_status( |
---|
153 | status, |
---|
154 | RTEMS_INVALID_NUMBER, |
---|
155 | "rtems_timer_server_fire_after with 0 ticks" |
---|
156 | ); |
---|
157 | puts( "TA1 - rtems_timer_server_fire_after - RTEMS_INVALID_NUMBER" ); |
---|
158 | |
---|
159 | /* illegal time */ |
---|
160 | build_time( &time, 2, 5, 1987, 8, 30, 45, 0 ); |
---|
161 | status = rtems_timer_server_fire_when( |
---|
162 | timer_id, &time, Delayed_routine, NULL ); |
---|
163 | fatal_directive_status( |
---|
164 | status, |
---|
165 | RTEMS_INVALID_CLOCK, |
---|
166 | "rtems_timer_server_fire_when with illegal time" |
---|
167 | ); |
---|
168 | print_time( |
---|
169 | "TA1 - rtems_timer_server_fire_when - ", |
---|
170 | &time, |
---|
171 | " - RTEMS_INVALID_CLOCK\n" |
---|
172 | ); |
---|
173 | |
---|
174 | status = rtems_clock_get_tod( &time ); |
---|
175 | directive_failed( status, "rtems_clock_get_tod" ); |
---|
176 | print_time( "TA1 - rtems_clock_get_tod - ", &time, "\n" ); |
---|
177 | |
---|
178 | /* when NULL routine */ |
---|
179 | status = rtems_timer_server_fire_when( timer_id, &time, NULL, NULL ); |
---|
180 | fatal_directive_status( |
---|
181 | status, |
---|
182 | RTEMS_INVALID_ADDRESS, |
---|
183 | "rtems_timer_server_fire_when NULL routine" |
---|
184 | ); |
---|
185 | puts( "TA1 - rtems_timer_server_fire_when - RTEMS_INVALID_ADDRESS" ); |
---|
186 | |
---|
187 | /* before current time */ |
---|
188 | build_time( &time, 2, 5, 1990, 8, 30, 45, 0 ); |
---|
189 | status = rtems_timer_server_fire_when( |
---|
190 | timer_id, &time, Delayed_routine, NULL ); |
---|
191 | fatal_directive_status( |
---|
192 | status, |
---|
193 | RTEMS_INVALID_CLOCK, |
---|
194 | "rtems_timer_server_fire_when before current time" |
---|
195 | ); |
---|
196 | print_time( |
---|
197 | "TA1 - rtems_timer_server_fire_when - ", |
---|
198 | &time, |
---|
199 | " - before RTEMS_INVALID_CLOCK\n" |
---|
200 | ); |
---|
201 | |
---|
202 | TEST_END(); |
---|
203 | |
---|
204 | rtems_test_exit(0); |
---|
205 | } |
---|
206 | |
---|
207 | rtems_timer_service_routine Delayed_routine( |
---|
208 | rtems_id ignored_id, |
---|
209 | void *ignored_address |
---|
210 | ) |
---|
211 | { |
---|
212 | /* Empty routine that gets passed to rtems_timer_fire_when */ |
---|
213 | } |
---|
214 | |
---|
215 | #define CONFIGURE_INIT |
---|
216 | /* configuration information */ |
---|
217 | |
---|
218 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
219 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
220 | |
---|
221 | /* Two Tasks: Init and Timer Server */ |
---|
222 | #define CONFIGURE_MAXIMUM_TASKS 2 |
---|
223 | #define CONFIGURE_MAXIMUM_TIMERS 1 |
---|
224 | #define CONFIGURE_INIT_TASK_STACK_SIZE (RTEMS_MINIMUM_STACK_SIZE * 2) |
---|
225 | |
---|
226 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
227 | |
---|
228 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
229 | |
---|
230 | #define CONFIGURE_EXTRA_TASK_STACKS (1 * RTEMS_MINIMUM_STACK_SIZE) |
---|
231 | |
---|
232 | #include <rtems/confdefs.h> |
---|