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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 786 skrzyp
//===========================================================================
2
//
3
//      test6.c
4
//
5
//      uITRON "C" test program six
6
//
7
//===========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2009 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//===========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):   hmt
43
// Contributors:        hmt
44
// Date:        1998-10-01
45
// Purpose:     uITRON API testing
46
// Description: 
47
//
48
//####DESCRIPTIONEND####
49
//
50
//===========================================================================
51
 
52
#include <pkgconf/uitron.h>             // uITRON setup CYGNUM_UITRON_SEMAS
53
                                        // CYGPKG_UITRON et al
54
#include <cyg/infra/testcase.h>         // testing infrastructure
55
 
56
#ifdef CYGPKG_UITRON                    // we DO want the uITRON package
57
 
58
#ifdef CYGSEM_KERNEL_SCHED_MLQUEUE      // we DO want prioritized threads
59
 
60
#ifdef CYGFUN_KERNEL_THREADS_TIMER      // we DO want timout-able calls
61
 
62
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK     // we DO want the realtime clock
63
 
64
// we're OK if it's C++ or neither of those two is defined:
65
#if defined( __cplusplus ) || \
66
    (!defined( CYGIMP_UITRON_INLINE_FUNCS ) && \
67
     !defined( CYGIMP_UITRON_CPP_OUTLINE_FUNCS) )
68
 
69
// =================== TEST CONFIGURATION ===================
70
#if \
71
    /* test configuration for enough tasks */                      \
72
    (CYGNUM_UITRON_TASKS >= 4)                                  && \
73
    (CYGNUM_UITRON_TASKS < 90)                                  && \
74
    (CYGNUM_UITRON_START_TASKS == 1)                            && \
75
    ( !defined(CYGPKG_UITRON_TASKS_CREATE_DELETE) ||               \
76
      CYGNUM_UITRON_TASKS_INITIALLY >= 4             )          && \
77
                                                                   \
78
    /* test configuration for enough semaphores */                 \
79
    defined( CYGPKG_UITRON_SEMAS )                              && \
80
    (CYGNUM_UITRON_SEMAS >= 3)                                  && \
81
    (CYGNUM_UITRON_SEMAS < 90)                                  && \
82
    ( !defined(CYGPKG_UITRON_SEMAS_CREATE_DELETE) ||               \
83
      CYGNUM_UITRON_SEMAS_INITIALLY >= 3             )          && \
84
                                                                   \
85
    /* test configuration for enough flag objects */               \
86
    defined( CYGPKG_UITRON_FLAGS )                              && \
87
    (CYGNUM_UITRON_FLAGS >= 3)                                  && \
88
    (CYGNUM_UITRON_FLAGS < 90)                                  && \
89
    ( !defined(CYGPKG_UITRON_FLAGS_CREATE_DELETE) ||               \
90
      CYGNUM_UITRON_FLAGS_INITIALLY >= 3             )          && \
91
                                                                   \
92
    /* test configuration for enough message boxes */              \
93
    defined( CYGPKG_UITRON_MBOXES )                             && \
94
    (CYGNUM_UITRON_MBOXES >= 3)                                 && \
95
    (CYGNUM_UITRON_MBOXES < 90)                                 && \
96
    ( !defined(CYGPKG_UITRON_MBOXES_CREATE_DELETE) ||              \
97
      CYGNUM_UITRON_MBOXES_INITIALLY >= 3            )          && \
98
                                                                   \
99
    /* the end of the large #if statement */                       \
100
    1
101
 
102
// ============================ END ============================
103
 
104
 
105
 
106
#include <cyg/compat/uitron/uit_func.h> // uITRON
107
 
108
externC void
109
cyg_package_start( void )
110
{
111
    CYG_TEST_INIT();
112
    CYG_TEST_INFO( "Calling cyg_uitron_start()" );
113
    cyg_uitron_start();
114
}
115
 
