1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2010. |
---|
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 <tmacros.h> |
---|
13 | #include "test_support.h" |
---|
14 | #include <sys/times.h> |
---|
15 | #include <errno.h> |
---|
16 | |
---|
17 | clock_t _times_r( |
---|
18 | struct _reent *ptr, |
---|
19 | struct tms *ptms |
---|
20 | ); |
---|
21 | |
---|
22 | clock_t _times( |
---|
23 | struct tms *ptms |
---|
24 | ); |
---|
25 | |
---|
26 | rtems_task Init( |
---|
27 | rtems_task_argument argument |
---|
28 | ) |
---|
29 | { |
---|
30 | clock_t start; |
---|
31 | clock_t now; |
---|
32 | clock_t sc; |
---|
33 | clock_t difference; |
---|
34 | struct tms start_tm; |
---|
35 | struct tms end_tm; |
---|
36 | |
---|
37 | puts( "\n\n*** TEST TIMES 01 ***" ); |
---|
38 | |
---|
39 | puts( "times( NULL ) -- EFAULT" ); |
---|
40 | sc = times( NULL ); |
---|
41 | rtems_test_assert( sc == -1 ); |
---|
42 | rtems_test_assert( errno == EFAULT ); |
---|
43 | |
---|
44 | puts( "_times_r( NULL, NULL ) -- EFAULT" ); |
---|
45 | start = _times_r( NULL, NULL ); |
---|
46 | rtems_test_assert( sc == -1 ); |
---|
47 | rtems_test_assert( errno == EFAULT ); |
---|
48 | |
---|
49 | while ( rtems_clock_get_ticks_since_boot() == 0 ) |
---|
50 | ; |
---|
51 | |
---|
52 | puts( "_times( &start_tm ) -- OK" ); |
---|
53 | now = _times( &start_tm ); |
---|
54 | rtems_test_assert( start != 0 ); |
---|
55 | |
---|
56 | rtems_test_spin_for_ticks(5); |
---|
57 | |
---|
58 | puts( "_times( &end_tm ) -- OK" ); |
---|
59 | end = _times( &end_tm ); |
---|
60 | rtems_test_assert( end != 0 ); |
---|
61 | |
---|
62 | puts( "Check various values" ); |
---|
63 | difference = end - start; |
---|
64 | rtems_test_assert( difference >= 5 ); |
---|
65 | |
---|
66 | rtems_test_assert( end_tm.tms_utime >= start_tm.tms_utime ); |
---|
67 | rtems_test_assert( end_tm.tms_stime >= start_tm.tms_stime ); |
---|
68 | rtems_test_assert( end_tm.tms_cutime == 0 ); |
---|
69 | rtems_test_assert( end_tm.tms_cstime == 0 ); |
---|
70 | |
---|
71 | puts( "*** END OF TEST TIMES 01 ***" ); |
---|
72 | |
---|
73 | rtems_test_exit(0); |
---|
74 | } |
---|
75 | |
---|
76 | /* configuration information */ |
---|
77 | |
---|
78 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
79 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
80 | |
---|
81 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
82 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
83 | |
---|
84 | #define CONFIGURE_INIT |
---|
85 | |
---|
86 | #include <rtems/confdefs.h> |
---|
87 | /* end of file */ |
---|