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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [compat/] [uitron/] [current/] [tests/] [testcx9.cxx] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//===========================================================================
2
//
3
//      testcx9.cxx
4
//
5
//      uITRON "C++" test program nine
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-10-16
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 fixed memory pools */         \
79
    defined( CYGPKG_UITRON_MEMPOOLFIXED )                       && \
80
    (CYGNUM_UITRON_MEMPOOLFIXED >= 3)                           && \
81
    (CYGNUM_UITRON_MEMPOOLFIXED < 90)                           && \
82
    ( !defined(CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE) ||        \
83
      CYGNUM_UITRON_MEMPOOLFIXED_INITIALLY >= 3       )         && \
84
                                                                   \
85
    /* test configuration for enough variable mempools */          \
86
    defined( CYGPKG_UITRON_MEMPOOLVAR )                         && \
87
    (CYGNUM_UITRON_MEMPOOLVAR >= 3)                             && \
88
    (CYGNUM_UITRON_MEMPOOLVAR < 90)                             && \
89
    ( !defined(CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE) ||          \
90
      CYGNUM_UITRON_MEMPOOLVAR_INITIALLY >= 3       )           && \
91
                                                                   \
92
    /* the end of the large #if statement */                       \
93
    1
94
 
95
// ============================ END ============================
96
 
97
 
98
 
99
#include <cyg/compat/uitron/uit_func.h> // uITRON
100
 
101
externC void
102
cyg_package_start( void )
103
{
104
    CYG_TEST_INIT();
105
    CYG_TEST_INFO( "Calling cyg_uitron_start()" );
106
    cyg_uitron_start();
107
}
108
 
109
VP vp;
110
 
111
T_CMPL t_cmpl = { NULL, 0, 1000 };
112
T_RMPL t_rmpl;
113
T_CMPF t_cmpf = { NULL, 0, 10, 100 };
114
T_RMPF t_rmpf;
115
 
116
 
117
extern "C" {
118
    void task1( unsigned int arg );
119
    void task2( unsigned int arg );
120
    void task3( unsigned int arg );
121
    void task4( unsigned int arg );
122
}
123
 
