OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [compat/] [uitron/] [current/] [tests/] [test3.c] - Blame information for rev 817

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//===========================================================================
2
//
3
//      test3.c
4
//
5
//      uITRON "C" test program three
6
//
7
//===========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//===========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):   hmt
43
// Contributors:        hmt
44
// Date:        1998-03-13
45
// Purpose:     uITRON API testing
46
// Description: 
47
//
48
//####DESCRIPTIONEND####
49
//
50
//===========================================================================
51
 
52
#include <pkgconf/uitron.h>             // uITRON setup CYGNUM_UITRON_SEMAS
53
                                        // CYGPKG_UITRON et al
54
#include <cyg/infra/testcase.h>         // testing infrastructure
55
 
56
#ifdef CYGPKG_UITRON                    // we DO want the uITRON package
57
 
58
#ifdef CYGSEM_KERNEL_SCHED_MLQUEUE      // we DO want prioritized threads
59
 
60
#ifdef CYGFUN_KERNEL_THREADS_TIMER      // we DO want timout-able calls
61
 
62
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK     // we DO want the realtime clock
63
 
64
// we're OK if it's C++ or neither of those two is defined:
65
#if defined( __cplusplus ) || \
66
    (!defined( CYGIMP_UITRON_INLINE_FUNCS ) && \
67
     !defined( CYGIMP_UITRON_CPP_OUTLINE_FUNCS) )
68
 
69
// =================== TEST CONFIGURATION ===================
70
#if \
71
    /* test configuration for enough tasks */                      \
72
    (CYGNUM_UITRON_TASKS >= 4)                                  && \
73
    (CYGNUM_UITRON_TASKS < 90)                                  && \
74
    (CYGNUM_UITRON_START_TASKS == 1)                            && \
75
    ( !defined(CYGPKG_UITRON_TASKS_CREATE_DELETE) ||               \
76
      CYGNUM_UITRON_TASKS_INITIALLY >= 4             )          && \
77
                                                                   \
78
    /* test configuration for enough semaphores */                 \
79
    defined( CYGPKG_UITRON_SEMAS )                              && \
80
    (CYGNUM_UITRON_SEMAS >= 3)                                  && \
81
    (CYGNUM_UITRON_SEMAS < 90)                                  && \
82
    ( !defined(CYGPKG_UITRON_SEMAS_CREATE_DELETE) ||               \
83
      CYGNUM_UITRON_SEMAS_INITIALLY >= 3             )          && \
84
                                                                   \
85
    /* the end of the large #if statement */                       \
86
    1
87
 
88
// ============================ END ============================
89
 
90
 
91
 
92
#include <cyg/compat/uitron/uit_func.h> // uITRON
93
 
94
int t2done = 0;
95
int t3done = 0;
96
int t4done = 0;
97
 
98
externC void
99
cyg_package_start( void )
100
{
101
    CYG_TEST_INIT();
102
    CYG_TEST_INFO( "Calling cyg_uitron_start()" );
103
    cyg_uitron_start();
104
}
105
 
106
void task1( unsigned int arg )
107
{
108
    ER ercd;
109
    INT scratch;
110
 
111
    CYG_TEST_INFO( "Task 1 running" );
112
    ercd = get_tid( &scratch );
113
    CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
114
    CYG_TEST_CHECK( 1 == scratch, "tid not 1" );
115
 
116
    // start lower prio tasks to interact with
117
    ercd = sta_tsk( 2, 222 );
118
    CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
119
    ercd = sta_tsk( 3, 333 );
120
    CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
121
    ercd = sta_tsk( 4, 444 );
122
    CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
123
 
124
    // now start the test
125
    ercd = slp_tsk();
126
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
127
    CYG_TEST_INFO( "T1 awoken" );
128
    ercd = wai_sem( 1 );
129
    CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
130
    CYG_TEST_INFO( "T1 signalled" );
131
 
132
    // let the others complete, so we get the status back
133
    ercd = dly_tsk( 50 );
134
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
135
 
136
    CYG_TEST_CHECK( t2done, "t2 not done" );
137
    CYG_TEST_CHECK( t3done, "t3 not done" );
138
    CYG_TEST_CHECK( t4done, "t4 not done" );
139
 
140
    CYG_TEST_PASS( "Immediate-dispatch producer/consumer test OK" );
141
 
142
    // all done
143
    CYG_TEST_EXIT( "All done" );
144
    ext_tsk();
145
}
146
 
