source: rtems/testsuites/sptests/sp09/screen02.c @ 90733a86

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

rtems: Add rtems_clock_get_uptime_seconds()

  • Property mode set to 100644
File size: 8.3 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_uptime_seconds" );
90  rtems_clock_get_uptime_seconds();
91
92  puts( "TA1 - rtems_clock_get_tod_timeval - RTEMS_INVALID_ADDRESS" );
93  status = rtems_clock_get_tod_timeval( NULL );
94  fatal_directive_status(
95    status,
96    RTEMS_INVALID_ADDRESS,
97    "rtems_clock_get_tod_timeval NULL param"
98  );
99
100  status = rtems_clock_get_tod_timeval( &tv );
101  if ( status == RTEMS_SUCCESSFUL ) {
102    puts(
103     "TA1 - rtems_clock_get_tod_timeval - RTEMS_NOT_DEFINED -- "
104         "DID BSP SET THE TIME OF DAY?"
105    );
106  } else {
107    fatal_directive_status(
108      status,
109      RTEMS_NOT_DEFINED,
110      "rtems_clock_get_timeval"
111    );
112    puts( "TA1 - rtems_clock_get_tod_timeval - RTEMS_NOT_DEFINED" );
113  }
114
115  puts( "TA1 - rtems_clock_set_nanoseconds_extension - RTEMS_INVALID_ADDRESS" );
116  status = rtems_clock_set_nanoseconds_extension( NULL );
117  fatal_directive_status(
118    status,
119    RTEMS_INVALID_ADDRESS,
120    "rtems_clock_set_nanoseconds_extension NULL param"
121  );
122
123  /* NULL parameter */
124  status = rtems_clock_set( NULL );
125  fatal_directive_status(
126    status,
127    RTEMS_INVALID_ADDRESS,
128    "rtems_clock_set sull pointer"
129  );
130  puts( "TA1 - rtems_clock_set - RTEMS_INVALID_ADDRESS" );
131
132  /* wake when NULL param */
133  status = rtems_task_wake_when( NULL );
134  fatal_directive_status(
135    status,
136    RTEMS_NOT_DEFINED,
137    "rtems_task_wake_when NULL param"
138  );
139  puts( "TA1 - rtems_task_wake_when - RTEMS_INVALID_ADDRESS" );
140
141  /* wake when before set */
142  status = rtems_task_wake_when( &time );
143  if ( status == RTEMS_SUCCESSFUL ) {
144    puts(
145     "TA1 - rtems_task_wake_when - RTEMS_NOT_DEFINED -- "
146         "DID BSP SET THE TIME OF DAY?"
147    );
148  } else {
149    fatal_directive_status(
150      status,
151      RTEMS_NOT_DEFINED,
152      "rtems_task_wake_when before clock is set"
153    );
154    puts( "TA1 - rtems_task_wake_when - RTEMS_NOT_DEFINED" );
155  }
156
157  /* before time set */
158  status = rtems_timer_fire_when( 0, &time, Delayed_routine, NULL );
159  if ( status == RTEMS_SUCCESSFUL ) {
160    puts(
161    "TA1 - timer_wake_when - RTEMS_NOT_DEFINED -- DID BSP SET THE TIME OF DAY?"
162    );
163  } else {
164    fatal_directive_status(
165      status,
166      RTEMS_NOT_DEFINED,
167      "task_fire_when before clock is set"
168    );
169    puts( "TA1 - rtems_timer_fire_when - RTEMS_NOT_DEFINED" );
170  }
171
172  build_time( &time, 2, 5, 1987, 8, 30, 45, 0 );
173  print_time( "TA1 - rtems_clock_set - ", &time, "" );
174  status = rtems_clock_set( &time );
175  fatal_directive_status(
176    status,
177    RTEMS_INVALID_CLOCK,
178    "rtems_clock_set with invalid year"
179  );
180  puts( " - RTEMS_INVALID_CLOCK" );
181
182  build_time( &time, 15, 5, 1988, 8, 30, 45, 0 );
183  print_time( "TA1 - rtems_clock_set - ", &time, "" );
184  status = rtems_clock_set( &time );
185  fatal_directive_status(
186    status,
187    RTEMS_INVALID_CLOCK,
188    "rtems_clock_set with invalid month"
189  );
190  puts( " - RTEMS_INVALID_CLOCK" );
191
192  build_time( &time, 2, 32, 1988, 8, 30, 45, 0 );
193  print_time( "TA1 - rtems_clock_set - ", &time, "" );
194  status = rtems_clock_set( &time );
195  fatal_directive_status(
196    status,
197    RTEMS_INVALID_CLOCK,
198    "rtems_clock_set with invalid day"
199  );
200  puts( " - RTEMS_INVALID_CLOCK" );
201
202  build_time( &time, 2, 5, 1988, 25, 30, 45, 0 );
203  print_time( "TA1 - rtems_clock_set - ", &time, "" );
204  status = rtems_clock_set( &time );
205  fatal_directive_status(
206    status,
207    RTEMS_INVALID_CLOCK,
208    "rtems_clock_set with invalid hour"
209  );
210  puts( " - RTEMS_INVALID_CLOCK" );
211
212  build_time( &time, 2, 5, 1988, 8, 61, 45, 0 );
213  print_time( "TA1 - rtems_clock_set - ", &time, "" );
214  status = rtems_clock_set( &time );
215  fatal_directive_status(
216    status,
217    RTEMS_INVALID_CLOCK,
218    "rtems_clock_set with invalid minute"
219  );
220  puts( " - RTEMS_INVALID_CLOCK" );
221
222  build_time( &time, 2, 5, 1988, 8, 30, 61, 0 );
223  print_time( "TA1 - rtems_clock_set - ", &time, "" );
224  status = rtems_clock_set( &time );
225  fatal_directive_status(
226    status,
227    RTEMS_INVALID_CLOCK,
228    "rtems_clock_set with invalid second"
229  );
230  puts( " - RTEMS_INVALID_CLOCK" );
231
232  build_time(
233    &time, 2, 5, 1988, 8, 30, 45,
234    rtems_clock_get_ticks_per_second() + 1
235  );
236  print_time( "TA1 - rtems_clock_set - ", &time, "" );
237  status = rtems_clock_set( &time );
238  fatal_directive_status(
239    status,
240    RTEMS_INVALID_CLOCK,
241    "rtems_clock_set with invalid ticks per second"
242  );
243  puts( " - RTEMS_INVALID_CLOCK" );
244
245  build_time( &time, 2, 5, 1988, 8, 30, 45, 0 );
246  print_time( "TA1 - rtems_clock_set - ", &time, "" );
247  status = rtems_clock_set( &time );
248  directive_failed( status, "rtems_clock_set successful" );
249  puts( " - RTEMS_SUCCESSFUL" );
250
251/* rtems_task_wake_when */
252
253  build_time(
254    &time,
255    2, 5, 1988, 8, 30, 48,
256    rtems_clock_get_ticks_per_second() + 1
257  );
258  time.second += 3;
259  puts( "TA1 - rtems_task_wake_when - TICKINVALID - sleep about 3 seconds" );
260
261  /* NULL time */
262  status = rtems_task_wake_when( NULL );
263  fatal_directive_status(
264    status,
265    RTEMS_INVALID_ADDRESS,
266    "rtems_task_wake_when with NULL"
267  );
268  puts( "TA1 - rtems_task_wake_when - RTEMS_INVALID_ADDRESS" );
269
270  /* invalid ticks */
271  status = rtems_task_wake_when( &time );
272  directive_failed(
273    status,
274    "rtems_task_wake_when with invalid ticks per second"
275  );
276  puts( "TA1 - rtems_task_wake_when - TICKINVALID - woke up RTEMS_SUCCESSFUL" );
277
278  build_time( &time, 2, 5, 1961, 8, 30, 48, 0 );
279  print_time( "TA1 - rtems_task_wake_when - ", &time, "" );
280  status = rtems_task_wake_when( &time );
281  fatal_directive_status(
282    status,
283    RTEMS_INVALID_CLOCK,
284    "rtems_task_wake_when with invalid year"
285  );
286  puts( " - RTEMS_INVALID_CLOCK" );
287
288  build_time( &time, 2, 5, 1988, 25, 30, 48, 0 );
289  print_time( "TA1 - rtems_task_wake_when - ", &time, "" );
290  status = rtems_task_wake_when( &time );
291  fatal_directive_status(
292    status,
293    RTEMS_INVALID_CLOCK,
294    "rtems_task_wake_when with invalid hour"
295  );
296  puts( " - RTEMS_INVALID_CLOCK" );
297
298  rtems_clock_get_tod( &time );
299  print_time( "TA1 - current time - ", &time, "\n" );
300
301  time.month = 1;
302  print_time( "TA1 - rtems_task_wake_when - ", &time, "" );
303  status = rtems_task_wake_when( &time );
304  fatal_directive_status(
305    status,
306    RTEMS_INVALID_CLOCK,
307    "rtems_task_wake_when before current time"
308  );
309  puts( " - RTEMS_INVALID_CLOCK" );
310}
Note: See TracBrowser for help on using the repository browser.