source: rtems/testsuites/psxtests/psxtimes01/init.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.1 KB
Line 
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 <tmacros.h>
15#include "test_support.h"
16#include <sys/times.h>
17#include <errno.h>
18
19/* forward declarations to avoid warnings */
20rtems_task Init(rtems_task_argument argument);
21clock_t _times_r(struct _reent *ptr, struct tms  *ptms);
22clock_t _times(struct tms  *ptms);
23
24rtems_task Init(
25  rtems_task_argument argument
26)
27{
28  clock_t    start;
29  clock_t    end;
30  clock_t    now;
31  clock_t    sc;
32  clock_t    difference;
33  struct tms start_tm;
34  struct tms end_tm;
35  int        interval = 5;
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  rtems_test_assert( now != 0 );
56 
57  rtems_test_spin_for_ticks( interval );
58
59  puts( "_times( &end_tm ) -- OK" );
60  end = _times( &end_tm );
61  rtems_test_assert( end != 0 );
62 
63  puts( "Check various values" );
64  difference = end - start;
65  rtems_test_assert( difference >= interval );
66
67  rtems_test_assert( end_tm.tms_utime - start_tm.tms_utime >= interval );
68  rtems_test_assert( end_tm.tms_stime - start_tm.tms_stime >= interval );
69  rtems_test_assert( end_tm.tms_cutime == 0 );
70  rtems_test_assert( end_tm.tms_cstime == 0 );
71 
72  puts( "*** END OF TEST TIMES 01 ***" );
73
74  rtems_test_exit(0);
75}
76
77/* configuration information */
78
79#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
80#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
81
82#define CONFIGURE_MAXIMUM_TASKS             1
83#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
84
85#define CONFIGURE_INIT
86
87#include <rtems/confdefs.h>
88/* end of file */
Note: See TracBrowser for help on using the repository browser.