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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [compat/] [uitron/] [current/] [tests/] [testcx2.cxx] - 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
//      testcx2.cxx
4
//
5
//      uITRON "C++" test program two
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, 2009 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 CYGIMP_UITRON_STRICT_CONFORMANCE // we DO want strict conformance
59
 
60
#ifdef CYGSEM_KERNEL_SCHED_MLQUEUE      // we DO want prioritized threads
61
 
62
#ifdef CYGFUN_KERNEL_THREADS_TIMER      // we DO want timout-able calls
63
 
64
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK     // we DO want the realtime clock
65
 
66
// we're OK if it's C++ or neither of those two is defined:
67
#if defined( __cplusplus ) || \
68
    (!defined( CYGIMP_UITRON_INLINE_FUNCS ) && \
69
     !defined( CYGIMP_UITRON_CPP_OUTLINE_FUNCS) )
70
 
71
// =================== TEST CONFIGURATION ===================
72
#if \
73
    /* test configuration for enough tasks */                      \
74
    (CYGNUM_UITRON_TASKS >= 4)                                  && \
75
    (CYGNUM_UITRON_TASKS < 90)                                  && \
76
    (CYGNUM_UITRON_START_TASKS == 1)                            && \
77
    ( !defined(CYGPKG_UITRON_TASKS_CREATE_DELETE) ||               \
78
      CYGNUM_UITRON_TASKS_INITIALLY >= 4             )          && \
79
                                                                   \
80
    /* test configuration for enough semaphores */                 \
81
    defined( CYGPKG_UITRON_SEMAS )                              && \
82
    (CYGNUM_UITRON_SEMAS >= 3)                                  && \
83
    (CYGNUM_UITRON_SEMAS < 90)                                  && \
84
    ( !defined(CYGPKG_UITRON_SEMAS_CREATE_DELETE) ||               \
85
      CYGNUM_UITRON_SEMAS_INITIALLY >= 3             )          && \
86
                                                                   \
87
    /* test configuration for enough flag objects */               \
88
    defined( CYGPKG_UITRON_FLAGS )                              && \
89
    (CYGNUM_UITRON_FLAGS >= 3)                                  && \
90
    (CYGNUM_UITRON_FLAGS < 90)                                  && \
91
    ( !defined(CYGPKG_UITRON_FLAGS_CREATE_DELETE) ||               \
92
      CYGNUM_UITRON_FLAGS_INITIALLY >= 3             )          && \
93
                                                                   \
94
    /* test configuration for enough message boxes */              \
95
    defined( CYGPKG_UITRON_MBOXES )                             && \
96
    (CYGNUM_UITRON_MBOXES >= 3)                                 && \
97
    (CYGNUM_UITRON_MBOXES < 90)                                 && \
98
    ( !defined(CYGPKG_UITRON_MBOXES_CREATE_DELETE) ||              \
99
      CYGNUM_UITRON_MBOXES_INITIALLY >= 3            )          && \
100
                                                                   \
101
    /* test configuration for enough fixed memory pools */         \
102
    defined( CYGPKG_UITRON_MEMPOOLFIXED )                       && \
103
    (CYGNUM_UITRON_MEMPOOLFIXED >= 3)                           && \
104
    (CYGNUM_UITRON_MEMPOOLFIXED < 90)                           && \
105
    ( !defined(CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE) ||        \
106
      CYGNUM_UITRON_MEMPOOLFIXED_INITIALLY >= 3       )         && \
107
                                                                   \
108
    /* test configuration for enough variable mempools */          \
109
    defined( CYGPKG_UITRON_MEMPOOLVAR )                         && \
110
    (CYGNUM_UITRON_MEMPOOLVAR >= 3)                             && \
111
    (CYGNUM_UITRON_MEMPOOLVAR < 90)                             && \
112
    ( !defined(CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE) ||          \
113
      CYGNUM_UITRON_MEMPOOLVAR_INITIALLY >= 3       )           && \
114
                                                                   \
115
    /* the end of the large #if statement */                       \
116
    1
117
 
118
// ============================ END ============================
119
 
120
 
121
 
122
#include <cyg/compat/uitron/uit_func.h> // uITRON
123
 
124
externC void
125
cyg_package_start( void )
126
{
127
    CYG_TEST_INIT();
128
    CYG_TEST_INFO( "Calling cyg_uitron_start()" );
129
    cyg_uitron_start();
130
}
131
 
132
int intercom = 0;
133
int intercount = 0;
134
INT scratch = 0;
135
 
136
extern "C" {
137
    void task1( unsigned int arg );
138
    void task2( unsigned int arg );
139
    void task3( unsigned int arg );
140
    void task4( unsigned int arg );
141
}
142
 
