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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [ecos-2.0/] [packages/] [compat/] [uitron/] [v2_0/] [tests/] [testcx6.cxx] - Blame information for rev 1254

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

Line No. Rev Author Line
1 1254 phoenix
//===========================================================================
2
//
3
//      testcx6.cxx
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 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-10-14
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
    /* the end of the large #if statement */                       \
101
    1
102
 
103
// ============================ END ============================
104
 
105
 
106
 
107
#include <cyg/compat/uitron/uit_func.h> // uITRON
108
 
109
externC void
110
cyg_package_start( void )
111
{
112
    CYG_TEST_INIT();
113
    CYG_TEST_INFO( "Calling cyg_uitron_start()" );
114
    cyg_uitron_start();
115
}
116
 
117
volatile int intercount = 0;
118
UINT scratch;
119
T_MSG *t_msg = (T_MSG *)&scratch;
120
T_MSG *msg;
121
VP vp;
122
 
123
T_CSEM t_csem = { NULL, 0, 0 };
124
T_CMBX t_cmbx = { NULL, 0 };
125
T_CFLG t_cflg = { NULL, 0, 0 };
126
T_RSEM t_rsem;
127
T_RMBX t_rmbx;
128
T_RFLG t_rflg;
129
 
130
 
131
extern "C" {
132
    void task1( unsigned int arg );
133
    void task2( unsigned int arg );
134
    void task3( unsigned int arg );
135
    void task4( unsigned int arg );
136
}
137
 
