source: rtems/testsuites/sptests/sp32/init.c @ d71542c

5
Last change on this file since d71542c was c4b8b147, checked in by Sebastian Huber <sebastian.huber@…>, on 11/03/17 at 07:35:38

tests: Use simple console driver

Update #3170.
Update #3199.

  • Property mode set to 100644
File size: 2.7 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>  /* includes bsp.h, stdio, etc... */
15
16const char rtems_test_name[] = "SP 32";
17
18/* forward declarations to avoid warnings */
19rtems_task Init(rtems_task_argument argument);
20
21rtems_task Init(
22    rtems_task_argument ignored
23) {
24  rtems_status_code  status;
25  rtems_interval     timestamps[6],
26                     wantintervals[5] = { 1, 50, 200, 25, 3 };
27  rtems_name         period_name = rtems_build_name('P','E','R','a');
28  rtems_id           period_id;
29  int                loopy;
30
31  TEST_BEGIN();
32
33  /* create period */
34  status = rtems_rate_monotonic_create(
35      period_name,
36      &period_id
37  );
38  directive_failed(status, "rate_monotonic_create");
39
40  /* start period with initial value */
41  status = rtems_rate_monotonic_period( period_id, wantintervals[0] );
42  directive_failed(status, "rate_monotonic_period #1");
43
44  /* get our first timestamp */
45  timestamps[0] = rtems_clock_get_ticks_since_boot();
46
47  /* loop through and gather more timestamps */
48  for (loopy = 1; loopy < 5; loopy++) {
49
50    status = rtems_rate_monotonic_period( period_id, wantintervals[loopy] );
51    directive_failed(status, "rate_monotonic_period #2");
52
53    timestamps[loopy] = rtems_clock_get_ticks_since_boot();
54  }
55
56  /* block one last time */
57  status = rtems_rate_monotonic_period( period_id, 1 );
58  directive_failed(status, "rate_monotonic_period #3");
59
60  /* get one last timestamp */
61  timestamps[loopy] = rtems_clock_get_ticks_since_boot();
62
63  /* cancel the period */
64  status = rtems_rate_monotonic_cancel(period_id);
65  directive_failed(status, "rate_monotonic_cancel");
66
67  /* delete it */
68  status = rtems_rate_monotonic_delete(period_id);
69  directive_failed(status, "rate_monotonic_delete");
70
71  /* tabulate and print results */
72  for (loopy = 0; loopy < 5; loopy++) {
73    printf(
74      "period %d: measured %" PRIdrtems_interval " tick(s), wanted %"
75        PRIdrtems_interval "\n",
76      loopy,
77      timestamps[loopy+1] - timestamps[loopy],
78      wantintervals[loopy]
79    );
80  }
81
82  TEST_END();
83  rtems_test_exit(0);
84}
85
86#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
87
88#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
89
90#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
91#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
92#define CONFIGURE_MAXIMUM_TASKS        1
93#define CONFIGURE_MAXIMUM_PERIODS      1
94
95#define CONFIGURE_MICROSECONDS_PER_TICK 100000
96
97#define CONFIGURE_INIT
98
99#include <rtems/confdefs.h>
100
Note: See TracBrowser for help on using the repository browser.