116
volatile int intercount = 0;
117
UINT scratch;
118
T_MSG *t_msg = (T_MSG *)&scratch;
119
T_MSG *msg;
120
VP vp;
121
 
122
T_CSEM t_csem = { NULL, 0, 0 };
123
T_CMBX t_cmbx = { NULL, 0 };
124
T_CFLG t_cflg = { NULL, 0, 0 };
125
T_RSEM t_rsem;
126
T_RMBX t_rmbx;
127
T_RFLG t_rflg;
128
 
129
 
130
void task1( unsigned int arg )
131
{
132
    ER ercd;
133
    int tests = 0;
134
 
135
    CYG_TEST_INFO( "Task 1 running" );
136
 
137
    ercd = dis_dsp();
138
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
139
    ercd = sta_tsk( 2, 22222 );
140
    CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
141
    ercd = chg_pri( 2, 5 );
142
    CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
143
    ercd = ena_dsp();
144
    CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
145
    ercd = dly_tsk( 10 );
146
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
147
 
148
#ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE
149
    tests++;
150
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
151
    ercd = del_sem( -6 );
152
    CYG_TEST_CHECK( E_ID == ercd, "del_sem bad ercd !E_ID" );
153
    ercd = del_sem( 99 );
154
    CYG_TEST_CHECK( E_ID == ercd, "del_sem bad ercd !E_ID" );
155
    ercd = cre_sem( -6, &t_csem );
156
    CYG_TEST_CHECK( E_ID == ercd, "cre_sem bad ercd !E_ID" );
157
    ercd = cre_sem( 99, &t_csem );
158
    CYG_TEST_CHECK( E_ID == ercd, "cre_sem bad ercd !E_ID" );
159
#endif // we can test bad param error returns
160
    // try a pre-existing object
161
    ercd = cre_sem( 3, &t_csem );
162
    CYG_TEST_CHECK( E_OBJ == ercd, "cre_sem bad ercd !E_OBJ" );
163
    // delete it so we can play
164
    ercd = del_sem( 3 );
165
    CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" );
166
    // check it is deleted
167
    ercd = sig_sem( 3 );
168
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
169
    ercd = preq_sem( 3 );
170
    CYG_TEST_CHECK( E_NOEXS == ercd, "preq_sem bad ercd !E_NOEXS" );
171
    ercd = twai_sem( 3, 10 );
172
    CYG_TEST_CHECK( E_NOEXS == ercd, "twai_sem bad ercd !E_NOEXS" );
173
    ercd = wai_sem( 3 );
174
    CYG_TEST_CHECK( E_NOEXS == ercd, "wai_sem bad ercd !E_NOEXS" );
175
    ercd = ref_sem( &t_rsem, 3 );
176
    CYG_TEST_CHECK( E_NOEXS == ercd, "ref_sem bad ercd !E_NOEXS" );
177
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
178
    // now try creating it (badly)
179
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
180
    ercd = cre_sem( 3, NULL );
181
    CYG_TEST_CHECK( E_PAR == ercd, "cre_sem bad ercd !E_PAR" );
182
#endif
183
    ercd = cre_sem( 3, NADR );
184
    CYG_TEST_CHECK( E_PAR == ercd, "cre_sem bad ercd !E_PAR" );
185
    t_csem.sematr = 0xfff;
186
    ercd = cre_sem( 3, &t_csem );
187
    CYG_TEST_CHECK( E_RSATR == ercd, "cre_sem bad ercd !E_RSATR" );
188
    t_csem.sematr = 0;
189
#endif // we can test bad param error returns
190
    ercd = cre_sem( 3, &t_csem );
191
    CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
192
    // and check we can use it
193
    ercd = sig_sem( 3 );
194
    CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
195
    ercd = wai_sem( 3 );
196
    CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
197
    ercd = preq_sem( 3 );
198
    CYG_TEST_CHECK( E_TMOUT == ercd, "preq_sem bad ercd !E_TMOUT" );
199
    ercd = twai_sem( 3, 2 );
200
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem bad ercd !E_TMOUT" );
201
    ercd = ref_sem( &t_rsem, 3 );
202
    CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
203
 
204
    // now wait while task 2 deletes the wait objects
205
    ercd = wup_tsk( 2 );
206
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
207
    ercd = wai_sem( 1 );
208
    CYG_TEST_CHECK( E_DLT == ercd, "wai_sem bad ercd !E_DLT" );
209
    ercd = wup_tsk( 2 );
210
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
211
    ercd = twai_sem( 2, 20 );
212
    CYG_TEST_CHECK( E_DLT == ercd, "twai_sem bad ercd !E_DLT" );
213
 
214
    // check they are deleted
215
    ercd = sig_sem( 1 );
216
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
217
    ercd = sig_sem( 2 );
218
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
219
    // re-create and do it again
220
    ercd = cre_sem( 1, &t_csem );
221
    CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
222
    ercd = cre_sem( 2, &t_csem );
223
    CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
224
 
225
    // now wait while task 2 deletes the wait objects again
226
    ercd = wup_tsk( 2 );
227
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
228
    ercd = wai_sem( 1 );
229
    CYG_TEST_CHECK( E_DLT == ercd, "wai_sem bad ercd !E_DLT" );
230
    ercd = wup_tsk( 2 );
231
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
232
    ercd = twai_sem( 2, 20 );
233
    CYG_TEST_CHECK( E_DLT == ercd, "twai_sem bad ercd !E_DLT" );
234
 
235
    // check they are deleted
236
    ercd = sig_sem( 1 );
237
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
238
    ercd = sig_sem( 2 );
239
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
240
 
241
    CYG_TEST_PASS("create/delete semaphores");
242
#endif // CYGPKG_UITRON_SEMAS_CREATE_DELETE
243
 
244
 
245
#ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE
246
    tests++;
247
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
248
    ercd = del_flg( -6 );
249
    CYG_TEST_CHECK( E_ID == ercd, "del_flg bad ercd !E_ID" );
250
    ercd = del_flg( 99 );
251
    CYG_TEST_CHECK( E_ID == ercd, "del_flg bad ercd !E_ID" );
252
    ercd = cre_flg( -6, &t_cflg );
253
    CYG_TEST_CHECK( E_ID == ercd, "cre_flg bad ercd !E_ID" );
254
    ercd = cre_flg( 99, &t_cflg );
255
    CYG_TEST_CHECK( E_ID == ercd, "cre_flg bad ercd !E_ID" );
256
#endif // we can test bad param error returns
257
    // try a pre-existing object
258
    ercd = cre_flg( 3, &t_cflg );
259
    CYG_TEST_CHECK( E_OBJ == ercd, "cre_flg bad ercd !E_OBJ" );
260
    // delete it so we can play
261
    ercd = del_flg( 3 );
262
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
263
    // check it is deleted
264
    ercd = set_flg( 3, 0x6789 );
265
    CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" );
266
    ercd = clr_flg( 3, 0x9876 );
267
    CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" );
268
    ercd = pol_flg( &scratch, 3, 0xdddd, TWF_ANDW );
269
    CYG_TEST_CHECK( E_NOEXS == ercd, "pol_flg bad ercd !E_NOEXS" );
270
    ercd = twai_flg( &scratch, 3, 0x4444, TWF_ORW, 10 );
271
    CYG_TEST_CHECK( E_NOEXS == ercd, "twai_flg bad ercd !E_NOEXS" );
272
    ercd = wai_flg( &scratch, 3, 0xbbbb, TWF_ANDW | TWF_CLR );
273
    CYG_TEST_CHECK( E_NOEXS == ercd, "wai_flg bad ercd !E_NOEXS" );
274
    ercd = ref_flg( &t_rflg, 3 );
275
    CYG_TEST_CHECK( E_NOEXS == ercd, "ref_flg bad ercd !E_NOEXS" );
276
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
277
    // now try creating it (badly)
278
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
279
    ercd = cre_flg( 3, NULL );
280
    CYG_TEST_CHECK( E_PAR == ercd, "cre_flg bad ercd !E_PAR" );
281
#endif
282
    ercd = cre_flg( 3, NADR );
283
    CYG_TEST_CHECK( E_PAR == ercd, "cre_flg bad ercd !E_PAR" );
284
    t_cflg.flgatr = 0xfff;
285
    ercd = cre_flg( 3, &t_cflg );
286
    CYG_TEST_CHECK( E_RSATR == ercd, "cre_flg bad ercd !E_RSATR" );
287
#endif // we can test bad param error returns
288
    // now create it well
289
    t_cflg.flgatr = 0;
290
    t_cflg.iflgptn = 0;
291
    ercd = cre_flg( 3, &t_cflg );
292
    CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" );
293
    // and check we can use it
294
    ercd = clr_flg( 3, 0x7256 );
295
    CYG_TEST_CHECK( E_OK == ercd, "clr_flg bad ercd" );
296
    ercd = set_flg( 3, 0xff );
297
    CYG_TEST_CHECK( E_OK == ercd, "set_flg bad ercd" );
298
    ercd = wai_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR );
