1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2012. |
---|
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 <pmacros.h> |
---|
15 | #include <time.h> |
---|
16 | #include <errno.h> |
---|
17 | |
---|
18 | const char rtems_test_name[] = "PSXUSLEEP"; |
---|
19 | |
---|
20 | /* forward declarations to avoid warnings */ |
---|
21 | rtems_task Init(rtems_task_argument argument); |
---|
22 | |
---|
23 | rtems_task Init( |
---|
24 | rtems_task_argument argument |
---|
25 | ) |
---|
26 | { |
---|
27 | struct tm tm; |
---|
28 | struct timespec tv; |
---|
29 | useconds_t remaining; |
---|
30 | int sc; |
---|
31 | |
---|
32 | TEST_BEGIN(); |
---|
33 | |
---|
34 | tm_build_time( &tm, TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 ); |
---|
35 | |
---|
36 | /* set the time of day, and print our buffer in multiple ways */ |
---|
37 | |
---|
38 | tv.tv_nsec = 0; |
---|
39 | tv.tv_sec = mktime( &tm ); |
---|
40 | rtems_test_assert( tv.tv_sec != -1 ); |
---|
41 | |
---|
42 | /* now set the time of day */ |
---|
43 | |
---|
44 | printf( asctime( &tm ) ); |
---|
45 | puts( "Init: clock_settime - SUCCESSFUL" ); |
---|
46 | sc = clock_settime( CLOCK_REALTIME, &tv ); |
---|
47 | rtems_test_assert( !sc ); |
---|
48 | |
---|
49 | printf( asctime( &tm ) ); |
---|
50 | printf( ctime( &tv.tv_sec ) ); |
---|
51 | |
---|
52 | /* use sleep to delay */ |
---|
53 | |
---|
54 | remaining = usleep( 3 * 1000000 ); |
---|
55 | rtems_test_assert( !remaining ); |
---|
56 | |
---|
57 | sc = clock_gettime( CLOCK_REALTIME, &tv ); |
---|
58 | rtems_test_assert( !sc ); |
---|
59 | |
---|
60 | printf( ctime( &tv.tv_sec ) ); |
---|
61 | |
---|
62 | TEST_END(); |
---|
63 | rtems_test_exit(0); |
---|
64 | } |
---|
65 | |
---|
66 | |
---|
67 | /* configuration information */ |
---|
68 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
69 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
70 | |
---|
71 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
72 | |
---|
73 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
74 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
75 | |
---|
76 | #define CONFIGURE_INIT |
---|
77 | #include <rtems/confdefs.h> |
---|