143
void task1( unsigned int arg )
144
{
145
    ER ercd;
146
 
147
    T_RSEM sem_info;
148
    T_RFLG flg_info;
149
    T_RMBX mbx_info;
150
    T_RMPF mpf_info;
151
    T_RMPL mpl_info;
152
    UINT flagptn;
153
    static char foo[] = "Test message";
154
    T_MSG *msgptr = (T_MSG *)foo;
155
    T_MSG *rxptr = NULL;
156
    VP blfptr = (VP)foo;
157
    VP blkptr = (VP)foo;
158
 
159
    int delay = 10;
160
    if (cyg_test_is_simulator)
161
        delay = 3;
162
 
163
    CYG_TEST_INFO( "Task 1 running" );
164
    ercd = get_tid( &scratch );
165
    CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
166
    CYG_TEST_CHECK( 1 == scratch, "tid not 1" );
167
 
168
    // start a lower prio task to interact with
169
    intercom = 1;
170
    ercd = sta_tsk( 2, 222 );
171
    CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
172
    ercd = dly_tsk( delay );
173
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
174
 
175
    // Semaphores; all the illegal argument combinations first
176
    CYG_TEST_INFO( "Testing semaphore ops" );
177
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
178
    ercd = sig_sem( -6 );
179
    CYG_TEST_CHECK( E_ID == ercd, "sig_sem bad ercd !E_ID" );
180
    ercd = sig_sem( 99 );
181
    CYG_TEST_CHECK( E_ID == ercd, "sig_sem bad ercd !E_ID" );
182
    ercd = wai_sem( -6 );
183
    CYG_TEST_CHECK( E_ID == ercd, "wai_sem bad ercd !E_ID" );
184
    ercd = wai_sem( 99 );
185
    CYG_TEST_CHECK( E_ID == ercd, "wai_sem bad ercd !E_ID" );
186
    ercd = preq_sem( -6 );
187
    CYG_TEST_CHECK( E_ID == ercd, "preq_sem bad ercd !E_ID" );
188
    ercd = preq_sem( 99 );
189
    CYG_TEST_CHECK( E_ID == ercd, "preq_sem bad ercd !E_ID" );
190
    ercd = twai_sem( -6, delay );
191
    CYG_TEST_CHECK( E_ID == ercd, "twai_sem bad ercd !E_ID" );
192
    ercd = twai_sem( 99, delay );
193
    CYG_TEST_CHECK( E_ID == ercd, "twai_sem bad ercd !E_ID" );
194
    ercd = twai_sem( 2, -999 );
195
    CYG_TEST_CHECK( E_PAR == ercd, "twai_sem bad ercd !E_PAR" );
196
    ercd = ref_sem( &sem_info, -6 );
197
    CYG_TEST_CHECK( E_ID == ercd, "ref_sem bad ercd !E_ID" );
198
    ercd = ref_sem( &sem_info, 99 );
199
    CYG_TEST_CHECK( E_ID == ercd, "ref_sem bad ercd !E_ID" );
200
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
201
    ercd = ref_sem( NULL, 2 );
202
    CYG_TEST_CHECK( E_PAR == ercd, "ref_sem bad ercd !E_PAR" );
203
#endif
204
    CYG_TEST_PASS( "bad calls: sig_sem, [t]wai_sem, preq_sem, ref_sem" );
205
#endif // we can test bad param error returns
206
 
207
    // check the waitable functions versus dispatch disable
208
    ercd = preq_sem( 2 );
209
    CYG_TEST_CHECK( E_TMOUT == ercd, "preq_sem bad ercd !E_TMOUT" );
210
    ercd = twai_sem( 2, delay );
211
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem bad ercd !E_TMOUT" );
212
    ercd = twai_sem( 2, TMO_POL );
213
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem(POL) bad ercd !E_TMOUT" );
214
    ercd = dis_dsp();
215
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
216
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
217
    ercd = wai_sem( 2 );
218
    CYG_TEST_CHECK( E_CTX == ercd, "wai_sem bad ercd !E_CTX" );
219
    ercd = twai_sem( 2, delay );
220
    CYG_TEST_CHECK( E_CTX == ercd, "twai_sem bad ercd !E_CTX" );
221
    ercd = twai_sem( 2, TMO_FEVR );
222
    CYG_TEST_CHECK( E_CTX == ercd, "twai_sem(FEVR) bad ercd !E_CTX" );
223
#endif // we can test bad param error returns
224
    ercd = twai_sem( 2, TMO_POL );
225
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem(POL) bad ercd !E_TMOUT" );
226
    ercd = preq_sem( 2 );
227
    CYG_TEST_CHECK( E_TMOUT == ercd, "preq_sem bad ercd !E_TMOUT" );
228
    ercd = ena_dsp();
229
    CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
230
    ercd = preq_sem( 2 );
231
    CYG_TEST_CHECK( E_TMOUT == ercd, "preq_sem bad ercd !E_TMOUT" );
232
    ercd = twai_sem( 2, delay );
233
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem bad ercd !E_TMOUT" );
234
    ercd = twai_sem( 2, TMO_POL );
235
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem(POL) bad ercd !E_TMOUT" );
236
    CYG_TEST_PASS( "bad calls: wai_sem, twai_sem with dis_dsp" );
237
 
238
    // check ref_sem with various states
239
    ercd = ref_sem( &sem_info, 2 );
240
    CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
241
    CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
242
    CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
243
    ercd = sig_sem( 2 );
244
    CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
245
    ercd = ref_sem( &sem_info, 2 );
246
    CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
247
    CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
248
    CYG_TEST_CHECK( 1 == sem_info.semcnt, "semcnt should be 1" );
249
    ercd = preq_sem( 2 );
250
    CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
251
    ercd = ref_sem( &sem_info, 2 );
252
    CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
253
    CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
254
    CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
255
    ercd = ref_sem( &sem_info, 2 );
256
    CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
257
    CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
258
    CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
259
    ercd = sig_sem( 2 );
260
    CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
261
    ercd = sig_sem( 2 );
262
    CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
263
    ercd = ref_sem( &sem_info, 2 );
264
    CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
265
    CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
266
    CYG_TEST_CHECK( 2 == sem_info.semcnt, "semcnt should be 2" );
267
    ercd = wai_sem( 2 );
268
    CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
269
    ercd = ref_sem( &sem_info, 2 );
270
    CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
271
    CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
272
    CYG_TEST_CHECK( 1 == sem_info.semcnt, "semcnt should be 1" );
273
    ercd = twai_sem( 2, delay );
274
    CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
275
    ercd = ref_sem( &sem_info, 2 );
276
    CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
277
    CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
278
    CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
279
    intercom = 0;
280
    ercd = dly_tsk( delay );
281
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
282
    intercom = 1;
283
    ercd = ref_sem( &sem_info, 2 );
284
    CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
285
    CYG_TEST_CHECK( 0 != sem_info.wtsk, "sem.wtsk should be non0" );
286
    CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
287
    ercd = sig_sem( 2 );
288
    CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
289
    ercd = ref_sem( &sem_info, 2 );
290
    CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
291
    CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be non0" );
292
#if 1
293
    CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
294
#else // old, non-uITRON semantics
295
    CYG_TEST_CHECK( 1 == sem_info.semcnt, "semcnt should be 1" );
296
#endif
297
    ercd = dly_tsk( delay );               // let task 2 pick up the signal
298
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
299
    ercd = ref_sem( &sem_info, 2 );
300
    CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
301
    CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
302
    CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
303
    CYG_TEST_PASS( "good calls: sig_sem, [t]wai,preq_sem with ref_sem" );
304
 
305
    // Flags; all the illegal argument combinations first
306
    CYG_TEST_INFO( "Testing flag ops" );
307
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
308
    ercd = set_flg( -6, 1 );
309
    CYG_TEST_CHECK( E_ID == ercd, "set_flg bad ercd !E_ID" );
310
    ercd = set_flg( 99, 1 );
311
    CYG_TEST_CHECK( E_ID == ercd, "set_flg bad ercd !E_ID" );
312
    ercd = clr_flg( -6, 1 );
313
    CYG_TEST_CHECK( E_ID == ercd, "clr_flg bad ercd !E_ID" );
314
    ercd = clr_flg( 99, 1 );
315
    CYG_TEST_CHECK( E_ID == ercd, "sig_flg bad ercd !E_ID" );
316
    ercd = wai_flg( &flagptn, -6, 7, TWF_ANDW );
317
    CYG_TEST_CHECK( E_ID == ercd, "wai_flg bad ercd !E_ID" );
318
    ercd = wai_flg( &flagptn, 99, 7, TWF_ANDW );
319
    CYG_TEST_CHECK( E_ID == ercd, "wai_flg bad ercd !E_ID" );
320
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
321
    ercd = wai_flg( NULL, 2, 7, TWF_ANDW );
322
    CYG_TEST_CHECK( E_PAR == ercd, "wai_flg bad ercd !E_PAR" );
323
#endif
324
    ercd = wai_flg( &flagptn, 2, 7, 34657 );
325
    CYG_TEST_CHECK( E_PAR == ercd, "wai_flg bad ercd !E_PAR" );
326
    ercd = wai_flg( &flagptn, 2, 0, TWF_ANDW );
327
    CYG_TEST_CHECK( E_PAR == ercd, "wai_flg bad ercd !E_PAR" );
328
    ercd = pol_flg( &flagptn, -6, 7, TWF_ANDW );
329
    CYG_TEST_CHECK( E_ID == ercd, "pol_flg bad ercd !E_ID" );
330
    ercd = pol_flg( &flagptn, 99, 7, TWF_ANDW );
331
    CYG_TEST_CHECK( E_ID == ercd, "pol_flg bad ercd !E_ID" );
332
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
333
    ercd = pol_flg( NULL, 2, 7, TWF_ANDW );
334
    CYG_TEST_CHECK( E_PAR == ercd, "pol_flg bad ercd !E_PAR" );
335
#endif
336
    ercd = pol_flg( &flagptn, 2, 7, 34657 );
337
    CYG_TEST_CHECK( E_PAR == ercd, "pol_flg bad ercd !E_PAR" );
338
    ercd = pol_flg( &flagptn, 2, 0, TWF_ANDW );
339
    CYG_TEST_CHECK( E_PAR == ercd, "pol_flg bad ercd !E_PAR" );
340
    ercd = twai_flg( &flagptn, -6, 7, TWF_ANDW, delay );
341
    CYG_TEST_CHECK( E_ID == ercd, "twai_flg bad ercd !E_ID" );
342
    ercd = twai_flg( &flagptn, 99, 7, TWF_ANDW, delay );
343
    CYG_TEST_CHECK( E_ID == ercd, "twai_flg bad ercd !E_ID" );
344
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
345
    ercd = twai_flg( NULL, 2, 7, TWF_ANDW, delay );
346
    CYG_TEST_CHECK( E_PAR == ercd, "twai_flg bad ercd !E_PAR" );
347
#endif
348
    ercd = twai_flg( &flagptn, 2, 7, 34657, delay );
349
    CYG_TEST_CHECK( E_PAR == ercd, "twai_flg bad ercd !E_PAR" );
350
    ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, -999 );