299
    CYG_TEST_CHECK( E_OK == ercd, "wai_flg bad ercd" );
300
    ercd = pol_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR );
301
    CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" );
302
    ercd = twai_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR, 2 );
303
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg bad ercd !E_TMOUT" );
304
    ercd = ref_flg( &t_rflg, 3 );
305
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
306
    CYG_TEST_CHECK( 0 == t_rflg.flgptn, "ref_flg bad ercd" );
307
    // now create it again with a preset pattern and check that we can
308
    // detect that pattern:
309
    ercd = del_flg( 3 );
310
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
311
    t_cflg.flgatr = 0;
312
    t_cflg.iflgptn = 0x1234;
313
    ercd = cre_flg( 3, &t_cflg );
314
    CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" );
315
    // and check we can use it
316
    ercd = wai_flg( &scratch, 3, 0x1200, TWF_ANDW );
317
    CYG_TEST_CHECK( E_OK == ercd, "wai_flg bad ercd" );
318
    ercd = pol_flg( &scratch, 3, 0x0034, TWF_ANDW );
319
    CYG_TEST_CHECK( E_OK == ercd, "pol_flg bad ercd" );
320
    ercd = twai_flg( &scratch, 3, 0x1004, TWF_ANDW, 10 );
321
    CYG_TEST_CHECK( E_OK == ercd, "twai_flg bad ercd" );
