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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [compat/] [uitron/] [v2_0/] [tests/] [test6.c] - Blame information for rev 831

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

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

powered by: WebSVN 2.1.0

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