351
    CYG_TEST_CHECK( E_PAR == ercd, "twai_flg bad ercd !E_PAR" );
352
    ercd = twai_flg( &flagptn, 2, 0, TWF_ANDW, delay );
353
    CYG_TEST_CHECK( E_PAR == ercd, "twai_flg bad ercd !E_PAR" );
354
    ercd = ref_flg( &flg_info, -6 );
355
    CYG_TEST_CHECK( E_ID == ercd, "ref_flg bad ercd !E_ID" );
356
    ercd = ref_flg( &flg_info, 99 );
357
    CYG_TEST_CHECK( E_ID == ercd, "ref_flg bad ercd !E_ID" );
358
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
359
    ercd = ref_flg( NULL, 2 );
360
    CYG_TEST_CHECK( E_PAR == ercd, "ref_flg bad ercd !E_PAR" );
361
#endif
362
    CYG_TEST_PASS( "bad calls: set_flg, clr_flg, [t]wai,pol_flg, ref_flg" );
363
#endif // we can test bad param error returns
364
 
365
    // check the waitable functions versus dispatch disable
366
    ercd = pol_flg( &flagptn, 2, 7, TWF_ANDW );
367
    CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" );
368
    ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, delay );
369
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg bad ercd !E_TMOUT" );
370
    ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, TMO_POL );
371
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg(POL) bad ercd !E_TMOUT" );
372
    ercd = dis_dsp();
373
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
374
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
375
    ercd = wai_flg( &flagptn, 2, 7, TWF_ANDW );
376
    CYG_TEST_CHECK( E_CTX == ercd, "wai_flg bad ercd !E_CTX" );
377
    ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, delay );
378
    CYG_TEST_CHECK( E_CTX == ercd, "twai_flg bad ercd !E_CTX" );
379
    ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, TMO_FEVR );
380
    CYG_TEST_CHECK( E_CTX == ercd, "twai_flg(FEVR) bad ercd !E_CTX" );
381
#endif // we can test bad param error returns
382
    ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, TMO_POL );
383
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg(POL) bad ercd !E_TMOUT" );
384
    ercd = pol_flg( &flagptn, 2, 7, TWF_ANDW );
385
    CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" );
386
    ercd = ena_dsp();
387
    CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
388
    ercd = pol_flg( &flagptn, 2, 7, TWF_ANDW );
389
    CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" );
390
    ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, delay );
391
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg bad ercd !E_TMOUT" );
392
    ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, TMO_POL );
393
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg(POL) bad ercd !E_TMOUT" );
394
    CYG_TEST_PASS( "bad calls: wai_flg, twai_flg with dis_dsp" );
395
 
396
    // check ref_flg with various states
397
    ercd = ref_flg( &flg_info, 2 );
398
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
399
    CYG_TEST_CHECK( 0 == flg_info.wtsk, "flg.wtsk should be non0" );
400
    CYG_TEST_CHECK( 0 == flg_info.flgptn, "flgptn should be 0" );
401
    intercom = 0;
402
    ercd = dly_tsk( delay );               // let task 2 start waiting
403
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
404
    intercom = 1;
405
    ercd = ref_flg( &flg_info, 2 );
406
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
407
    CYG_TEST_CHECK( 0 != flg_info.wtsk, "flg.wtsk should be non0" );
408
    CYG_TEST_CHECK( 0 == flg_info.flgptn, "flgptn should be 0" );
409
    ercd = set_flg( 2, 0x5555 );
410
    CYG_TEST_CHECK( E_OK == ercd, "sig_flg bad ercd" );