322
    ercd = pol_flg( &scratch, 3, 0xffedcb, TWF_ORW );
323
    CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" );
324
    ercd = ref_flg( &t_rflg, 3 );
325
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
326
    CYG_TEST_CHECK( 0x1234 == t_rflg.flgptn, "ref_flg bad ercd" );
327
    ercd = clr_flg( 3, 0 );
328
    ercd = ref_flg( &t_rflg, 3 );
329
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
330
    CYG_TEST_CHECK( 0 == t_rflg.flgptn, "ref_flg bad ercd" );
331
 
332
    // now wait while task 2 deletes the wait objects
333
    ercd = wup_tsk( 2 );
334
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
335
    ercd = wai_flg( &scratch, 1, 0xaa, TWF_ANDW );
336
    CYG_TEST_CHECK( E_DLT == ercd, "wai_flg bad ercd !E_DLT" );
337
    ercd = wup_tsk( 2 );
338
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
339
    ercd = twai_flg( &scratch, 2, 0x55, TWF_ANDW, 20 );
340
    CYG_TEST_CHECK( E_DLT == ercd, "twai_flg bad ercd !E_DLT" );
341
 
342
    // check they are deleted
343
    ercd = set_flg( 1, 0x22 );
344
    CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" );
345
    ercd = clr_flg( 2, 0xdd );