138
void task1( unsigned int arg )
139
{
140
    ER ercd;
141
    int tests = 0;
142
 
143
    CYG_TEST_INFO( "Task 1 running" );
144
 
145
    ercd = dis_dsp();
146
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
147
    ercd = sta_tsk( 2, 22222 );
148
    CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
149
    ercd = chg_pri( 2, 5 );
150
    CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
151
    ercd = ena_dsp();
152
    CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
153
    ercd = dly_tsk( 10 );
154
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
155
 
156
#ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE
157
    tests++;
158
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
159
    ercd = del_sem( -6 );
160
    CYG_TEST_CHECK( E_ID == ercd, "del_sem bad ercd !E_ID" );
161
    ercd = del_sem( 99 );
162
    CYG_TEST_CHECK( E_ID == ercd, "del_sem bad ercd !E_ID" );
163
    ercd = cre_sem( -6, &t_csem );
164
    CYG_TEST_CHECK( E_ID == ercd, "cre_sem bad ercd !E_ID" );
165
    ercd = cre_sem( 99, &t_csem );
166
    CYG_TEST_CHECK( E_ID == ercd, "cre_sem bad ercd !E_ID" );
167
#endif // we can test bad param error returns
168
    // try a pre-existing object
169
    ercd = cre_sem( 3, &t_csem );
170
    CYG_TEST_CHECK( E_OBJ == ercd, "cre_sem bad ercd !E_OBJ" );
171
    // delete it so we can play
172
    ercd = del_sem( 3 );
173
    CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" );
174
    // check it is deleted
175
    ercd = sig_sem( 3 );
176
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
177
    ercd = preq_sem( 3 );
178
    CYG_TEST_CHECK( E_NOEXS == ercd, "preq_sem bad ercd !E_NOEXS" );
179
    ercd = twai_sem( 3, 10 );
180
    CYG_TEST_CHECK( E_NOEXS == ercd, "twai_sem bad ercd !E_NOEXS" );
181
    ercd = wai_sem( 3 );
182
    CYG_TEST_CHECK( E_NOEXS == ercd, "wai_sem bad ercd !E_NOEXS" );
183
    ercd = ref_sem( &t_rsem, 3 );
184
    CYG_TEST_CHECK( E_NOEXS == ercd, "ref_sem bad ercd !E_NOEXS" );
185
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
186
    // now try creating it (badly)
187
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
188
    ercd = cre_sem( 3, NULL );
189
    CYG_TEST_CHECK( E_PAR == ercd, "cre_sem bad ercd !E_PAR" );
190
#endif
191
    t_csem.sematr = 0xfff;
192
    ercd = cre_sem( 3, &t_csem );
193
    CYG_TEST_CHECK( E_RSATR == ercd, "cre_sem bad ercd !E_RSATR" );
194
    t_csem.sematr = 0;
195
#endif // we can test bad param error returns
196
    ercd = cre_sem( 3, &t_csem );
197
    CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
198
    // and check we can use it
199
    ercd = sig_sem( 3 );
200
    CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
201
    ercd = wai_sem( 3 );
202
    CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
203
    ercd = preq_sem( 3 );
204
    CYG_TEST_CHECK( E_TMOUT == ercd, "preq_sem bad ercd !E_TMOUT" );
205
    ercd = twai_sem( 3, 2 );
206
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem bad ercd !E_TMOUT" );
207
    ercd = ref_sem( &t_rsem, 3 );
208
    CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
209
 
210
    // now wait while task 2 deletes the wait objects
211
    ercd = wup_tsk( 2 );
212
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
213
    ercd = wai_sem( 1 );
214
    CYG_TEST_CHECK( E_DLT == ercd, "wai_sem bad ercd !E_DLT" );
215
    ercd = wup_tsk( 2 );
216
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
217
    ercd = twai_sem( 2, 20 );
218
    CYG_TEST_CHECK( E_DLT == ercd, "twai_sem bad ercd !E_DLT" );
219
 
220
    // check they are deleted
221
    ercd = sig_sem( 1 );
222
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
223
    ercd = sig_sem( 2 );
224
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
225
    // re-create and do it again
226
    ercd = cre_sem( 1, &t_csem );
227
    CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
228
    ercd = cre_sem( 2, &t_csem );
229
    CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
230
 
231
    // now wait while task 2 deletes the wait objects again
232
    ercd = wup_tsk( 2 );
233
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
234
    ercd = wai_sem( 1 );
235
    CYG_TEST_CHECK( E_DLT == ercd, "wai_sem bad ercd !E_DLT" );
236
    ercd = wup_tsk( 2 );
237
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
238
    ercd = twai_sem( 2, 20 );
239
    CYG_TEST_CHECK( E_DLT == ercd, "twai_sem bad ercd !E_DLT" );
240
 
241
    // check they are deleted
242
    ercd = sig_sem( 1 );
243
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
244
    ercd = sig_sem( 2 );
245
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
246
 
247
    CYG_TEST_PASS("create/delete semaphores");
248
#endif // CYGPKG_UITRON_SEMAS_CREATE_DELETE
249
 
250
 
251
#ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE
252
    tests++;
253
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
254
    ercd = del_flg( -6 );
255
    CYG_TEST_CHECK( E_ID == ercd, "del_flg bad ercd !E_ID" );
256
    ercd = del_flg( 99 );
257
    CYG_TEST_CHECK( E_ID == ercd, "del_flg bad ercd !E_ID" );
258
    ercd = cre_flg( -6, &t_cflg );
259
    CYG_TEST_CHECK( E_ID == ercd, "cre_flg bad ercd !E_ID" );
260
    ercd = cre_flg( 99, &t_cflg );
261
    CYG_TEST_CHECK( E_ID == ercd, "cre_flg bad ercd !E_ID" );
262
#endif // we can test bad param error returns
263
    // try a pre-existing object
264
    ercd = cre_flg( 3, &t_cflg );
265
    CYG_TEST_CHECK( E_OBJ == ercd, "cre_flg bad ercd !E_OBJ" );
266
    // delete it so we can play
267
    ercd = del_flg( 3 );
268
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
269
    // check it is deleted
270
    ercd = set_flg( 3, 0x6789 );
271
    CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" );
272
    ercd = clr_flg( 3, 0x9876 );
273
    CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" );
274
    ercd = pol_flg( &scratch, 3, 0xdddd, TWF_ANDW );
275
    CYG_TEST_CHECK( E_NOEXS == ercd, "pol_flg bad ercd !E_NOEXS" );
276
    ercd = twai_flg( &scratch, 3, 0x4444, TWF_ORW, 10 );
277
    CYG_TEST_CHECK( E_NOEXS == ercd, "twai_flg bad ercd !E_NOEXS" );
278
    ercd = wai_flg( &scratch, 3, 0xbbbb, TWF_ANDW | TWF_CLR );
279
    CYG_TEST_CHECK( E_NOEXS == ercd, "wai_flg bad ercd !E_NOEXS" );
280
    ercd = ref_flg( &t_rflg, 3 );
281
    CYG_TEST_CHECK( E_NOEXS == ercd, "ref_flg bad ercd !E_NOEXS" );
282
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
283
    // now try creating it (badly)
284
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
285
    ercd = cre_flg( 3, NULL );
286
    CYG_TEST_CHECK( E_PAR == ercd, "cre_flg bad ercd !E_PAR" );
287
#endif
288
    t_cflg.flgatr = 0xfff;
289
    ercd = cre_flg( 3, &t_cflg );
290
    CYG_TEST_CHECK( E_RSATR == ercd, "cre_flg bad ercd !E_RSATR" );
291
#endif // we can test bad param error returns
292
    // now create it well
293
    t_cflg.flgatr = 0;
294
    t_cflg.iflgptn = 0;
295
    ercd = cre_flg( 3, &t_cflg );
296
    CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" );
297
    // and check we can use it
298
    ercd = clr_flg( 3, 0x7256 );
299
    CYG_TEST_CHECK( E_OK == ercd, "clr_flg bad ercd" );
300
    ercd = set_flg( 3, 0xff );
301
    CYG_TEST_CHECK( E_OK == ercd, "set_flg bad ercd" );
302
    ercd = wai_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR );
303
    CYG_TEST_CHECK( E_OK == ercd, "wai_flg bad ercd" );
304
    ercd = pol_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR );
305
    CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" );
306
    ercd = twai_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR, 2 );
307
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg bad ercd !E_TMOUT" );
308
    ercd = ref_flg( &t_rflg, 3 );
309
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
310
    CYG_TEST_CHECK( 0 == t_rflg.flgptn, "ref_flg bad ercd" );
311
    // now create it again with a preset pattern and check that we can
312
    // detect that pattern:
313
    ercd = del_flg( 3 );
314
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
315
    t_cflg.flgatr = 0;
316
    t_cflg.iflgptn = 0x1234;
317
    ercd = cre_flg( 3, &t_cflg );
318
    CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" );
319
    // and check we can use it
320
    ercd = wai_flg( &scratch, 3, 0x1200, TWF_ANDW );
321
    CYG_TEST_CHECK( E_OK == ercd, "wai_flg bad ercd" );
322
    ercd = pol_flg( &scratch, 3, 0x0034, TWF_ANDW );
323
    CYG_TEST_CHECK( E_OK == ercd, "pol_flg bad ercd" );
324
    ercd = twai_flg( &scratch, 3, 0x1004, TWF_ANDW, 10 );
325
    CYG_TEST_CHECK( E_OK == ercd, "twai_flg bad ercd" );
326
    ercd = pol_flg( &scratch, 3, 0xffedcb, TWF_ORW );
327
    CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" );
328
    ercd = ref_flg( &t_rflg, 3 );
329
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
330
    CYG_TEST_CHECK( 0x1234 == t_rflg.flgptn, "ref_flg bad ercd" );
331
    ercd = clr_flg( 3, 0 );
332
    ercd = ref_flg( &t_rflg, 3 );
333
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
334
    CYG_TEST_CHECK( 0 == t_rflg.flgptn, "ref_flg bad ercd" );
335
 
336
    // now wait while task 2 deletes the wait objects
337
    ercd = wup_tsk( 2 );