411
    ercd = dly_tsk( delay );
412
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
413
    ercd = ref_flg( &flg_info, 2 );
414
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
415
    CYG_TEST_CHECK( 0 != flg_info.wtsk, "flg.wtsk should be non0" );
416
    CYG_TEST_CHECK( 0x5555 == flg_info.flgptn, "flgptn should be 0x5555" );
417
    ercd = clr_flg( 2, 0xF0F0 );
418
    CYG_TEST_CHECK( E_OK == ercd, "clr_flg bad ercd" );
419
    ercd = dly_tsk( delay );
420
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
421
    ercd = ref_flg( &flg_info, 2 );
422
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
423
    CYG_TEST_CHECK( 0 != flg_info.wtsk, "flg.wtsk should be non0" );
424
    CYG_TEST_CHECK( 0x5050 == flg_info.flgptn, "flgptn should be 0x5050" );
425
    ercd = set_flg( 2, 0xFFFF );
426
    CYG_TEST_CHECK( E_OK == ercd, "sig_flg bad ercd" );
427
    ercd = dly_tsk( delay );
428
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
429
    ercd = ref_flg( &flg_info, 2 );
430
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
431
    CYG_TEST_CHECK( 0 == flg_info.wtsk, "flg.wtsk should be 0" );
432
    CYG_TEST_CHECK( 0xFFFF == flg_info.flgptn, "flgptn should be 0xFFFF" );
433
    CYG_TEST_PASS( "good calls: clr_flg, set_flg, wai_flg with ref_flg" );
434
 
435
    // Mailboxes; all the illegal argument combinations first
436
    CYG_TEST_INFO( "Testing mailbox ops" );
437
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
438
    ercd = snd_msg( -6, msgptr );
439
    CYG_TEST_CHECK( E_ID == ercd, "snd_msg bad ercd !E_ID" );
440
    ercd = snd_msg( 99, msgptr );
441
    CYG_TEST_CHECK( E_ID == ercd, "snd_msg bad ercd !E_ID" );
442
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
443
    ercd = snd_msg( 2, NULL );
444
    CYG_TEST_CHECK( E_PAR == ercd, "snd_msg bad ercd !E_PAR" );
445
#endif
446
    ercd = rcv_msg( &rxptr, -6 );
447
    CYG_TEST_CHECK( E_ID == ercd, "rcv_msg bad ercd !E_ID" );
448
    ercd = rcv_msg( &rxptr, 99 );
449
    CYG_TEST_CHECK( E_ID == ercd, "rcv_msg bad ercd !E_ID" );
450
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
451
    ercd = rcv_msg( NULL, 2 );
452
    CYG_TEST_CHECK( E_PAR == ercd, "rcv_msg bad ercd !E_PAR" );
453
#endif
454
    ercd = prcv_msg( &rxptr, -6 );
455
    CYG_TEST_CHECK( E_ID == ercd, "prcv_msg bad ercd !E_ID" );
456
    ercd = prcv_msg( &rxptr, 99 );
457
    CYG_TEST_CHECK( E_ID == ercd, "prcv_msg bad ercd !E_ID" );
458
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
459
    ercd = prcv_msg( NULL, 2 );
460
    CYG_TEST_CHECK( E_PAR == ercd, "prcv_msg bad ercd !E_PAR" );
461
#endif
462
    ercd = trcv_msg( &rxptr, -6, delay );
463
    CYG_TEST_CHECK( E_ID == ercd, "trcv_msg bad ercd !E_ID" );
464
    ercd = trcv_msg( &rxptr, 99, delay );
465
    CYG_TEST_CHECK( E_ID == ercd, "trcv_msg bad ercd !E_ID" );
466
    ercd = trcv_msg( &rxptr, 2, -999 );
467
    CYG_TEST_CHECK( E_PAR == ercd, "trcv_msg bad ercd !E_PAR" );
468
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
469
    ercd = trcv_msg( NULL, 2, delay );
470
    CYG_TEST_CHECK( E_PAR == ercd, "trcv_msg bad ercd !E_PAR" );
471
#endif
472
    ercd = ref_mbx( &mbx_info, -6 );
473
    CYG_TEST_CHECK( E_ID == ercd, "ref_mbx bad ercd !E_ID" );
474
    ercd = ref_mbx( &mbx_info, 99 );
475
    CYG_TEST_CHECK( E_ID == ercd, "ref_mbx bad ercd !E_ID" );
476
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
477
    ercd = ref_mbx( NULL, 2 );
478
    CYG_TEST_CHECK( E_PAR == ercd, "ref_mbx bad ercd !E_PAR" );
479
#endif
480
    CYG_TEST_PASS( "bad calls: snd_msg, [pt]rcv_msg, ref_mbx" );
481
#endif // we can test bad param error returns
482
 
483
    // check the waitable functions versus dispatch disable
484
    ercd = prcv_msg( &rxptr, 2 );
485
    CYG_TEST_CHECK( E_TMOUT == ercd, "prcv_msg bad ercd !E_TMOUT" );
486
    ercd = trcv_msg( &rxptr, 2, delay );
487
    CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg bad ercd !E_TMOUT" );
488
    ercd = trcv_msg( &rxptr, 2, TMO_POL );
489
    CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg(POL) bad ercd !E_TMOUT" );
490
    ercd = dis_dsp();
491
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
492
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
493
    ercd = rcv_msg( &rxptr, 2 );
494
    CYG_TEST_CHECK( E_CTX == ercd, "rcv_msg bad ercd !E_CTX" );
495
    ercd = trcv_msg( &rxptr, 2, delay );
496
    CYG_TEST_CHECK( E_CTX == ercd, "trcv_msg bad ercd !E_CTX" );
497
    ercd = trcv_msg( &rxptr, 2, TMO_FEVR );
498
    CYG_TEST_CHECK( E_CTX == ercd, "trcv_msg(FEVR) bad ercd !E_CTX" );
499
#endif // we can test bad param error returns
500
    ercd = trcv_msg( &rxptr, 2, TMO_POL );
501
    CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg(POL) bad ercd !E_TMOUT" );
502
    ercd = prcv_msg( &rxptr, 2 );
503
    CYG_TEST_CHECK( E_TMOUT == ercd, "prcv_msg bad ercd !E_TMOUT" );
504
    ercd = ena_dsp();
505
    CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
506
    ercd = prcv_msg( &rxptr, 2 );
507
    CYG_TEST_CHECK( E_TMOUT == ercd, "prcv_msg bad ercd !E_TMOUT" );
