source: rtems/testsuites/psxtests/psxtimes01/init.c @ 698c2e50

4.115
Last change on this file since 698c2e50 was 698c2e50, checked in by Sebastian Huber <sebastian.huber@…>, on 03/25/14 at 07:06:16

tests/psxtests: Use <rtems/test.h>

  • Property mode set to 100644
File size: 2.2 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
19const char rtems_test_name[] = "PSXTIMES 1";
20
21/* forward declarations to avoid warnings */
22rtems_task Init(rtems_task_argument argument);
23clock_t _times_r(struct _reent *ptr, struct tms  *ptms);
24clock_t _times(struct tms  *ptms);
25
26rtems_task Init(
27  rtems_task_argument argument
28)
29{
30  clock_t    start;
31  clock_t    end;
32  clock_t    now;
33  clock_t    sc;
34  clock_t    difference;
35  struct tms start_tm;
36  struct tms end_tm;
37  int        interval = 5;
38
39  TEST_BEGIN();
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 );
57  rtems_test_assert( now != 0 );
58 
59  rtems_test_spin_for_ticks( interval );
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;
67  rtems_test_assert( difference >= interval );
68
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 );
71  rtems_test_assert( end_tm.tms_cutime == 0 );
72  rtems_test_assert( end_tm.tms_cstime == 0 );
73 
74  TEST_END();
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
85#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
86
87#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
88
89#define CONFIGURE_INIT
90
91#include <rtems/confdefs.h>
92/* end of file */
Note: See TracBrowser for help on using the repository browser.