147
 
148
 
149
void task2( unsigned int arg )
150
{
151
    ER ercd;
152
    INT scratch;
153
 
154
    CYG_TEST_INFO( "Task 2 running" );
155
    ercd = get_tid( &scratch );
156
    CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
157
    CYG_TEST_CHECK( 2 == scratch, "tid not 2" );
158
    if ( 222 != arg )
159
        CYG_TEST_FAIL( "Task 2 arg not 222" );
160
 
161
    // now start the test
162
    ercd = slp_tsk();
163
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
164
    CYG_TEST_INFO( "T2 awoken" );
165
    ercd = sig_sem( 1 );
166
    CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
167
    ercd = wup_tsk( 1 );
168
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
169
 
170
    CYG_TEST_INFO( "T2 completing" );
171
    t2done++;
172
 
173
    ercd = slp_tsk();
174
    CYG_TEST_FAIL( "Task 2 sleep came back" );
175
}
176
 
177
void task3( unsigned int arg )
178
{
179
    ER ercd;
180
    INT scratch;
181
 
182
    CYG_TEST_INFO( "Task 3 running" );
183
    ercd = get_tid( &scratch );
184
    CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
185
    CYG_TEST_CHECK( 3 == scratch, "tid not 3" );
186
    if ( 333 != arg )
187
        CYG_TEST_FAIL( "Task 3 arg not 333" );
188
 
189
    // now start the test
190
    ercd = wai_sem( 1 );
191
    CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
192
    CYG_TEST_INFO( "T3 awoken" );
193
    ercd = sig_sem( 1 );
194
    CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
195
 
196
    CYG_TEST_INFO( "T3 completing" );
197
    t3done++;
198
 
199
    ercd = slp_tsk();
200
    CYG_TEST_FAIL( "Task 3 sleep came back" );
201
}
202
 
203
void task4( unsigned int arg )
204
{
205
    ER ercd;
206
    INT scratch;
207
 
208
    CYG_TEST_INFO( "Task 4 running" );
209
    ercd = get_tid( &scratch );
210
    CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
211
    CYG_TEST_CHECK( 4 == scratch, "tid not 4" );
212
    if ( 444 != arg )
213
        CYG_TEST_FAIL( "Task 4 arg not 444" );
214
 
215
    // now start the test
216
    ercd = wup_tsk( 2 );
217
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
218
 
219
    CYG_TEST_INFO( "T4 completing" );
220
    t4done++;
221
 
222
    ercd = slp_tsk();
223
    CYG_TEST_FAIL( "Task 4 sleep came back" );
224
}
225
 
226
#else // not enough (or too many) uITRON objects configured in
227
#define N_A_MSG "not enough uITRON objects to run test"
228
#endif // not enough (or too many) uITRON objects configured in
229
#else  // not C++ and some C++ specific options enabled
230
#define N_A_MSG "C++ specific options selected but this is C"
231
#endif  // not C++ and some C++ specific options enabled
232
#else // ! CYGVAR_KERNEL_COUNTERS_CLOCK   - can't test without it
233
#define N_A_MSG "no CYGVAR_KERNEL_COUNTERS_CLOCK"
234
#endif // ! CYGVAR_KERNEL_COUNTERS_CLOCK  - can't test without it
235
#else  // ! CYGFUN_KERNEL_THREADS_TIMER   - can't test without it
236
#define N_A_MSG "no CYGFUN_KERNEL_THREADS_TIMER"
237
#endif // ! CYGFUN_KERNEL_THREADS_TIMER   - can't test without it
238
#else  // ! CYGIMP_THREAD_PRIORITY        - can't test without it
239
#define N_A_MSG "no CYGSEM_KERNEL_SCHED_MLQUEUE"
240
#endif // ! CYGSEM_KERNEL_SCHED_MLQUEUE   - can't test without it
241
#else  // ! CYGPKG_UITRON
242
#define N_A_MSG "uITRON Compatibility layer disabled"
243
#endif // CYGPKG_UITRON
244
 
245
#ifdef N_A_MSG
246
void
247
cyg_start( void )
248
{
249
    CYG_TEST_INIT();
250
    CYG_TEST_NA( N_A_MSG );
251
}
252
#endif // N_A_MSG defined ie. we are N/A.
253
 
254
// EOF test3.c

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.