508
    ercd = trcv_msg( &rxptr, 2, delay );
509
    CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg bad ercd !E_TMOUT" );
510
    ercd = trcv_msg( &rxptr, 2, TMO_POL );
511
    CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg(POL) bad ercd !E_TMOUT" );
512
    CYG_TEST_PASS( "bad calls: rcv_msg, trcv_msg with dis_dsp" );
513
 
514
    // check ref_mbx with various states
515
    ercd = ref_mbx( &mbx_info, 2 );
516
    CYG_TEST_CHECK( E_OK == ercd, "ref_mbx bad ercd" );
517
    CYG_TEST_CHECK( 0 == mbx_info.wtsk, "mbx.wtsk should be 0" );
518
    CYG_TEST_CHECK( NADR == mbx_info.pk_msg, "mbx peek should be NADR" );
519
    intercom = 0;
520
    ercd = dly_tsk( delay );               // let task 2 start waiting
521
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
522
    intercom = 1;
523
    ercd = ref_mbx( &mbx_info, 2 );
524
    CYG_TEST_CHECK( E_OK == ercd, "ref_mbx bad ercd" );
525
    CYG_TEST_CHECK( 0 != mbx_info.wtsk, "mbx.wtsk should be non0" );
526
    CYG_TEST_CHECK( NADR == mbx_info.pk_msg, "mbx peek should be NADR" );
527
    ercd = snd_msg( 2, msgptr );
528
    CYG_TEST_CHECK( E_OK == ercd, "snd_msg bad ercd" );
529
    ercd = ref_mbx( &mbx_info, 2 );
530
    CYG_TEST_CHECK( E_OK == ercd, "ref_mbx bad ercd" );
531
    CYG_TEST_CHECK( 0 == mbx_info.wtsk, "mbx.wtsk should be 0" );
532
#if 1
533
    CYG_TEST_CHECK( NADR == mbx_info.pk_msg, "mbx peek should be NADR" );
534
#else // old, non-uITRON semantics
535
    CYG_TEST_CHECK( msgptr == mbx_info.pk_msg, "mbx peek should be msgptr" );
536
#endif
537
    ercd = dly_tsk( delay );
538
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
539
    ercd = ref_mbx( &mbx_info, 2 );
540
    CYG_TEST_CHECK( E_OK == ercd, "ref_mbx bad ercd" );
541
    CYG_TEST_CHECK( 0 == mbx_info.wtsk, "mbx.wtsk should be 0" );
542
    CYG_TEST_CHECK( NADR == mbx_info.pk_msg, "mbx peek should be NADR" );
543
    // fill the message box, expect E_QOVR
544
    for ( scratch = 0 ; scratch < 100 ; scratch++ ) {
545
        if ( E_OK != ( ercd = snd_msg( 2, msgptr ) ) )
546
            break;
547
    }
548
    CYG_TEST_CHECK( (100 == scratch) || (E_QOVR == ercd),
549
                    "snd_msg bad ercd !E_QOVR/E_OK" );
550
    // empty the message box, expect the right number and E_TMOUT
551
    for (             ;     1         ; scratch-- ) {
552
        if ( E_OK != ( ercd = prcv_msg( &rxptr, 2 ) ) )
553
            break;
554
    }
555
    CYG_TEST_CHECK( 0 == scratch, "rcv_msg count bad scratch!=0" );
556
    CYG_TEST_CHECK( E_TMOUT == ercd, "rcv_msg bad ercd !E_TMOUT" );
557
 
558
    CYG_TEST_PASS( "good calls: rcv_msg, snd_msg with ref_msg" );
559
 
560
    // Fixed block memory pools: all the illegal argument combinations first
561
    CYG_TEST_INFO( "Testing fixed block memory ops" );
562
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
563
    ercd = rel_blf( -6, blfptr );
564
    CYG_TEST_CHECK( E_ID == ercd, "rel_blf bad ercd !E_ID" );
565
    ercd = rel_blf( 99, blfptr );
566
    CYG_TEST_CHECK( E_ID == ercd, "rel_blf bad ercd !E_ID" );
567
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
568
    ercd = rel_blf( 2, NULL );
569
    CYG_TEST_CHECK( E_PAR == ercd, "rel_blf bad ercd !E_PAR" );
570
#endif
571
#endif // we can test bad param error returns
572
    ercd = rel_blf( 2, blfptr );        // it did not come from a mpf
573
    CYG_TEST_CHECK( E_PAR == ercd, "rel_blf bad ercd !E_PAR" );
574
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
575
    ercd = get_blf( &blfptr, -6 );
576
    CYG_TEST_CHECK( E_ID == ercd, "get_blf bad ercd !E_ID" );
577
    ercd = get_blf( &blfptr, 99 );
578
    CYG_TEST_CHECK( E_ID == ercd, "get_blf bad ercd !E_ID" );
579
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
580
    ercd = get_blf( NULL, 2 );
581
    CYG_TEST_CHECK( E_PAR == ercd, "get_blf bad ercd !E_PAR" );
582
#endif
583
    ercd = pget_blf( &blfptr, -6 );
584
    CYG_TEST_CHECK( E_ID == ercd, "pget_blf bad ercd !E_ID" );
585
    ercd = pget_blf( &blfptr, 99 );
586
    CYG_TEST_CHECK( E_ID == ercd, "pget_blf bad ercd !E_ID" );
587
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
588
    ercd = pget_blf( NULL, 2 );
589
    CYG_TEST_CHECK( E_PAR == ercd, "pget_blf bad ercd !E_PAR" );
590
#endif
591
    ercd = tget_blf( &blfptr, -6, delay );
592
    CYG_TEST_CHECK( E_ID == ercd, "tget_blf bad ercd !E_ID" );
593
    ercd = tget_blf( &blfptr, 99, delay );
594
    CYG_TEST_CHECK( E_ID == ercd, "tget_blf bad ercd !E_ID" );
595
    ercd = tget_blf( &blfptr, 2, -999 );
596
    CYG_TEST_CHECK( E_PAR == ercd, "tget_blf bad ercd !E_PAR" );
597
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
598
    ercd = tget_blf( NULL, 2, delay );
599
    CYG_TEST_CHECK( E_PAR == ercd, "tget_blf bad ercd !E_PAR" );
600
#endif
601
    ercd = ref_mpf( &mpf_info, -6 );
602
    CYG_TEST_CHECK( E_ID == ercd, "ref_mpf bad ercd !E_ID" );