346
    CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" );
347
    // re-create and do it again
348
    t_cflg.iflgptn = 0x5555;
349
    ercd = cre_flg( 1, &t_cflg );
350
    CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" );
351
    t_cflg.iflgptn = 0;
352
    ercd = cre_flg( 2, &t_cflg );
353
    CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" );
354
 
355
    // now wait while task 2 deletes the wait objects again
356
    ercd = wup_tsk( 2 );
357
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
358
    ercd = wai_flg( &scratch, 1, 0xaaaa, TWF_ORW | TWF_CLR );
359
    CYG_TEST_CHECK( E_DLT == ercd, "wai_flg bad ercd !E_DLT" );
360
    ercd = wup_tsk( 2 );
361
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
362
    ercd = twai_flg( &scratch, 2, 0xffff, TWF_ORW, 20 );
363
    CYG_TEST_CHECK( E_DLT == ercd, "twai_flg bad ercd !E_DLT" );
364
 
365
    // check they are deleted
366
    ercd = clr_flg( 1, 0xd00d );
367
    CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" );
368
    ercd = set_flg( 2, 0xfff00 );
369
    CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" );
370
 
371
    CYG_TEST_PASS("create/delete flags");
372
#endif // CYGPKG_UITRON_FLAGS_CREATE_DELETE
373
 
374
#if defined(CYGPKG_UITRON_MBOXES_CREATE_DELETE) && defined(CYGIMP_UITRON_STRICT_CONFORMANCE)
375
    tests++;
376
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
377
    ercd = del_mbx( -6 );
378
    CYG_TEST_CHECK( E_ID == ercd, "del_mbx bad ercd !E_ID" );
379
    ercd = del_mbx( 99 );
380
    CYG_TEST_CHECK( E_ID == ercd, "del_mbx bad ercd !E_ID" );
381
    ercd = cre_mbx( -6, &t_cmbx );
382
    CYG_TEST_CHECK( E_ID == ercd, "cre_mbx bad ercd !E_ID" );
383
    ercd = cre_mbx( 99, &t_cmbx );
384
    CYG_TEST_CHECK( E_ID == ercd, "cre_mbx bad ercd !E_ID" );
385
#endif // we can test bad param error returns
386
    // try a pre-existing object
387
    ercd = cre_mbx( 3, &t_cmbx );
388
    CYG_TEST_CHECK( E_OBJ == ercd, "cre_mbx bad ercd !E_OBJ" );
389
    // delete it so we can play
390
    ercd = del_mbx( 3 );
391
    CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" );
392
    // check it is deleted
393
    ercd = snd_msg( 3, t_msg );
394
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
395
    ercd = rcv_msg( &msg, 3 );
396
    CYG_TEST_CHECK( E_NOEXS == ercd, "rcv_msg bad ercd !E_NOEXS" );
397
    ercd = trcv_msg( &msg, 3, 10 );
398
    CYG_TEST_CHECK( E_NOEXS == ercd, "trcv_msg bad ercd !E_NOEXS" );
399
    ercd = prcv_msg( &msg, 3 );
400
    CYG_TEST_CHECK( E_NOEXS == ercd, "prcv_msg bad ercd !E_NOEXS" );
401
    ercd = ref_mbx( &t_rmbx, 3 );
402
    CYG_TEST_CHECK( E_NOEXS == ercd, "ref_mbx bad ercd !E_NOEXS" );
403
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
404
    // now try creating it (badly)
405
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
406
    ercd = cre_mbx( 3, NULL );
407
    CYG_TEST_CHECK( E_PAR == ercd, "cre_mbx bad ercd !E_PAR" );
