1 |
27 |
unneback |
//===========================================================================
|
2 |
|
|
//
|
3 |
|
|
// testcx9.cxx
|
4 |
|
|
//
|
5 |
|
|
// uITRON "C++" test program nine
|
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-16
|
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 fixed memory pools */ \
|
80 |
|
|
defined( CYGPKG_UITRON_MEMPOOLFIXED ) && \
|
81 |
|
|
(CYGNUM_UITRON_MEMPOOLFIXED >= 3) && \
|
82 |
|
|
(CYGNUM_UITRON_MEMPOOLFIXED < 90) && \
|
83 |
|
|
( !defined(CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE) || \
|
84 |
|
|
CYGNUM_UITRON_MEMPOOLFIXED_INITIALLY >= 3 ) && \
|
85 |
|
|
\
|
86 |
|
|
/* test configuration for enough variable mempools */ \
|
87 |
|
|
defined( CYGPKG_UITRON_MEMPOOLVAR ) && \
|
88 |
|
|
(CYGNUM_UITRON_MEMPOOLVAR >= 3) && \
|
89 |
|
|
(CYGNUM_UITRON_MEMPOOLVAR < 90) && \
|
90 |
|
|
( !defined(CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE) || \
|
91 |
|
|
CYGNUM_UITRON_MEMPOOLVAR_INITIALLY >= 3 ) && \
|
92 |
|
|
\
|
93 |
|
|
/* the end of the large #if statement */ \
|
94 |
|
|
1
|
95 |
|
|
|
96 |
|
|
// ============================ END ============================
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
#include <cyg/compat/uitron/uit_func.h> // uITRON
|
101 |
|
|
|
102 |
|
|
externC void
|
103 |
|
|
cyg_package_start( void )
|
104 |
|
|
{
|
105 |
|
|
CYG_TEST_INIT();
|
106 |
|
|
CYG_TEST_INFO( "Calling cyg_uitron_start()" );
|
107 |
|
|
cyg_uitron_start();
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
VP vp;
|
111 |
|
|
|
112 |
|
|
T_CMPL t_cmpl = { NULL, 0, 1000 };
|
113 |
|
|
T_RMPL t_rmpl;
|
114 |
|
|
T_CMPF t_cmpf = { NULL, 0, 10, 100 };
|
115 |
|
|
T_RMPF t_rmpf;
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
extern "C" {
|
119 |
|
|
void task1( unsigned int arg );
|
120 |
|
|
void task2( unsigned int arg );
|
121 |
|
|
void task3( unsigned int arg );
|
122 |
|
|
void task4( unsigned int arg );
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
void task1( unsigned int arg )
|
126 |
|
|
{
|
127 |
|
|
ER ercd;
|
128 |
|
|
int tests = 0;
|
129 |
|
|
|
130 |
|
|
CYG_TEST_INFO( "Task 1 running" );
|
131 |
|
|
|
132 |
|
|
ercd = dis_dsp();
|
133 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
134 |
|
|
ercd = sta_tsk( 2, 22222 );
|
135 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
|
136 |
|
|
ercd = chg_pri( 2, 5 );
|
137 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
|
138 |
|
|
ercd = ena_dsp();
|
139 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
140 |
|
|
ercd = dly_tsk( 10 );
|
141 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
142 |
|
|
|
143 |
|
|
#ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
|
144 |
|
|
tests++;
|
145 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
146 |
|
|
ercd = del_mpf( -6 );
|
147 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "del_mpf bad ercd !E_ID" );
|
148 |
|
|
ercd = del_mpf( 99 );
|
149 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "del_mpf bad ercd !E_ID" );
|
150 |
|
|
ercd = cre_mpf( -6, &t_cmpf );
|
151 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "cre_mpf bad ercd !E_ID" );
|
152 |
|
|
ercd = cre_mpf( 99, &t_cmpf );
|
153 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "cre_mpf bad ercd !E_ID" );
|
154 |
|
|
#endif // we can test bad param error returns
|
155 |
|
|
// try a pre-existing object
|
156 |
|
|
// [first get a valid block from it for the freeing test later]
|
157 |
|
|
ercd = pget_blf( &vp, 3 );
|
158 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "pget_blf bad ercd" );
|
159 |
|
|
ercd = cre_mpf( 3, &t_cmpf );
|
160 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "cre_mpf bad ercd !E_OBJ" );
|
161 |
|
|
// delete it so we can play
|
162 |
|
|
ercd = del_mpf( 3 );
|
163 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" );
|
164 |
|
|
// check it is deleted
|
165 |
|
|
ercd = rel_blf( 3, vp ); // vp did come from this pool
|
166 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "rel_blf bad ercd !E_NOEXS" );
|
167 |
|
|
ercd = pget_blf( &vp, 3 );
|
168 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blf bad ercd !E_NOEXS" );
|
169 |
|
|
ercd = tget_blf( &vp, 3, 10 );
|
170 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "tget_blf bad ercd !E_NOEXS" );
|
171 |
|
|
ercd = get_blf( &vp, 3 );
|
172 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "get_blf bad ercd !E_NOEXS" );
|
173 |
|
|
ercd = ref_mpf( &t_rmpf, 3 );
|
174 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "ref_mpf bad ercd !E_NOEXS" );
|
175 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
176 |
|
|
// now try creating it (badly)
|
177 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
178 |
|
|
ercd = cre_mpf( 3, NULL );
|
179 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "cre_mpf bad ercd !E_PAR" );
|
180 |
|
|
#endif
|
181 |
|
|
t_cmpf.mpfatr = 0xfff;
|
182 |
|
|
ercd = cre_mpf( 3, &t_cmpf );
|
183 |
|
|
CYG_TEST_CHECK( E_RSATR == ercd, "cre_mpf bad ercd !E_RSATR" );
|
184 |
|
|
#endif // we can test bad param error returns
|
185 |
|
|
t_cmpf.mpfatr = 0;
|
186 |
|
|
t_cmpf.mpfcnt = 10000;
|
187 |
|
|
t_cmpf.blfsz = 100;
|
188 |
|
|
ercd = cre_mpf( 3, &t_cmpf );
|
189 |
|
|
CYG_TEST_CHECK( E_NOMEM == ercd, "cre_mpf bad ercd" );
|
190 |
|
|
t_cmpf.mpfcnt = 100;
|
191 |
|
|
t_cmpf.blfsz = 100000;
|
192 |
|
|
ercd = cre_mpf( 3, &t_cmpf );
|
193 |
|
|
CYG_TEST_CHECK( E_NOMEM == ercd, "cre_mpf bad ercd" );
|
194 |
|
|
// now create it well
|
195 |
|
|
t_cmpf.mpfatr = 0;
|
196 |
|
|
t_cmpf.mpfcnt = 10;
|
197 |
|
|
t_cmpf.blfsz = 100;
|
198 |
|
|
ercd = cre_mpf( 3, &t_cmpf );
|
199 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "cre_mpf bad ercd" );
|
200 |
|
|
// and check we can use it
|
201 |
|
|
ercd = pget_blf( &vp, 3 );
|
202 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "pget_blf bad ercd" );
|
203 |
|
|
ercd = tget_blf( &vp, 3, 10 );
|
204 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "tget_blf bad ercd" );
|
205 |
|
|
ercd = get_blf( &vp, 3 );
|
206 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "get_blf bad ercd" );
|
207 |
|
|
ercd = rel_blf( 3, vp ); // vp did come from new pool
|
208 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
|
209 |
|
|
ercd = rel_blf( 3, vp ); // vp already freed
|
210 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "rel_blf bad ercd !E_PAR" );
|
211 |
|
|
ercd = ref_mpf( &t_rmpf, 3 );
|
212 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mpf bad ercd" );
|
213 |
|
|
|
214 |
|
|
// In order to wait on the pools, we must first consume all they have:
|
215 |
|
|
while ( E_OK == (ercd = pget_blf( &vp, 1 )) ) /* nothing */;
|
216 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
|
217 |
|
|
while ( E_OK == (ercd = tget_blf( &vp, 2, 1 )) ) /* nothing */;
|
218 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf bad ercd !E_TMOUT" );
|
219 |
|
|
// now wait while task 2 deletes the wait objects
|
220 |
|
|
ercd = wup_tsk( 2 );
|
221 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
222 |
|
|
ercd = get_blf( &vp, 1 );
|
223 |
|
|
CYG_TEST_CHECK( E_DLT == ercd, "get_blf bad ercd !E_DLT" );
|
224 |
|
|
ercd = wup_tsk( 2 );
|
225 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
226 |
|
|
ercd = tget_blf( &vp, 2, 20 );
|
227 |
|
|
CYG_TEST_CHECK( E_DLT == ercd, "tget_blf bad ercd !E_DLT" );
|
228 |
|
|
// check they are deleted
|
229 |
|
|
ercd = get_blf( &vp, 1 );
|
230 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "get_blf bad ercd !E_NOEXS" );
|
231 |
|
|
ercd = pget_blf( &vp, 2 );
|
232 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blf bad ercd !E_NOEXS" );
|
233 |
|
|
|
234 |
|
|
// re-create and do it again
|
235 |
|
|
t_cmpf.mpfcnt = 90;
|
236 |
|
|
t_cmpf.blfsz = 20;
|
237 |
|
|
ercd = cre_mpf( 1, &t_cmpf );
|
238 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "cre_mpf bad ercd" );
|
239 |
|
|
t_cmpf.mpfcnt = 5;
|
240 |
|
|
t_cmpf.blfsz = 200;
|
241 |
|
|
ercd = cre_mpf( 2, &t_cmpf );
|
242 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "cre_mpf bad ercd" );
|
243 |
|
|
|
244 |
|
|
// In order to wait on the pools, we must first consume all they have:
|
245 |
|
|
while ( E_OK == (ercd = pget_blf( &vp, 1 )) ) /* nothing */;
|
246 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
|
247 |
|
|
while ( E_OK == (ercd = tget_blf( &vp, 2, 1 )) ) /* nothing */;
|
248 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf bad ercd !E_TMOUT" );
|
249 |
|
|
// now wait while task 2 deletes the wait objects
|
250 |
|
|
ercd = wup_tsk( 2 );
|
251 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
252 |
|
|
ercd = get_blf( &vp, 1 );
|
253 |
|
|
CYG_TEST_CHECK( E_DLT == ercd, "get_blf bad ercd !E_DLT" );
|
254 |
|
|
ercd = wup_tsk( 2 );
|
255 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
256 |
|
|
ercd = tget_blf( &vp, 2, 10 );
|
257 |
|
|
CYG_TEST_CHECK( E_DLT == ercd, "tget_blf bad ercd !E_DLT" );
|
258 |
|
|
// check they are deleted
|
259 |
|
|
ercd = tget_blf( &vp, 1, 1 );
|
260 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "get_blf bad ercd !E_NOEXS" );
|
261 |
|
|
ercd = get_blf( &vp, 2 );
|
262 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blf bad ercd !E_NOEXS" );
|
263 |
|
|
|
264 |
|
|
CYG_TEST_PASS("create/delete fixed mempools");
|
265 |
|
|
#endif // CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
|
266 |
|
|
|
267 |
|
|
#ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
|
268 |
|
|
tests++;
|
269 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
270 |
|
|
ercd = del_mpl( -6 );
|
271 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "del_mpl bad ercd !E_ID" );
|
272 |
|
|
ercd = del_mpl( 99 );
|
273 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "del_mpl bad ercd !E_ID" );
|
274 |
|
|
ercd = cre_mpl( -6, &t_cmpl );
|
275 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "cre_mpl bad ercd !E_ID" );
|
276 |
|
|
ercd = cre_mpl( 99, &t_cmpl );
|
277 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "cre_mpl bad ercd !E_ID" );
|
278 |
|
|
#endif // we can test bad param error returns
|
279 |
|
|
// try a pre-existing object
|
280 |
|
|
// [first get a valid block from it for the freeing test later]
|
281 |
|
|
ercd = pget_blk( &vp, 3, 100 );
|
282 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "pget_blk bad ercd" );
|
283 |
|
|
ercd = cre_mpl( 3, &t_cmpl );
|
284 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "cre_mpl bad ercd !E_OBJ" );
|
285 |
|
|
// delete it so we can play
|
286 |
|
|
ercd = del_mpl( 3 );
|
287 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" );
|
288 |
|
|
// check it is deleted
|
289 |
|
|
ercd = rel_blk( 3, vp ); // vp did come from this pool
|
290 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "rel_blk bad ercd !E_NOEXS" );
|
291 |
|
|
ercd = pget_blk( &vp, 3, 100 );
|
292 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blk bad ercd !E_NOEXS" );
|
293 |
|
|
ercd = tget_blk( &vp, 3, 100, 10 );
|
294 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "tget_blk bad ercd !E_NOEXS" );
|
295 |
|
|
ercd = get_blk( &vp, 3, 100 );
|
296 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "get_blk bad ercd !E_NOEXS" );
|
297 |
|
|
ercd = ref_mpl( &t_rmpl, 3 );
|
298 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "ref_mpl bad ercd !E_NOEXS" );
|
299 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
300 |
|
|
// now try creating it (badly)
|
301 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
302 |
|
|
ercd = cre_mpl( 3, NULL );
|
303 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "cre_mpl bad ercd !E_PAR" );
|
304 |
|
|
#endif
|
305 |
|
|
t_cmpl.mplatr = 0xfff;
|
306 |
|
|
ercd = cre_mpl( 3, &t_cmpl );
|
307 |
|
|
CYG_TEST_CHECK( E_RSATR == ercd, "cre_mpl bad ercd !E_RSATR" );
|
308 |
|
|
#endif // we can test bad param error returns
|
309 |
|
|
t_cmpl.mplatr = 0;
|
310 |
|
|
t_cmpl.mplsz = 100000000;
|
311 |
|
|
ercd = cre_mpl( 3, &t_cmpl );
|
312 |
|
|
CYG_TEST_CHECK( E_NOMEM == ercd, "cre_mpl bad ercd" );
|
313 |
|
|
// now create it well
|
314 |
|
|
t_cmpl.mplatr = 0;
|
315 |
|
|
t_cmpl.mplsz = 1000;
|
316 |
|
|
ercd = cre_mpl( 3, &t_cmpl );
|
317 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "cre_mpl bad ercd" );
|
318 |
|
|
// and check we can use it
|
319 |
|
|
ercd = pget_blk( &vp, 3, 100 );
|
320 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "pget_blk bad ercd" );
|
321 |
|
|
ercd = pget_blk( &vp, 3, 100000000 ); // way too large
|
322 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
|
323 |
|
|
ercd = tget_blk( &vp, 3, 100, 10 );
|
324 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "tget_blk bad ercd" );
|
325 |
|
|
ercd = get_blk( &vp, 3, 100 );
|
326 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "get_blk bad ercd" );
|
327 |
|
|
ercd = rel_blk( 3, vp ); // vp did come from new pool
|
328 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
|
329 |
|
|
ercd = rel_blk( 3, vp ); // vp already freed
|
330 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "rel_blk bad ercd !E_PAR" );
|
331 |
|
|
ercd = ref_mpl( &t_rmpl, 3 );
|
332 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mpl bad ercd" );
|
333 |
|
|
|
334 |
|
|
// In order to wait on the pools, we must first consume all they have:
|
335 |
|
|
while ( E_OK == (ercd = pget_blk( &vp, 1, 100 )) ) /* nothing */;
|
336 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
|
337 |
|
|
while ( E_OK == (ercd = tget_blk( &vp, 2, 100, 1 )) ) /* nothing */;
|
338 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk bad ercd !E_TMOUT" );
|
339 |
|
|
// now wait while task 2 deletes the wait objects
|
340 |
|
|
ercd = wup_tsk( 2 );
|
341 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
342 |
|
|
ercd = get_blk( &vp, 1, 200 );
|
343 |
|
|
CYG_TEST_CHECK( E_DLT == ercd, "get_blk bad ercd !E_DLT" );
|
344 |
|
|
ercd = wup_tsk( 2 );
|
345 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
346 |
|
|
ercd = tget_blk( &vp, 2, 100, 20 );
|
347 |
|
|
CYG_TEST_CHECK( E_DLT == ercd, "tget_blk bad ercd !E_DLT" );
|
348 |
|
|
// check they are deleted
|
349 |
|
|
ercd = get_blk( &vp, 1, 200 );
|
350 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "get_blk bad ercd !E_NOEXS" );
|
351 |
|
|
ercd = pget_blk( &vp, 2, 20 );
|
352 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blk bad ercd !E_NOEXS" );
|
353 |
|
|
|
354 |
|
|
// re-create and do it again
|
355 |
|
|
ercd = cre_mpl( 1, &t_cmpl );
|
356 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "cre_mpl bad ercd" );
|
357 |
|
|
ercd = cre_mpl( 2, &t_cmpl );
|
358 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "cre_mpl bad ercd" );
|
359 |
|
|
|
360 |
|
|
// In order to wait on the pools, we must first consume all they have:
|
361 |
|
|
while ( E_OK == (ercd = pget_blk( &vp, 1, 20 )) ) /* nothing */;
|
362 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
|
363 |
|
|
while ( E_OK == (ercd = tget_blk( &vp, 2, 400, 1 )) ) /* nothing */;
|
364 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk bad ercd !E_TMOUT" );
|
365 |
|
|
// now wait while task 2 deletes the wait objects
|
366 |
|
|
ercd = wup_tsk( 2 );
|
367 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
368 |
|
|
ercd = get_blk( &vp, 1, 200 );
|
369 |
|
|
CYG_TEST_CHECK( E_DLT == ercd, "get_blk bad ercd !E_DLT" );
|
370 |
|
|
ercd = wup_tsk( 2 );
|
371 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
372 |
|
|
ercd = tget_blk( &vp, 2, 500, 20 );
|
373 |
|
|
CYG_TEST_CHECK( E_DLT == ercd, "tget_blk bad ercd !E_DLT" );
|
374 |
|
|
// check they are deleted
|
375 |
|
|
ercd = tget_blk( &vp, 1, 200, 1 );
|
376 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "get_blk bad ercd !E_NOEXS" );
|
377 |
|
|
ercd = get_blk( &vp, 2, 20 );
|
378 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blk bad ercd !E_NOEXS" );
|
379 |
|
|
|
380 |
|
|
CYG_TEST_PASS("create/delete variable mempools");
|
381 |
|
|
#endif // CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
|
382 |
|
|
|
383 |
|
|
ercd = ter_tsk( 2 );
|
384 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
385 |
|
|
ercd = dly_tsk( 5 );
|
386 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
387 |
|
|
|
388 |
|
|
// all done
|
389 |
|
|
if ( 0 == tests ) {
|
390 |
|
|
CYG_TEST_NA( "No objects have create/delete enabled" );
|
391 |
|
|
}
|
392 |
|
|
else {
|
393 |
|
|
CYG_TEST_EXIT( "All done" );
|
394 |
|
|
}
|
395 |
|
|
ext_tsk();
|
396 |
|
|
}
|
397 |
|
|
|
398 |
|
|
|
399 |
|
|
|
400 |
|
|
void task2( unsigned int arg )
|
401 |
|
|
{
|
402 |
|
|
ER ercd;
|
403 |
|
|
int i;
|
404 |
|
|
CYG_TEST_INFO( "Task 2 running" );
|
405 |
|
|
ercd = get_tid( &i );
|
406 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
|
407 |
|
|
CYG_TEST_CHECK( 2 == i, "tid not 2" );
|
408 |
|
|
if ( 22222 != arg )
|
409 |
|
|
CYG_TEST_FAIL( "Task 2 arg not 22222" );
|
410 |
|
|
|
411 |
|
|
ercd = slp_tsk();
|
412 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
|
413 |
|
|
|
414 |
|
|
#ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
|
415 |
|
|
ercd = del_mpf( 1 );
|
416 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" );
|
417 |
|
|
ercd = slp_tsk();
|
418 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
|
419 |
|
|
ercd = del_mpf( 2 );
|
420 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" );
|
421 |
|
|
ercd = slp_tsk();
|
422 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
|
423 |
|
|
ercd = del_mpf( 1 );
|
424 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" );
|
425 |
|
|
ercd = slp_tsk();
|
426 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
|
427 |
|
|
ercd = del_mpf( 2 );
|
428 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" );
|
429 |
|
|
ercd = slp_tsk();
|
430 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
|
431 |
|
|
#endif // CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
|
432 |
|
|
|
433 |
|
|
#ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
|
434 |
|
|
ercd = del_mpl( 1 );
|
435 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" );
|
436 |
|
|
ercd = slp_tsk();
|
437 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
|
438 |
|
|
ercd = del_mpl( 2 );
|
439 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" );
|
440 |
|
|
ercd = slp_tsk();
|
441 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
|
442 |
|
|
ercd = del_mpl( 1 );
|
443 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" );
|
444 |
|
|
ercd = slp_tsk();
|
445 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
|
446 |
|
|
ercd = del_mpl( 2 );
|
447 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" );
|
448 |
|
|
ercd = slp_tsk();
|
449 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
|
450 |
|
|
#endif // CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
|
451 |
|
|
|
452 |
|
|
// we expect task2 to be killed here
|
453 |
|
|
CYG_TEST_FAIL( "Task 2 ran to completion!" );
|
454 |
|
|
}
|
455 |
|
|
|
456 |
|
|
void task3( unsigned int arg )
|
457 |
|
|
{
|
458 |
|
|
}
|
459 |
|
|
|
460 |
|
|
void task4( unsigned int arg )
|
461 |
|
|
{
|
462 |
|
|
}
|
463 |
|
|
|
464 |
|
|
#else // not enough (or too many) uITRON objects configured in
|
465 |
|
|
#define N_A_MSG "not enough uITRON objects to run test"
|
466 |
|
|
#endif // not enough (or too many) uITRON objects configured in
|
467 |
|
|
#else // not C++ and some C++ specific options enabled
|
468 |
|
|
#define N_A_MSG "C++ specific options selected but this is C"
|
469 |
|
|
#endif // not C++ and some C++ specific options enabled
|
470 |
|
|
#else // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it
|
471 |
|
|
#define N_A_MSG "no CYGVAR_KERNEL_COUNTERS_CLOCK"
|
472 |
|
|
#endif // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it
|
473 |
|
|
#else // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it
|
474 |
|
|
#define N_A_MSG "no CYGFUN_KERNEL_THREADS_TIMER"
|
475 |
|
|
#endif // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it
|
476 |
|
|
#else // ! CYGIMP_THREAD_PRIORITY - can't test without it
|
477 |
|
|
#define N_A_MSG "no CYGSEM_KERNEL_SCHED_MLQUEUE"
|
478 |
|
|
#endif // ! CYGSEM_KERNEL_SCHED_MLQUEUE - can't test without it
|
479 |
|
|
#else // ! CYGPKG_UITRON
|
480 |
|
|
#define N_A_MSG "uITRON Compatibility layer disabled"
|
481 |
|
|
#endif // CYGPKG_UITRON
|
482 |
|
|
|
483 |
|
|
#ifdef N_A_MSG
|
484 |
|
|
externC void
|
485 |
|
|
cyg_start( void )
|
486 |
|
|
{
|
487 |
|
|
CYG_TEST_INIT();
|
488 |
|
|
CYG_TEST_NA( N_A_MSG );
|
489 |
|
|
}
|
490 |
|
|
#endif // N_A_MSG defined ie. we are N/A.
|
491 |
|
|
|
492 |
|
|
// EOF testcx9.cxx
|