603
    ercd = ref_mpf( &mpf_info, 99 );
604
    CYG_TEST_CHECK( E_ID == ercd, "ref_mpf bad ercd !E_ID" );
605
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
606
    ercd = ref_mpf( NULL, 2 );
607
    CYG_TEST_CHECK( E_PAR == ercd, "ref_mpf bad ercd !E_PAR" );
608
#endif
609
    CYG_TEST_PASS( "bad calls: rel_blf, [pt]get_blf, ref_mpf " );
610
#endif // we can test bad param error returns
611
 
612
    // check the waitable functions versus dispatch disable
613
    ercd = pget_blf( &blfptr, 2 );
614
    CYG_TEST_CHECK( E_OK == ercd, "pget_blf bad ercd" );
615
    ercd = rel_blf( 2, blfptr );
616
    CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
617
    ercd = tget_blf( &blfptr, 2, delay );
618
    CYG_TEST_CHECK( E_OK == ercd, "tget_blf bad ercd" );
619
    ercd = dis_dsp();
620
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
621
    ercd = rel_blf( 2, blfptr );
622
    CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
623
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
624
    ercd = get_blf( &blfptr, 2 );
625
    CYG_TEST_CHECK( E_CTX == ercd, "get_blf bad ercd !E_CTX" );
626
    ercd = tget_blf( &blfptr, 2, delay );
627
    CYG_TEST_CHECK( E_CTX == ercd, "tget_blf bad ercd !E_CTX" );
628
#endif // we can test bad param error returns
629
    ercd = ena_dsp();
630
    CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
631
    ercd = pget_blf( &blfptr, 2 );
632
    CYG_TEST_CHECK( E_OK == ercd, "pget_blf bad ercd" );
633
    ercd = rel_blf( 2, blfptr );
634
    CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
635
    ercd = tget_blf( &blfptr, 2, delay );
636
    CYG_TEST_CHECK( E_OK == ercd, "tget_blf bad ercd" );
637
    ercd = rel_blf( 2, blfptr );
638
    CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
639
    // consume the whole thing then do it again, expecting E_TMOUT
640
    while ( E_OK == (ercd = pget_blf( &blfptr, 2 ) ) )
641
        continue;
642
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
643
    ercd = pget_blf( &blfptr, 2 );
644
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
645
    ercd = tget_blf( &blfptr, 2, delay );
646
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf bad ercd !E_TMOUT" );
647
    ercd = tget_blf( &blfptr, 2, TMO_POL );
648
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf(POL) bad ercd !E_TMOUT" );
649
    ercd = dis_dsp();
650
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
651
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
652
    ercd = get_blf( &blfptr, 2 );
653
    CYG_TEST_CHECK( E_CTX == ercd, "get_blf bad ercd !E_CTX" );
654
    ercd = tget_blf( &blfptr, 2, delay );
655
    CYG_TEST_CHECK( E_CTX == ercd, "tget_blf bad ercd !E_CTX" );
656
    ercd = tget_blf( &blfptr, 2, TMO_FEVR );
657
    CYG_TEST_CHECK( E_CTX == ercd, "tget_blf(FEVR) bad ercd !E_CTX" );
658
#endif // we can test bad param error returns
659
    ercd = tget_blf( &blfptr, 2, TMO_POL );
660
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf(POL) bad ercd !E_TMOUT" );
661
    ercd = ena_dsp();
662
    CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
663
    ercd = pget_blf( &blfptr, 2 );
664
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
665
    ercd = tget_blf( &blfptr, 2, delay );
666
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
667
    ercd = tget_blf( &blfptr, 2, TMO_POL );
668
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf(POL) bad ercd !E_TMOUT" );
669
    CYG_TEST_PASS( "bad calls: rel_blf, [pt]get_blf with ena_dsp" );
670
 
671
    // check ref_mpf with various states
672
    ercd = ref_mpf( &mpf_info, 2 );
673
    CYG_TEST_CHECK( E_OK == ercd, "ref_mpf bad ercd" );
674
    CYG_TEST_CHECK( 0 == mpf_info.wtsk, "mpf.wtsk should be 0" );
675
    CYG_TEST_CHECK( 0 == mpf_info.frbcnt, "mpf.frbcnt should be 0" );
676
    intercom = 0;
677
    ercd = dly_tsk( delay );               // let task 2 start waiting
678
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
679
    intercom = 1;
680
    ercd = ref_mpf( &mpf_info, 2 );
681
    CYG_TEST_CHECK( E_OK == ercd, "ref_mpf bad ercd" );
682
    CYG_TEST_CHECK( 0 != mpf_info.wtsk, "mpf.wtsk should be non0" );
683
    CYG_TEST_CHECK( 0 == mpf_info.frbcnt, "mpf.frbcnt should be 0" );
684
    ercd = rel_blf( 2, blfptr );
685
    CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
686
    ercd = ref_mpf( &mpf_info, 2 );
687
    CYG_TEST_CHECK( E_OK == ercd, "ref_mpf bad ercd" );
688
    CYG_TEST_CHECK( 0 == mpf_info.wtsk, "mpf.wtsk should be 0" );
689
#if 1
690
    CYG_TEST_CHECK( 0 == mpf_info.frbcnt, "mpf.frbcnt should be 0" );
691
#else // old, non-uITRON semantics
692
    CYG_TEST_CHECK( 0 != mpf_info.frbcnt, "mpf.frbcnt should be non0" );
693
#endif
694
    ercd = dly_tsk( delay );               // let task 2 start waiting
695
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
696
    ercd = ref_mpf( &mpf_info, 2 );
697
    CYG_TEST_CHECK( E_OK == ercd, "ref_mpf bad ercd" );
698
    CYG_TEST_CHECK( 0 == mpf_info.wtsk, "mpf.wtsk should be 0" );
699
    CYG_TEST_CHECK( 0 == mpf_info.frbcnt, "mpf.frbcnt should be 0" );
700
    CYG_TEST_PASS( "good calls: rel_blf, get_blf with ref_mpf" );
701
 
702
    // Variable block memory pools; illegal arguments
703
    CYG_TEST_INFO( "Testing variable block memory ops" );
704
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
705
    ercd = rel_blk( -6, blkptr );
706
    CYG_TEST_CHECK( E_ID == ercd, "rel_blk bad ercd !E_ID" );
707
    ercd = rel_blk( 99, blkptr );
708
    CYG_TEST_CHECK( E_ID == ercd, "rel_blk bad ercd !E_ID" );
