source: rtems/c/src/tests/sptests/sp20/task1.c @ 3aa4c2e0

4.104.114.84.95
Last change on this file since 3aa4c2e0 was 3aa4c2e0, checked in by Joel Sherrill <joel.sherrill@…>, on 08/02/02 at 00:52:14

2002-08-01 Joel Sherrill <joel@…>

  • Per PR47 add support for buffered test output. This involved adding defines to redirect output to a buffer and dump it when full, at "test pause", and at exit. To avoid problems when redefining exit(), all tests were modified to call rtems_test_exit(). Some tests, notable psxtests, had to be modified to include the standard test macro .h file (pmacros.h or tmacros.h) to enable this support.
  • sp01/task1.c, sp02/task1.c, sp03/task2.c, sp04/task1.c, sp05/task1.c, sp06/task1.c, sp07/taskexit.c, sp08/task1.c, sp09/task1.c, sp11/task1.c, sp12/pritask.c, sp12/task5.c, sp13/task1.c, sp14/task2.c, sp15/task1.c, sp16/task1.c, sp17/task1.c, sp19/fptask.c, sp20/task1.c, sp21/task1.c, sp22/task1.c, sp23/task1.c, sp24/task1.c, sp25/task1.c, sp26/init.c, sp26/task1.c, sp30/task1.c, sp31/task1.c, spsize/init.c, spsize/size.c: Modified.
  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*  Task_1_through_5
2 *
3 *  This routine serves as a test task for the period capabilities of the
4 *  Rate Monotonic Manager.
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1989-1999.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.OARcorp.com/rtems/license.html.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22
23/*
24 runtime of TA6 should be shorter than TA5
25 */
26#define TA6_ITERATIONS 10
27#define TA6_PERIOD_FACTOR 10
28
29rtems_unsigned32    Periods[7]    = { 0,   2,   2,   2,   2, 100, 0 };
30rtems_unsigned32    Iterations[7] = { 0,  50,  50,  50,  50,   1, TA6_ITERATIONS };
31rtems_task_priority Priorities[7] = { 0,   1,   1,   3,   4,   5, 1 };
32
33rtems_task Task_1_through_6(
34  rtems_unsigned32 argument
35)
36{
37  rtems_id          rmid;
38  rtems_id          test_rmid;
39  rtems_unsigned32  index;
40  rtems_unsigned32  pass;
41  rtems_unsigned32  failed;
42  rtems_status_code status;
43
44  status = rtems_rate_monotonic_create( argument, &rmid );
45  directive_failed( status, "rtems_rate_monotonic_create" );
46  put_name( Task_name[ argument ], FALSE );
47  printf( "- rtems_rate_monotonic_create id = 0x%08x\n", rmid );
48
49  status = rtems_rate_monotonic_ident( argument, &test_rmid );
50  directive_failed( status, "rtems_rate_monotonic_ident" );
51  put_name( Task_name[ argument ], FALSE );
52  printf( "- rtems_rate_monotonic_ident id = 0x%08x\n", test_rmid );
53
54  if ( rmid != test_rmid ) {
55     printf( "RMID's DO NOT MATCH (0x%x and 0x%x)\n", rmid, test_rmid );
56     rtems_test_exit( 0 );
57  }
58
59  put_name( Task_name[ argument ], FALSE );
60  printf( "- (0x%08x) period %d\n", rmid, Periods[ argument ] );
61
62  status = rtems_task_wake_after( 2 );
63  directive_failed( status, "rtems_task_wake_after" );
64
65  switch ( argument ) {
66    case 1:
67    case 2:
68    case 3:
69    case 4:
70      while ( FOREVER ) {
71        status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
72        directive_failed( status, "rtems_rate_monotonic_period" );
73        Count.count[ argument ]++;
74      }
75      break;
76    case 5:
77      pass   = 0;
78      failed = 0;
79
80      status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
81      directive_failed( status, "rtems_rate_monotonic_period 1 of TA5" );
82
83      Get_all_counters();
84
85      while ( FOREVER ) {
86
87        status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
88        directive_failed( status, "rtems_rate_monotonic_period 2 of TA5" );
89
90        Get_all_counters();
91
92        for( index = 1 ; index <= 4 ; index++ ) {
93          if ( Temporary_count.count[ index ] != Iterations[ index ] ) {
94            puts_nocr( "FAIL -- " );
95            put_name ( Task_name[ index ], FALSE );
96            printf   ( " Actual=%d, Expected=%d\n",
97                       Temporary_count.count[ index ],
98                       Iterations[ index ]
99                     );
100            failed += 1;
101          }
102        }
103
104        if ( failed == 5 )
105          rtems_test_exit( 0 );
106
107        pass += 1;
108
109        printf( "TA5 - PERIODS CHECK OK (%d)\n", pass );
110
111        fflush( stdout );
112
113        if ( pass == 10 ) {
114          puts( "*** END OF TEST 20 ***" );
115          rtems_test_exit( 0 );
116        }
117
118      }
119      break;
120    case 6:
121      /* test changing periods */
122      {
123        unsigned32 time[TA6_ITERATIONS+1];
124        rtems_interval period;
125
126        period = 1*TA6_PERIOD_FACTOR;
127        status = rtems_rate_monotonic_period( rmid, period);
128        directive_failed( status, "rtems_rate_monotonic_period of TA6" );
129        time[0] = _Watchdog_Ticks_since_boot; /* timestamp */
130        /*printf("%d - %d\n", period, time[0]);*/
131
132        for (index = 1; index <= TA6_ITERATIONS; index++)
133        {
134          period = (index+1)*TA6_PERIOD_FACTOR;
135          status = rtems_rate_monotonic_period( rmid,  period);
136          directive_failed( status, "rtems_rate_monotonic_period of TA6" );
137          time[index] = _Watchdog_Ticks_since_boot; /* timestamp */
138          /*printf("%d - %d\n", period, time[index]);*/
139        }
140
141        for (index = 1; index <= TA6_ITERATIONS; index++)
142        {
143          rtems_interval meas = time[index] - time[index-1];
144          period = index*TA6_PERIOD_FACTOR;
145          printf("TA6 - Actual: %d  Expected: %d", meas, period);
146          if (period == meas) printf(" - OK\n");
147          else printf(" - FAILED\n");
148        }
149      }
150      rtems_task_suspend(RTEMS_SELF);
151      break;
152  }
153}
Note: See TracBrowser for help on using the repository browser.