source: rtems/testsuites/sptests/sp69/init.c @ 75c133bd

Last change on this file since 75c133bd was 75c133bd, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 25, 2021 at 4:03:42 PM

sptests/sp69: Remove test case

This error condition no longer exists.

Update #4528.

  • Property mode set to 100644
File size: 5.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 <rtems/cpuuse.h>
15#include <tmacros.h>
16#include "test_support.h"
17
18const char rtems_test_name[] = "SP 69";
19
20/* forward declarations to avoid warnings */
21rtems_task Init(rtems_task_argument argument);
22
23rtems_task Init(
24  rtems_task_argument argument
25)
26{
27  rtems_id                                period_id;
28  rtems_name                              period_name;
29  rtems_rate_monotonic_period_status      period_status;
30  rtems_status_code                       status;
31  rtems_rate_monotonic_period_statistics  statistics;
32  int                                     i;
33
34  period_name = rtems_build_name('P','E','R','1');
35
36  TEST_BEGIN();
37
38  /* create period */
39  status = rtems_rate_monotonic_create(
40      period_name,
41      &period_id
42  );
43  directive_failed( status, "rate_monotonic_create" );
44
45  /*
46   * Check get_status on an inactive period.
47   */
48  puts(
49    "rtems_rate_monotonic_get_status - verify values of an inactive period"
50  );
51
52  status = rtems_rate_monotonic_get_status( period_id, &period_status );
53  directive_failed( status, "rate_monotonic_get_status" );
54
55  /* Check status values. */
56  rtems_test_assert( period_status.owner == rtems_task_self() );
57  rtems_test_assert( period_status.state == RATE_MONOTONIC_INACTIVE );
58  rtems_test_assert( period_status.since_last_period.tv_sec == 0 );
59  rtems_test_assert( period_status.since_last_period.tv_nsec == 0 );
60  rtems_test_assert( period_status.executed_since_last_period.tv_sec == 0 );
61  rtems_test_assert( period_status.executed_since_last_period.tv_nsec == 0 );
62
63  /* Clean up. */
64  status = rtems_rate_monotonic_cancel( period_id );
65  directive_failed( status, "rate_monotonic_cancel" );
66
67  /*
68   * Check normal get_status results.
69   */
70  puts( "rtems_rate_monotonic_get_status - verify values of an active period" );
71  rtems_test_spin_until_next_tick();
72  status = rtems_rate_monotonic_period( period_id, 100 );
73  directive_failed( status, "rate_monotonic_period" );
74
75  /* Do some work */
76  rtems_test_spin_for_ticks( 10 );
77
78  /* Block a little */
79  status = rtems_task_wake_after( 50 );
80
81  /* Check the status */
82  status = rtems_rate_monotonic_get_status( period_id, &period_status );
83  directive_failed( status, "rate_monotonic_get_status" );
84
85  /* Check status values. */
86  /* Note: POSIX mandates struct timespec->tv_nsec to be a "long" */
87  printf(
88    "wall time should be ~600000000 is %ld\n",
89    period_status.since_last_period.tv_nsec
90  );
91  printf(
92    "cpu time should be ~100000000 is %ld\n",
93    period_status.executed_since_last_period.tv_nsec
94  );
95  rtems_test_assert( period_status.since_last_period.tv_sec == 0 );
96  rtems_test_assert( period_status.since_last_period.tv_nsec >= 600000000 );
97  rtems_test_assert( period_status.since_last_period.tv_nsec <= 610000000 );
98  rtems_test_assert( period_status.executed_since_last_period.tv_sec == 0 );
99  rtems_test_assert(
100    period_status.executed_since_last_period.tv_nsec >= 100000000
101  );
102  rtems_test_assert(
103    period_status.executed_since_last_period.tv_nsec <= 110000000
104  );
105
106  /* ensure the missed periods are properly accounted for */
107  puts( "rtems_rate_monotonic_cancel -  OK" );
108  status = rtems_rate_monotonic_cancel( period_id );
109  directive_failed( status, "rate_monotonic_cancel" );
110
111  puts( "Testing statistics on missed periods" );
112  rtems_test_spin_until_next_tick();
113  status = rtems_rate_monotonic_period( period_id, 50 );
114  directive_failed( status, "rate_monotonic_period above loop" );
115
116  for ( i=1 ; i <= 3 ; i++ ) {
117    status = rtems_task_wake_after( 100 );
118    directive_failed( status, "rtems_task_wake_after(100)" );
119
120    rtems_test_spin_until_next_tick();
121    status = rtems_rate_monotonic_period( period_id, 50 );
122    fatal_directive_status(
123      status,
124      RTEMS_TIMEOUT,
125      "rtems_rate_monotonic_period 2-n"
126    );
127
128    status = rtems_rate_monotonic_get_statistics( period_id, &statistics );
129    directive_failed( status, "rate_monotonic_get_statistics" );
130    if ( statistics.missed_count != i ) {
131      printf(
132        "Expected %d got %" PRIu32 " for missed_count\n",
133        i,
134        statistics.missed_count
135      );
136    }
137
138    rtems_test_assert( statistics.missed_count == i );
139  }
140
141  /* Check the status */
142  status = rtems_rate_monotonic_get_status( period_id, &period_status );
143  directive_failed( status, "rate_monotonic_get_status" );
144  puts(
145    "rtems_rate_monotonic_get_status - verify value of a postponed jobs count"
146  );
147  rtems_test_assert( period_status.postponed_jobs_count == 3 );
148
149  TEST_END();
150
151  rtems_test_exit(0);
152}
153
154/* configuration information */
155
156#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
157#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
158
159#define CONFIGURE_MAXIMUM_TASKS             1
160#define CONFIGURE_MAXIMUM_PERIODS           1
161
162#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
163
164#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
165
166
167#define CONFIGURE_INIT
168
169#include <rtems/confdefs.h>
170/* end of file */
Note: See TracBrowser for help on using the repository browser.