709
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
710
    ercd = rel_blk( 2, NULL );
711
    CYG_TEST_CHECK( E_PAR == ercd, "rel_blk bad ercd !E_PAR" );
712
#endif
713
#endif // we can test bad param error returns
714
    ercd = rel_blk( 2, blkptr );        // it did not come from a mpl
715
    CYG_TEST_CHECK( E_PAR == ercd, "rel_blk bad ercd !E_PAR" );
716
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
717
    ercd = get_blk( &blkptr, -6, 100 );
718
    CYG_TEST_CHECK( E_ID == ercd, "get_blk bad ercd !E_ID" );
719
    ercd = get_blk( &blkptr, 99, 100 );
720
    CYG_TEST_CHECK( E_ID == ercd, "get_blk bad ercd !E_ID" );
721
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
722
    ercd = get_blk( NULL, 2, 100 );
723
    CYG_TEST_CHECK( E_PAR == ercd, "get_blk bad ercd !E_PAR" );
724
#endif
725
    ercd = pget_blk( &blkptr, -6, 100 );
726
    CYG_TEST_CHECK( E_ID == ercd, "pget_blk bad ercd !E_ID" );
727
    ercd = pget_blk( &blkptr, 99, 100 );
728
    CYG_TEST_CHECK( E_ID == ercd, "pget_blk bad ercd !E_ID" );
729
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
730
    ercd = pget_blk( NULL, 2, 100 );
731
    CYG_TEST_CHECK( E_PAR == ercd, "pget_blk bad ercd !E_PAR" );
732
#endif
733
    ercd = tget_blk( &blkptr, -6, 100, delay );
734
    CYG_TEST_CHECK( E_ID == ercd, "tget_blk bad ercd !E_ID" );
735
    ercd = tget_blk( &blkptr, 99, 100, delay );
736
    CYG_TEST_CHECK( E_ID == ercd, "tget_blk bad ercd !E_ID" );
737
    ercd = tget_blk( &blkptr, 2, 100, -999 );
738
    CYG_TEST_CHECK( E_PAR == ercd, "tget_blk bad ercd !E_PAR" );
739
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
740
    ercd = tget_blk( NULL, 2, 100, delay );
741
    CYG_TEST_CHECK( E_PAR == ercd, "tget_blk bad ercd !E_PAR" );
742
#endif
743
    ercd = ref_mpl( &mpl_info, -6 );
744
    CYG_TEST_CHECK( E_ID == ercd, "ref_mpl bad ercd !E_ID" );
745
    ercd = ref_mpl( &mpl_info, 99 );
746
    CYG_TEST_CHECK( E_ID == ercd, "ref_mpl bad ercd !E_ID" );
747
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
748
    ercd = ref_mpl( NULL, 2 );
749
    CYG_TEST_CHECK( E_PAR == ercd, "ref_mpl bad ercd !E_PAR" );
750
#endif
751
    CYG_TEST_PASS( "bad calls: rel_blk, [pt]get_blk, ref_mpl " );
752
#endif // we can test bad param error returns
753
 
754
    // check the waitable functions versus dispatch disable
755
    ercd = pget_blk( &blkptr, 2, 100 );
756
    CYG_TEST_CHECK( E_OK == ercd, "pget_blk bad ercd" );
757
    ercd = rel_blk( 2, blkptr );
758
    CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
759
    ercd = tget_blk( &blkptr, 2, 100, delay );
760
    CYG_TEST_CHECK( E_OK == ercd, "tget_blk bad ercd" );
761
    ercd = dis_dsp();
762
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
763
    ercd = rel_blk( 2, blkptr );
764
    CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
765
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
766
    ercd = get_blk( &blkptr, 2, 100 );
767
    CYG_TEST_CHECK( E_CTX == ercd, "get_blk bad ercd !E_CTX" );
768
    ercd = tget_blk( &blkptr, 2, 100, delay );
769
    CYG_TEST_CHECK( E_CTX == ercd, "tget_blk bad ercd !E_CTX" );
770
#endif // we can test bad param error returns
771
    ercd = ena_dsp();
772
    CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
773
    ercd = pget_blk( &blkptr, 2, 100 );
774
    CYG_TEST_CHECK( E_OK == ercd, "pget_blk bad ercd" );
775
    ercd = rel_blk( 2, blkptr );
776
    CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
777
    ercd = tget_blk( &blkptr, 2, 100, delay );
778
    CYG_TEST_CHECK( E_OK == ercd, "tget_blk bad ercd" );
779
    ercd = rel_blk( 2, blkptr );
780
    CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
781
    // consume the whole thing then do it again, expecting E_TMOUT
782
    while ( E_OK == (ercd = pget_blk( &blkptr, 2, 100 ) ) )
783
        continue;
784
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
785
    ercd = pget_blk( &blkptr, 2, 100 );
786
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
787
    ercd = tget_blk( &blkptr, 2, 100, delay );
788
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk bad ercd !E_TMOUT" );
789
    ercd = tget_blk( &blkptr, 2, 100, TMO_POL );
790
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk(POL) bad ercd !E_TMOUT" );
791
    ercd = dis_dsp();
792
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
793
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
794
    ercd = get_blk( &blkptr, 2, 100 );
795
    CYG_TEST_CHECK( E_CTX == ercd, "get_blk bad ercd !E_CTX" );
796
    ercd = tget_blk( &blkptr, 2, 100, delay );
797
    CYG_TEST_CHECK( E_CTX == ercd, "tget_blk bad ercd !E_CTX" );
798
    ercd = tget_blk( &blkptr, 2, 100, TMO_FEVR );
799
    CYG_TEST_CHECK( E_CTX == ercd, "tget_blk(FEVR) bad ercd !E_CTX" );
800
#endif // we can test bad param error returns
801
    ercd = tget_blk( &blkptr, 2, 100, TMO_POL );
802
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk(POL) bad ercd !E_TMOUT" );
803
    ercd = ena_dsp();
804
    CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
805
    ercd = pget_blk( &blkptr, 2, 100 );
806
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
807
    ercd = tget_blk( &blkptr, 2, 100, delay );
808
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
809
    ercd = tget_blk( &blkptr, 2, 100, TMO_POL );
810
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk(POL) bad ercd !E_TMOUT" );
811
    CYG_TEST_PASS( "bad calls: rel_blk, [pt]get_blk with ena_dsp" );
812
 
813
    // check ref_mpl with various states
814
    ercd = ref_mpl( &mpl_info, 2 );