338
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
339
    ercd = wai_flg( &scratch, 1, 0xaa, TWF_ANDW );
340
    CYG_TEST_CHECK( E_DLT == ercd, "wai_flg bad ercd !E_DLT" );
341
    ercd = wup_tsk( 2 );
342
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
343
    ercd = twai_flg( &scratch, 2, 0x55, TWF_ANDW, 20 );
344
    CYG_TEST_CHECK( E_DLT == ercd, "twai_flg bad ercd !E_DLT" );
345
 
346
    // check they are deleted
347
    ercd = set_flg( 1, 0x22 );
348
    CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" );
349
    ercd = clr_flg( 2, 0xdd );
350
    CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" );
351
    // re-create and do it again
352
    t_cflg.iflgptn = 0x5555;
353
    ercd = cre_flg( 1, &t_cflg );
354
    CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" );
355
    t_cflg.iflgptn = 0;
356
    ercd = cre_flg( 2, &t_cflg );
357
    CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" );
358
 
359
    // now wait while task 2 deletes the wait objects again
360
    ercd = wup_tsk( 2 );
361
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
362
    ercd = wai_flg( &scratch, 1, 0xaaaa, TWF_ORW | TWF_CLR );
363
    CYG_TEST_CHECK( E_DLT == ercd, "wai_flg bad ercd !E_DLT" );
364
    ercd = wup_tsk( 2 );
365
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
366
    ercd = twai_flg( &scratch, 2, 0xffff, TWF_ORW, 20 );
367
    CYG_TEST_CHECK( E_DLT == ercd, "twai_flg bad ercd !E_DLT" );
368
 
369
    // check they are deleted
370
    ercd = clr_flg( 1, 0xd00d );
371
    CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" );
372
    ercd = set_flg( 2, 0xfff00 );
373
    CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" );
374
 
375
    CYG_TEST_PASS("create/delete flags");
376
#endif // CYGPKG_UITRON_FLAGS_CREATE_DELETE
377
 
378
#ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE
379
    tests++;
380
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
381
    ercd = del_mbx( -6 );
382
    CYG_TEST_CHECK( E_ID == ercd, "del_mbx bad ercd !E_ID" );
383
    ercd = del_mbx( 99 );
384
    CYG_TEST_CHECK( E_ID == ercd, "del_mbx bad ercd !E_ID" );
385
    ercd = cre_mbx( -6, &t_cmbx );
386
    CYG_TEST_CHECK( E_ID == ercd, "cre_mbx bad ercd !E_ID" );
387
    ercd = cre_mbx( 99, &t_cmbx );
388
    CYG_TEST_CHECK( E_ID == ercd, "cre_mbx bad ercd !E_ID" );
389
#endif // we can test bad param error returns
390
    // try a pre-existing object
391
    ercd = cre_mbx( 3, &t_cmbx );
392
    CYG_TEST_CHECK( E_OBJ == ercd, "cre_mbx bad ercd !E_OBJ" );
393
    // delete it so we can play
394
    ercd = del_mbx( 3 );
395
    CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" );
396
    // check it is deleted
397
    ercd = snd_msg( 3, t_msg );
398
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
399
    ercd = rcv_msg( &msg, 3 );
400
    CYG_TEST_CHECK( E_NOEXS == ercd, "rcv_msg bad ercd !E_NOEXS" );
401
    ercd = trcv_msg( &msg, 3, 10 );
402
    CYG_TEST_CHECK( E_NOEXS == ercd, "trcv_msg bad ercd !E_NOEXS" );
403
    ercd = prcv_msg( &msg, 3 );
404
    CYG_TEST_CHECK( E_NOEXS == ercd, "prcv_msg bad ercd !E_NOEXS" );
405
    ercd = ref_mbx( &t_rmbx, 3 );
406
    CYG_TEST_CHECK( E_NOEXS == ercd, "ref_mbx bad ercd !E_NOEXS" );
