1 |
27 |
unneback |
//===========================================================================
|
2 |
|
|
//
|
3 |
|
|
// testcxx.cxx
|
4 |
|
|
//
|
5 |
|
|
// uITRON "C++" test program
|
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-03-13
|
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 |
|
|
/* the end of the large #if statement */ \
|
80 |
|
|
1
|
81 |
|
|
|
82 |
|
|
// ============================ END ============================
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
#include <cyg/compat/uitron/uit_func.h> // uITRON
|
87 |
|
|
|
88 |
|
|
externC void
|
89 |
|
|
cyg_package_start( void )
|
90 |
|
|
{
|
91 |
|
|
CYG_TEST_INIT();
|
92 |
|
|
CYG_TEST_INFO( "Calling cyg_uitron_start()" );
|
93 |
|
|
cyg_uitron_start();
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
volatile int intercom = 0;
|
97 |
|
|
volatile int intercount = 0;
|
98 |
|
|
INT scratch = 0;
|
99 |
|
|
|
100 |
|
|
extern "C" {
|
101 |
|
|
void task1( unsigned int arg );
|
102 |
|
|
void task2( unsigned int arg );
|
103 |
|
|
void task3( unsigned int arg );
|
104 |
|
|
void task4( unsigned int arg );
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
#ifndef CYGSEM_KERNEL_SCHED_TIMESLICE
|
109 |
|
|
#define TIMESLICEMSG "Assuming no kernel timeslicing"
|
110 |
|
|
#define TSGO() (1)
|
111 |
|
|
#define TSRELEASE() CYG_EMPTY_STATEMENT
|
112 |
|
|
#define TSSTOP() CYG_EMPTY_STATEMENT
|
113 |
|
|
#define TSLOCK() CYG_EMPTY_STATEMENT
|
114 |
|
|
#define TSUNLOCK() CYG_EMPTY_STATEMENT
|
115 |
|
|
#define ICWAIT( _i_ ) CYG_EMPTY_STATEMENT
|
116 |
|
|
|
117 |
|
|
#else
|
118 |
|
|
// Now follow some nasty bodges to control the scheduling when basically it
|
119 |
|
|
// isn't controlled ie. timeslicing is on. It's bodgy because we're
|
120 |
|
|
// testing normal synchronization methods, so we shouldn't rely on them for
|
121 |
|
|
// comms between threads here. Instead there's a mixture of communicating
|
122 |
|
|
// via a flag (ts_interlock) which stops the "controlled" thread running
|
123 |
|
|
// away, and waiting for the controlled thread to run enough for us.
|
124 |
|
|
//
|
125 |
|
|
// Tasks 3 and 4 are waited for by the control task: task 3 locks the
|
126 |
|
|
// scheduler so is immediately descheduled when it unlocks it, task 4 does
|
127 |
|
|
// waiting-type operations, so we must give it chance to run by yielding a
|
128 |
|
|
// few times ourselves. Note the plain constant in ICWAIT() below.
|
129 |
|
|
|
130 |
|
|
#define TIMESLICEMSG "Assuming kernel timeslicing ENABLED"
|
131 |
|
|
volatile int ts_interlock = 0;
|
132 |
|
|
#define TSGO() (ts_interlock)
|
133 |
|
|
#define TSRELEASE() ts_interlock = 1
|
134 |
|
|
#define TSSTOP() ts_interlock = 0
|
135 |
|
|
|
136 |
|
|
#define TSLOCK() CYG_MACRO_START \
|
137 |
|
|
ER ercd2 = dis_dsp(); \
|
138 |
|
|
CYG_TEST_CHECK( E_OK == ercd2, "dis_dsp (TSLOCK) bad ercd2" ); \
|
139 |
|
|
CYG_MACRO_END
|
140 |
|
|
|
141 |
|
|
#define TSUNLOCK() CYG_MACRO_START \
|
142 |
|
|
ER ercd3 = ena_dsp(); \
|
143 |
|
|
CYG_TEST_CHECK( E_OK == ercd3, "ena_dsp (TSUNLOCK) bad ercd3" ); \
|
144 |
|
|
CYG_MACRO_END
|
145 |
|
|
|
146 |
|
|
#define ICWAIT( _i_ ) CYG_MACRO_START \
|
147 |
|
|
int loops; \
|
148 |
|
|
for ( loops = 3; (0 < loops) || ((_i_) > intercount); loops-- ) { \
|
149 |
|
|
ER ercd4 = rot_rdq( 0 ); /* yield */ \
|
150 |
|
|
CYG_TEST_CHECK( E_OK == ercd4, "rot_rdq (ICWAIT) bad ercd4" ); \
|
151 |
|
|
} \
|
152 |
|
|
CYG_MACRO_END
|
153 |
|
|
#endif // CYGSEM_KERNEL_SCHED_TIMESLICE
|
154 |
|
|
|
155 |
|
|
/*
|
156 |
|
|
#define IC() \
|
157 |
|
|
CYG_MACRO_START \
|
158 |
|
|
static char *msgs[] = { "ZERO", "ONE", "TWO", "THREE", "FOUR", "LOTS" }; \
|
159 |
|
|
CYG_TEST_INFO( msgs[ intercount > 5 ? 5 : intercount ] ); \
|
160 |
|
|
CYG_MACRO_END
|
161 |
|
|
*/
|
162 |
|
|
|
163 |
|
|
// #define CYG_TEST_UITRON_TEST1_LOOPING 1
|
164 |
|
|
|
165 |
|
|
void task1( unsigned int arg )
|
166 |
|
|
{
|
167 |
|
|
ER ercd;
|
168 |
|
|
T_RTSK ref_tskd;
|
169 |
|
|
|
170 |
|
|
#ifdef CYG_TEST_UITRON_TEST1_LOOPING
|
171 |
|
|
while ( 1 ) {
|
172 |
|
|
#endif // CYG_TEST_UITRON_TEST1_LOOPING
|
173 |
|
|
|
174 |
|
|
CYG_TEST_INFO( "Task 1 running" );
|
175 |
|
|
CYG_TEST_INFO( TIMESLICEMSG );
|
176 |
|
|
|
177 |
|
|
intercom = 0;
|
178 |
|
|
intercount = 0;
|
179 |
|
|
|
180 |
|
|
CYG_TEST_INFO( "Testing get_tid and ref_tsk" );
|
181 |
|
|
ercd = get_tid( &scratch );
|
182 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
|
183 |
|
|
CYG_TEST_CHECK( 1 == scratch, "tid not 1" );
|
184 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
185 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
186 |
|
|
ercd = get_tid( NULL );
|
187 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "get_tid bad ercd !E_PAR" );
|
188 |
|
|
#endif
|
189 |
|
|
ercd = ref_tsk( &ref_tskd, -6 );
|
190 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "ref_tsk bad ercd !E_ID" );
|
191 |
|
|
ercd = ref_tsk( &ref_tskd, 99 );
|
192 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "ref_tsk bad ercd !E_ID" );
|
193 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
194 |
|
|
ercd = ref_tsk( NULL, 1 );
|
195 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "ref_tsk bad ercd !E_PAR" );
|
196 |
|
|
#endif
|
197 |
|
|
#endif // we can test bad param error returns
|
198 |
|
|
ercd = ref_tsk( &ref_tskd, 1 );
|
199 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
200 |
|
|
CYG_TEST_CHECK( TTS_RUN == ref_tskd.tskstat, "Bad task status 1" );
|
201 |
|
|
ercd = ref_tsk( &ref_tskd, 0 );
|
202 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
203 |
|
|
CYG_TEST_CHECK( TTS_RUN == ref_tskd.tskstat, "Bad task status 0" );
|
204 |
|
|
ercd = ref_tsk( &ref_tskd, 2 );
|
205 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
206 |
|
|
CYG_TEST_CHECK( TTS_DMT == ref_tskd.tskstat, "Bad task status 2" );
|
207 |
|
|
CYG_TEST_CHECK( 2 == ref_tskd.tskpri, "Bad task prio 2" );
|
208 |
|
|
|
209 |
|
|
ercd = rsm_tsk( 2 );
|
210 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "rsm_tsk DMT bad ercd !E_OBJ" );
|
211 |
|
|
ercd = frsm_tsk( 2 );
|
212 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "frsm_tsk DMT bad ercd !E_OBJ" );
|
213 |
|
|
ercd = rel_wai( 2 );
|
214 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "rel_wai DMT bad ercd !E_OBJ" );
|
215 |
|
|
ercd = sus_tsk( 2 );
|
216 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "sus_tsk DMT bad ercd !E_OBJ" );
|
217 |
|
|
ercd = wup_tsk( 2 );
|
218 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "wup_tsk DMT bad ercd !E_OBJ" );
|
219 |
|
|
ercd = can_wup( &scratch, 2 );
|
220 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "can_wup DMT bad ercd !E_OBJ" );
|
221 |
|
|
|
222 |
|
|
CYG_TEST_PASS( "get_tid, ref_tsk" );
|
223 |
|
|
|
224 |
|
|
CYG_TEST_INFO( "Testing prio change and start task" );
|
225 |
|
|
ercd = sta_tsk( 2, 99 );
|
226 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
|
227 |
|
|
|
228 |
|
|
// drop pri of task 2
|
229 |
|
|
ercd = chg_pri( 2, 4 );
|
230 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
|
231 |
|
|
ercd = ref_tsk( &ref_tskd, 2 );
|
232 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
233 |
|
|
CYG_TEST_CHECK( TTS_RDY == ref_tskd.tskstat, "Bad task status 2" );
|
234 |
|
|
CYG_TEST_CHECK( 4 == ref_tskd.tskpri, "Bad task prio 2" );
|
235 |
|
|
|
236 |
|
|
// drop our pri below task 2
|
237 |
|
|
ercd = chg_pri( 0, 5 );
|
238 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
|
239 |
|
|
|
240 |
|
|
ercd = ref_tsk( &ref_tskd, 1 );
|
241 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
242 |
|
|
CYG_TEST_CHECK( 5 == ref_tskd.tskpri, "Bad task prio 1" );
|
243 |
|
|
ercd = ref_tsk( &ref_tskd, 0 );
|
244 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
245 |
|
|
CYG_TEST_CHECK( 5 == ref_tskd.tskpri, "Bad task prio 0" );
|
246 |
|
|
ercd = ref_tsk( &ref_tskd, 2 );
|
247 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
248 |
|
|
// it will have run to completion and regained its original prio
|
249 |
|
|
CYG_TEST_CHECK( 2 == ref_tskd.tskpri, "Bad task prio 2" );
|
250 |
|
|
CYG_TEST_CHECK( TTS_DMT == ref_tskd.tskstat, "Bad task status 2" );
|
251 |
|
|
|
252 |
|
|
// retest these now that the task has executed once
|
253 |
|
|
ercd = rsm_tsk( 2 );
|
254 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "rsm_tsk DMT bad ercd !E_OBJ" );
|
255 |
|
|
ercd = frsm_tsk( 2 );
|
256 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "frsm_tsk DMT bad ercd !E_OBJ" );
|
257 |
|
|
ercd = rel_wai( 2 );
|
258 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "rel_wai DMT bad ercd !E_OBJ" );
|
259 |
|
|
ercd = sus_tsk( 2 );
|
260 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "sus_tsk DMT bad ercd !E_OBJ" );
|
261 |
|
|
ercd = wup_tsk( 2 );
|
262 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "wup_tsk DMT bad ercd !E_OBJ" );
|
263 |
|
|
ercd = can_wup( &scratch, 2 );
|
264 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "can_wup DMT bad ercd !E_OBJ" );
|
265 |
|
|
|
266 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
267 |
|
|
ercd = chg_pri( -6, 9 );
|
268 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "chg_pri bad ercd !E_ID" );
|
269 |
|
|
ercd = chg_pri( 99, 9 );
|
270 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "chg_pri bad ercd !E_ID" );
|
271 |
|
|
ercd = sta_tsk( -6, 99 );
|
272 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "sta_tsk bad ercd !E_ID" );
|
273 |
|
|
ercd = sta_tsk( 99, 99 );
|
274 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "sta_tsk bad ercd !E_ID" );
|
275 |
|
|
#endif // we can test bad param error returns
|
276 |
|
|
|
277 |
|
|
CYG_TEST_PASS( "sta_tsk, chg_pri" );
|
278 |
|
|
|
279 |
|
|
CYG_TEST_INFO( "Testing delay and dispatch disabling" );
|
280 |
|
|
ercd = dly_tsk( 10 );
|
281 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
282 |
|
|
ercd = ena_dsp();
|
283 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
284 |
|
|
ercd = dly_tsk( 10 );
|
285 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
286 |
|
|
ercd = dis_dsp();
|
287 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
288 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
289 |
|
|
ercd = dly_tsk( 10 );
|
290 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "dly_tsk bad ercd !E_CTX" );
|
291 |
|
|
ercd = dis_dsp();
|
292 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
293 |
|
|
ercd = dly_tsk( 10 );
|
294 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "dly_tsk bad ercd !E_CTX" );
|
295 |
|
|
#endif // we can test bad param error returns
|
296 |
|
|
ercd = ena_dsp();
|
297 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
298 |
|
|
ercd = dly_tsk( 10 );
|
299 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
300 |
|
|
ercd = ena_dsp();
|
301 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
302 |
|
|
ercd = dly_tsk( 10 );
|
303 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
304 |
|
|
|
305 |
|
|
CYG_TEST_PASS( "dly_tsk, ena_dsp, dis_dsp" );
|
306 |
|
|
|
307 |
|
|
CYG_TEST_INFO( "Testing ready queue manipulation" );
|
308 |
|
|
ercd = rot_rdq( 0 );
|
309 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
310 |
|
|
ercd = rot_rdq( 4 );
|
311 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
312 |
|
|
ercd = rot_rdq( 5 );
|
313 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
314 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
315 |
|
|
ercd = rot_rdq( -6 );
|
316 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "rot_rdq bad ercd !E_PAR" );
|
317 |
|
|
ercd = rot_rdq( 99 );
|
318 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "rot_rdq bad ercd !E_PAR" );
|
319 |
|
|
#endif // we can test bad param error returns
|
320 |
|
|
|
321 |
|
|
CYG_TEST_PASS( "rot_rdq" );
|
322 |
|
|
|
323 |
|
|
CYG_TEST_INFO( "Testing suspend/resume" );
|
324 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
325 |
|
|
ercd = sus_tsk( -6 );
|
326 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "sus_tsk bad ercd !E_ID" );
|
327 |
|
|
ercd = sus_tsk( 99 );
|
328 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "sus_tsk bad ercd !E_ID" );
|
329 |
|
|
ercd = rsm_tsk( -6 );
|
330 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "rsm_tsk bad ercd !E_ID" );
|
331 |
|
|
ercd = rsm_tsk( 99 );
|
332 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "rsm_tsk bad ercd !E_ID" );
|
333 |
|
|
ercd = frsm_tsk( -6 );
|
334 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "frsm_tsk bad ercd !E_ID" );
|
335 |
|
|
ercd = frsm_tsk( 99 );
|
336 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "frsm_tsk bad ercd !E_ID" );
|
337 |
|
|
#endif // we can test bad param error returns
|
338 |
|
|
// drop task 3 pri to same as us
|
339 |
|
|
CYG_TEST_CHECK( 0 == intercount, "intercount != 0" );
|
340 |
|
|
|
341 |
|
|
intercom = 3; // tell T3 to loop
|
342 |
|
|
TSRELEASE();
|
343 |
|
|
ercd = dis_dsp();
|
344 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
345 |
|
|
ercd = sta_tsk( 3, 66 );
|
346 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
|
347 |
|
|
ercd = chg_pri( 3, 5 );
|
348 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
|
349 |
|
|
ercd = ena_dsp();
|
350 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
351 |
|
|
|
352 |
|
|
ercd = rot_rdq( 0 );
|
353 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
354 |
|
|
ICWAIT( 1 );
|
355 |
|
|
CYG_TEST_CHECK( 1 == intercount, "intercount != 1" );
|
356 |
|
|
ercd = sus_tsk( 3 );
|
357 |
|
|
TSRELEASE();
|
358 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sus_tsk bad ercd" );
|
359 |
|
|
intercom = 0; // bad data to T3
|
360 |
|
|
ercd = rot_rdq( 0 );
|
361 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
362 |
|
|
CYG_TEST_CHECK( 1 == intercount, "intercount != 1" );
|
363 |
|
|
intercom = 3; // tell T3 to loop
|
364 |
|
|
TSRELEASE();
|
365 |
|
|
ercd = rsm_tsk( 3 );
|
366 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rsm_tsk bad ercd" );
|
367 |
|
|
ercd = rot_rdq( 0 );
|
368 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
369 |
|
|
ICWAIT( 2 );
|
370 |
|
|
CYG_TEST_CHECK( 2 == intercount, "intercount != 2" );
|
371 |
|
|
|
372 |
|
|
CYG_TEST_INFO( "Command task 3 inner loop stop" );
|
373 |
|
|
intercom = 2 + 4;
|
374 |
|
|
TSRELEASE();
|
375 |
|
|
ercd = rot_rdq( 0 );
|
376 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
377 |
|
|
CYG_TEST_CHECK( 2 == intercount, "intercount != 2" );
|
378 |
|
|
|
379 |
|
|
ercd = sus_tsk( 3 );
|
380 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sus_tsk bad ercd" );
|
381 |
|
|
intercom = 0; // bad data to T3
|
382 |
|
|
TSRELEASE();
|
383 |
|
|
ercd = rot_rdq( 0 );
|
384 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
385 |
|
|
ercd = sus_tsk( 3 ); // suspend AGAIN
|
386 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sus_tsk bad ercd" );
|
387 |
|
|
ercd = sus_tsk( 3 ); // AND AGAIN
|
388 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sus_tsk bad ercd" );
|
389 |
|
|
TSRELEASE();
|
390 |
|
|
ercd = rot_rdq( 0 );
|
391 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
392 |
|
|
CYG_TEST_CHECK( 2 == intercount, "intercount != 2" );
|
393 |
|
|
ercd = rsm_tsk( 3 );
|
394 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rsm_tsk bad ercd" );
|
395 |
|
|
ercd = rsm_tsk( 3 );
|
396 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rsm_tsk bad ercd" );
|
397 |
|
|
TSRELEASE();
|
398 |
|
|
ercd = rot_rdq( 0 );
|
399 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
400 |
|
|
CYG_TEST_CHECK( 2 == intercount, "intercount != 2" );
|
401 |
|
|
intercom = 3; // tell T3 to loop
|
402 |
|
|
TSRELEASE();
|
403 |
|
|
ercd = rsm_tsk( 3 ); // expect restart this time
|
404 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rsm_tsk bad ercd" );
|
405 |
|
|
ercd = rot_rdq( 0 );
|
406 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
407 |
|
|
ICWAIT( 3 );
|
408 |
|
|
CYG_TEST_CHECK( 3 == intercount, "intercount != 3" );
|
409 |
|
|
|
410 |
|
|
CYG_TEST_INFO( "Command task 3 inner loop stop 2" );
|
411 |
|
|
intercom = 2 + 4;
|
412 |
|
|
TSRELEASE();
|
413 |
|
|
ercd = rot_rdq( 0 );
|
414 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
415 |
|
|
CYG_TEST_CHECK( 3 == intercount, "intercount != 3" );
|
416 |
|
|
|
417 |
|
|
ercd = sus_tsk( 3 );
|
418 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sus_tsk bad ercd" );
|
419 |
|
|
intercom = 0; // bad data to T3
|
420 |
|
|
TSRELEASE();
|
421 |
|
|
ercd = rot_rdq( 0 );
|
422 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
423 |
|
|
CYG_TEST_CHECK( 3 == intercount, "intercount != 3" );
|
424 |
|
|
ercd = sus_tsk( 3 ); // suspend AGAIN
|
425 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sus_tsk bad ercd" );
|
426 |
|
|
ercd = sus_tsk( 3 ); // AND AGAIN
|
427 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sus_tsk bad ercd" );
|
428 |
|
|
TSRELEASE();
|
429 |
|
|
ercd = rot_rdq( 0 );
|
430 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
431 |
|
|
CYG_TEST_CHECK( 3 == intercount, "intercount != 3" );
|
432 |
|
|
intercom = 3; // tell T3 to loop
|
433 |
|
|
TSRELEASE();
|
434 |
|
|
ercd = frsm_tsk( 3 ); // expect restart this time
|
435 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "frsm_tsk bad ercd" );
|
436 |
|
|
ercd = rot_rdq( 0 );
|
437 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
438 |
|
|
ICWAIT( 4 );
|
439 |
|
|
CYG_TEST_CHECK( 4 == intercount, "intercount != 4" );
|
440 |
|
|
|
441 |
|
|
TSRELEASE();
|
442 |
|
|
ercd = rsm_tsk( 3 ); // try it again
|
443 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "rsm_tsk bad ercd !E_OBJ" );
|
444 |
|
|
ercd = rot_rdq( 0 );
|
445 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
446 |
|
|
ICWAIT( 5 );
|
447 |
|
|
CYG_TEST_CHECK( 5 == intercount, "intercount != 5" );
|
448 |
|
|
|
449 |
|
|
TSRELEASE();
|
450 |
|
|
ercd = frsm_tsk( 3 ); // try it again
|
451 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "frsm_tsk bad ercd !E_OBJ" );
|
452 |
|
|
ercd = rot_rdq( 0 );
|
453 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
454 |
|
|
ICWAIT( 6 );
|
455 |
|
|
CYG_TEST_CHECK( 6 == intercount, "intercount != 6" );
|
456 |
|
|
|
457 |
|
|
CYG_TEST_INFO( "Command task 3 all loops stop" );
|
458 |
|
|
intercom = 4 + 8;
|
459 |
|
|
TSRELEASE();
|
460 |
|
|
ercd = rot_rdq( 0 );
|
461 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
462 |
|
|
TSRELEASE();
|
463 |
|
|
ercd = rot_rdq( 0 );
|
464 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
465 |
|
|
CYG_TEST_CHECK( 6 == intercount, "intercount != 6" );
|
466 |
|
|
|
467 |
|
|
intercom = intercount = 0;
|
468 |
|
|
|
469 |
|
|
CYG_TEST_PASS( "sus_tsk, rsm_tsk, frsm_tsk" );
|
470 |
|
|
|
471 |
|
|
CYG_TEST_INFO( "Testing sleep/wakeup stuff" );
|
472 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
473 |
|
|
ercd = wup_tsk( -6 );
|
474 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "wup_tsk bad ercd !E_ID" );
|
475 |
|
|
ercd = wup_tsk( 99 );
|
476 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "wup_tsk bad ercd !E_ID" );
|
477 |
|
|
ercd = can_wup( &scratch, -6 );
|
478 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "can_wup bad ercd !E_ID" );
|
479 |
|
|
ercd = can_wup( &scratch, 99 );
|
480 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "can_wup bad ercd !E_ID" );
|
481 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
482 |
|
|
ercd = can_wup( NULL, 2 );
|
483 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "can_wup bad ercd !E_PAR" );
|
484 |
|
|
#endif
|
485 |
|
|
|
486 |
|
|
ercd = wup_tsk( 0 ); // not ourself
|
487 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "wup_tsk bad ercd !E_ID" );
|
488 |
|
|
ercd = wup_tsk( 1 ); // ourself
|
489 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "wup_tsk bad ercd !E_OBJ" );
|
490 |
|
|
#endif // we can test bad param error returns
|
491 |
|
|
|
492 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
493 |
|
|
ercd = tslp_tsk( -6 );
|
494 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "tslp_tsk bad ercd !E_PAR" );
|
495 |
|
|
#endif // we can test bad param error returns
|
496 |
|
|
ercd = tslp_tsk( TMO_POL );
|
497 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tslp_tsk bad ercd !E_TMOUT" );
|
498 |
|
|
ercd = tslp_tsk( 5 );
|
499 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tslp_tsk bad ercd !E_TMOUT" );
|
500 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
501 |
|
|
ercd = dis_dsp();
|
502 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
503 |
|
|
ercd = tslp_tsk( TMO_FEVR );
|
504 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "tslp_tsk bad ercd !E_CTX" );
|
505 |
|
|
ercd = tslp_tsk( TMO_POL );
|
506 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "tslp_tsk bad ercd !E_CTX" );
|
507 |
|
|
ercd = tslp_tsk( 5 );
|
508 |
|
|
CYG_TEST_CHECK( E_CTX == ercd, "tslp_tsk bad ercd !E_CTX" );
|
509 |
|
|
ercd = ena_dsp();
|
510 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
511 |
|
|
ercd = tslp_tsk( -6 );
|
512 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "tslp_tsk bad ercd !E_PAR" );
|
513 |
|
|
#endif // we can test bad param error returns
|
514 |
|
|
ercd = tslp_tsk( TMO_POL );
|
515 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tslp_tsk bad ercd !E_TMOUT" );
|
516 |
|
|
ercd = tslp_tsk( 5 );
|
517 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tslp_tsk bad ercd !E_TMOUT" );
|
518 |
|
|
|
519 |
|
|
// drop task 4 pri to same as us
|
520 |
|
|
intercount = 0;
|
521 |
|
|
intercom = 1; // test plain slp_tsk
|
522 |
|
|
TSRELEASE();
|
523 |
|
|
ercd = chg_pri( 4, 5 );
|
524 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "chg_pri bad ercd" );
|
525 |
|
|
|
526 |
|
|
ercd = dis_dsp();
|
527 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
528 |
|
|
ercd = sta_tsk( 4, 77 );
|
529 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
|
530 |
|
|
ercd = chg_pri( 4, 5 );
|
531 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
|
532 |
|
|
ercd = ena_dsp();
|
533 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
534 |
|
|
|
535 |
|
|
ercd = wup_tsk( 4 );
|
536 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
537 |
|
|
ercd = rot_rdq( 0 );
|
538 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
539 |
|
|
ICWAIT( 1 );
|
540 |
|
|
CYG_TEST_CHECK( 1 == intercount, "intercount != 1" );
|
541 |
|
|
intercom = 2; // test tslp_tsk
|
542 |
|
|
TSRELEASE();
|
543 |
|
|
ercd = wup_tsk( 4 );
|
544 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
545 |
|
|
ercd = rot_rdq( 0 );
|
546 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
547 |
|
|
ICWAIT( 2 );
|
548 |
|
|
CYG_TEST_CHECK( 2 == intercount, "intercount != 2" );
|
549 |
|
|
intercom = 3; // test tslp_tsk
|
550 |
|
|
TSRELEASE();
|
551 |
|
|
ercd = rot_rdq( 0 );
|
552 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
553 |
|
|
CYG_TEST_CHECK( 2 == intercount, "intercount != 2" );
|
554 |
|
|
intercom = 1; // test slp_tsk next...
|
555 |
|
|
ercd = dly_tsk( 20 ); // without a wup
|
556 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
557 |
|
|
ICWAIT( 3 );
|
558 |
|
|
CYG_TEST_CHECK( 3 == intercount, "intercount != 3" );
|
559 |
|
|
|
560 |
|
|
intercom = 1; // ...test slp_tsk
|
561 |
|
|
TSRELEASE();
|
562 |
|
|
ercd = dly_tsk( 20 ); // without a wup (yet)
|
563 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
564 |
|
|
CYG_TEST_CHECK( 3 == intercount, "intercount != 3" );
|
565 |
|
|
TSRELEASE();
|
566 |
|
|
ercd = tslp_tsk( 20 ); // yield again
|
567 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd, "tslp_tsk bad ercd !E_TMOUT" );
|
568 |
|
|
CYG_TEST_CHECK( 3 == intercount, "intercount != 3" );
|
569 |
|
|
TSRELEASE();
|
570 |
|
|
ercd = rot_rdq( 0 ); // and again
|
571 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
572 |
|
|
CYG_TEST_CHECK( 3 == intercount, "intercount != 3" );
|
573 |
|
|
TSRELEASE();
|
574 |
|
|
ercd = wup_tsk( 4 ); // now issue a wup
|
575 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
576 |
|
|
ercd = rot_rdq( 0 ); // and yield
|
577 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
578 |
|
|
ICWAIT( 4 );
|
579 |
|
|
CYG_TEST_CHECK( 4 == intercount, "intercount != 4" );
|
580 |
|
|
|
581 |
|
|
intercom = 1; // test slp_tsk
|
582 |
|
|
TSRELEASE();
|
583 |
|
|
ercd = dly_tsk( 20 ); // without a wup (yet)
|
584 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
585 |
|
|
CYG_TEST_CHECK( 4 == intercount, "intercount != 4" );
|
586 |
|
|
|
587 |
|
|
// this wup will restart it when we yield:
|
588 |
|
|
TSLOCK();
|
589 |
|
|
ercd = wup_tsk( 4 ); // now issue a wup
|
590 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
591 |
|
|
// these will count up:
|
592 |
|
|
ercd = wup_tsk( 4 ); // now issue a wup
|
593 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
594 |
|
|
ercd = wup_tsk( 4 ); // now issue a wup
|
595 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
596 |
|
|
scratch = -1;
|
597 |
|
|
ercd = can_wup( &scratch, 4 );
|
598 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "can_wup bad ercd" );
|
599 |
|
|
CYG_TEST_CHECK( 2 == scratch, "Cancelled wups not 2" );
|
600 |
|
|
CYG_TEST_CHECK( 4 == intercount, "intercount != 4" );
|
601 |
|
|
TSUNLOCK();
|
602 |
|
|
|
603 |
|
|
intercom = 4; // do nothing
|
604 |
|
|
TSRELEASE();
|
605 |
|
|
ercd = rot_rdq( 0 ); // and yield
|
606 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
607 |
|
|
ICWAIT( 5 );
|
608 |
|
|
CYG_TEST_CHECK( 5 == intercount, "intercount != 5" );
|
609 |
|
|
TSRELEASE();
|
610 |
|
|
ercd = dly_tsk( 20 ); // let it do nothing
|
611 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
612 |
|
|
|
613 |
|
|
TSRELEASE();
|
614 |
|
|
ercd = wup_tsk( 4 ); // now issue a wup
|
615 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
616 |
|
|
TSRELEASE();
|
617 |
|
|
ercd = wup_tsk( 4 ); // now issue a wup
|
618 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
619 |
|
|
TSRELEASE();
|
620 |
|
|
ercd = wup_tsk( 4 ); // now issue a wup
|
621 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
622 |
|
|
TSRELEASE();
|
623 |
|
|
ercd = dly_tsk( 20 ); // lots of wups but no sleep
|
624 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
625 |
|
|
CYG_TEST_CHECK( 5 == intercount, "intercount != 5" );
|
626 |
|
|
scratch = -1;
|
627 |
|
|
ercd = can_wup( &scratch, 4 );
|
628 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "can_wup bad ercd" );
|
629 |
|
|
CYG_TEST_CHECK( 3 == scratch, "Cancelled wups not 3" );
|
630 |
|
|
// now check that they are cancelled by doing a wait again
|
631 |
|
|
intercom = 1; // test slp_tsk
|
632 |
|
|
TSRELEASE();
|
633 |
|
|
ercd = rot_rdq( 0 ); // still without a wup
|
634 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
635 |
|
|
TSRELEASE();
|
636 |
|
|
ercd = rot_rdq( 0 ); // still without a wup
|
637 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
638 |
|
|
intercom = 4; // do nothing next
|
639 |
|
|
TSRELEASE();
|
640 |
|
|
ICWAIT( 6 );
|
641 |
|
|
CYG_TEST_CHECK( 6 == intercount, "intercount != 6" );
|
642 |
|
|
ercd = rot_rdq( 0 ); // still without a wup
|
643 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
644 |
|
|
CYG_TEST_CHECK( 6 == intercount, "intercount != 6" );
|
645 |
|
|
TSRELEASE();
|
646 |
|
|
ercd = wup_tsk( 4 ); // now issue a wup
|
647 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
648 |
|
|
ercd = rot_rdq( 0 ); // it will run now
|
649 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
650 |
|
|
TSRELEASE();
|
651 |
|
|
ercd = rot_rdq( 0 ); // it will run now
|
652 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
653 |
|
|
ICWAIT( 7 );
|
654 |
|
|
CYG_TEST_CHECK( 7 == intercount, "intercount != 7" );
|
655 |
|
|
|
656 |
|
|
TSRELEASE();
|
657 |
|
|
intercom = 99; // exit, all done
|
658 |
|
|
ercd = rot_rdq( 0 ); // let it run
|
659 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
660 |
|
|
ICWAIT( 8 );
|
661 |
|
|
CYG_TEST_CHECK( 8 == intercount, "intercount != 8" );
|
662 |
|
|
|
663 |
|
|
TSRELEASE();
|
664 |
|
|
ercd = rot_rdq( 0 ); // let it run
|
665 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq bad ercd" );
|
666 |
|
|
CYG_TEST_CHECK( 8 == intercount, "intercount != 8" );
|
667 |
|
|
|
668 |
|
|
CYG_TEST_PASS( "wup_tsk, can_wup, slp_tsk, tslp_tsk" );
|
669 |
|
|
|
670 |
|
|
#ifdef CYG_TEST_UITRON_TEST1_LOOPING
|
671 |
|
|
chg_pri( 1, 1 );
|
672 |
|
|
rot_rdq( 0 );
|
673 |
|
|
ter_tsk( 2 );
|
674 |
|
|
rot_rdq( 0 );
|
675 |
|
|
ter_tsk( 3 );
|
676 |
|
|
rot_rdq( 0 );
|
677 |
|
|
ter_tsk( 4 );
|
678 |
|
|
rot_rdq( 0 );
|
679 |
|
|
}
|
680 |
|
|
#endif // CYG_TEST_UITRON_TEST1_LOOPING
|
681 |
|
|
|
682 |
|
|
CYG_TEST_EXIT( "All done" );
|
683 |
|
|
ext_tsk();
|
684 |
|
|
}
|
685 |
|
|
|
686 |
|
|
|
687 |
|
|
|
688 |
|
|
void task2( unsigned int arg )
|
689 |
|
|
{
|
690 |
|
|
ER ercd;
|
691 |
|
|
CYG_TEST_PASS( "Task 2 running" );
|
692 |
|
|
ercd = get_tid( &scratch );
|
693 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
|
694 |
|
|
CYG_TEST_CHECK( 2 == scratch, "tid not 2" );
|
695 |
|
|
if ( 99 != arg )
|
696 |
|
|
CYG_TEST_FAIL( "Task 2 arg not 99" );
|
697 |
|
|
ext_tsk();
|
698 |
|
|
CYG_TEST_FAIL( "Task 2 failed to exit" );
|
699 |
|
|
}
|
700 |
|
|
|
701 |
|
|
void task3( unsigned int arg )
|
702 |
|
|
{
|
703 |
|
|
ER ercd;
|
704 |
|
|
TSLOCK();
|
705 |
|
|
CYG_TEST_PASS("Task3 running");
|
706 |
|
|
ercd = get_tid( &scratch );
|
707 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
|
708 |
|
|
CYG_TEST_CHECK( 3 == scratch, "tid not 3" );
|
709 |
|
|
if ( 66 != arg )
|
710 |
|
|
CYG_TEST_FAIL( "Task 3 arg not 66" );
|
711 |
|
|
|
712 |
|
|
while ( 2 & intercom ) {
|
713 |
|
|
while ( 1 & intercom ) {
|
714 |
|
|
intercount++;
|
715 |
|
|
TSSTOP();
|
716 |
|
|
do {
|
717 |
|
|
TSUNLOCK();
|
718 |
|
|
ercd = rot_rdq( 0 ); // yield()
|
719 |
|
|
TSLOCK();
|
720 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq 1 (task3) bad ercd" );
|
721 |
|
|
} while ( !TSGO() );
|
722 |
|
|
}
|
723 |
|
|
CYG_TEST_CHECK( 4 & intercom, "should not have got here yet 1" );
|
724 |
|
|
TSSTOP();
|
725 |
|
|
do {
|
726 |
|
|
TSUNLOCK();
|
727 |
|
|
ercd = rot_rdq( 0 ); // yield()
|
728 |
|
|
TSLOCK();
|
729 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq 2 (task3) bad ercd" );
|
730 |
|
|
} while ( !TSGO() );
|
731 |
|
|
}
|
732 |
|
|
CYG_TEST_CHECK( 8 & intercom, "should not have got here yet 2" );
|
733 |
|
|
|
734 |
|
|
TSUNLOCK();
|
735 |
|
|
ext_tsk();
|
736 |
|
|
CYG_TEST_FAIL( "Task 3 failed to exit" );
|
737 |
|
|
}
|
738 |
|
|
|
739 |
|
|
void task4( unsigned int arg )
|
740 |
|
|
{
|
741 |
|
|
ER ercd;
|
742 |
|
|
CYG_TEST_PASS("Task4 running");
|
743 |
|
|
ercd = get_tid( &scratch );
|
744 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
|
745 |
|
|
CYG_TEST_CHECK( 4 == scratch, "tid not 4" );
|
746 |
|
|
if ( 77 != arg )
|
747 |
|
|
CYG_TEST_FAIL( "Task 4 arg not 77" );
|
748 |
|
|
while ( 1 ) {
|
749 |
|
|
switch ( intercom ) {
|
750 |
|
|
case 1:
|
751 |
|
|
ercd = slp_tsk();
|
752 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "slp_tsk (task4) bad ercd" );
|
753 |
|
|
break;
|
754 |
|
|
case 2:
|
755 |
|
|
ercd = tslp_tsk( 10 );
|
756 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "slp_tsk (task4) bad ercd" );
|
757 |
|
|
break;
|
758 |
|
|
case 3:
|
759 |
|
|
ercd = tslp_tsk( 10 );
|
760 |
|
|
CYG_TEST_CHECK( E_TMOUT == ercd,
|
761 |
|
|
"slp_tsk (task4) bad ercd !E_TMOUT" );
|
762 |
|
|
break;
|
763 |
|
|
case 4:
|
764 |
|
|
// busily do nothing
|
765 |
|
|
while ( 4 == intercom ) {
|
766 |
|
|
ercd = rot_rdq( 0 );
|
767 |
|
|
CYG_TEST_CHECK( E_OK == ercd,
|
768 |
|
|
"rot_rdq (task4 idle) bad ercd" );
|
769 |
|
|
}
|
770 |
|
|
break;
|
771 |
|
|
case 99:
|
772 |
|
|
goto out;
|
773 |
|
|
default:
|
774 |
|
|
CYG_TEST_FAIL( "Task 4 bad intercom" );
|
775 |
|
|
goto out;
|
776 |
|
|
}
|
777 |
|
|
intercount++;
|
778 |
|
|
TSSTOP();
|
779 |
|
|
do {
|
780 |
|
|
ercd = rot_rdq( 0 ); // yield()
|
781 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "rot_rdq (task4) bad ercd" );
|
782 |
|
|
} while ( !TSGO() );
|
783 |
|
|
}
|
784 |
|
|
out:
|
785 |
|
|
ext_tsk();
|
786 |
|
|
CYG_TEST_FAIL( "Task 4 failed to exit" );
|
787 |
|
|
}
|
788 |
|
|
|
789 |
|
|
#else // not enough (or too many) uITRON objects configured in
|
790 |
|
|
#define N_A_MSG "not enough uITRON objects to run test"
|
791 |
|
|
#endif // not enough (or too many) uITRON objects configured in
|
792 |
|
|
#else // not C++ and some C++ specific options enabled
|
793 |
|
|
#define N_A_MSG "C++ specific options selected but this is C"
|
794 |
|
|
#endif // not C++ and some C++ specific options enabled
|
795 |
|
|
#else // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it
|
796 |
|
|
#define N_A_MSG "no CYGVAR_KERNEL_COUNTERS_CLOCK"
|
797 |
|
|
#endif // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it
|
798 |
|
|
#else // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it
|
799 |
|
|
#define N_A_MSG "no CYGFUN_KERNEL_THREADS_TIMER"
|
800 |
|
|
#endif // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it
|
801 |
|
|
#else // ! CYGIMP_THREAD_PRIORITY - can't test without it
|
802 |
|
|
#define N_A_MSG "no CYGSEM_KERNEL_SCHED_MLQUEUE"
|
803 |
|
|
#endif // ! CYGSEM_KERNEL_SCHED_MLQUEUE - can't test without it
|
804 |
|
|
#else // ! CYGPKG_UITRON
|
805 |
|
|
#define N_A_MSG "uITRON Compatibility layer disabled"
|
806 |
|
|
#endif // CYGPKG_UITRON
|
807 |
|
|
|
808 |
|
|
#ifdef N_A_MSG
|
809 |
|
|
externC void
|
810 |
|
|
cyg_start( void )
|
811 |
|
|
{
|
812 |
|
|
CYG_TEST_INIT();
|
813 |
|
|
CYG_TEST_NA( N_A_MSG );
|
814 |
|
|
}
|
815 |
|
|
#endif // N_A_MSG defined ie. we are N/A.
|
816 |
|
|
|
817 |
|
|
// EOF testcxx.cxx
|