1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2009. |
---|
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.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #include <pmacros.h> |
---|
13 | #include <time.h> |
---|
14 | #include <errno.h> |
---|
15 | |
---|
16 | rtems_task Init( |
---|
17 | rtems_task_argument argument |
---|
18 | ) |
---|
19 | { |
---|
20 | struct tm tm; |
---|
21 | struct timespec tv; |
---|
22 | useconds_t remaining; |
---|
23 | int sc; |
---|
24 | |
---|
25 | puts( "\n\n*** POSIX USLEEP TEST ***" ); |
---|
26 | |
---|
27 | tm_build_time( &tm, TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 ); |
---|
28 | |
---|
29 | /* set the time of day, and print our buffer in multiple ways */ |
---|
30 | |
---|
31 | tv.tv_nsec = 0; |
---|
32 | tv.tv_sec = mktime( &tm ); |
---|
33 | rtems_test_assert( tv.tv_sec != -1 ); |
---|
34 | |
---|
35 | /* now set the time of day */ |
---|
36 | |
---|
37 | printf( asctime( &tm ) ); |
---|
38 | puts( "Init: clock_settime - SUCCESSFUL" ); |
---|
39 | sc = clock_settime( CLOCK_REALTIME, &tv ); |
---|
40 | rtems_test_assert( !sc ); |
---|
41 | |
---|
42 | printf( asctime( &tm ) ); |
---|
43 | printf( ctime( &tv.tv_sec ) ); |
---|
44 | |
---|
45 | /* use sleep to delay */ |
---|
46 | |
---|
47 | remaining = usleep( 3 * 1000000 ); |
---|
48 | rtems_test_assert( !remaining ); |
---|
49 | |
---|
50 | sc = clock_gettime( CLOCK_REALTIME, &tv ); |
---|
51 | rtems_test_assert( !sc ); |
---|
52 | |
---|
53 | printf( ctime( &tv.tv_sec ) ); |
---|
54 | |
---|
55 | puts( "*** END OF POSIX USLEEP TEST ***" ); |
---|
56 | rtems_test_exit(0); |
---|
57 | } |
---|
58 | |
---|
59 | |
---|
60 | /* configuration information */ |
---|
61 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
62 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
63 | |
---|
64 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
65 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
66 | |
---|
67 | #define CONFIGURE_INIT |
---|
68 | #include <rtems/confdefs.h> |
---|