1 |
786 |
skrzyp |
//===========================================================================
|
2 |
|
|
//
|
3 |
|
|
// testcx8.cxx
|
4 |
|
|
//
|
5 |
|
|
// uITRON "C++" test program eight
|
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 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-10-14
|
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 CYGSEM_KERNEL_SCHED_MLQUEUE // we DO want prioritized threads
|
59 |
|
|
|
60 |
|
|
#ifdef CYGFUN_KERNEL_THREADS_TIMER // we DO want timout-able calls
|
61 |
|
|
|
62 |
|
|
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK // we DO want the realtime clock
|
63 |
|
|
|
64 |
|
|
// we're OK if it's C++ or neither of those two is defined:
|
65 |
|
|
#if defined( __cplusplus ) || \
|
66 |
|
|
(!defined( CYGIMP_UITRON_INLINE_FUNCS ) && \
|
67 |
|
|
!defined( CYGIMP_UITRON_CPP_OUTLINE_FUNCS) )
|
68 |
|
|
|
69 |
|
|
// =================== TEST CONFIGURATION ===================
|
70 |
|
|
#if \
|
71 |
|
|
/* test configuration for enough tasks */ \
|
72 |
|
|
(CYGNUM_UITRON_TASKS >= 4) && \
|
73 |
|
|
(CYGNUM_UITRON_TASKS < 90) && \
|
74 |
|
|
(CYGNUM_UITRON_START_TASKS == 1) && \
|
75 |
|
|
( !defined(CYGPKG_UITRON_TASKS_CREATE_DELETE) || \
|
76 |
|
|
CYGNUM_UITRON_TASKS_INITIALLY >= 4 ) && \
|
77 |
|
|
\
|
78 |
|
|
/* test configuration for enough semaphores */ \
|
79 |
|
|
defined( CYGPKG_UITRON_SEMAS ) && \
|
80 |
|
|
(CYGNUM_UITRON_SEMAS >= 3) && \
|
81 |
|
|
(CYGNUM_UITRON_SEMAS < 90) && \
|
82 |
|
|
( !defined(CYGPKG_UITRON_SEMAS_CREATE_DELETE) || \
|
83 |
|
|
CYGNUM_UITRON_SEMAS_INITIALLY >= 3 ) && \
|
84 |
|
|
\
|
85 |
|
|
/* the end of the large #if statement */ \
|
86 |
|
|
1
|
87 |
|
|
|
88 |
|
|
// ============================ END ============================
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
#include <cyg/compat/uitron/uit_func.h> // uITRON
|
93 |
|
|
|
94 |
|
|
externC void
|
95 |
|
|
cyg_package_start( void )
|
96 |
|
|
{
|
97 |
|
|
CYG_TEST_INIT();
|
98 |
|
|
CYG_TEST_INFO( "Calling cyg_uitron_start()" );
|
99 |
|
|
cyg_uitron_start();
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
volatile int intercount = 0;
|
103 |
|
|
INT scratch;
|
104 |
|
|
|
105 |
|
|
void newtask( unsigned int arg );
|
106 |
|
|
|
107 |
|
|
T_CTSK t_ctsk = { NULL, 0, (FP)&newtask, 1, CYGNUM_UITRON_STACK_SIZE };
|
108 |
|
|
T_RTSK t_rtsk;
|
109 |
|
|
|
110 |
|
|
extern "C" {
|
111 |
|
|
void task1( unsigned int arg );
|
112 |
|
|
void task2( unsigned int arg );
|
113 |
|
|
void task3( unsigned int arg );
|
114 |
|
|
void task4( unsigned int arg );
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
void task1( unsigned int arg )
|
118 |
|
|
{
|
119 |
|
|
ER ercd;
|
120 |
|
|
|
121 |
|
|
CYG_TEST_INFO( "Task 1 running" );
|
122 |
|
|
|
123 |
|
|
// change us to prio 3 for flexibility
|
124 |
|
|
ercd = chg_pri( 0, 3 );
|
125 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
|
126 |
|
|
|
127 |
|
|
#ifdef CYGPKG_UITRON_TASKS_CREATE_DELETE
|
128 |
|
|
// first, check that we can delete a task:
|
129 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
130 |
|
|
ercd = del_tsk( -6 );
|
131 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "del_tsk bad ercd !E_ID" );
|
132 |
|
|
ercd = del_tsk( 99 );
|
133 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "del_tsk bad ercd !E_ID" );
|
134 |
|
|
ercd = cre_tsk( -6, &t_ctsk );
|
135 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "cre_tsk bad ercd !E_ID" );
|
136 |
|
|
ercd = cre_tsk( 99, &t_ctsk );
|
137 |
|
|
CYG_TEST_CHECK( E_ID == ercd, "cre_tsk bad ercd !E_ID" );
|
138 |
|
|
#endif // we can test bad param error returns
|
139 |
|
|
// try a pre-existing object
|
140 |
|
|
ercd = cre_tsk( 2, &t_ctsk );
|
141 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "cre_tsk bad ercd !E_OBJ" );
|
142 |
|
|
// try a pre-existing object - ourselves!
|
143 |
|
|
ercd = cre_tsk( 1, &t_ctsk );
|
144 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "cre_tsk bad ercd !E_OBJ" );
|
145 |
|
|
// try deleting an active task
|
146 |
|
|
ercd = dis_dsp();
|
147 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
|
148 |
|
|
ercd = sta_tsk( 2, 22222 );
|
149 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
|
150 |
|
|
ercd = chg_pri( 2, 5 );
|
151 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
|
152 |
|
|
ercd = ena_dsp();
|
153 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
|
154 |
|
|
// Task 2 is now ready-to-run, lower prio than us
|
155 |
|
|
ercd = del_tsk( 2 );
|
156 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "del_tsk bad ercd !E_OBJ" );
|
157 |
|
|
ercd = dly_tsk( 10 );
|
158 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
159 |
|
|
// Task 2 is now sleeping
|
160 |
|
|
CYG_TEST_CHECK( 1 == intercount, "bad intercount !1" );
|
161 |
|
|
ercd = del_tsk( 2 );
|
162 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "del_tsk bad ercd !E_OBJ" );
|
163 |
|
|
// try deleting a running task - ourselves!
|
164 |
|
|
ercd = del_tsk( 1 );
|
165 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "del_tsk bad ercd !E_OBJ" );
|
166 |
|
|
// terminate task 2; should then be OK to delete it
|
167 |
|
|
ercd = ter_tsk( 2 );
|
168 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
|
169 |
|
|
CYG_TEST_CHECK( 1 == intercount, "bad intercount !1" );
|
170 |
|
|
ercd = del_tsk( 2 );
|
171 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "del_tsk bad ercd" );
|
172 |
|
|
CYG_TEST_CHECK( 1 == intercount, "bad intercount !1" );
|
173 |
|
|
// and check it is deleted
|
174 |
|
|
ercd = sta_tsk( 2, 99 );
|
175 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "sta_tsk bad ercd !E_NOEXS" );
|
176 |
|
|
ercd = ter_tsk( 2 );
|
177 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "ter_tsk bad ercd !E_NOEXS" );
|
178 |
|
|
ercd = chg_pri( 2, 6 );
|
179 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "chg_pri bad ercd !E_NOEXS" );
|
180 |
|
|
ercd = rel_wai( 2 );
|
181 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "rel_wai bad ercd !E_NOEXS" );
|
182 |
|
|
ercd = sus_tsk( 2 );
|
183 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "sus_tsk bad ercd !E_NOEXS" );
|
184 |
|
|
ercd = rsm_tsk( 2 );
|
185 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "rsm_tsk bad ercd !E_NOEXS" );
|
186 |
|
|
ercd = frsm_tsk( 2 );
|
187 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "frsm_tsk bad ercd !E_NOEXS" );
|
188 |
|
|
ercd = wup_tsk( 2 );
|
189 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "wup_tsk bad ercd !E_NOEXS" );
|
190 |
|
|
ercd = can_wup( &scratch, 2 );
|
191 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "can_wup bad ercd !E_NOEXS" );
|
192 |
|
|
ercd = ref_tsk( &t_rtsk, 2 );
|
193 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "ref_tsk bad ercd !E_NOEXS" );
|
194 |
|
|
ercd = del_tsk( 2 );
|
195 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "del_tsk bad ercd !E_NOEXS" );
|
196 |
|
|
// recreate task2, with the same function
|
197 |
|
|
t_ctsk.task = (FP)&task2;
|
198 |
|
|
t_ctsk.itskpri = 7;
|
199 |
|
|
ercd = cre_tsk( 2, &t_ctsk );
|
200 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "cre_tsk bad ercd" );
|
201 |
|
|
ercd = ref_tsk( &t_rtsk, 2 );
|
202 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
203 |
|
|
CYG_TEST_CHECK( 7 == t_rtsk.tskpri, "Bad tskpri in new task2 !7" );
|
204 |
|
|
CYG_TEST_CHECK( TTS_DMT == t_rtsk.tskstat,
|
205 |
|
|
"Bad tskstat in new task2 !TTS_DMT" );
|
206 |
|
|
CYG_TEST_CHECK( 1 == intercount, "bad intercount !1" );
|
207 |
|
|
// now start the task and do the same lot again...
|
208 |
|
|
ercd = cre_tsk( 2, &t_ctsk );
|
209 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "cre_tsk bad ercd !E_OBJ" );
|
210 |
|
|
// try deleting an active task
|
211 |
|
|
ercd = sta_tsk( 2, 22222 );
|
212 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
|
213 |
|
|
// Task 2 is now ready-to-run, lower prio than us
|
214 |
|
|
ercd = del_tsk( 2 );
|
215 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "del_tsk bad ercd !E_OBJ" );
|
216 |
|
|
CYG_TEST_CHECK( 1 == intercount, "bad intercount !1" );
|
217 |
|
|
ercd = dly_tsk( 10 );
|
218 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
|
219 |
|
|
CYG_TEST_CHECK( 2 == intercount, "bad intercount !2" );
|
220 |
|
|
// Task 2 is now sleeping
|
221 |
|
|
ercd = ref_tsk( &t_rtsk, 2 );
|
222 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" );
|
223 |
|
|
CYG_TEST_CHECK( 7 == t_rtsk.tskpri, "Bad tskpri in new task2 !7" );
|
224 |
|
|
CYG_TEST_CHECK( TTS_WAI == t_rtsk.tskstat,
|
225 |
|
|
"Bad tskstat in new task2 !TTS_WAI" );
|
226 |
|
|
ercd = del_tsk( 2 );
|
227 |
|
|
CYG_TEST_CHECK( E_OBJ == ercd, "del_tsk bad ercd !E_OBJ" );
|
228 |
|
|
// up its priority
|
229 |
|
|
ercd = chg_pri( 2, 1 );
|
230 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
|
231 |
|
|
// awaken task 2; it will then exit-and-delete itself:
|
232 |
|
|
CYG_TEST_CHECK( 2 == intercount, "bad intercount !2" );
|
233 |
|
|
ercd = wup_tsk( 2 );
|
234 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
|
235 |
|
|
CYG_TEST_CHECK( 3 == intercount, "bad intercount !3" );
|
236 |
|
|
// and check it is deleted
|
237 |
|
|
ercd = sta_tsk( 2, 99 );
|
238 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "sta_tsk bad ercd !E_NOEXS" );
|
239 |
|
|
CYG_TEST_CHECK( 3 == intercount, "bad intercount !3" );
|
240 |
|
|
ercd = ter_tsk( 2 );
|
241 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "ter_tsk bad ercd !E_NOEXS" );
|
242 |
|
|
ercd = chg_pri( 2, 1 );
|
243 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "chg_pri bad ercd !E_NOEXS" );
|
244 |
|
|
ercd = rel_wai( 2 );
|
245 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "rel_wai bad ercd !E_NOEXS" );
|
246 |
|
|
ercd = sus_tsk( 2 );
|
247 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "sus_tsk bad ercd !E_NOEXS" );
|
248 |
|
|
ercd = rsm_tsk( 2 );
|
249 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "rsm_tsk bad ercd !E_NOEXS" );
|
250 |
|
|
ercd = frsm_tsk( 2 );
|
251 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "frsm_tsk bad ercd !E_NOEXS" );
|
252 |
|
|
ercd = wup_tsk( 2 );
|
253 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "wup_tsk bad ercd !E_NOEXS" );
|
254 |
|
|
ercd = can_wup( &scratch, 2 );
|
255 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "can_wup bad ercd !E_NOEXS" );
|
256 |
|
|
ercd = ref_tsk( &t_rtsk, 2 );
|
257 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "ref_tsk bad ercd !E_NOEXS" );
|
258 |
|
|
CYG_TEST_CHECK( 3 == intercount, "bad intercount !3" );
|
259 |
|
|
ercd = del_tsk( 2 );
|
260 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "del_tsk bad ercd !E_NOEXS" );
|
261 |
|
|
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
|
262 |
|
|
// now try creating it (badly)
|
263 |
|
|
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
|
264 |
|
|
ercd = cre_tsk( 2, NULL );
|
265 |
|
|
CYG_TEST_CHECK( E_PAR == ercd, "cre_tsk bad ercd !E_PAR" );
|
266 |
|
|
#endif
|
267 |
|
|
t_ctsk.stksz = 0x40000000;
|
268 |
|
|
ercd = cre_tsk( 2, &t_ctsk );
|
269 |
|
|
CYG_TEST_CHECK( E_NOMEM == ercd, "cre_tsk bad ercd !E_NOMEM" );
|
270 |
|
|
t_ctsk.stksz = CYGNUM_UITRON_STACK_SIZE;
|
271 |
|
|
CYG_TEST_CHECK( 3 == intercount, "bad intercount !3" );
|
272 |
|
|
#endif // we can test bad param error returns
|
273 |
|
|
|
274 |
|
|
ercd = del_tsk( 3 );
|
275 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "del_tsk bad ercd" );
|
276 |
|
|
t_ctsk.task = (FP)&task4;
|
277 |
|
|
t_ctsk.itskpri = 9;
|
278 |
|
|
ercd = cre_tsk( 3, &t_ctsk );
|
279 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "cre_tsk bad ercd" );
|
280 |
|
|
// check we can delete it again immediately
|
281 |
|
|
ercd = del_tsk( 3 );
|
282 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "del_tsk bad ercd" );
|
283 |
|
|
ercd = ref_tsk( &t_rtsk, 3 );
|
284 |
|
|
CYG_TEST_CHECK( E_NOEXS == ercd, "ref_tsk bad ercd !E_NOEXS" );
|
285 |
|
|
t_ctsk.task = (FP)&newtask;
|
286 |
|
|
t_ctsk.itskpri = 1;
|
287 |
|
|
ercd = cre_tsk( 3, &t_ctsk );
|
288 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "cre_tsk bad ercd" );
|
289 |
|
|
CYG_TEST_CHECK( 3 == intercount, "bad intercount !3" );
|
290 |
|
|
ercd = sta_tsk( 3, 999 );
|
291 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "cre_tsk bad ercd" );
|
292 |
|
|
// it should have run now, and exited
|
293 |
|
|
CYG_TEST_CHECK( 5 == intercount, "bad intercount !5" );
|
294 |
|
|
ercd = wai_sem( 1 );
|
295 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
|
296 |
|
|
// and check that it will just run again...
|
297 |
|
|
ercd = sta_tsk( 3, 999 );
|
298 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "cre_tsk bad ercd" );
|
299 |
|
|
// it should have run now, and exited
|
300 |
|
|
CYG_TEST_CHECK( 7 == intercount, "bad intercount !7" );
|
301 |
|
|
ercd = wai_sem( 1 );
|
302 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
|
303 |
|
|
// all done.
|
304 |
|
|
|
305 |
|
|
CYG_TEST_PASS("create/delete tasks");
|
306 |
|
|
|
307 |
|
|
// all done
|
308 |
|
|
CYG_TEST_EXIT( "All done" );
|
309 |
|
|
#else // ! CYGPKG_UITRON_TASKS_CREATE_DELETE
|
310 |
|
|
CYG_TEST_NA( "Tasks do not have create/delete enabled" );
|
311 |
|
|
#endif // ! CYGPKG_UITRON_TASKS_CREATE_DELETE
|
312 |
|
|
ext_tsk();
|
313 |
|
|
}
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
void newtask( unsigned int arg )
|
318 |
|
|
{
|
319 |
|
|
ER ercd;
|
320 |
|
|
int i;
|
321 |
|
|
CYG_TEST_INFO( "Newtask running" );
|
322 |
|
|
CYG_TEST_CHECK( 999 == arg, "Bad arg to newtask() !999" );
|
323 |
|
|
ercd = get_tid( &i );
|
324 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
|
325 |
|
|
CYG_TEST_CHECK( 3 == i, "tid not 3" );
|
326 |
|
|
intercount++;
|
327 |
|
|
ercd = sig_sem( 1 );
|
328 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
|
329 |
|
|
intercount++;
|
330 |
|
|
// and just return
|
331 |
|
|
}
|
332 |
|
|
|
333 |
|
|
void task2( unsigned int arg )
|
334 |
|
|
{
|
335 |
|
|
ER ercd;
|
336 |
|
|
int i;
|
337 |
|
|
CYG_TEST_INFO( "Task 2 running" );
|
338 |
|
|
ercd = get_tid( &i );
|
339 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
|
340 |
|
|
CYG_TEST_CHECK( 2 == i, "tid not 2" );
|
341 |
|
|
if ( 22222 != arg )
|
342 |
|
|
CYG_TEST_FAIL( "Task 2 arg not 22222" );
|
343 |
|
|
|
344 |
|
|
intercount++;
|
345 |
|
|
|
346 |
|
|
ercd = slp_tsk();
|
347 |
|
|
CYG_TEST_CHECK( E_OK == ercd, "slp_tsk bad ercd" );
|
348 |
|
|
|
349 |
|
|
intercount++;
|
350 |
|
|
|
351 |
|
|
exd_tsk(); // if we are not killed first
|
352 |
|
|
|
353 |
|
|
intercount++; // shouldn't happen
|
354 |
|
|
}
|
355 |
|
|
|
356 |
|
|
void task3( unsigned int arg )
|
357 |
|
|
{
|
358 |
|
|
CYG_TEST_FAIL( "How come I'm being run?" );
|
359 |
|
|
}
|
360 |
|
|
|
361 |
|
|
void task4( unsigned int arg )
|
362 |
|
|
{
|
363 |
|
|
CYG_TEST_FAIL( "How come I'm being run?" );
|
364 |
|
|
}
|
365 |
|
|
|
366 |
|
|
#else // not enough (or too many) uITRON objects configured in
|
367 |
|
|
#define N_A_MSG "not enough uITRON objects to run test"
|
368 |
|
|
#endif // not enough (or too many) uITRON objects configured in
|
369 |
|
|
#else // not C++ and some C++ specific options enabled
|
370 |
|
|
#define N_A_MSG "C++ specific options selected but this is C"
|
371 |
|
|
#endif // not C++ and some C++ specific options enabled
|
372 |
|
|
#else // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it
|
373 |
|
|
#define N_A_MSG "no CYGVAR_KERNEL_COUNTERS_CLOCK"
|
374 |
|
|
#endif // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it
|
375 |
|
|
#else // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it
|
376 |
|
|
#define N_A_MSG "no CYGFUN_KERNEL_THREADS_TIMER"
|
377 |
|
|
#endif // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it
|
378 |
|
|
#else // ! CYGIMP_THREAD_PRIORITY - can't test without it
|
379 |
|
|
#define N_A_MSG "no CYGSEM_KERNEL_SCHED_MLQUEUE"
|
380 |
|
|
#endif // ! CYGSEM_KERNEL_SCHED_MLQUEUE - can't test without it
|
381 |
|
|
#else // ! CYGPKG_UITRON
|
382 |
|
|
#define N_A_MSG "uITRON Compatibility layer disabled"
|
383 |
|
|
#endif // CYGPKG_UITRON
|
384 |
|
|
|
385 |
|
|
#ifdef N_A_MSG
|
386 |
|
|
externC void
|
387 |
|
|
cyg_start( void )
|
388 |
|
|
{
|
389 |
|
|
CYG_TEST_INIT();
|
390 |
|
|
CYG_TEST_NA( N_A_MSG );
|
391 |
|
|
}
|
392 |
|
|
#endif // N_A_MSG defined ie. we are N/A.
|
393 |
|
|
|
394 |
|
|
// EOF testcx8.cxx
|