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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [compat/] [uitron/] [v2_0/] [tests/] [testcx2.cxx] - Blame information for rev 773

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

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

powered by: WebSVN 2.1.0

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