408
#endif
409
    ercd = cre_mbx( 3, NADR );
410
    CYG_TEST_CHECK( E_PAR == ercd, "cre_mbx bad ercd !E_PAR" );
411
    t_cmbx.mbxatr = 0xfff;
412
    ercd = cre_mbx( 3, &t_cmbx );
413
    CYG_TEST_CHECK( E_RSATR == ercd, "cre_mbx bad ercd !E_RSATR" );
414
    t_cmbx.mbxatr = 0;
415
#endif // we can test bad param error returns
416
    ercd = cre_mbx( 3, &t_cmbx );
417
    CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" );
418
    // and check we can use it
419
    ercd = snd_msg( 3, t_msg );
420
    CYG_TEST_CHECK( E_OK == ercd, "snd_msg bad ercd" );
421
    ercd = rcv_msg( &msg, 3 );
422
    CYG_TEST_CHECK( E_OK == ercd, "rcv_msg bad ercd" );
423
    ercd = trcv_msg( &msg, 3, 2 );
424
    CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg bad ercd !E_TMOUT" );
425
    ercd = prcv_msg( &msg, 3 );
426
    CYG_TEST_CHECK( E_TMOUT == ercd, "prcv_msg bad ercd !E_TMOUT" );
427
    ercd = ref_mbx( &t_rmbx, 3 );
428
    CYG_TEST_CHECK( E_OK == ercd, "ref_mbx bad ercd" );
429
 
430
    // now wait while task 2 deletes the wait objects
431
    ercd = wup_tsk( 2 );
432
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
433
    ercd = rcv_msg( &msg, 1 );
434
    CYG_TEST_CHECK( E_DLT == ercd, "wai_mbx bad ercd !E_DLT" );
435
    ercd = wup_tsk( 2 );
436
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
437
    ercd = trcv_msg( &msg, 2, 20 );
438
    CYG_TEST_CHECK( E_DLT == ercd, "twai_mbx bad ercd !E_DLT" );
439
 
440
    // check they are deleted
441
    ercd = snd_msg( 1, t_msg );
442
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
443
    ercd = snd_msg( 2, t_msg );
444
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
445
    // re-create and do it again
446
    ercd = cre_mbx( 1, &t_cmbx );
447
    CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" );
448
    ercd = cre_mbx( 2, &t_cmbx );
449
    CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" );
450
 
451
    // now wait while task 2 deletes the wait objects again
452
    ercd = wup_tsk( 2 );
453
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
454
    ercd = rcv_msg( &msg, 1 );
455
    CYG_TEST_CHECK( E_DLT == ercd, "wai_mbx bad ercd !E_DLT" );
456
    ercd = wup_tsk( 2 );
457
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
458
    ercd = trcv_msg( &msg, 2, 20 );
459
    CYG_TEST_CHECK( E_DLT == ercd, "twai_mbx bad ercd !E_DLT" );
460
 
461
    // check they are deleted
462
    ercd = snd_msg( 1, t_msg );
463
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
464
    ercd = snd_msg( 2, t_msg );
465
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
466
 
467
    CYG_TEST_PASS("create/delete mboxes");
468
#endif // CYGPKG_UITRON_MBOXES_CREATE_DELETE
469
 
470
    ercd = ter_tsk( 2 );
471
    CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
472
    ercd = dly_tsk( 5 );
473
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
474
 
475
    // all done
476
    if ( 0 == tests ) {
477
        CYG_TEST_NA( "No objects have create/delete enabled" );
478
    }
479
    else {
480
        CYG_TEST_EXIT( "All done" );
481
    }
482
    ext_tsk();
483
}
484
 
485
 
486
 
