1 |
786 |
skrzyp |
//===========================================================================
|
2 |
|
|
//
|
3 |
|
|
// test2.c
|
4 |
|
|
//
|
5 |
|
|
// uITRON "C" test program two
|
6 |
|
|
//
|
7 |
|
|
//===========================================================================
|
8 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2009 Free Software Foundation, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
16 |
|
|
// version.
|
17 |
|
|
//
|
18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
21 |
|
|
// for more details.
|
22 |
|
|
//
|
23 |
|
|
// You should have received a copy of the GNU General Public License
|
24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
26 |
|
|
//
|
27 |
|
|
// As a special exception, if other files instantiate templates or use
|
28 |
|
|
// macros or inline functions from this file, or you compile this file
|
29 |
|
|
// and link it with other works to produce a work based on this file,
|
30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
31 |
|
|
// the GNU General Public License. However the source code for this file
|
32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
33 |
|
|
// General Public License v2.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
36 |
|
|
// on this file might be covered by the GNU General Public License.
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//===========================================================================
|
40 |
|
|
//#####DESCRIPTIONBEGIN####
|
41 |
|
|
//
|
42 |
|
|
// Author(s): hmt
|
43 |
|
|
// Contributors: hmt
|
44 |
|
|
// Date: 1998-03-13
|
45 |
|
|
// Purpose: uITRON API testing
|
46 |
|
|
// Description:
|
47 |
|
|
//
|
48 |
|
|
//####DESCRIPTIONEND####
|
49 |
|
|
//
|
50 |
|
|
//===========================================================================
|
51 |
|
|
|
52 |
|
|
#include <pkgconf/uitron.h> // uITRON setup CYGNUM_UITRON_SEMAS
|
53 |
|
|
// CYGPKG_UITRON et al
|
54 |
|
|
#include <cyg/infra/testcase.h> // testing infrastructure
|
55 |
|
|
|
56 |
|
|
#ifdef CYGPKG_UITRON // we DO want the uITRON package
|
57 |
|
|
|
58 |
|
|
#ifdef CYGIMP_UITRON_STRICT_CONFORMANCE // we DO want strict conformance
|
59 |
|
|
|
60 |
|
|
#ifdef CYGSEM_KERNEL_SCHED_MLQUEUE // we DO want prioritized threads
|
61 |
|
|
|
62 |
|
|
#ifdef CYGFUN_KERNEL_THREADS_TIMER // we DO want timout-able calls
|
63 |
|
|
|
64 |
|
|
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK // we DO want the realtime clock
|
65 |
|
|
|
66 |
|
|
// we're OK if it's C++ or neither of those two is defined:
|
67 |
|
|
#if defined( __cplusplus ) || \
|
68 |
|
|
(!defined( CYGIMP_UITRON_INLINE_FUNCS ) && \
|
69 |
|
|
!defined( CYGIMP_UITRON_CPP_OUTLINE_FUNCS) )
|
70 |
|
|
|
71 |
|
|
// =================== TEST CONFIGURATION ===================
|
72 |
|
|
#if \
|
73 |
|
|
/* test configuration for enough tasks */ \
|
74 |
|
|
(CYGNUM_UITRON_TASKS >= 4) && \
|
75 |
|
|
(CYGNUM_UITRON_TASKS < 90) && \
|
76 |
|
|
(CYGNUM_UITRON_START_TASKS == 1) && \
|
77 |
|
|
( !defined(CYGPKG_UITRON_TASKS_CREATE_DELETE) || \
|
78 |
|
|
CYGNUM_UITRON_TASKS_INITIALLY >= 4 ) && \
|
79 |
|
|
\
|
80 |
|
|
/* test configuration for enough semaphores */ \
|
81 |
|
|
defined( CYGPKG_UITRON_SEMAS ) && \
|
82 |
|
|
(CYGNUM_UITRON_SEMAS >= 3) && \
|
83 |
|
|
(CYGNUM_UITRON_SEMAS < 90) && \
|
84 |
|
|
( !defined(CYGPKG_UITRON_SEMAS_CREATE_DELETE) || \
|
85 |
|
|
CYGNUM_UITRON_SEMAS_INITIALLY >= 3 ) && \
|
86 |
|
|
\
|
87 |
|
|
/* test configuration for enough flag objects */ \
|
88 |
|
|
defined( CYGPKG_UITRON_FLAGS ) && \
|
89 |
|
|
(CYGNUM_UITRON_FLAGS >= 3) && \
|
90 |
|
|
(CYGNUM_UITRON_FLAGS < 90) && \
|
91 |
|
|
( !defined(CYGPKG_UITRON_FLAGS_CREATE_DELETE) || \
|
92 |
|
|
CYGNUM_UITRON_FLAGS_INITIALLY >= 3 ) && \
|
93 |
|
|
\
|
94 |
|
|
/* test configuration for enough message boxes */ \
|
95 |
|
|
defined( CYGPKG_UITRON_MBOXES ) && \
|
96 |
|
|
(CYGNUM_UITRON_MBOXES >= 3) && \
|
97 |
|
|
(CYGNUM_UITRON_MBOXES < 90) && \
|
98 |
|
|
( !defined(CYGPKG_UITRON_MBOXES_CREATE_DELETE) || \
|
99 |
|
|
CYGNUM_UITRON_MBOXES_INITIALLY >= 3 ) && \
|
100 |
|
|
\
|
101 |
|
|
/* test configuration for enough fixed memory pools */ \
|
102 |
|
|
defined( CYGPKG_UITRON_MEMPOOLFIXED ) && \
|
103 |
|
|
(CYGNUM_UITRON_MEMPOOLFIXED >= 3) && \
|
104 |
|
|
(CYGNUM_UITRON_MEMPOOLFIXED < 90) && \
|
105 |
|
|
( !defined(CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE) || \
|
106 |
|
|
CYGNUM_UITRON_MEMPOOLFIXED_INITIALLY >= 3 ) && \
|
107 |
|
|
\
|
108 |
|
|
/* test configuration for enough variable mempools */ \
|
109 |
|
|
defined( CYGPKG_UITRON_MEMPOOLVAR ) && \
|
110 |
|
|
(CYGNUM_UITRON_MEMPOOLVAR >= 3) && \
|
111 |
|
|
(CYGNUM_UITRON_MEMPOOLVAR < 90) && \
|
112 |
|
|
( !defined(CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE) || \
|
113 |
|
|
CYGNUM_UITRON_MEMPOOLVAR_INITIALLY >= 3 ) && \
|
114 |
|
|
\
|
115 |
|
|
/* the end of the large #if statement */ \
|
116 |
|
|
1
|
117 |
|
|
|
118 |
|
|
// ============================ END ============================
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
#include <cyg/compat/uitron/uit_func.h> // uITRON
|
123 |
|
|
|
124 |
|
|
externC void
|
125 |
|
|
cyg_package_start( void )
|
126 |
|
|
{
|
127 |
|
|
CYG_TEST_INIT();
|
128 |
|
|
CYG_TEST_INFO( "Calling cyg_uitron_start()" );
|
129 |
|
|
cyg_uitron_start();
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
int intercom = 0;
|
133 |
|
|
int intercount = 0;
|
134 |
|
|
INT scratch = 0;
|
135 |
|
|
|
136 |
|
|
void task1( unsigned int arg )
|
137 |
|
|
{
|
138 |
|
|
ER ercd;
|
139 |
|
|
|
140 |
|
|
T_RSEM sem_info;
|
141 |
|
|
T_RFLG flg_info;
|
142 |
|
|
T_RMBX mbx_info;
|
143 |
|
|
T_RMPF mpf_info;
|
144 |
|
|
T_RMPL mpl_info;
|
145 |
|
|
UINT flagptn;
|
146 |
|
|
static char foo[] = "Test message";
|
147 |
|
|
T_MSG *msgptr = (T_MSG *)foo;
|
148 |
|
|
T_MSG *rxptr = NULL;
|
149 |
|
|
VP blfptr = (VP)foo;
|
150 |
|
|
VP blkptr = (VP)foo;
|
151 |
|
|
|
152 |
|
|
int delay = 10;
|
153 |
|
|
if (cyg_test_is_simulator)
|
154 |
|
|
delay = 3;
|
155 |
|
|
|
156 |
|
|
CYG_TEST_INFO( "Task 1 running" );
|
157 |
|
|
ercd = get_tid( &scratch );
|
158 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
|
159 |
|
|
CYG_TEST_CHECK( 1 == scratch, "tid not 1" );
|
160 |
|
|
|
161 |
|
|
// start a lower prio task to interact with
|
162 |
|
|
intercom = 1;
|
163 |
|
|
ercd = sta_tsk( 2, 222 );
|
164 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
|
165 |
|
|
ercd = dly_tsk( delay );
|
166 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
167 |
|
|
|
168 |
|
|
// Semaphores; all the illegal argument combinations first
|
169 |
|
|
CYG_TEST_INFO( "Testing semaphore ops" );
|
170 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
171 |
|
|
ercd = sig_sem( -6 );
|
172 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "sig_sem bad ercd !E_ID" );
|
173 |
|
|
ercd = sig_sem( 99 );
|
174 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "sig_sem bad ercd !E_ID" );
|
175 |
|
|
ercd = wai_sem( -6 );
|
176 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "wai_sem bad ercd !E_ID" );
|
177 |
|
|
ercd = wai_sem( 99 );
|
178 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "wai_sem bad ercd !E_ID" );
|
179 |
|
|
ercd = preq_sem( -6 );
|
180 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "preq_sem bad ercd !E_ID" );
|
181 |
|
|
ercd = preq_sem( 99 );
|
182 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "preq_sem bad ercd !E_ID" );
|
183 |
|
|
ercd = twai_sem( -6, delay );
|
184 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "twai_sem bad ercd !E_ID" );
|
185 |
|
|
ercd = twai_sem( 99, delay );
|
186 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "twai_sem bad ercd !E_ID" );
|
187 |
|
|
ercd = twai_sem( 2, -999 );
|
188 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "twai_sem bad ercd !E_PAR" );
|
189 |
|
|
ercd = ref_sem( &sem_info, -6 );
|
190 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "ref_sem bad ercd !E_ID" );
|
191 |
|
|
ercd = ref_sem( &sem_info, 99 );
|
192 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "ref_sem bad ercd !E_ID" );
|
193 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
194 |
|
|
ercd = ref_sem( NULL, 2 );
|
195 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "ref_sem bad ercd !E_PAR" );
|
196 |
|
|
#endif
|
197 |
|
|
ercd = ref_sem( NADR, 2 );
|
198 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "ref_sem bad ercd !E_PAR" );
|
199 |
|
|
CYG_TEST_PASS( "bad calls: sig_sem, [t]wai_sem, preq_sem, ref_sem" );
|
200 |
|
|
#endif // we can test bad param error returns
|
201 |
|
|
|
202 |
|
|
// check the waitable functions versus dispatch disable
|
203 |
|
|
ercd = preq_sem( 2 );
|
204 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "preq_sem bad ercd !E_TMOUT" );
|
205 |
|
|
ercd = twai_sem( 2, delay );
|
206 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem bad ercd !E_TMOUT" );
|
207 |
|
|
ercd = twai_sem( 2, TMO_POL );
|
208 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem(POL) bad ercd !E_TMOUT" );
|
209 |
|
|
ercd = dis_dsp();
|
210 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
211 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
212 |
|
|
ercd = wai_sem( 2 );
|
213 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "wai_sem bad ercd !E_CTX" );
|
214 |
|
|
ercd = twai_sem( 2, delay );
|
215 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "twai_sem bad ercd !E_CTX" );
|
216 |
|
|
ercd = twai_sem( 2, TMO_FEVR );
|
217 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "twai_sem(FEVR) bad ercd !E_CTX" );
|
218 |
|
|
#endif // we can test bad param error returns
|
219 |
|
|
ercd = twai_sem( 2, TMO_POL );
|
220 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem(POL) bad ercd !E_TMOUT" );
|
221 |
|
|
ercd = preq_sem( 2 );
|
222 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "preq_sem bad ercd !E_TMOUT" );
|
223 |
|
|
ercd = ena_dsp();
|
224 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
225 |
|
|
ercd = preq_sem( 2 );
|
226 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "preq_sem bad ercd !E_TMOUT" );
|
227 |
|
|
ercd = twai_sem( 2, delay );
|
228 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem bad ercd !E_TMOUT" );
|
229 |
|
|
ercd = twai_sem( 2, TMO_POL );
|
230 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem(POL) bad ercd !E_TMOUT" );
|
231 |
|
|
CYG_TEST_PASS( "bad calls: wai_sem, twai_sem with dis_dsp" );
|
232 |
|
|
|
233 |
|
|
// check ref_sem with various states
|
234 |
|
|
ercd = ref_sem( &sem_info, 2 );
|
235 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
|
236 |
|
|
CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
|
237 |
|
|
CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
|
238 |
|
|
ercd = sig_sem( 2 );
|
239 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
|
240 |
|
|
ercd = ref_sem( &sem_info, 2 );
|
241 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
|
242 |
|
|
CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
|
243 |
|
|
CYG_TEST_CHECK( 1 == sem_info.semcnt, "semcnt should be 1" );
|
244 |
|
|
ercd = preq_sem( 2 );
|
245 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
|
246 |
|
|
ercd = ref_sem( &sem_info, 2 );
|
247 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
|
248 |
|
|
CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
|
249 |
|
|
CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
|
250 |
|
|
ercd = ref_sem( &sem_info, 2 );
|
251 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
|
252 |
|
|
CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
|
253 |
|
|
CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
|
254 |
|
|
ercd = sig_sem( 2 );
|
255 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
|
256 |
|
|
ercd = sig_sem( 2 );
|
257 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
|
258 |
|
|
ercd = ref_sem( &sem_info, 2 );
|
259 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
|
260 |
|
|
CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
|
261 |
|
|
CYG_TEST_CHECK( 2 == sem_info.semcnt, "semcnt should be 2" );
|
262 |
|
|
ercd = wai_sem( 2 );
|
263 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
|
264 |
|
|
ercd = ref_sem( &sem_info, 2 );
|
265 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
|
266 |
|
|
CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
|
267 |
|
|
CYG_TEST_CHECK( 1 == sem_info.semcnt, "semcnt should be 1" );
|
268 |
|
|
ercd = twai_sem( 2, delay );
|
269 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
|
270 |
|
|
ercd = ref_sem( &sem_info, 2 );
|
271 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
|
272 |
|
|
CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
|
273 |
|
|
CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
|
274 |
|
|
intercom = 0;
|
275 |
|
|
ercd = dly_tsk( delay );
|
276 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
277 |
|
|
intercom = 1;
|
278 |
|
|
ercd = ref_sem( &sem_info, 2 );
|
279 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
|
280 |
|
|
CYG_TEST_CHECK( 0 != sem_info.wtsk, "sem.wtsk should be non0" );
|
281 |
|
|
CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
|
282 |
|
|
ercd = sig_sem( 2 );
|
283 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
|
284 |
|
|
ercd = ref_sem( &sem_info, 2 );
|
285 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
|
286 |
|
|
CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be non0" );
|
287 |
|
|
#if 1
|
288 |
|
|
CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
|
289 |
|
|
#else // old, non-uITRON semantics
|
290 |
|
|
CYG_TEST_CHECK( 1 == sem_info.semcnt, "semcnt should be 1" );
|
291 |
|
|
#endif
|
292 |
|
|
ercd = dly_tsk( delay ); // let task 2 pick up the signal
|
293 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
294 |
|
|
ercd = ref_sem( &sem_info, 2 );
|
295 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );
|
296 |
|
|
CYG_TEST_CHECK( 0 == sem_info.wtsk, "sem.wtsk should be 0" );
|
297 |
|
|
CYG_TEST_CHECK( 0 == sem_info.semcnt, "semcnt should be 0" );
|
298 |
|
|
CYG_TEST_PASS( "good calls: sig_sem, [t]wai,preq_sem with ref_sem" );
|
299 |
|
|
|
300 |
|
|
// Flags; all the illegal argument combinations first
|
301 |
|
|
CYG_TEST_INFO( "Testing flag ops" );
|
302 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
303 |
|
|
ercd = set_flg( -6, 1 );
|
304 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "set_flg bad ercd !E_ID" );
|
305 |
|
|
ercd = set_flg( 99, 1 );
|
306 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "set_flg bad ercd !E_ID" );
|
307 |
|
|
ercd = clr_flg( -6, 1 );
|
308 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "clr_flg bad ercd !E_ID" );
|
309 |
|
|
ercd = clr_flg( 99, 1 );
|
310 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "sig_flg bad ercd !E_ID" );
|
311 |
|
|
ercd = wai_flg( &flagptn, -6, 7, TWF_ANDW );
|
312 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "wai_flg bad ercd !E_ID" );
|
313 |
|
|
ercd = wai_flg( &flagptn, 99, 7, TWF_ANDW );
|
314 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "wai_flg bad ercd !E_ID" );
|
315 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
316 |
|
|
ercd = wai_flg( NULL, 2, 7, TWF_ANDW );
|
317 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "wai_flg bad ercd !E_PAR" );
|
318 |
|
|
#endif
|
319 |
|
|
ercd = wai_flg( NADR, 2, 7, TWF_ANDW );
|
320 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "wai_flg bad ercd !E_PAR" );
|
321 |
|
|
ercd = wai_flg( &flagptn, 2, 7, 34657 );
|
322 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "wai_flg bad ercd !E_PAR" );
|
323 |
|
|
ercd = wai_flg( &flagptn, 2, 0, TWF_ANDW );
|
324 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "wai_flg bad ercd !E_PAR" );
|
325 |
|
|
ercd = pol_flg( &flagptn, -6, 7, TWF_ANDW );
|
326 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "pol_flg bad ercd !E_ID" );
|
327 |
|
|
ercd = pol_flg( &flagptn, 99, 7, TWF_ANDW );
|
328 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "pol_flg bad ercd !E_ID" );
|
329 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
330 |
|
|
ercd = pol_flg( NULL, 2, 7, TWF_ANDW );
|
331 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "pol_flg bad ercd !E_PAR" );
|
332 |
|
|
#endif
|
333 |
|
|
ercd = pol_flg( NADR, 2, 7, TWF_ANDW );
|
334 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "pol_flg bad ercd !E_PAR" );
|
335 |
|
|
ercd = pol_flg( &flagptn, 2, 7, 34657 );
|
336 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "pol_flg bad ercd !E_PAR" );
|
337 |
|
|
ercd = pol_flg( &flagptn, 2, 0, TWF_ANDW );
|
338 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "pol_flg bad ercd !E_PAR" );
|
339 |
|
|
ercd = twai_flg( &flagptn, -6, 7, TWF_ANDW, delay );
|
340 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "twai_flg bad ercd !E_ID" );
|
341 |
|
|
ercd = twai_flg( &flagptn, 99, 7, TWF_ANDW, delay );
|
342 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "twai_flg bad ercd !E_ID" );
|
343 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
344 |
|
|
ercd = twai_flg( NULL, 2, 7, TWF_ANDW, delay );
|
345 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "twai_flg bad ercd !E_PAR" );
|
346 |
|
|
#endif
|
347 |
|
|
ercd = twai_flg( NADR, 2, 7, TWF_ANDW, delay );
|
348 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "twai_flg bad ercd !E_PAR" );
|
349 |
|
|
ercd = twai_flg( &flagptn, 2, 7, 34657, delay );
|
350 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "twai_flg bad ercd !E_PAR" );
|
351 |
|
|
ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, -999 );
|
352 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "twai_flg bad ercd !E_PAR" );
|
353 |
|
|
ercd = twai_flg( &flagptn, 2, 0, TWF_ANDW, delay );
|
354 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "twai_flg bad ercd !E_PAR" );
|
355 |
|
|
ercd = ref_flg( &flg_info, -6 );
|
356 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "ref_flg bad ercd !E_ID" );
|
357 |
|
|
ercd = ref_flg( &flg_info, 99 );
|
358 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "ref_flg bad ercd !E_ID" );
|
359 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
360 |
|
|
ercd = ref_flg( NULL, 2 );
|
361 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "ref_flg bad ercd !E_PAR" );
|
362 |
|
|
#endif
|
363 |
|
|
ercd = ref_flg( NADR, 2 );
|
364 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "ref_flg bad ercd !E_PAR" );
|
365 |
|
|
CYG_TEST_PASS( "bad calls: set_flg, clr_flg, [t]wai,pol_flg, ref_flg" );
|
366 |
|
|
#endif // we can test bad param error returns
|
367 |
|
|
|
368 |
|
|
// check the waitable functions versus dispatch disable
|
369 |
|
|
ercd = pol_flg( &flagptn, 2, 7, TWF_ANDW );
|
370 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" );
|
371 |
|
|
ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, delay );
|
372 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg bad ercd !E_TMOUT" );
|
373 |
|
|
ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, TMO_POL );
|
374 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg(POL) bad ercd !E_TMOUT" );
|
375 |
|
|
ercd = dis_dsp();
|
376 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
377 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
378 |
|
|
ercd = wai_flg( &flagptn, 2, 7, TWF_ANDW );
|
379 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "wai_flg bad ercd !E_CTX" );
|
380 |
|
|
ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, delay );
|
381 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "twai_flg bad ercd !E_CTX" );
|
382 |
|
|
ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, TMO_FEVR );
|
383 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "twai_flg(FEVR) bad ercd !E_CTX" );
|
384 |
|
|
#endif // we can test bad param error returns
|
385 |
|
|
ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, TMO_POL );
|
386 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg(POL) bad ercd !E_TMOUT" );
|
387 |
|
|
ercd = pol_flg( &flagptn, 2, 7, TWF_ANDW );
|
388 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" );
|
389 |
|
|
ercd = ena_dsp();
|
390 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
391 |
|
|
ercd = pol_flg( &flagptn, 2, 7, TWF_ANDW );
|
392 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" );
|
393 |
|
|
ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, delay );
|
394 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg bad ercd !E_TMOUT" );
|
395 |
|
|
ercd = twai_flg( &flagptn, 2, 7, TWF_ANDW, TMO_POL );
|
396 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg(POL) bad ercd !E_TMOUT" );
|
397 |
|
|
CYG_TEST_PASS( "bad calls: wai_flg, twai_flg with dis_dsp" );
|
398 |
|
|
|
399 |
|
|
// check ref_flg with various states
|
400 |
|
|
ercd = ref_flg( &flg_info, 2 );
|
401 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
|
402 |
|
|
CYG_TEST_CHECK( 0 == flg_info.wtsk, "flg.wtsk should be non0" );
|
403 |
|
|
CYG_TEST_CHECK( 0 == flg_info.flgptn, "flgptn should be 0" );
|
404 |
|
|
intercom = 0;
|
405 |
|
|
ercd = dly_tsk( delay ); // let task 2 start waiting
|
406 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
407 |
|
|
intercom = 1;
|
408 |
|
|
ercd = ref_flg( &flg_info, 2 );
|
409 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
|
410 |
|
|
CYG_TEST_CHECK( 0 != flg_info.wtsk, "flg.wtsk should be non0" );
|
411 |
|
|
CYG_TEST_CHECK( 0 == flg_info.flgptn, "flgptn should be 0" );
|
412 |
|
|
ercd = set_flg( 2, 0x5555 );
|
413 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sig_flg bad ercd" );
|
414 |
|
|
ercd = dly_tsk( delay );
|
415 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
416 |
|
|
ercd = ref_flg( &flg_info, 2 );
|
417 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
|
418 |
|
|
CYG_TEST_CHECK( 0 != flg_info.wtsk, "flg.wtsk should be non0" );
|
419 |
|
|
CYG_TEST_CHECK( 0x5555 == flg_info.flgptn, "flgptn should be 0x5555" );
|
420 |
|
|
ercd = clr_flg( 2, 0xF0F0 );
|
421 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "clr_flg bad ercd" );
|
422 |
|
|
ercd = dly_tsk( delay );
|
423 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
424 |
|
|
ercd = ref_flg( &flg_info, 2 );
|
425 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
|
426 |
|
|
CYG_TEST_CHECK( 0 != flg_info.wtsk, "flg.wtsk should be non0" );
|
427 |
|
|
CYG_TEST_CHECK( 0x5050 == flg_info.flgptn, "flgptn should be 0x5050" );
|
428 |
|
|
ercd = set_flg( 2, 0xFFFF );
|
429 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sig_flg bad ercd" );
|
430 |
|
|
ercd = dly_tsk( delay );
|
431 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
432 |
|
|
ercd = ref_flg( &flg_info, 2 );
|
433 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
|
434 |
|
|
CYG_TEST_CHECK( 0 == flg_info.wtsk, "flg.wtsk should be 0" );
|
435 |
|
|
CYG_TEST_CHECK( 0xFFFF == flg_info.flgptn, "flgptn should be 0xFFFF" );
|
436 |
|
|
CYG_TEST_PASS( "good calls: clr_flg, set_flg, wai_flg with ref_flg" );
|
437 |
|
|
|
438 |
|
|
// Mailboxes; all the illegal argument combinations first
|
439 |
|
|
CYG_TEST_INFO( "Testing mailbox ops" );
|
440 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
441 |
|
|
ercd = snd_msg( -6, msgptr );
|
442 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "snd_msg bad ercd !E_ID" );
|
443 |
|
|
ercd = snd_msg( 99, msgptr );
|
444 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "snd_msg bad ercd !E_ID" );
|
445 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
446 |
|
|
ercd = snd_msg( 2, NULL );
|
447 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "snd_msg bad ercd !E_PAR" );
|
448 |
|
|
#endif
|
449 |
|
|
ercd = snd_msg( 2, NADR );
|
450 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "snd_msg bad ercd !E_PAR" );
|
451 |
|
|
ercd = rcv_msg( &rxptr, -6 );
|
452 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "rcv_msg bad ercd !E_ID" );
|
453 |
|
|
ercd = rcv_msg( &rxptr, 99 );
|
454 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "rcv_msg bad ercd !E_ID" );
|
455 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
456 |
|
|
ercd = rcv_msg( NULL, 2 );
|
457 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "rcv_msg bad ercd !E_PAR" );
|
458 |
|
|
#endif
|
459 |
|
|
ercd = rcv_msg( NADR, 2 );
|
460 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "rcv_msg bad ercd !E_PAR" );
|
461 |
|
|
ercd = prcv_msg( &rxptr, -6 );
|
462 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "prcv_msg bad ercd !E_ID" );
|
463 |
|
|
ercd = prcv_msg( &rxptr, 99 );
|
464 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "prcv_msg bad ercd !E_ID" );
|
465 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
466 |
|
|
ercd = prcv_msg( NULL, 2 );
|
467 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "prcv_msg bad ercd !E_PAR" );
|
468 |
|
|
#endif
|
469 |
|
|
ercd = prcv_msg( NADR, 2 );
|
470 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "prcv_msg bad ercd !E_PAR" );
|
471 |
|
|
ercd = trcv_msg( &rxptr, -6, delay );
|
472 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "trcv_msg bad ercd !E_ID" );
|
473 |
|
|
ercd = trcv_msg( &rxptr, 99, delay );
|
474 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "trcv_msg bad ercd !E_ID" );
|
475 |
|
|
ercd = trcv_msg( &rxptr, 2, -999 );
|
476 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "trcv_msg bad ercd !E_PAR" );
|
477 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
478 |
|
|
ercd = trcv_msg( NULL, 2, delay );
|
479 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "trcv_msg bad ercd !E_PAR" );
|
480 |
|
|
#endif
|
481 |
|
|
ercd = trcv_msg( NADR, 2, delay );
|
482 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "trcv_msg bad ercd !E_PAR" );
|
483 |
|
|
ercd = ref_mbx( &mbx_info, -6 );
|
484 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "ref_mbx bad ercd !E_ID" );
|
485 |
|
|
ercd = ref_mbx( &mbx_info, 99 );
|
486 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "ref_mbx bad ercd !E_ID" );
|
487 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
488 |
|
|
ercd = ref_mbx( NULL, 2 );
|
489 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "ref_mbx bad ercd !E_PAR" );
|
490 |
|
|
#endif
|
491 |
|
|
ercd = ref_mbx( NADR, 2 );
|
492 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "ref_mbx bad ercd !E_PAR" );
|
493 |
|
|
CYG_TEST_PASS( "bad calls: snd_msg, [pt]rcv_msg, ref_mbx" );
|
494 |
|
|
#endif // we can test bad param error returns
|
495 |
|
|
|
496 |
|
|
// check the waitable functions versus dispatch disable
|
497 |
|
|
ercd = prcv_msg( &rxptr, 2 );
|
498 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "prcv_msg bad ercd !E_TMOUT" );
|
499 |
|
|
ercd = trcv_msg( &rxptr, 2, delay );
|
500 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg bad ercd !E_TMOUT" );
|
501 |
|
|
ercd = trcv_msg( &rxptr, 2, TMO_POL );
|
502 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg(POL) bad ercd !E_TMOUT" );
|
503 |
|
|
ercd = dis_dsp();
|
504 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
505 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
506 |
|
|
ercd = rcv_msg( &rxptr, 2 );
|
507 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "rcv_msg bad ercd !E_CTX" );
|
508 |
|
|
ercd = trcv_msg( &rxptr, 2, delay );
|
509 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "trcv_msg bad ercd !E_CTX" );
|
510 |
|
|
ercd = trcv_msg( &rxptr, 2, TMO_FEVR );
|
511 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "trcv_msg(FEVR) bad ercd !E_CTX" );
|
512 |
|
|
#endif // we can test bad param error returns
|
513 |
|
|
ercd = trcv_msg( &rxptr, 2, TMO_POL );
|
514 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg(POL) bad ercd !E_TMOUT" );
|
515 |
|
|
ercd = prcv_msg( &rxptr, 2 );
|
516 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "prcv_msg bad ercd !E_TMOUT" );
|
517 |
|
|
ercd = ena_dsp();
|
518 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
519 |
|
|
ercd = prcv_msg( &rxptr, 2 );
|
520 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "prcv_msg bad ercd !E_TMOUT" );
|
521 |
|
|
ercd = trcv_msg( &rxptr, 2, delay );
|
522 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg bad ercd !E_TMOUT" );
|
523 |
|
|
ercd = trcv_msg( &rxptr, 2, TMO_POL );
|
524 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg(POL) bad ercd !E_TMOUT" );
|
525 |
|
|
CYG_TEST_PASS( "bad calls: rcv_msg, trcv_msg with dis_dsp" );
|
526 |
|
|
|
527 |
|
|
// check ref_mbx with various states
|
528 |
|
|
ercd = ref_mbx( &mbx_info, 2 );
|
529 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mbx bad ercd" );
|
530 |
|
|
CYG_TEST_CHECK( 0 == mbx_info.wtsk, "mbx.wtsk should be 0" );
|
531 |
|
|
CYG_TEST_CHECK( NADR == mbx_info.pk_msg, "mbx peek should be NADR" );
|
532 |
|
|
intercom = 0;
|
533 |
|
|
ercd = dly_tsk( delay ); // let task 2 start waiting
|
534 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
535 |
|
|
intercom = 1;
|
536 |
|
|
ercd = ref_mbx( &mbx_info, 2 );
|
537 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mbx bad ercd" );
|
538 |
|
|
CYG_TEST_CHECK( 0 != mbx_info.wtsk, "mbx.wtsk should be non0" );
|
539 |
|
|
CYG_TEST_CHECK( NADR == mbx_info.pk_msg, "mbx peek should be NADR" );
|
540 |
|
|
ercd = snd_msg( 2, msgptr );
|
541 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "snd_msg bad ercd" );
|
542 |
|
|
ercd = ref_mbx( &mbx_info, 2 );
|
543 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mbx bad ercd" );
|
544 |
|
|
CYG_TEST_CHECK( 0 == mbx_info.wtsk, "mbx.wtsk should be 0" );
|
545 |
|
|
#if 1
|
546 |
|
|
CYG_TEST_CHECK( NADR == mbx_info.pk_msg, "mbx peek should be NADR" );
|
547 |
|
|
#else // old, non-uITRON semantics
|
548 |
|
|
CYG_TEST_CHECK( msgptr == mbx_info.pk_msg, "mbx peek should be msgptr" );
|
549 |
|
|
#endif
|
550 |
|
|
ercd = dly_tsk( delay );
|
551 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
552 |
|
|
ercd = ref_mbx( &mbx_info, 2 );
|
553 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mbx bad ercd" );
|
554 |
|
|
CYG_TEST_CHECK( 0 == mbx_info.wtsk, "mbx.wtsk should be 0" );
|
555 |
|
|
CYG_TEST_CHECK( NADR == mbx_info.pk_msg, "mbx peek should be NADR" );
|
556 |
|
|
// fill the message box, expect E_QOVR
|
557 |
|
|
for ( scratch = 0 ; scratch < 100 ; scratch++ ) {
|
558 |
|
|
if ( E_OK != ( ercd = snd_msg( 2, msgptr ) ) )
|
559 |
|
|
break;
|
560 |
|
|
}
|
561 |
|
|
CYG_TEST_CHECK( (100 == scratch) || (E_QOVR == ercd),
|
562 |
|
|
"snd_msg bad ercd !E_QOVR/E_OK" );
|
563 |
|
|
// empty the message box, expect the right number and E_TMOUT
|
564 |
|
|
for ( ; 1 ; scratch-- ) {
|
565 |
|
|
if ( E_OK != ( ercd = prcv_msg( &rxptr, 2 ) ) )
|
566 |
|
|
break;
|
567 |
|
|
}
|
568 |
|
|
CYG_TEST_CHECK( 0 == scratch, "rcv_msg count bad scratch!=0" );
|
569 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "rcv_msg bad ercd !E_TMOUT" );
|
570 |
|
|
|
571 |
|
|
CYG_TEST_PASS( "good calls: rcv_msg, snd_msg with ref_msg" );
|
572 |
|
|
|
573 |
|
|
// Fixed block memory pools: all the illegal argument combinations first
|
574 |
|
|
CYG_TEST_INFO( "Testing fixed block memory ops" );
|
575 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
576 |
|
|
ercd = rel_blf( -6, blfptr );
|
577 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "rel_blf bad ercd !E_ID" );
|
578 |
|
|
ercd = rel_blf( 99, blfptr );
|
579 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "rel_blf bad ercd !E_ID" );
|
580 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
581 |
|
|
ercd = rel_blf( 2, NULL );
|
582 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "rel_blf bad ercd !E_PAR" );
|
583 |
|
|
#endif
|
584 |
|
|
ercd = rel_blf( 2, NADR );
|
585 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "rel_blf bad ercd !E_PAR" );
|
586 |
|
|
#endif // we can test bad param error returns
|
587 |
|
|
ercd = rel_blf( 2, blfptr ); // it did not come from a mpf
|
588 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "rel_blf bad ercd !E_PAR" );
|
589 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
590 |
|
|
ercd = get_blf( &blfptr, -6 );
|
591 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "get_blf bad ercd !E_ID" );
|
592 |
|
|
ercd = get_blf( &blfptr, 99 );
|
593 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "get_blf bad ercd !E_ID" );
|
594 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
595 |
|
|
ercd = get_blf( NULL, 2 );
|
596 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "get_blf bad ercd !E_PAR" );
|
597 |
|
|
#endif
|
598 |
|
|
ercd = get_blf( NADR, 2 );
|
599 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "get_blf bad ercd !E_PAR" );
|
600 |
|
|
ercd = pget_blf( &blfptr, -6 );
|
601 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "pget_blf bad ercd !E_ID" );
|
602 |
|
|
ercd = pget_blf( &blfptr, 99 );
|
603 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "pget_blf bad ercd !E_ID" );
|
604 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
605 |
|
|
ercd = pget_blf( NULL, 2 );
|
606 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "pget_blf bad ercd !E_PAR" );
|
607 |
|
|
#endif
|
608 |
|
|
ercd = pget_blf( NADR, 2 );
|
609 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "pget_blf bad ercd !E_PAR" );
|
610 |
|
|
ercd = tget_blf( &blfptr, -6, delay );
|
611 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "tget_blf bad ercd !E_ID" );
|
612 |
|
|
ercd = tget_blf( &blfptr, 99, delay );
|
613 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "tget_blf bad ercd !E_ID" );
|
614 |
|
|
ercd = tget_blf( &blfptr, 2, -999 );
|
615 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "tget_blf bad ercd !E_PAR" );
|
616 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
617 |
|
|
ercd = tget_blf( NULL, 2, delay );
|
618 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "tget_blf bad ercd !E_PAR" );
|
619 |
|
|
#endif
|
620 |
|
|
ercd = tget_blf( NADR, 2, delay );
|
621 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "tget_blf bad ercd !E_PAR" );
|
622 |
|
|
ercd = ref_mpf( &mpf_info, -6 );
|
623 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "ref_mpf bad ercd !E_ID" );
|
624 |
|
|
ercd = ref_mpf( &mpf_info, 99 );
|
625 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "ref_mpf bad ercd !E_ID" );
|
626 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
627 |
|
|
ercd = ref_mpf( NULL, 2 );
|
628 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "ref_mpf bad ercd !E_PAR" );
|
629 |
|
|
#endif
|
630 |
|
|
ercd = ref_mpf( NADR, 2 );
|
631 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "ref_mpf bad ercd !E_PAR" );
|
632 |
|
|
CYG_TEST_PASS( "bad calls: rel_blf, [pt]get_blf, ref_mpf " );
|
633 |
|
|
#endif // we can test bad param error returns
|
634 |
|
|
|
635 |
|
|
// check the waitable functions versus dispatch disable
|
636 |
|
|
ercd = pget_blf( &blfptr, 2 );
|
637 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "pget_blf bad ercd" );
|
638 |
|
|
ercd = rel_blf( 2, blfptr );
|
639 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
|
640 |
|
|
ercd = tget_blf( &blfptr, 2, delay );
|
641 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "tget_blf bad ercd" );
|
642 |
|
|
ercd = dis_dsp();
|
643 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
644 |
|
|
ercd = rel_blf( 2, blfptr );
|
645 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
|
646 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
647 |
|
|
ercd = get_blf( &blfptr, 2 );
|
648 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "get_blf bad ercd !E_CTX" );
|
649 |
|
|
ercd = tget_blf( &blfptr, 2, delay );
|
650 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "tget_blf bad ercd !E_CTX" );
|
651 |
|
|
#endif // we can test bad param error returns
|
652 |
|
|
ercd = ena_dsp();
|
653 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
654 |
|
|
ercd = pget_blf( &blfptr, 2 );
|
655 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "pget_blf bad ercd" );
|
656 |
|
|
ercd = rel_blf( 2, blfptr );
|
657 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
|
658 |
|
|
ercd = tget_blf( &blfptr, 2, delay );
|
659 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "tget_blf bad ercd" );
|
660 |
|
|
ercd = rel_blf( 2, blfptr );
|
661 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
|
662 |
|
|
// consume the whole thing then do it again, expecting E_TMOUT
|
663 |
|
|
while ( E_OK == (ercd = pget_blf( &blfptr, 2 ) ) )
|
664 |
|
|
continue;
|
665 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
|
666 |
|
|
ercd = pget_blf( &blfptr, 2 );
|
667 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
|
668 |
|
|
ercd = tget_blf( &blfptr, 2, delay );
|
669 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf bad ercd !E_TMOUT" );
|
670 |
|
|
ercd = tget_blf( &blfptr, 2, TMO_POL );
|
671 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf(POL) bad ercd !E_TMOUT" );
|
672 |
|
|
ercd = dis_dsp();
|
673 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
674 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
675 |
|
|
ercd = get_blf( &blfptr, 2 );
|
676 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "get_blf bad ercd !E_CTX" );
|
677 |
|
|
ercd = tget_blf( &blfptr, 2, delay );
|
678 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "tget_blf bad ercd !E_CTX" );
|
679 |
|
|
ercd = tget_blf( &blfptr, 2, TMO_FEVR );
|
680 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "tget_blf(FEVR) bad ercd !E_CTX" );
|
681 |
|
|
#endif // we can test bad param error returns
|
682 |
|
|
ercd = tget_blf( &blfptr, 2, TMO_POL );
|
683 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf(POL) bad ercd !E_TMOUT" );
|
684 |
|
|
ercd = ena_dsp();
|
685 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
686 |
|
|
ercd = pget_blf( &blfptr, 2 );
|
687 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
|
688 |
|
|
ercd = tget_blf( &blfptr, 2, delay );
|
689 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
|
690 |
|
|
ercd = tget_blf( &blfptr, 2, TMO_POL );
|
691 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf(POL) bad ercd !E_TMOUT" );
|
692 |
|
|
CYG_TEST_PASS( "bad calls: rel_blf, [pt]get_blf with ena_dsp" );
|
693 |
|
|
|
694 |
|
|
// check ref_mpf with various states
|
695 |
|
|
ercd = ref_mpf( &mpf_info, 2 );
|
696 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mpf bad ercd" );
|
697 |
|
|
CYG_TEST_CHECK( 0 == mpf_info.wtsk, "mpf.wtsk should be 0" );
|
698 |
|
|
CYG_TEST_CHECK( 0 == mpf_info.frbcnt, "mpf.frbcnt should be 0" );
|
699 |
|
|
intercom = 0;
|
700 |
|
|
ercd = dly_tsk( delay ); // let task 2 start waiting
|
701 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
702 |
|
|
intercom = 1;
|
703 |
|
|
ercd = ref_mpf( &mpf_info, 2 );
|
704 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mpf bad ercd" );
|
705 |
|
|
CYG_TEST_CHECK( 0 != mpf_info.wtsk, "mpf.wtsk should be non0" );
|
706 |
|
|
CYG_TEST_CHECK( 0 == mpf_info.frbcnt, "mpf.frbcnt should be 0" );
|
707 |
|
|
ercd = rel_blf( 2, blfptr );
|
708 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
|
709 |
|
|
ercd = ref_mpf( &mpf_info, 2 );
|
710 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mpf bad ercd" );
|
711 |
|
|
CYG_TEST_CHECK( 0 == mpf_info.wtsk, "mpf.wtsk should be 0" );
|
712 |
|
|
#if 1
|
713 |
|
|
CYG_TEST_CHECK( 0 == mpf_info.frbcnt, "mpf.frbcnt should be 0" );
|
714 |
|
|
#else // old, non-uITRON semantics
|
715 |
|
|
CYG_TEST_CHECK( 0 != mpf_info.frbcnt, "mpf.frbcnt should be non0" );
|
716 |
|
|
#endif
|
717 |
|
|
ercd = dly_tsk( delay ); // let task 2 start waiting
|
718 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
719 |
|
|
ercd = ref_mpf( &mpf_info, 2 );
|
720 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mpf bad ercd" );
|
721 |
|
|
CYG_TEST_CHECK( 0 == mpf_info.wtsk, "mpf.wtsk should be 0" );
|
722 |
|
|
CYG_TEST_CHECK( 0 == mpf_info.frbcnt, "mpf.frbcnt should be 0" );
|
723 |
|
|
CYG_TEST_PASS( "good calls: rel_blf, get_blf with ref_mpf" );
|
724 |
|
|
|
725 |
|
|
// Variable block memory pools; illegal arguments
|
726 |
|
|
CYG_TEST_INFO( "Testing variable block memory ops" );
|
727 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
728 |
|
|
ercd = rel_blk( -6, blkptr );
|
729 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "rel_blk bad ercd !E_ID" );
|
730 |
|
|
ercd = rel_blk( 99, blkptr );
|
731 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "rel_blk bad ercd !E_ID" );
|
732 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
733 |
|
|
ercd = rel_blk( 2, NULL );
|
734 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "rel_blk bad ercd !E_PAR" );
|
735 |
|
|
#endif
|
736 |
|
|
ercd = rel_blk( 2, NADR );
|
737 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "rel_blk bad ercd !E_PAR" );
|
738 |
|
|
#endif // we can test bad param error returns
|
739 |
|
|
ercd = rel_blk( 2, blkptr ); // it did not come from a mpl
|
740 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "rel_blk bad ercd !E_PAR" );
|
741 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
742 |
|
|
ercd = get_blk( &blkptr, -6, 100 );
|
743 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "get_blk bad ercd !E_ID" );
|
744 |
|
|
ercd = get_blk( &blkptr, 99, 100 );
|
745 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "get_blk bad ercd !E_ID" );
|
746 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
747 |
|
|
ercd = get_blk( NULL, 2, 100 );
|
748 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "get_blk bad ercd !E_PAR" );
|
749 |
|
|
#endif
|
750 |
|
|
ercd = get_blk( NADR, 2, 100 );
|
751 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "get_blk bad ercd !E_PAR" );
|
752 |
|
|
ercd = pget_blk( &blkptr, -6, 100 );
|
753 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "pget_blk bad ercd !E_ID" );
|
754 |
|
|
ercd = pget_blk( &blkptr, 99, 100 );
|
755 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "pget_blk bad ercd !E_ID" );
|
756 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
757 |
|
|
ercd = pget_blk( NULL, 2, 100 );
|
758 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "pget_blk bad ercd !E_PAR" );
|
759 |
|
|
#endif
|
760 |
|
|
ercd = pget_blk( NADR, 2, 100 );
|
761 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "pget_blk bad ercd !E_PAR" );
|
762 |
|
|
ercd = tget_blk( &blkptr, -6, 100, delay );
|
763 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "tget_blk bad ercd !E_ID" );
|
764 |
|
|
ercd = tget_blk( &blkptr, 99, 100, delay );
|
765 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "tget_blk bad ercd !E_ID" );
|
766 |
|
|
ercd = tget_blk( &blkptr, 2, 100, -999 );
|
767 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "tget_blk bad ercd !E_PAR" );
|
768 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
769 |
|
|
ercd = tget_blk( NULL, 2, 100, delay );
|
770 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "tget_blk bad ercd !E_PAR" );
|
771 |
|
|
#endif
|
772 |
|
|
ercd = tget_blk( NADR, 2, 100, delay );
|
773 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "tget_blk bad ercd !E_PAR" );
|
774 |
|
|
ercd = ref_mpl( &mpl_info, -6 );
|
775 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "ref_mpl bad ercd !E_ID" );
|
776 |
|
|
ercd = ref_mpl( &mpl_info, 99 );
|
777 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "ref_mpl bad ercd !E_ID" );
|
778 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
779 |
|
|
ercd = ref_mpl( NULL, 2 );
|
780 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "ref_mpl bad ercd !E_PAR" );
|
781 |
|
|
#endif
|
782 |
|
|
ercd = ref_mpl( NADR, 2 );
|
783 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "ref_mpl bad ercd !E_PAR" );
|
784 |
|
|
CYG_TEST_PASS( "bad calls: rel_blk, [pt]get_blk, ref_mpl " );
|
785 |
|
|
#endif // we can test bad param error returns
|
786 |
|
|
|
787 |
|
|
// check the waitable functions versus dispatch disable
|
788 |
|
|
ercd = pget_blk( &blkptr, 2, 100 );
|
789 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "pget_blk bad ercd" );
|
790 |
|
|
ercd = rel_blk( 2, blkptr );
|
791 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
|
792 |
|
|
ercd = tget_blk( &blkptr, 2, 100, delay );
|
793 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "tget_blk bad ercd" );
|
794 |
|
|
ercd = dis_dsp();
|
795 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
796 |
|
|
ercd = rel_blk( 2, blkptr );
|
797 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
|
798 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
799 |
|
|
ercd = get_blk( &blkptr, 2, 100 );
|
800 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "get_blk bad ercd !E_CTX" );
|
801 |
|
|
ercd = tget_blk( &blkptr, 2, 100, delay );
|
802 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "tget_blk bad ercd !E_CTX" );
|
803 |
|
|
#endif // we can test bad param error returns
|
804 |
|
|
ercd = ena_dsp();
|
805 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
806 |
|
|
ercd = pget_blk( &blkptr, 2, 100 );
|
807 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "pget_blk bad ercd" );
|
808 |
|
|
ercd = rel_blk( 2, blkptr );
|
809 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
|
810 |
|
|
ercd = tget_blk( &blkptr, 2, 100, delay );
|
811 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "tget_blk bad ercd" );
|
812 |
|
|
ercd = rel_blk( 2, blkptr );
|
813 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
|
814 |
|
|
// consume the whole thing then do it again, expecting E_TMOUT
|
815 |
|
|
while ( E_OK == (ercd = pget_blk( &blkptr, 2, 100 ) ) )
|
816 |
|
|
continue;
|
817 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
|
818 |
|
|
ercd = pget_blk( &blkptr, 2, 100 );
|
819 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
|
820 |
|
|
ercd = tget_blk( &blkptr, 2, 100, delay );
|
821 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk bad ercd !E_TMOUT" );
|
822 |
|
|
ercd = tget_blk( &blkptr, 2, 100, TMO_POL );
|
823 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk(POL) bad ercd !E_TMOUT" );
|
824 |
|
|
ercd = dis_dsp();
|
825 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
826 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
827 |
|
|
ercd = get_blk( &blkptr, 2, 100 );
|
828 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "get_blk bad ercd !E_CTX" );
|
829 |
|
|
ercd = tget_blk( &blkptr, 2, 100, delay );
|
830 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "tget_blk bad ercd !E_CTX" );
|
831 |
|
|
ercd = tget_blk( &blkptr, 2, 100, TMO_FEVR );
|
832 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "tget_blk(FEVR) bad ercd !E_CTX" );
|
833 |
|
|
#endif // we can test bad param error returns
|
834 |
|
|
ercd = tget_blk( &blkptr, 2, 100, TMO_POL );
|
835 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk(POL) bad ercd !E_TMOUT" );
|
836 |
|
|
ercd = ena_dsp();
|
837 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
838 |
|
|
ercd = pget_blk( &blkptr, 2, 100 );
|
839 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
|
840 |
|
|
ercd = tget_blk( &blkptr, 2, 100, delay );
|
841 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
|
842 |
|
|
ercd = tget_blk( &blkptr, 2, 100, TMO_POL );
|
843 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk(POL) bad ercd !E_TMOUT" );
|
844 |
|
|
CYG_TEST_PASS( "bad calls: rel_blk, [pt]get_blk with ena_dsp" );
|
845 |
|
|
|
846 |
|
|
// check ref_mpl with various states
|
847 |
|
|
ercd = ref_mpl( &mpl_info, 2 );
|
848 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mpl bad ercd" );
|
849 |
|
|
CYG_TEST_CHECK( 0 == mpl_info.wtsk, "mpl.wtsk should be 0" );
|
850 |
|
|
CYG_TEST_CHECK( mpl_info.maxsz <= mpl_info.frsz,
|
851 |
|
|
"mpl.maxsz not < mpl.frsz" );
|
852 |
|
|
intercom = 0;
|
853 |
|
|
ercd = dly_tsk( delay ); // let task 2 start waiting
|
854 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
855 |
|
|
intercom = 1;
|
856 |
|
|
ercd = ref_mpl( &mpl_info, 2 );
|
857 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mpl bad ercd" );
|
858 |
|
|
CYG_TEST_CHECK( 0 != mpl_info.wtsk, "mpl.wtsk should be non0" );
|
859 |
|
|
ercd = rel_blk( 2, blkptr );
|
860 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
|
861 |
|
|
ercd = ref_mpl( &mpl_info, 2 );
|
862 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mpl bad ercd" );
|
863 |
|
|
CYG_TEST_CHECK( 0 == mpl_info.wtsk, "mpl.wtsk should be 0" );
|
864 |
|
|
ercd = dly_tsk( delay ); // let task 2 start waiting
|
865 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
866 |
|
|
ercd = ref_mpl( &mpl_info, 2 );
|
867 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_mpl bad ercd" );
|
868 |
|
|
CYG_TEST_CHECK( 0 == mpl_info.wtsk, "mpl.wtsk should be 0" );
|
869 |
|
|
CYG_TEST_PASS( "good calls: rel_blk, get_blk with ref_mpl" );
|
870 |
|
|
|
871 |
|
|
// all done
|
872 |
|
|
CYG_TEST_EXIT( "All done" );
|
873 |
|
|
ext_tsk();
|
874 |
|
|
}
|
875 |
|
|
|
876 |
|
|
|
877 |
|
|
|
878 |
|
|
void task2( unsigned int arg )
|
879 |
|
|
{
|
880 |
|
|
ER ercd;
|
881 |
|
|
T_MSG *msgp = NULL;
|
882 |
|
|
UINT flgval = 0;
|
883 |
|
|
VP blfp = NULL;
|
884 |
|
|
VP blkp = NULL;
|
885 |
|
|
|
886 |
|
|
CYG_TEST_INFO( "Task 2 running" );
|
887 |
|
|
ercd = get_tid( &scratch );
|
888 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
|
889 |
|
|
CYG_TEST_CHECK( 2 == scratch, "tid not 2" );
|
890 |
|
|
if ( 222 != arg )
|
891 |
|
|
CYG_TEST_FAIL( "Task 2 arg not 222" );
|
892 |
|
|
|
893 |
|
|
while ( intercom ) {
|
894 |
|
|
ercd = rot_rdq( 0 );
|
895 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
896 |
|
|
}
|
897 |
|
|
ercd = wai_sem( 2 );
|
898 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
|
899 |
|
|
while ( intercom ) {
|
900 |
|
|
ercd = rot_rdq( 0 );
|
901 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
902 |
|
|
}
|
903 |
|
|
ercd = wai_flg( &flgval, 2, 99, TWF_ANDW );
|
904 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wai_flg bad ercd" );
|
905 |
|
|
CYG_TEST_CHECK( 99 == (99 & flgval), "flg value no good" );
|
906 |
|
|
while ( intercom ) {
|
907 |
|
|
ercd = rot_rdq( 0 );
|
908 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
909 |
|
|
}
|
910 |
|
|
ercd = rcv_msg( &msgp, 2 );
|
911 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rcv_msg bad ercd" );
|
912 |
|
|
CYG_TEST_CHECK( NULL != msgp, "no msg received" );
|
913 |
|
|
CYG_TEST_CHECK( NADR != msgp, "no msg received" );
|
914 |
|
|
while ( intercom ) {
|
915 |
|
|
ercd = rot_rdq( 0 );
|
916 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
917 |
|
|
}
|
918 |
|
|
ercd = get_blf( &blfp, 2 );
|
919 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "get_blf bad ercd" );
|
920 |
|
|
CYG_TEST_CHECK( NULL != blfp, "no blf allocated" );
|
921 |
|
|
CYG_TEST_CHECK( NADR != blfp, "no blf allocated" );
|
922 |
|
|
while ( intercom ) {
|
923 |
|
|
ercd = rot_rdq( 0 );
|
924 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
925 |
|
|
}
|
926 |
|
|
ercd = get_blk( &blkp, 2, 100 );
|
927 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "get_blk bad ercd" );
|
928 |
|
|
CYG_TEST_CHECK( NULL != blkp, "no blk allocated" );
|
929 |
|
|
CYG_TEST_CHECK( NADR != blkp, "no blk allocated" );
|
930 |
|
|
|
931 |
|
|
ext_tsk();
|
932 |
|
|
CYG_TEST_FAIL( "Task 2 failed to exit" );
|
933 |
|
|
}
|
934 |
|
|
|
935 |
|
|
void task3( unsigned int arg )
|
936 |
|
|
{
|
937 |
|
|
}
|
938 |
|
|
|
939 |
|
|
void task4( unsigned int arg )
|
940 |
|
|
{
|
941 |
|
|
}
|
942 |
|
|
|
943 |
|
|
#else // not enough (or too many) uITRON objects configured in
|
944 |
|
|
#define N_A_MSG "not enough uITRON objects to run test"
|
945 |
|
|
#endif // not enough (or too many) uITRON objects configured in
|
946 |
|
|
#else // not C++ and some C++ specific options enabled
|
947 |
|
|
#define N_A_MSG "C++ specific options selected but this is C"
|
948 |
|
|
#endif // not C++ and some C++ specific options enabled
|
949 |
|
|
#else // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it
|
950 |
|
|
#define N_A_MSG "no CYGVAR_KERNEL_COUNTERS_CLOCK"
|
951 |
|
|
#endif // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it
|
952 |
|
|
#else // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it
|
953 |
|
|
#define N_A_MSG "no CYGFUN_KERNEL_THREADS_TIMER"
|
954 |
|
|
#endif // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it
|
955 |
|
|
#else // ! CYGIMP_THREAD_PRIORITY - can't test without it
|
956 |
|
|
#define N_A_MSG "no CYGSEM_KERNEL_SCHED_MLQUEUE"
|
957 |
|
|
#endif // ! CYGSEM_KERNEL_SCHED_MLQUEUE - can't test without it
|
958 |
|
|
#else // ! CYGIMP_UITRON_STRICT_CONFORMANCE - can't test without it
|
959 |
|
|
#define N_A_MSG "no CYGIMP_UITRON_STRICT_CONFORMANCE"
|
960 |
|
|
#endif // ! CYGIMP_UITRON_STRICT_CONFORMANCE - can't test without it
|
961 |
|
|
#else // ! CYGPKG_UITRON
|
962 |
|
|
#define N_A_MSG "uITRON Compatibility layer disabled"
|
963 |
|
|
#endif // CYGPKG_UITRON
|
964 |
|
|
|
965 |
|
|
#ifdef N_A_MSG
|
966 |
|
|
void
|
967 |
|
|
cyg_start( void )
|
968 |
|
|
{
|
969 |
|
|
CYG_TEST_INIT();
|
970 |
|
|
CYG_TEST_NA( N_A_MSG );
|
971 |
|
|
}
|
972 |
|
|
#endif // N_A_MSG defined ie. we are N/A.
|
973 |
|
|
|
974 |
|
|
// EOF test2.c
|