124
void task1( unsigned int arg )
125
{
126
    ER ercd;
127
    int tests = 0;
128
 
129
    CYG_TEST_INFO( "Task 1 running" );
130
 
131
    ercd = dis_dsp();
132
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
133
    ercd = sta_tsk( 2, 22222 );
134
    CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
135
    ercd = chg_pri( 2, 5 );
136
    CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
137
    ercd = ena_dsp();
138
    CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
139
    ercd = dly_tsk( 10 );
140
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
141
 
142
#ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
143
    tests++;
144
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
145
    ercd = del_mpf( -6 );
146
    CYG_TEST_CHECK( E_ID == ercd, "del_mpf bad ercd !E_ID" );
147
    ercd = del_mpf( 99 );
148
    CYG_TEST_CHECK( E_ID == ercd, "del_mpf bad ercd !E_ID" );
149
    ercd = cre_mpf( -6, &t_cmpf );
150
    CYG_TEST_CHECK( E_ID == ercd, "cre_mpf bad ercd !E_ID" );
151
    ercd = cre_mpf( 99, &t_cmpf );
152
    CYG_TEST_CHECK( E_ID == ercd, "cre_mpf bad ercd !E_ID" );
153
#endif // we can test bad param error returns
154
    // try a pre-existing object
155
    // [first get a valid block from it for the freeing test later]
156
    ercd = pget_blf( &vp, 3 );
157
    CYG_TEST_CHECK( E_OK == ercd, "pget_blf bad ercd" );
158
    ercd = cre_mpf( 3, &t_cmpf );
159
    CYG_TEST_CHECK( E_OBJ == ercd, "cre_mpf bad ercd !E_OBJ" );
160
    // delete it so we can play
161
    ercd = del_mpf( 3 );
162
    CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" );
163
    // check it is deleted
164
    ercd = rel_blf( 3, vp );            // vp did come from this pool
165
    CYG_TEST_CHECK( E_NOEXS == ercd, "rel_blf bad ercd !E_NOEXS" );
166
    ercd = pget_blf( &vp, 3 );
167
    CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blf bad ercd !E_NOEXS" );
168
    ercd = tget_blf( &vp, 3, 10 );
169
    CYG_TEST_CHECK( E_NOEXS == ercd, "tget_blf bad ercd !E_NOEXS" );
170
    ercd = get_blf( &vp, 3 );
171
    CYG_TEST_CHECK( E_NOEXS == ercd, "get_blf bad ercd !E_NOEXS" );
172
    ercd = ref_mpf( &t_rmpf, 3 );
173
    CYG_TEST_CHECK( E_NOEXS == ercd, "ref_mpf bad ercd !E_NOEXS" );
174
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
175
    // now try creating it (badly)
176
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
177
    ercd = cre_mpf( 3, NULL );
178
    CYG_TEST_CHECK( E_PAR == ercd, "cre_mpf bad ercd !E_PAR" );
179
#endif
180
    t_cmpf.mpfatr = 0xfff;
181
    ercd = cre_mpf( 3, &t_cmpf );
182
    CYG_TEST_CHECK( E_RSATR == ercd, "cre_mpf bad ercd !E_RSATR" );
183
#endif // we can test bad param error returns
184
    t_cmpf.mpfatr = 0;
185
    t_cmpf.mpfcnt = 10000;
186
    t_cmpf.blfsz = 100;
187
    ercd = cre_mpf( 3, &t_cmpf );
188
    CYG_TEST_CHECK( E_NOMEM == ercd, "cre_mpf bad ercd" );
189
    t_cmpf.mpfcnt = 100;
190
    t_cmpf.blfsz = 100000;
191
    ercd = cre_mpf( 3, &t_cmpf );
192
    CYG_TEST_CHECK( E_NOMEM == ercd, "cre_mpf bad ercd" );
193
    // now create it well
194
    t_cmpf.mpfatr = 0;
195
    t_cmpf.mpfcnt = 10;
196
    t_cmpf.blfsz = 100;
197
    ercd = cre_mpf( 3, &t_cmpf );
198
    CYG_TEST_CHECK( E_OK == ercd, "cre_mpf bad ercd" );
199
    // and check we can use it
200
    ercd = pget_blf( &vp, 3 );
201
    CYG_TEST_CHECK( E_OK == ercd, "pget_blf bad ercd" );
202
    ercd = tget_blf( &vp, 3, 10 );
203
    CYG_TEST_CHECK( E_OK == ercd, "tget_blf bad ercd" );
204
    ercd = get_blf( &vp, 3 );
205
    CYG_TEST_CHECK( E_OK == ercd, "get_blf bad ercd" );
206
    ercd = rel_blf( 3, vp );            // vp did come from new pool
207
    CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
208
    ercd = rel_blf( 3, vp );            // vp already freed
209
    CYG_TEST_CHECK( E_PAR == ercd, "rel_blf bad ercd !E_PAR" );
210
    ercd = ref_mpf( &t_rmpf, 3 );
211
    CYG_TEST_CHECK( E_OK == ercd, "ref_mpf bad ercd" );
212
 
213
    // In order to wait on the pools, we must first consume all they have:
214
    while ( E_OK == (ercd = pget_blf( &vp, 1 )) ) /* nothing */;
215
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
216
    while ( E_OK == (ercd = tget_blf( &vp, 2, 1 )) ) /* nothing */;
217
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf bad ercd !E_TMOUT" );
218
    // now wait while task 2 deletes the wait objects
219
    ercd = wup_tsk( 2 );
220
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
221
    ercd = get_blf( &vp, 1 );
222
    CYG_TEST_CHECK( E_DLT == ercd, "get_blf bad ercd !E_DLT" );
223
    ercd = wup_tsk( 2 );
224
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
225
    ercd = tget_blf( &vp, 2, 20 );
226
    CYG_TEST_CHECK( E_DLT == ercd, "tget_blf bad ercd !E_DLT" );
227
    // check they are deleted
228
    ercd = get_blf( &vp, 1 );
229
    CYG_TEST_CHECK( E_NOEXS == ercd, "get_blf bad ercd !E_NOEXS" );
230
    ercd = pget_blf( &vp, 2 );
231
    CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blf bad ercd !E_NOEXS" );
232
 
233
    // re-create and do it again
234
    t_cmpf.mpfcnt = 90;
235
    t_cmpf.blfsz = 20;
236
    ercd = cre_mpf( 1, &t_cmpf );
237
    CYG_TEST_CHECK( E_OK == ercd, "cre_mpf bad ercd" );
238
    t_cmpf.mpfcnt = 5;
239
    t_cmpf.blfsz = 200;
240
    ercd = cre_mpf( 2, &t_cmpf );
241
    CYG_TEST_CHECK( E_OK == ercd, "cre_mpf bad ercd" );
242
 
243
    // In order to wait on the pools, we must first consume all they have:
244
    while ( E_OK == (ercd = pget_blf( &vp, 1 )) ) /* nothing */;
245
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
246
    while ( E_OK == (ercd = tget_blf( &vp, 2, 1 )) ) /* nothing */;
247
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf bad ercd !E_TMOUT" );
248
    // now wait while task 2 deletes the wait objects
249
    ercd = wup_tsk( 2 );
250
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
251
    ercd = get_blf( &vp, 1 );
252
    CYG_TEST_CHECK( E_DLT == ercd, "get_blf bad ercd !E_DLT" );
253
    ercd = wup_tsk( 2 );
254
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
255
    ercd = tget_blf( &vp, 2, 10 );
256
    CYG_TEST_CHECK( E_DLT == ercd, "tget_blf bad ercd !E_DLT" );
257
    // check they are deleted
258
    ercd = tget_blf( &vp, 1, 1 );
259
    CYG_TEST_CHECK( E_NOEXS == ercd, "get_blf bad ercd !E_NOEXS" );
260
    ercd = get_blf( &vp, 2 );
261
    CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blf bad ercd !E_NOEXS" );
262
 
263
    CYG_TEST_PASS("create/delete fixed mempools");
264
#endif // CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
265
 
266
#ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
267
    tests++;
268
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
269
    ercd = del_mpl( -6 );
270
    CYG_TEST_CHECK( E_ID == ercd, "del_mpl bad ercd !E_ID" );
271
    ercd = del_mpl( 99 );
272
    CYG_TEST_CHECK( E_ID == ercd, "del_mpl bad ercd !E_ID" );
273
    ercd = cre_mpl( -6, &t_cmpl );
274
    CYG_TEST_CHECK( E_ID == ercd, "cre_mpl bad ercd !E_ID" );
275
    ercd = cre_mpl( 99, &t_cmpl );
276
    CYG_TEST_CHECK( E_ID == ercd, "cre_mpl bad ercd !E_ID" );
277
#endif // we can test bad param error returns
278
    // try a pre-existing object
279
    // [first get a valid block from it for the freeing test later]
280
    ercd = pget_blk( &vp, 3, 100 );
281
    CYG_TEST_CHECK( E_OK == ercd, "pget_blk bad ercd" );
282
    ercd = cre_mpl( 3, &t_cmpl );
283
    CYG_TEST_CHECK( E_OBJ == ercd, "cre_mpl bad ercd !E_OBJ" );
284
    // delete it so we can play
285
    ercd = del_mpl( 3 );
286
    CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" );
287
    // check it is deleted
288
    ercd = rel_blk( 3, vp );            // vp did come from this pool
289
    CYG_TEST_CHECK( E_NOEXS == ercd, "rel_blk bad ercd !E_NOEXS" );
290
    ercd = pget_blk( &vp, 3, 100 );
291
    CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blk bad ercd !E_NOEXS" );
292
    ercd = tget_blk( &vp, 3, 100, 10 );
293
    CYG_TEST_CHECK( E_NOEXS == ercd, "tget_blk bad ercd !E_NOEXS" );
294
    ercd = get_blk( &vp, 3, 100 );
295
    CYG_TEST_CHECK( E_NOEXS == ercd, "get_blk bad ercd !E_NOEXS" );
296
    ercd = ref_mpl( &t_rmpl, 3 );
297
    CYG_TEST_CHECK( E_NOEXS == ercd, "ref_mpl bad ercd !E_NOEXS" );
298
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
299
    // now try creating it (badly)
300
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
301
    ercd = cre_mpl( 3, NULL );
302
    CYG_TEST_CHECK( E_PAR == ercd, "cre_mpl bad ercd !E_PAR" );
303
#endif
304
    t_cmpl.mplatr = 0xfff;
305
    ercd = cre_mpl( 3, &t_cmpl );
306
    CYG_TEST_CHECK( E_RSATR == ercd, "cre_mpl bad ercd !E_RSATR" );
307
#endif // we can test bad param error returns
308
    t_cmpl.mplatr = 0;
309
    t_cmpl.mplsz = 100000000;
310
    ercd = cre_mpl( 3, &t_cmpl );
311
    CYG_TEST_CHECK( E_NOMEM == ercd, "cre_mpl bad ercd" );
312
    // now create it well
313
    t_cmpl.mplatr = 0;
314
    t_cmpl.mplsz = 1000;
315
    ercd = cre_mpl( 3, &t_cmpl );
316
    CYG_TEST_CHECK( E_OK == ercd, "cre_mpl bad ercd" );
317
    // and check we can use it
318
    ercd = pget_blk( &vp, 3, 100 );
319
    CYG_TEST_CHECK( E_OK == ercd, "pget_blk bad ercd" );
320
    ercd = pget_blk( &vp, 3, 100000000 ); // way too large
321
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
322
    ercd = tget_blk( &vp, 3, 100, 10 );
323
    CYG_TEST_CHECK( E_OK == ercd, "tget_blk bad ercd" );
324
    ercd = get_blk( &vp, 3, 100 );
325
    CYG_TEST_CHECK( E_OK == ercd, "get_blk bad ercd" );
326
    ercd = rel_blk( 3, vp );            // vp did come from new pool
327
    CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
328
    ercd = rel_blk( 3, vp );            // vp already freed
329
    CYG_TEST_CHECK( E_PAR == ercd, "rel_blk bad ercd !E_PAR" );
330
    ercd = ref_mpl( &t_rmpl, 3 );
331
    CYG_TEST_CHECK( E_OK == ercd, "ref_mpl bad ercd" );
332
 
333
    // In order to wait on the pools, we must first consume all they have:
334
    while ( E_OK == (ercd = pget_blk( &vp, 1, 100 )) ) /* nothing */;
335
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
336
    while ( E_OK == (ercd = tget_blk( &vp, 2, 100, 1 )) ) /* nothing */;
337
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk bad ercd !E_TMOUT" );
338
    // now wait while task 2 deletes the wait objects
339
    ercd = wup_tsk( 2 );
340
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
341
    ercd = get_blk( &vp, 1, 200 );
342
    CYG_TEST_CHECK( E_DLT == ercd, "get_blk bad ercd !E_DLT" );
343
    ercd = wup_tsk( 2 );
344
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
345
    ercd = tget_blk( &vp, 2, 100, 20 );
346
    CYG_TEST_CHECK( E_DLT == ercd, "tget_blk bad ercd !E_DLT" );
347
    // check they are deleted
348
    ercd = get_blk( &vp, 1, 200 );
349
    CYG_TEST_CHECK( E_NOEXS == ercd, "get_blk bad ercd !E_NOEXS" );
350
    ercd = pget_blk( &vp, 2, 20 );
351
    CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blk bad ercd !E_NOEXS" );
352
 
353
    // re-create and do it again
354
    ercd = cre_mpl( 1, &t_cmpl );
355
    CYG_TEST_CHECK( E_OK == ercd, "cre_mpl bad ercd" );
356
    ercd = cre_mpl( 2, &t_cmpl );
357
    CYG_TEST_CHECK( E_OK == ercd, "cre_mpl bad ercd" );
358
 
359
    // In order to wait on the pools, we must first consume all they have:
360
    while ( E_OK == (ercd = pget_blk( &vp, 1, 20 )) ) /* nothing */;
361
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
362
    while ( E_OK == (ercd = tget_blk( &vp, 2, 400, 1 )) ) /* nothing */;
363
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk bad ercd !E_TMOUT" );
364
    // now wait while task 2 deletes the wait objects
365
    ercd = wup_tsk( 2 );
366
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
367
    ercd = get_blk( &vp, 1, 200 );
368
    CYG_TEST_CHECK( E_DLT == ercd, "get_blk bad ercd !E_DLT" );
369
    ercd = wup_tsk( 2 );
370
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
371
    ercd = tget_blk( &vp, 2, 500, 20 );
372
    CYG_TEST_CHECK( E_DLT == ercd, "tget_blk bad ercd !E_DLT" );
373
    // check they are deleted
374
    ercd = tget_blk( &vp, 1, 200, 1 );
375
    CYG_TEST_CHECK( E_NOEXS == ercd, "get_blk bad ercd !E_NOEXS" );
376
    ercd = get_blk( &vp, 2, 20 );
377
    CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blk bad ercd !E_NOEXS" );
378
 
379
    CYG_TEST_PASS("create/delete variable mempools");
380
#endif // CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
381
 
382
    ercd = ter_tsk( 2 );
383
    CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
384
    ercd = dly_tsk( 5 );
385
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
386
 
387
    // all done
388
    if ( 0 == tests ) {
389
        CYG_TEST_NA( "No objects have create/delete enabled" );
390
    }
391
    else {
392
        CYG_TEST_EXIT( "All done" );
393
    }
394
    ext_tsk();
395
}
396
 
