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