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

Subversion Repositories openrisc

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

powered by: WebSVN 2.1.0

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