source: rtems/testsuites/sptests/sp09/screen02.c @ bfddb047

4.11
Last change on this file since bfddb047 was bfddb047, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 16, 2012 at 1:02:12 PM

rtems: Add rtems_clock_get_uptime_timeval()

  • Property mode set to 100644
File size: 8.2 KB
Line 
1/*  Screen2
2 *
3 *  This routine generates error screen 2 for test 9.
4 *
5 *  Input parameters:  NONE
6 *
7 *  Output parameters:  NONE
8 *
9 *  COPYRIGHT (c) 1989-2011.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#ifdef HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include "system.h"
22
23void Screen2()
24{
25  rtems_time_of_day time;
26  rtems_interval    interval;
27  struct timeval    tv;
28  rtems_status_code status;
29
30  puts( "TA1 - rtems_clock_get_tod - RTEMS_INVALID_ADDRESS" );
31  status = rtems_clock_get_tod( NULL );
32  fatal_directive_status(
33    status,
34    RTEMS_INVALID_ADDRESS,
35    "rtems_clock_get_tod NULL param"
36  );
37
38/* errors before clock is set */
39
40  status = rtems_clock_get_tod( &time );
41  if ( status == RTEMS_SUCCESSFUL ) {
42    puts(
43     "TA1 - rtems_clock_get_tod - RTEMS_NOT_DEFINED -- "
44         "DID BSP SET THE TIME OF DAY?"
45    );
46  } else {
47    fatal_directive_status(
48      status,
49      RTEMS_NOT_DEFINED,
50      "rtems_clock_get_tod before clock is set #1"
51    );
52    puts( "TA1 - rtems_clock_get_tod - RTEMS_NOT_DEFINED" );
53  }
54
55  puts( "TA1 - rtems_clock_get_seconds_since_epoch - RTEMS_INVALID_ADDRESS" );
56  status = rtems_clock_get_seconds_since_epoch( NULL );
57  fatal_directive_status(
58    status,
59    RTEMS_INVALID_ADDRESS,
60    "rtems_clock_get_seconds_since_epoch NULL param"
61  );
62
63  status = rtems_clock_get_seconds_since_epoch( &interval );
64  if ( status == RTEMS_SUCCESSFUL ) {
65    puts(
66     "TA1 - rtems_clock_get_seconds_since_epoch - RTEMS_NOT_DEFINED -- "
67         "DID BSP SET THE TIME OF DAY?"
68    );
69  } else {
70    fatal_directive_status(
71      status,
72      RTEMS_NOT_DEFINED,
73      "rtems_clock_get_seconds_before_epoch"
74    );
75    puts( "TA1 - rtems_clock_get_seconds_since_epoch - RTEMS_NOT_DEFINED" );
76  }
77
78  puts( "TA1 - rtems_clock_get_uptime - RTEMS_INVALID_ADDRESS" );
79  status = rtems_clock_get_uptime( NULL );
80  fatal_directive_status(
81    status,
82    RTEMS_INVALID_ADDRESS,
83    "rtems_clock_get_uptime NULL param"
84  );
85
86  puts( "TA1 - rtems_clock_get_uptime_timeval" );
87  rtems_clock_get_uptime_timeval( &tv );
88
89  puts( "TA1 - rtems_clock_get_tod_timeval - RTEMS_INVALID_ADDRESS" );
90  status = rtems_clock_get_tod_timeval( NULL );
91  fatal_directive_status(
92    status,
93    RTEMS_INVALID_ADDRESS,
94    "rtems_clock_get_tod_timeval NULL param"
95  );
96
97  status = rtems_clock_get_tod_timeval( &tv );
98  if ( status == RTEMS_SUCCESSFUL ) {
99    puts(
100     "TA1 - rtems_clock_get_tod_timeval - RTEMS_NOT_DEFINED -- "
101         "DID BSP SET THE TIME OF DAY?"
102    );
103  } else {
104    fatal_directive_status(
105      status,
106      RTEMS_NOT_DEFINED,
107      "rtems_clock_get_timeval"
108    );
109    puts( "TA1 - rtems_clock_get_tod_timeval - RTEMS_NOT_DEFINED" );
110  }
111
112  puts( "TA1 - rtems_clock_set_nanoseconds_extension - RTEMS_INVALID_ADDRESS" );
113  status = rtems_clock_set_nanoseconds_extension( NULL );
114  fatal_directive_status(
115    status,
116    RTEMS_INVALID_ADDRESS,
117    "rtems_clock_set_nanoseconds_extension NULL param"
118  );
119
120  /* NULL parameter */
121  status = rtems_clock_set( NULL );
122  fatal_directive_status(
123    status,
124    RTEMS_INVALID_ADDRESS,
125    "rtems_clock_set sull pointer"
126  );
127  puts( "TA1 - rtems_clock_set - RTEMS_INVALID_ADDRESS" );
128
129  /* wake when NULL param */
130  status = rtems_task_wake_when( NULL );
131  fatal_directive_status(
132    status,
133    RTEMS_NOT_DEFINED,
134    "rtems_task_wake_when NULL param"
135  );
136  puts( "TA1 - rtems_task_wake_when - RTEMS_INVALID_ADDRESS" );
137
138  /* wake when before set */
139  status = rtems_task_wake_when( &time );
140  if ( status == RTEMS_SUCCESSFUL ) {
141    puts(
142     "TA1 - rtems_task_wake_when - RTEMS_NOT_DEFINED -- "
143         "DID BSP SET THE TIME OF DAY?"
144    );
145  } else {
146    fatal_directive_status(
147      status,
148      RTEMS_NOT_DEFINED,
149      "rtems_task_wake_when before clock is set"
150    );
151    puts( "TA1 - rtems_task_wake_when - RTEMS_NOT_DEFINED" );
152  }
153
154  /* before time set */
155  status = rtems_timer_fire_when( 0, &time, Delayed_routine, NULL );
156  if ( status == RTEMS_SUCCESSFUL ) {
157    puts(
158    "TA1 - timer_wake_when - RTEMS_NOT_DEFINED -- DID BSP SET THE TIME OF DAY?"
159    );
160  } else {
161    fatal_directive_status(
162      status,
163      RTEMS_NOT_DEFINED,
164      "task_fire_when before clock is set"
165    );
166    puts( "TA1 - rtems_timer_fire_when - RTEMS_NOT_DEFINED" );
167  }
168
169  build_time( &time, 2, 5, 1987, 8, 30, 45, 0 );
170  print_time( "TA1 - rtems_clock_set - ", &time, "" );
171  status = rtems_clock_set( &time );
172  fatal_directive_status(
173    status,
174    RTEMS_INVALID_CLOCK,
175    "rtems_clock_set with invalid year"
176  );
177  puts( " - RTEMS_INVALID_CLOCK" );
178
179  build_time( &time, 15, 5, 1988, 8, 30, 45, 0 );
180  print_time( "TA1 - rtems_clock_set - ", &time, "" );
181  status = rtems_clock_set( &time );
182  fatal_directive_status(
183    status,
184    RTEMS_INVALID_CLOCK,
185    "rtems_clock_set with invalid month"
186  );
187  puts( " - RTEMS_INVALID_CLOCK" );
188
189  build_time( &time, 2, 32, 1988, 8, 30, 45, 0 );
190  print_time( "TA1 - rtems_clock_set - ", &time, "" );
191  status = rtems_clock_set( &time );
192  fatal_directive_status(
193    status,
194    RTEMS_INVALID_CLOCK,
195    "rtems_clock_set with invalid day"
196  );
197  puts( " - RTEMS_INVALID_CLOCK" );
198
199  build_time( &time, 2, 5, 1988, 25, 30, 45, 0 );
200  print_time( "TA1 - rtems_clock_set - ", &time, "" );
201  status = rtems_clock_set( &time );
202  fatal_directive_status(
203    status,
204    RTEMS_INVALID_CLOCK,
205    "rtems_clock_set with invalid hour"
206  );
207  puts( " - RTEMS_INVALID_CLOCK" );
208
209  build_time( &time, 2, 5, 1988, 8, 61, 45, 0 );
210  print_time( "TA1 - rtems_clock_set - ", &time, "" );
211  status = rtems_clock_set( &time );
212  fatal_directive_status(
213    status,
214    RTEMS_INVALID_CLOCK,
215    "rtems_clock_set with invalid minute"
216  );
217  puts( " - RTEMS_INVALID_CLOCK" );
218
219  build_time( &time, 2, 5, 1988, 8, 30, 61, 0 );
220  print_time( "TA1 - rtems_clock_set - ", &time, "" );
221  status = rtems_clock_set( &time );
222  fatal_directive_status(
223    status,
224    RTEMS_INVALID_CLOCK,
225    "rtems_clock_set with invalid second"
226  );
227  puts( " - RTEMS_INVALID_CLOCK" );
228
229  build_time(
230    &time, 2, 5, 1988, 8, 30, 45,
231    rtems_clock_get_ticks_per_second() + 1
232  );
233  print_time( "TA1 - rtems_clock_set - ", &time, "" );
234  status = rtems_clock_set( &time );
235  fatal_directive_status(
236    status,
237    RTEMS_INVALID_CLOCK,
238    "rtems_clock_set with invalid ticks per second"
239  );
240  puts( " - RTEMS_INVALID_CLOCK" );
241
242  build_time( &time, 2, 5, 1988, 8, 30, 45, 0 );
243  print_time( "TA1 - rtems_clock_set - ", &time, "" );
244  status = rtems_clock_set( &time );
245  directive_failed( status, "rtems_clock_set successful" );
246  puts( " - RTEMS_SUCCESSFUL" );
247
248/* rtems_task_wake_when */
249
250  build_time(
251    &time,
252    2, 5, 1988, 8, 30, 48,
253    rtems_clock_get_ticks_per_second() + 1
254  );
255  time.second += 3;
256  puts( "TA1 - rtems_task_wake_when - TICKINVALID - sleep about 3 seconds" );
257
258  /* NULL time */
259  status = rtems_task_wake_when( NULL );
260  fatal_directive_status(
261    status,
262    RTEMS_INVALID_ADDRESS,
263    "rtems_task_wake_when with NULL"
264  );
265  puts( "TA1 - rtems_task_wake_when - RTEMS_INVALID_ADDRESS" );
266
267  /* invalid ticks */
268  status = rtems_task_wake_when( &time );
269  directive_failed(
270    status,
271    "rtems_task_wake_when with invalid ticks per second"
272  );
273  puts( "TA1 - rtems_task_wake_when - TICKINVALID - woke up RTEMS_SUCCESSFUL" );
274
275  build_time( &time, 2, 5, 1961, 8, 30, 48, 0 );
276  print_time( "TA1 - rtems_task_wake_when - ", &time, "" );
277  status = rtems_task_wake_when( &time );
278  fatal_directive_status(
279    status,
280    RTEMS_INVALID_CLOCK,
281    "rtems_task_wake_when with invalid year"
282  );
283  puts( " - RTEMS_INVALID_CLOCK" );
284
285  build_time( &time, 2, 5, 1988, 25, 30, 48, 0 );
286  print_time( "TA1 - rtems_task_wake_when - ", &time, "" );
287  status = rtems_task_wake_when( &time );
288  fatal_directive_status(
289    status,
290    RTEMS_INVALID_CLOCK,
291    "rtems_task_wake_when with invalid hour"
292  );
293  puts( " - RTEMS_INVALID_CLOCK" );
294
295  rtems_clock_get_tod( &time );
296  print_time( "TA1 - current time - ", &time, "\n" );
297
298  time.month = 1;
299  print_time( "TA1 - rtems_task_wake_when - ", &time, "" );
300  status = rtems_task_wake_when( &time );
301  fatal_directive_status(
302    status,
303    RTEMS_INVALID_CLOCK,
304    "rtems_task_wake_when before current time"
305  );
306  puts( " - RTEMS_INVALID_CLOCK" );
307}
Note: See TracBrowser for help on using the repository browser.