397
 
398
 
399
void task2( unsigned int arg )
400
{
401
    ER ercd;
402
    int i;
403
    CYG_TEST_INFO( "Task 2 running" );
404
    ercd = get_tid( &i );
405
    CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
406
    CYG_TEST_CHECK( 2 == i, "tid not 2" );
407
    if ( 22222 != arg )
408
        CYG_TEST_FAIL( "Task 2 arg not 22222" );
409
 
410
    ercd = slp_tsk();
411
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
412
 
413
#ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
414
    ercd = del_mpf( 1 );
415
    CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" );
416
    ercd = slp_tsk();
417
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
418
    ercd = del_mpf( 2 );
419
    CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" );
420
    ercd = slp_tsk();
421
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
422
    ercd = del_mpf( 1 );
423
    CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" );
424
    ercd = slp_tsk();
425
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
426
    ercd = del_mpf( 2 );
427
    CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" );
428
    ercd = slp_tsk();
429
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
430
#endif // CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
431
 
432
#ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
433
    ercd = del_mpl( 1 );
434
    CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" );
435
    ercd = slp_tsk();
436
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
437
    ercd = del_mpl( 2 );
438
    CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" );
439
    ercd = slp_tsk();
440
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
441
    ercd = del_mpl( 1 );
442
    CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" );
443
    ercd = slp_tsk();
444
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
445
    ercd = del_mpl( 2 );
446
    CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" );
447
    ercd = slp_tsk();
448
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
449
#endif // CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
450
 
451
    // we expect task2 to be killed here
452
    CYG_TEST_FAIL( "Task 2 ran to completion!" );
453
}
454
 
