source: rtems/testsuites/sptests/sp32/init.c @ 2186ba80

4.104.114.95
Last change on this file since 2186ba80 was 2186ba80, checked in by Joel Sherrill <joel.sherrill@…>, on 02/01/08 at 00:45:11

2008-01-31 Joel Sherrill <joel.sherrill@…>

  • sp01/init.c, sp02/init.c, sp03/init.c, sp04/init.c, sp05/init.c, sp06/init.c, sp07/init.c, sp08/init.c, sp09/init.c, sp11/init.c, sp12/init.c, sp13/init.c, sp14/init.c, sp15/init.c, sp16/init.c, sp17/init.c, sp19/init.c, sp20/init.c, sp21/init.c, sp22/init.c, sp23/init.c, sp24/init.c, sp25/init.c, sp26/init.c, sp28/init.c, sp30/init.c, sp31/init.c, sp32/init.c, sp33/init.c, sp37/init.c, sp38/init.c, sp39/init.c, sp40/init.c, sp41/init.c, sp43/init.c, spfatal/init.c, spfatal_support/init.c, spsize/init.c: Change TEST_INIT to CONFIGURE_INIT. Make tmacros.h available to all POSIX tests. Add a clock_settime case for < 1988.
  • 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 CONFIGURE_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 <rtems/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  puts("*** END OF TEST 32 ***");
111  rtems_test_exit(0);
112}
Note: See TracBrowser for help on using the repository browser.