407
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
408
    // now try creating it (badly)
409
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
410
    ercd = cre_mbx( 3, NULL );
411
    CYG_TEST_CHECK( E_PAR == ercd, "cre_mbx bad ercd !E_PAR" );
412
#endif
413
    t_cmbx.mbxatr = 0xfff;
414
    ercd = cre_mbx( 3, &t_cmbx );
415
    CYG_TEST_CHECK( E_RSATR == ercd, "cre_mbx bad ercd !E_RSATR" );
416
    t_cmbx.mbxatr = 0;
417
#endif // we can test bad param error returns
418
    ercd = cre_mbx( 3, &t_cmbx );
419
    CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" );
420
    // and check we can use it
421
    ercd = snd_msg( 3, t_msg );
422
    CYG_TEST_CHECK( E_OK == ercd, "snd_msg bad ercd" );
423
    ercd = rcv_msg( &msg, 3 );
424
    CYG_TEST_CHECK( E_OK == ercd, "rcv_msg bad ercd" );
425
    ercd = trcv_msg( &msg, 3, 2 );
426
    CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg bad ercd !E_TMOUT" );
427
    ercd = prcv_msg( &msg, 3 );
428
    CYG_TEST_CHECK( E_TMOUT == ercd, "prcv_msg bad ercd !E_TMOUT" );
429
    ercd = ref_mbx( &t_rmbx, 3 );
430
    CYG_TEST_CHECK( E_OK == ercd, "ref_mbx bad ercd" );
431
 
432
    // now wait while task 2 deletes the wait objects
433
    ercd = wup_tsk( 2 );
434
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
435
    ercd = rcv_msg( &msg, 1 );
436
    CYG_TEST_CHECK( E_DLT == ercd, "wai_mbx bad ercd !E_DLT" );
437
    ercd = wup_tsk( 2 );
438
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
439
    ercd = trcv_msg( &msg, 2, 20 );
440
    CYG_TEST_CHECK( E_DLT == ercd, "twai_mbx bad ercd !E_DLT" );
441
 
442
    // check they are deleted
443
    ercd = snd_msg( 1, t_msg );
444
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
445
    ercd = snd_msg( 2, t_msg );
446
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
447
    // re-create and do it again
448
    ercd = cre_mbx( 1, &t_cmbx );
449
    CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" );
450
    ercd = cre_mbx( 2, &t_cmbx );
451
    CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" );
452
 
453
    // now wait while task 2 deletes the wait objects again
454
    ercd = wup_tsk( 2 );
455
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
456
    ercd = rcv_msg( &msg, 1 );
457
    CYG_TEST_CHECK( E_DLT == ercd, "wai_mbx bad ercd !E_DLT" );
458
    ercd = wup_tsk( 2 );
459
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
460
    ercd = trcv_msg( &msg, 2, 20 );
461
    CYG_TEST_CHECK( E_DLT == ercd, "twai_mbx bad ercd !E_DLT" );
462
 
463
    // check they are deleted
464
    ercd = snd_msg( 1, t_msg );
465
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
466
    ercd = snd_msg( 2, t_msg );
467
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
468
 
469
    CYG_TEST_PASS("create/delete mboxes");
470
#endif // CYGPKG_UITRON_MBOXES_CREATE_DELETE
471
 
472
    ercd = ter_tsk( 2 );
473
    CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
474
    ercd = dly_tsk( 5 );
475
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
476
 
477
    // all done
478
    if ( 0 == tests ) {
479
        CYG_TEST_NA( "No objects have create/delete enabled" );
480
    }
481
    else {
482
        CYG_TEST_EXIT( "All done" );
483
    }
484
    ext_tsk();
485
}
486
 
487
 
488
 
