[85c8e754] | 1 | /* |
---|
[6c2de60] | 2 | * COPYRIGHT (c) 1989-2012. |
---|
[85c8e754] | 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 |
---|
[c499856] | 7 | * http://www.rtems.org/license/LICENSE. |
---|
[85c8e754] | 8 | */ |
---|
| 9 | |
---|
[cafefbf] | 10 | #ifdef HAVE_CONFIG_H |
---|
| 11 | #include "config.h" |
---|
| 12 | #endif |
---|
| 13 | |
---|
[85c8e754] | 14 | #include <tmacros.h> |
---|
| 15 | #include "test_support.h" |
---|
| 16 | #include <sys/times.h> |
---|
| 17 | #include <errno.h> |
---|
| 18 | |
---|
[698c2e50] | 19 | const char rtems_test_name[] = "PSXTIMES 1"; |
---|
| 20 | |
---|
[6c2de60] | 21 | /* forward declarations to avoid warnings */ |
---|
| 22 | rtems_task Init(rtems_task_argument argument); |
---|
| 23 | clock_t _times_r(struct _reent *ptr, struct tms *ptms); |
---|
| 24 | clock_t _times(struct tms *ptms); |
---|
[85c8e754] | 25 | |
---|
| 26 | rtems_task Init( |
---|
| 27 | rtems_task_argument argument |
---|
| 28 | ) |
---|
| 29 | { |
---|
| 30 | clock_t start; |
---|
[11e69fc] | 31 | clock_t end; |
---|
[85c8e754] | 32 | clock_t now; |
---|
| 33 | clock_t sc; |
---|
| 34 | clock_t difference; |
---|
| 35 | struct tms start_tm; |
---|
| 36 | struct tms end_tm; |
---|
[1e51fa5] | 37 | int interval = 5; |
---|
[85c8e754] | 38 | |
---|
[698c2e50] | 39 | TEST_BEGIN(); |
---|
[85c8e754] | 40 | |
---|
| 41 | puts( "times( NULL ) -- EFAULT" ); |
---|
| 42 | sc = times( NULL ); |
---|
| 43 | rtems_test_assert( sc == -1 ); |
---|
| 44 | rtems_test_assert( errno == EFAULT ); |
---|
| 45 | |
---|
| 46 | puts( "_times_r( NULL, NULL ) -- EFAULT" ); |
---|
| 47 | start = _times_r( NULL, NULL ); |
---|
| 48 | rtems_test_assert( sc == -1 ); |
---|
| 49 | rtems_test_assert( errno == EFAULT ); |
---|
| 50 | |
---|
| 51 | while ( rtems_clock_get_ticks_since_boot() == 0 ) |
---|
| 52 | ; |
---|
| 53 | |
---|
| 54 | puts( "_times( &start_tm ) -- OK" ); |
---|
| 55 | now = _times( &start_tm ); |
---|
| 56 | rtems_test_assert( start != 0 ); |
---|
[ff7ff62] | 57 | rtems_test_assert( now != 0 ); |
---|
[85c8e754] | 58 | |
---|
[1e51fa5] | 59 | rtems_test_spin_for_ticks( interval ); |
---|
[85c8e754] | 60 | |
---|
| 61 | puts( "_times( &end_tm ) -- OK" ); |
---|
| 62 | end = _times( &end_tm ); |
---|
| 63 | rtems_test_assert( end != 0 ); |
---|
| 64 | |
---|
| 65 | puts( "Check various values" ); |
---|
| 66 | difference = end - start; |
---|
[1e51fa5] | 67 | rtems_test_assert( difference >= interval ); |
---|
[85c8e754] | 68 | |
---|
[1e51fa5] | 69 | rtems_test_assert( end_tm.tms_utime - start_tm.tms_utime >= interval ); |
---|
| 70 | rtems_test_assert( end_tm.tms_stime - start_tm.tms_stime >= interval ); |
---|
[85c8e754] | 71 | rtems_test_assert( end_tm.tms_cutime == 0 ); |
---|
| 72 | rtems_test_assert( end_tm.tms_cstime == 0 ); |
---|
| 73 | |
---|
[698c2e50] | 74 | TEST_END(); |
---|
[85c8e754] | 75 | |
---|
| 76 | rtems_test_exit(0); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | /* configuration information */ |
---|
| 80 | |
---|
| 81 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
| 82 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
| 83 | |
---|
| 84 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
[698c2e50] | 85 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
| 86 | |
---|
[85c8e754] | 87 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
| 88 | |
---|
| 89 | #define CONFIGURE_INIT |
---|
| 90 | |
---|
| 91 | #include <rtems/confdefs.h> |
---|
| 92 | /* end of file */ |
---|