455
void task3( unsigned int arg )
456
{
457
}
458
 
459
void task4( unsigned int arg )
460
{
461
}
462
 
463
#else // not enough (or too many) uITRON objects configured in
464
#define N_A_MSG "not enough uITRON objects to run test"
465
#endif // not enough (or too many) uITRON objects configured in
466
#else  // not C++ and some C++ specific options enabled
467
#define N_A_MSG "C++ specific options selected but this is C"
468
#endif  // not C++ and some C++ specific options enabled
469
#else // ! CYGVAR_KERNEL_COUNTERS_CLOCK   - can't test without it
470
#define N_A_MSG "no CYGVAR_KERNEL_COUNTERS_CLOCK"
471
#endif // ! CYGVAR_KERNEL_COUNTERS_CLOCK  - can't test without it
472
#else  // ! CYGFUN_KERNEL_THREADS_TIMER   - can't test without it
473
#define N_A_MSG "no CYGFUN_KERNEL_THREADS_TIMER"
474
#endif // ! CYGFUN_KERNEL_THREADS_TIMER   - can't test without it
475
#else  // ! CYGIMP_THREAD_PRIORITY        - can't test without it
476
#define N_A_MSG "no CYGSEM_KERNEL_SCHED_MLQUEUE"
477
#endif // ! CYGSEM_KERNEL_SCHED_MLQUEUE   - can't test without it
478
#else  // ! CYGPKG_UITRON
479
#define N_A_MSG "uITRON Compatibility layer disabled"
480
#endif // CYGPKG_UITRON
481
 
482
#ifdef N_A_MSG
483
externC void
484
cyg_start( void )
485
{
486
    CYG_TEST_INIT();
487
    CYG_TEST_NA( N_A_MSG );
488
}
489
#endif // N_A_MSG defined ie. we are N/A.
490
 
491
// EOF testcx9.cxx

powered by: WebSVN 2.1.0

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