source: rtems/testsuites/sptests/sp32/init.c @ 378aed9

4.104.114.84.95
Last change on this file since 378aed9 was 378aed9, checked in by Joel Sherrill <joel.sherrill@…>, on 03/30/04 at 19:20:59

2004-03-30 David Querbach <querbach@…>

PR 596/tests

  • sp32/init.c: A missing definition of TEST_INIT before including <tmacros.h> means that buffered output will not work even if selected in buffer_test_io.h.
  • Property mode set to 100644
File size: 2.7 KB
Line 
1/* spmonotonic -- sanity check the rate monotonic manager
2 *
3 * license and distribution terms for this file may be found in the file
4 * LICENSE in this distribution or at
5 * http://www.rtems.com/license/LICENSE .
6 *
7 * $Id$
8 */
9
10#define TEST_INIT
11#include <tmacros.h>  /* includes bsp.h, stdio, etc... */
12
13/* prototype */
14rtems_task Init (rtems_task_argument ignored);
15
16#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
17
18#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
19#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
20#define CONFIGURE_MAXIMUM_TASKS                         1
21#define CONFIGURE_MAXIMUM_PERIODS               1
22
23#define CONFIGURE_INIT
24
25#include <confdefs.h>
26
27rtems_task Init(
28    rtems_task_argument ignored
29) {
30  rtems_status_code     status;
31  rtems_interval                timestamps[6],
32                        wantintervals[5] =
33                            { 1, 50, 200, 25, 3 };
34  rtems_name            period_name =
35                            rtems_build_name('P','E','R','a');
36  rtems_id              period_id;
37  int                   loopy;
38
39  printf("\n\n*** TEST 32 ***\n");
40
41  /* create period */
42  status = rtems_rate_monotonic_create(
43      period_name,
44      &period_id
45  );
46  directive_failed(status, "rate_monotonic_create");
47
48  /* start period with initial value */
49  status = rtems_rate_monotonic_period(
50      period_id,
51      wantintervals[0]
52  );
53  directive_failed(status, "rate_monotonic_period");
54
55  /* get our first timestamp */
56  status = rtems_clock_get(
57      RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
58      &timestamps[0]
59  );
60  directive_failed(status, "clock_get");
61
62  /* loop through and gather more timestamps */
63  for (loopy = 1; loopy < 5; loopy++) {
64
65        status = rtems_rate_monotonic_period(
66            period_id,
67            wantintervals[loopy]
68        );
69        directive_failed(status, "rate_monotonic_period");
70
71        status = rtems_clock_get(
72            RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
73            &timestamps[loopy]
74        );
75        directive_failed(status, "clock_get");
76  }
77
78  /* block one last time */
79  status = rtems_rate_monotonic_period(
80      period_id,
81      1
82  );
83  directive_failed(status, "rate_monotonic_period");
84
85  /* get one last timestamp */
86  status = rtems_clock_get(
87      RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
88      &timestamps[loopy]
89  );
90  directive_failed(status, "clock_get");
91
92  /* cancel the period */
93  status = rtems_rate_monotonic_cancel(period_id);
94  directive_failed(status, "rate_monotonic_cancel");
95
96  /* delete it */
97  status = rtems_rate_monotonic_delete(period_id);
98  directive_failed(status, "rate_monotonic_delete");
99
100  /* tabulate and print results */
101  for (loopy = 0; loopy < 5; loopy++) {
102        printf(
103            "period %d: measured %d tick(s), wanted %d\n",
104            loopy, timestamps[loopy+1] - timestamps[loopy],
105            wantintervals[loopy]
106        );
107  }
108
109  /* the end */
110  printf("*** END OF TEST SP32 ***\n");
111  exit(0);
112}
Note: See TracBrowser for help on using the repository browser.