815
    CYG_TEST_CHECK( E_OK == ercd, "ref_mpl bad ercd" );
816
    CYG_TEST_CHECK( 0 == mpl_info.wtsk, "mpl.wtsk should be 0" );
817
    CYG_TEST_CHECK( mpl_info.maxsz <= mpl_info.frsz,
818
                    "mpl.maxsz not < mpl.frsz" );
819
    intercom = 0;
820
    ercd = dly_tsk( delay );               // let task 2 start waiting
821
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
822
    intercom = 1;
823
    ercd = ref_mpl( &mpl_info, 2 );
824
    CYG_TEST_CHECK( E_OK == ercd, "ref_mpl bad ercd" );
825
    CYG_TEST_CHECK( 0 != mpl_info.wtsk, "mpl.wtsk should be non0" );
826
    ercd = rel_blk( 2, blkptr );
827
    CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
828
    ercd = ref_mpl( &mpl_info, 2 );
829
    CYG_TEST_CHECK( E_OK == ercd, "ref_mpl bad ercd" );
830
    CYG_TEST_CHECK( 0 == mpl_info.wtsk, "mpl.wtsk should be 0" );
831
    ercd = dly_tsk( delay );               // let task 2 start waiting
832
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
833
    ercd = ref_mpl( &mpl_info, 2 );
834
    CYG_TEST_CHECK( E_OK == ercd, "ref_mpl bad ercd" );
835
    CYG_TEST_CHECK( 0 == mpl_info.wtsk, "mpl.wtsk should be 0" );
836
    CYG_TEST_PASS( "good calls: rel_blk, get_blk with ref_mpl" );
837
 
838
    // all done
839
    CYG_TEST_EXIT( "All done" );
840
    ext_tsk();
841
}
842
 
843
 
844
 
845
void task2( unsigned int arg )
846
{
847
    ER ercd;
848
    T_MSG *msgp = NULL;
849
    UINT flgval = 0;
850
    VP blfp = NULL;
851
    VP blkp = NULL;
852
 
853
    CYG_TEST_INFO( "Task 2 running" );
854
    ercd = get_tid( &scratch );
855
    CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
856
    CYG_TEST_CHECK( 2 == scratch, "tid not 2" );
857
    if ( 222 != arg )
858
        CYG_TEST_FAIL( "Task 2 arg not 222" );
859
 
860
    while ( intercom ) {
861
        ercd = rot_rdq( 0 );
862
        CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
863
    }
864
    ercd = wai_sem( 2 );
865
    CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
866
    while ( intercom ) {
867
        ercd = rot_rdq( 0 );
868
        CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
869
    }
870
    ercd = wai_flg( &flgval, 2, 99, TWF_ANDW );
871
    CYG_TEST_CHECK( E_OK == ercd, "wai_flg bad ercd" );
872
    CYG_TEST_CHECK( 99 == (99 & flgval), "flg value no good" );
873
    while ( intercom ) {
874
        ercd = rot_rdq( 0 );
875
        CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
876
    }
877
    ercd = rcv_msg( &msgp, 2 );
878
    CYG_TEST_CHECK( E_OK == ercd, "rcv_msg bad ercd" );
879
    CYG_TEST_CHECK( NULL != msgp, "no msg received" );
880
    CYG_TEST_CHECK( NADR != msgp, "no msg received" );
881
    while ( intercom ) {
882
        ercd = rot_rdq( 0 );
883
        CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
884
    }
885
    ercd = get_blf( &blfp, 2 );
886
    CYG_TEST_CHECK( E_OK == ercd, "get_blf bad ercd" );
887
    CYG_TEST_CHECK( NULL != blfp, "no blf allocated" );
888
    CYG_TEST_CHECK( NADR != blfp, "no blf allocated" );
889
    while ( intercom ) {
890
        ercd = rot_rdq( 0 );
891
        CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
892
    }
893
    ercd = get_blk( &blkp, 2, 100 );
894
    CYG_TEST_CHECK( E_OK == ercd, "get_blk bad ercd" );
895
    CYG_TEST_CHECK( NULL != blkp, "no blk allocated" );
896
    CYG_TEST_CHECK( NADR != blkp, "no blk allocated" );
897
 
898
    ext_tsk();
899
    CYG_TEST_FAIL( "Task 2 failed to exit" );
900
}
901
 
902
void task3( unsigned int arg )
903
{
904
}
905
 
906
void task4( unsigned int arg )
907
{
908
}
909
 
910
#else // not enough (or too many) uITRON objects configured in
911
#define N_A_MSG "not enough uITRON objects to run test"
912
#endif // not enough (or too many) uITRON objects configured in
913
#else  // not C++ and some C++ specific options enabled
914
#define N_A_MSG "C++ specific options selected but this is C"
915
#endif  // not C++ and some C++ specific options enabled
916
#else // ! CYGVAR_KERNEL_COUNTERS_CLOCK   - can't test without it
917
#define N_A_MSG "no CYGVAR_KERNEL_COUNTERS_CLOCK "
918
#endif // ! CYGVAR_KERNEL_COUNTERS_CLOCK  - can't test without it
919
#else  // ! CYGFUN_KERNEL_THREADS_TIMER   - can't test without it
920
#define N_A_MSG "no CYGFUN_KERNEL_THREADS_TIMER"
921
#endif // ! CYGFUN_KERNEL_THREADS_TIMER   - can't test without it
922
#else  // ! CYGIMP_THREAD_PRIORITY        - can't test without it
923
#define N_A_MSG "no CYGSEM_KERNEL_SCHED_MLQUEUE"
924
#endif // ! CYGSEM_KERNEL_SCHED_MLQUEUE   - can't test without it
925
#else  // ! CYGIMP_UITRON_STRICT_CONFORMANCE - can't test without it
926
#define N_A_MSG "no CYGIMP_UITRON_STRICT_CONFORMANCE"
927
#endif // ! CYGIMP_UITRON_STRICT_CONFORMANCE - can't test without it
928
#else  // ! CYGPKG_UITRON
929
#define N_A_MSG "uITRON Compatibility layer disabled"
930
#endif // CYGPKG_UITRON
931
 
932
#ifdef N_A_MSG
933
externC void
934
cyg_start( void )
935
{
936
    CYG_TEST_INIT();
937
    CYG_TEST_NA( N_A_MSG );
938
}
939
#endif // N_A_MSG defined ie. we are N/A.
940
 
941
// EOF testcx2.cxx

powered by: WebSVN 2.1.0

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