489
void task2( unsigned int arg )
490
{
491
    ER ercd;
492
    int i;
493
    CYG_TEST_INFO( "Task 2 running" );
494
    ercd = get_tid( &i );
495
    CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
496
    CYG_TEST_CHECK( 2 == i, "tid not 2" );
497
    if ( 22222 != arg )
498
        CYG_TEST_FAIL( "Task 2 arg not 22222" );
499
 
500
    ercd = slp_tsk();
501
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
502
 
503
#ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE
504
    ercd = del_sem( 1 );
505
    CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" );
506
    ercd = slp_tsk();
507
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
508
    ercd = del_sem( 2 );
509
    CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" );
510
    ercd = slp_tsk();
511
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
512
    ercd = del_sem( 1 );
513
    CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" );
514
    ercd = slp_tsk();
515
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
516
    ercd = del_sem( 2 );
517
    CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" );
518
    ercd = slp_tsk();
519
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
520
#endif // CYGPKG_UITRON_SEMAS_CREATE_DELETE
521
 
522
#ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE
523
    ercd = del_flg( 1 );
524
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
525
    ercd = slp_tsk();
526
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
527
    ercd = del_flg( 2 );
528
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
529
    ercd = slp_tsk();
530
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
531
    ercd = del_flg( 1 );
532
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
533
    ercd = slp_tsk();
534
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
535
    ercd = del_flg( 2 );
536
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
537
    ercd = slp_tsk();
538
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
539
#endif // CYGPKG_UITRON_FLAGS_CREATE_DELETE
540
 
541
#ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE
542
    ercd = del_mbx( 1 );
543
    CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" );
544
    ercd = slp_tsk();
545
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
546
    ercd = del_mbx( 2 );
547
    CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" );
548
    ercd = slp_tsk();
549
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
550
    ercd = del_mbx( 1 );
551
    CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" );
552
    ercd = slp_tsk();
553
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
554
    ercd = del_mbx( 2 );
555
    CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" );
556
    ercd = slp_tsk();
557
    CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
558
#endif // CYGPKG_UITRON_MBOXES_CREATE_DELETE
559
 
560
    // we expect task2 to be killed here
561
    CYG_TEST_FAIL( "Task 2 ran to completion!" );
562
}
563
 
564
void task3( unsigned int arg )
565
{
566
}
567
 
568
void task4( unsigned int arg )
569
{
570
}
571
 
572
#else // not enough (or too many) uITRON objects configured in
573
#define N_A_MSG "not enough uITRON objects to run test"
574
#endif // not enough (or too many) uITRON objects configured in
575
#else  // not C++ and some C++ specific options enabled
576
#define N_A_MSG "C++ specific options selected but this is C"
577
#endif  // not C++ and some C++ specific options enabled
578
#else // ! CYGVAR_KERNEL_COUNTERS_CLOCK   - can't test without it
579
#define N_A_MSG "no CYGVAR_KERNEL_COUNTERS_CLOCK"
580
#endif // ! CYGVAR_KERNEL_COUNTERS_CLOCK  - can't test without it
581
#else  // ! CYGFUN_KERNEL_THREADS_TIMER   - can't test without it
582
#define N_A_MSG "no CYGFUN_KERNEL_THREADS_TIMER"
583
#endif // ! CYGFUN_KERNEL_THREADS_TIMER   - can't test without it
584
#else  // ! CYGIMP_THREAD_PRIORITY        - can't test without it
585
#define N_A_MSG "no CYGSEM_KERNEL_SCHED_MLQUEUE"
586
#endif // ! CYGSEM_KERNEL_SCHED_MLQUEUE   - can't test without it
587
#else  // ! CYGPKG_UITRON
588
#define N_A_MSG "uITRON Compatibility layer disabled"
589
#endif // CYGPKG_UITRON
590
 
591
#ifdef N_A_MSG
592
externC void
593
cyg_start( void )
594
{
595
    CYG_TEST_INIT();
596
    CYG_TEST_NA( N_A_MSG );
597
}
598
#endif // N_A_MSG defined ie. we are N/A.
599
 
600
// EOF testcx6.cxx

powered by: WebSVN 2.1.0

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