487
void task2( unsigned int arg )
488
{
489
    ER ercd;
490
    int i;
491
    CYG_TEST_INFO( "Task 2 running" );
492
    ercd = get_tid( &i );
493
    CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
494
    CYG_TEST_CHECK( 2 == i, "tid not 2" );
495
    if ( 22222 != arg )
496
        CYG_TEST_FAIL( "Task 2 arg not 22222" );
497
 
498
    ercd = slp_tsk();
499
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
500
 
501
#ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE
502
    ercd = del_sem( 1 );
503
    CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" );
504
    ercd = slp_tsk();
505
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
506
    ercd = del_sem( 2 );
507
    CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" );
508
    ercd = slp_tsk();
509
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
510
    ercd = del_sem( 1 );
511
    CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" );
512
    ercd = slp_tsk();
513
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
514
    ercd = del_sem( 2 );
515
    CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" );
516
    ercd = slp_tsk();
517
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
518
#endif // CYGPKG_UITRON_SEMAS_CREATE_DELETE
519
 
520
#ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE
521
    ercd = del_flg( 1 );
522
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
523
    ercd = slp_tsk();
524
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
525
    ercd = del_flg( 2 );
526
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
527
    ercd = slp_tsk();
528
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
529
    ercd = del_flg( 1 );
530
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
531
    ercd = slp_tsk();
532
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
533
    ercd = del_flg( 2 );
534
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
535
    ercd = slp_tsk();
536
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
537
#endif // CYGPKG_UITRON_FLAGS_CREATE_DELETE
538
 
539
#ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE
540
    ercd = del_mbx( 1 );
541
    CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" );
542
    ercd = slp_tsk();
543
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
544
    ercd = del_mbx( 2 );
545
    CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" );
546
    ercd = slp_tsk();
547
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
548
    ercd = del_mbx( 1 );
549
    CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" );
550
    ercd = slp_tsk();
551
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
552
    ercd = del_mbx( 2 );
553
    CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" );
554
    ercd = slp_tsk();
555
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
556
#endif // CYGPKG_UITRON_MBOXES_CREATE_DELETE
557
 
558
    // we expect task2 to be killed here
559
    CYG_TEST_FAIL( "Task 2 ran to completion!" );
560
}
561
 
562
void task3( unsigned int arg )
563
{
564
}
565
 
566
void task4( unsigned int arg )
567
{
568
}
569
 
570
#else // not enough (or too many) uITRON objects configured in
571
#define N_A_MSG "not enough uITRON objects to run test"
572
#endif // not enough (or too many) uITRON objects configured in
573
#else  // not C++ and some C++ specific options enabled
574
#define N_A_MSG "C++ specific options selected but this is C"
575
#endif  // not C++ and some C++ specific options enabled
576
#else // ! CYGVAR_KERNEL_COUNTERS_CLOCK   - can't test without it
577
#define N_A_MSG "no CYGVAR_KERNEL_COUNTERS_CLOCK"
578
#endif // ! CYGVAR_KERNEL_COUNTERS_CLOCK  - can't test without it
579
#else  // ! CYGFUN_KERNEL_THREADS_TIMER   - can't test without it
580
#define N_A_MSG "no CYGFUN_KERNEL_THREADS_TIMER"
581
#endif // ! CYGFUN_KERNEL_THREADS_TIMER   - can't test without it
582
#else  // ! CYGIMP_THREAD_PRIORITY        - can't test without it
583
#define N_A_MSG "no CYGSEM_KERNEL_SCHED_MLQUEUE"
584
#endif // ! CYGSEM_KERNEL_SCHED_MLQUEUE   - can't test without it
585
#else  // ! CYGPKG_UITRON
586
#define N_A_MSG "uITRON Compatibility layer disabled"
587
#endif // CYGPKG_UITRON
588
 
589
#ifdef N_A_MSG
590
void
591
cyg_start( void )
592
{
593
    CYG_TEST_INIT();
594
    CYG_TEST_NA( N_A_MSG );
595
}
596
#endif // N_A_MSG defined ie. we are N/A.
597
 
598
// EOF test6.c

powered by: WebSVN 2.1.0

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