Mercurial > ecos
annotate packages/compat/uitron/current/tests/test7.c @ 66:bf00f99aec69 ecos-sw-2000-02-02
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
| author | jlarmour |
|---|---|
| date | Wed, 02 Feb 2000 19:57:02 +0000 |
| parents | c38311975d4f |
| children | e0c0827131d1 |
| rev | line source |
|---|---|
| 0 | 1 //=========================================================================== |
| 2 // | |
| 3 // test7.c | |
| 4 // | |
| 5 // uITRON "C" test program seven | |
| 6 // | |
| 7 //=========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
9 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
10 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
11 // The contents of this file are subject to the Red Hat eCos Public License |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
12 // Version 1.1 (the "License"); you may not use this file except in |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
13 // compliance with the License. You may obtain a copy of the License at |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
14 // http://www.redhat.com/ |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
15 // |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
18 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
19 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
20 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
21 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
22 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
23 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
24 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
25 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
27 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
28 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
29 // |
| 0 | 30 //####COPYRIGHTEND#### |
| 31 //=========================================================================== | |
| 32 //#####DESCRIPTIONBEGIN#### | |
| 33 // | |
| 34 // Author(s): hmt | |
| 35 // Contributors: hmt | |
| 36 // Date: 1998-10-01 | |
| 37 // Purpose: uITRON API testing | |
| 38 // Description: | |
| 39 // | |
| 40 //####DESCRIPTIONEND#### | |
| 41 // | |
| 42 //=========================================================================== | |
| 43 | |
| 44 #include <pkgconf/uitron.h> // uITRON setup CYGNUM_UITRON_SEMAS | |
| 45 // CYGPKG_UITRON et al | |
| 46 #include <cyg/infra/testcase.h> // testing infrastructure | |
| 47 | |
| 48 #ifdef CYGPKG_UITRON // we DO want the uITRON package | |
| 49 | |
| 50 #ifdef CYGSEM_KERNEL_SCHED_MLQUEUE // we DO want prioritized threads | |
| 51 | |
| 52 #ifdef CYGFUN_KERNEL_THREADS_TIMER // we DO want timout-able calls | |
| 53 | |
| 54 #ifdef CYGVAR_KERNEL_COUNTERS_CLOCK // we DO want the realtime clock | |
| 55 | |
| 56 // we're OK if it's C++ or neither of those two is defined: | |
| 57 #if defined( __cplusplus ) || \ | |
| 58 (!defined( CYGIMP_UITRON_INLINE_FUNCS ) && \ | |
| 59 !defined( CYGIMP_UITRON_CPP_OUTLINE_FUNCS) ) | |
| 60 | |
| 61 // =================== TEST CONFIGURATION =================== | |
| 62 #if \ | |
| 63 /* test configuration for enough tasks */ \ | |
| 64 (CYGNUM_UITRON_TASKS >= 4) && \ | |
| 65 (CYGNUM_UITRON_TASKS < 90) && \ | |
| 66 (CYGNUM_UITRON_START_TASKS == 1) && \ | |
| 67 ( !defined(CYGPKG_UITRON_TASKS_CREATE_DELETE) || \ | |
| 68 CYGNUM_UITRON_TASKS_INITIALLY >= 4 ) && \ | |
| 69 \ | |
| 70 /* test configuration for enough semaphores */ \ | |
| 71 defined( CYGPKG_UITRON_SEMAS ) && \ | |
| 72 (CYGNUM_UITRON_SEMAS >= 3) && \ | |
| 73 (CYGNUM_UITRON_SEMAS < 90) && \ | |
| 74 ( !defined(CYGPKG_UITRON_SEMAS_CREATE_DELETE) || \ | |
| 75 CYGNUM_UITRON_SEMAS_INITIALLY >= 3 ) && \ | |
| 76 \ | |
| 77 /* test configuration for enough flag objects */ \ | |
| 78 defined( CYGPKG_UITRON_FLAGS ) && \ | |
| 79 (CYGNUM_UITRON_FLAGS >= 3) && \ | |
| 80 (CYGNUM_UITRON_FLAGS < 90) && \ | |
| 81 ( !defined(CYGPKG_UITRON_FLAGS_CREATE_DELETE) || \ | |
| 82 CYGNUM_UITRON_FLAGS_INITIALLY >= 3 ) && \ | |
| 83 \ | |
| 84 /* test configuration for enough message boxes */ \ | |
| 85 defined( CYGPKG_UITRON_MBOXES ) && \ | |
| 86 (CYGNUM_UITRON_MBOXES >= 3) && \ | |
| 87 (CYGNUM_UITRON_MBOXES < 90) && \ | |
| 88 ( !defined(CYGPKG_UITRON_MBOXES_CREATE_DELETE) || \ | |
| 89 CYGNUM_UITRON_MBOXES_INITIALLY >= 3 ) && \ | |
| 90 \ | |
| 91 /* test configuration for enough fixed memory pools */ \ | |
| 92 defined( CYGPKG_UITRON_MEMPOOLFIXED ) && \ | |
| 93 (CYGNUM_UITRON_MEMPOOLFIXED >= 3) && \ | |
| 94 (CYGNUM_UITRON_MEMPOOLFIXED < 90) && \ | |
| 95 ( !defined(CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE) || \ | |
| 96 CYGNUM_UITRON_MEMPOOLFIXED_INITIALLY >= 3 ) && \ | |
| 97 \ | |
| 98 /* test configuration for enough variable mempools */ \ | |
| 99 defined( CYGPKG_UITRON_MEMPOOLVAR ) && \ | |
| 100 (CYGNUM_UITRON_MEMPOOLVAR >= 3) && \ | |
| 101 (CYGNUM_UITRON_MEMPOOLVAR < 90) && \ | |
| 102 ( !defined(CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE) || \ | |
| 103 CYGNUM_UITRON_MEMPOOLVAR_INITIALLY >= 3 ) && \ | |
| 104 \ | |
| 105 /* the end of the large #if statement */ \ | |
| 106 1 | |
| 107 | |
| 108 // ============================ END ============================ | |
| 109 | |
| 110 | |
| 111 | |
| 112 #include <cyg/compat/uitron/uit_func.h> // uITRON | |
| 113 | |
| 114 externC void | |
| 115 cyg_package_start( void ) | |
| 116 { | |
| 117 CYG_TEST_INIT(); | |
| 118 CYG_TEST_INFO( "Calling cyg_uitron_start()" ); | |
| 119 cyg_uitron_start(); | |
| 120 } | |
| 121 | |
| 122 // ======================================================================== | |
| 123 | |
| 124 typedef enum { | |
| 125 START_WAITOP = 0, | |
| 126 SLEEP = 0, | |
| 127 DELAY, | |
| 128 SEMGET, | |
| 129 FLAGWAIT, | |
| 130 MSGGET, | |
| 131 MEMFIXEDGET, | |
| 132 MEMVARGET, | |
| 133 DONE_WAITOP | |
| 134 } WAITOP; | |
| 135 | |
| 136 typedef enum { | |
| 137 START_TYPE = 0, | |
| 138 PLAIN = 0, | |
| 139 TIMED = 1, | |
| 140 DONE_TYPE | |
| 141 } WAITTYPE; | |
| 142 | |
| 143 typedef enum { | |
| 144 START_KILLOP = 0, | |
| 145 | |
| 146 // These are the 5 ways out of a wait that we perm | |
| 147 // with other circumstances: | |
| 148 SIGNAL = 0, // do the appropriate producer op | |
| 149 TIMEOUT, // wait for the timeout to fire | |
| 150 RELEASE, // do a rel_wai() | |
| 151 DELETE, // delete the object; del_xxx() | |
| 152 KILL, // do a ter_tsk() on the waiter | |
| 153 | |
| 154 SUSPEND_SIGNAL_RESUME, | |
| 155 SUSPEND_TIMEOUT_RESUME, | |
| 156 SUSPEND_RELEASE_RESUME, | |
| 157 SUSPEND_DELETE_RESUME, | |
| 158 SUSPEND_KILL, // resume not applicable | |
| 159 | |
| 160 SUSPEND_SIGNAL_KILL, | |
| 161 SUSPEND_TIMEOUT_KILL, | |
| 162 SUSPEND_RELEASE_KILL, | |
| 163 SUSPEND_DELETE_KILL, | |
| 164 // SUSPEND_KILL_KILL not applicable | |
| 165 | |
| 166 #if 0 | |
| 167 // support these later if _really_ keen. | |
| 168 SUSPEND_SIGNAL_DELETE_RESUME, | |
| 169 SUSPEND_TIMEOUT_DELETE_RESUME, | |
| 170 SUSPEND_RELEASE_DELETE_RESUME, | |
| 171 // SUSPEND_DELETE_DELETE_RESUME not applicable | |
| 172 // SUSPEND_KILL_DELETE_RESUME not applicable | |
| 173 | |
| 174 SUSPEND_SIGNAL_DELETE_KILL, | |
| 175 SUSPEND_TIMEOUT_DELETE_KILL, | |
| 176 SUSPEND_RELEASE_DELETE_KILL, | |
| 177 // SUSPEND_DELETE_DELETE_KILL, | |
| 178 SUSPEND_KILL_DELETE // 2nd kill not applicable | |
| 179 #endif | |
| 180 | |
| 181 DONE_KILLOP | |
| 182 } KILLOP; | |
| 183 | |
| 184 // ======================================================================== | |
| 185 | |
| 186 char * waitstrings[] = | |
| 187 { "Sleep ", "Delay ", "Sema ", "Flag ", "Mbox ", "MemFix", "MemVar" }; | |
| 188 | |
| 189 char * typestrings[] = | |
| 190 { " (Plain) : ", " (Timed) : " }; | |
| 191 | |
| 192 char * killstrings[] = | |
| 193 { "Signal", | |
| 194 "Wait-for-timeout", | |
| 195 "Release-wait", | |
| 196 "Delete-object", | |
| 197 "Kill-task", | |
| 198 | |
| 199 "Suspend/Signal/Resume", | |
| 200 "Suspend/Wait-for-timeout/Resume", | |
| 201 "Suspend/Release-wait/Resume", | |
| 202 "Suspend/Delete-object/Resume", | |
| 203 "Suspend/Kill-task", | |
| 204 | |
| 205 "Suspend/Signal/Kill-task", | |
| 206 "Suspend/Wait-for-timeout/Kill-task", | |
| 207 "Suspend/Release-wait/Kill-task", | |
| 208 "Suspend/Delete-object/Kill-task", | |
| 209 | |
| 210 | |
| 211 }; | |
| 212 | |
| 213 // ======================================================================== | |
| 214 | |
| 215 inline int task2arg( WAITOP wait, WAITTYPE waittype, KILLOP kill ) | |
| 216 { | |
| 217 return waittype + (wait << 1) + (kill << 8); | |
| 218 } | |
| 219 | |
| 220 inline void decodearg( int arg, WAITOP *pwait, WAITTYPE *pwaittype, KILLOP *pkill ) | |
| 221 { | |
| 222 *pwaittype = (arg & 1) ? TIMED : PLAIN; | |
| 223 *pwait = (arg >> 1) & 0x7f; | |
| 224 *pkill = (arg >> 8); | |
| 225 } | |
| 226 | |
| 227 static char *strdog( char *p, char *q ) | |
| 228 { | |
| 229 while ( 0 != (*p++ = *q++) ); | |
| 230 return p - 1; | |
| 231 } | |
| 232 | |
| 233 static char * | |
| 234 makemsg( char *z, WAITOP wait, WAITTYPE waittype, KILLOP kill ) | |
| 235 { | |
| 236 static char buf[ 1000 ]; | |
| 237 char *p = buf; | |
| 238 p = strdog( p, z ); | |
| 239 p = strdog( p, waitstrings[ wait ] ); | |
| 240 p = strdog( p, typestrings[ waittype ] ); | |
| 241 p = strdog( p, killstrings[ kill ] ); | |
| 242 *p = 0; | |
| 243 return buf; | |
| 244 } | |
| 245 | |
| 246 // ======================================================================== | |
| 247 | |
| 248 volatile int intercom = 0; | |
| 249 | |
| 250 // ======================================================================== | |
| 251 | |
| 252 T_RTSK rtsk; | |
| 253 | |
| 254 void | |
| 255 do_suspend( void ) | |
| 256 { | |
| 257 ER ercd; | |
| 258 ercd = ref_tsk( &rtsk, 2 ); | |
| 259 CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" ); | |
| 260 CYG_TEST_CHECK( TTS_WAI == rtsk.tskstat, "bad tskstat !TTS_WAI" ); | |
| 261 ercd = sus_tsk( 2 ); | |
| 262 CYG_TEST_CHECK( E_OK == ercd, "sus_tsk bad ercd" ); | |
| 263 ercd = ref_tsk( &rtsk, 2 ); | |
| 264 CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" ); | |
| 265 CYG_TEST_CHECK( TTS_WAS == rtsk.tskstat, "bad tskstat !TTS_WAS" ); | |
| 266 } | |
| 267 | |
| 268 void | |
| 269 do_resume( void ) | |
| 270 { | |
| 271 ER ercd; | |
| 272 ercd = ref_tsk( &rtsk, 2 ); | |
| 273 CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" ); | |
| 274 CYG_TEST_CHECK( TTS_SUS == rtsk.tskstat, "bad tskstat !TTS_SUS" ); | |
| 275 ercd = dis_dsp(); | |
| 276 CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" ); | |
| 277 ercd = rsm_tsk( 2 ); | |
| 278 CYG_TEST_CHECK( E_OK == ercd, "rsm_tsk bad ercd" ); | |
| 279 ercd = ref_tsk( &rtsk, 2 ); | |
| 280 CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" ); | |
| 281 CYG_TEST_CHECK( TTS_RDY == rtsk.tskstat, "bad tskstat !TTS_RDY" ); | |
| 282 ercd = ena_dsp(); | |
| 283 CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" ); | |
| 284 } | |
| 285 | |
| 286 // ======================================================================== | |
| 287 | |
| 288 #define T1_WAIT (7) | |
| 289 #define T2_WAIT (5) | |
| 290 | |
| 291 #define T1_MALLOC (110) | |
| 2 | 292 #ifdef CYGSEM_KERNEL_MEMORY_COALESCE |
| 0 | 293 #define T2_MALLOC (100) |
| 2 | 294 #else |
| 295 #define T2_MALLOC T1_MALLOC | |
| 296 #endif | |
| 0 | 297 |
| 298 VP vptmp; | |
| 299 VP vp = NULL; | |
| 300 VP vp1 = NULL; | |
| 301 VP t2vp = NULL; | |
| 302 VP t2vp_backup = NULL; | |
| 303 | |
| 304 UINT scratch; | |
| 305 | |
| 306 T_MSG *msg = (T_MSG *)&scratch; | |
| 307 T_MSG *msg1; | |
| 308 | |
| 309 void | |
| 310 do_prep( WAITOP wait ) | |
| 311 { | |
| 312 ER ercd; | |
| 313 switch ( wait ) { | |
| 314 case SLEEP: | |
| 315 case DELAY: | |
| 316 case SEMGET: | |
| 317 case FLAGWAIT: | |
| 318 case MSGGET: | |
| 319 // do nothing for all of those | |
| 320 break; | |
| 321 case MEMFIXEDGET: | |
| 322 // allocate all the memory in the pool; remember a couple | |
| 323 // for freeing as the signalling operation: | |
| 324 t2vp = NULL; | |
| 325 vp = vptmp = NULL; | |
| 326 do { | |
| 327 vp1 = vptmp; | |
| 328 vptmp = vp; | |
| 329 ercd = pget_blf( &vp, 1 ); | |
| 330 } while ( E_OK == ercd ); | |
| 331 CYG_TEST_CHECK( E_TMOUT == ercd, "get_blf bad ercd" ); | |
| 332 CYG_TEST_CHECK( NULL != vp, "no allocated block to free" ); | |
| 333 CYG_TEST_CHECK( NULL != vp1, "no allocated block to free1" ); | |
| 334 break; | |
| 335 case MEMVARGET: | |
| 336 // allocate all the memory in the pool; remember a couple | |
| 337 // for freeing as the signalling operation: | |
| 338 t2vp = NULL; | |
| 339 vp = vptmp = NULL; | |
| 340 do { | |
| 341 vp1 = vptmp; | |
| 342 vptmp = vp; | |
| 343 ercd = pget_blk( &vp, 1, T1_MALLOC ); | |
| 344 } while ( E_OK == ercd ); | |
| 345 CYG_TEST_CHECK( E_TMOUT == ercd, "get_blk bad ercd" ); | |
| 346 CYG_TEST_CHECK( NULL != vp, "no allocated block to free" ); | |
| 347 CYG_TEST_CHECK( NULL != vp1, "no allocated block to free1" ); | |
| 348 break; | |
| 349 default: | |
| 350 CYG_TEST_FAIL( "bad switch" ); | |
| 351 break; | |
| 352 } | |
| 353 } | |
| 354 | |
| 355 void | |
| 356 do_tidyup( WAITOP wait ) | |
| 357 { | |
| 358 ER ercd; | |
| 359 switch ( wait ) { | |
| 360 case SLEEP: | |
| 361 case DELAY: | |
| 362 case SEMGET: | |
| 363 case MSGGET: | |
| 364 // do nothing for all of those | |
| 365 break; | |
| 366 case FLAGWAIT: | |
| 367 // clear the flag variable | |
| 368 ercd = clr_flg( 1, 0 ); | |
| 369 CYG_TEST_CHECK( E_OK == ercd, "clr_flg bad ercd, tidy vp" ); | |
| 370 break; | |
| 371 case MEMFIXEDGET: | |
| 372 if ( NULL != vp ) { | |
| 373 ercd = rel_blf( 1, vp ); | |
| 374 CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd, tidy vp" ); | |
| 375 } | |
| 376 if ( NULL != vp1 ) { | |
| 377 ercd = rel_blf( 1, vp1 ); | |
| 378 CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd, tidy vp1" ); | |
| 379 } | |
| 380 if ( NULL != t2vp ) { | |
| 381 ercd = rel_blf( 1, t2vp ); | |
| 382 CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd, tidy t2vp" ); | |
| 383 } | |
| 384 break; | |
| 385 case MEMVARGET: | |
| 386 if ( NULL != vp ) { | |
| 387 ercd = rel_blk( 1, vp ); | |
| 388 CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd, tidy vp" ); | |
| 389 } | |
| 390 if ( NULL != vp1 ) { | |
| 391 ercd = rel_blk( 1, vp1 ); | |
| 392 CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd, tidy vp1" ); | |
| 393 } | |
| 394 if ( NULL != t2vp ) { | |
| 395 ercd = rel_blk( 1, t2vp ); | |
| 396 CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd, tidy t2vp" ); | |
| 397 } | |
| 398 break; | |
| 399 default: | |
| 400 CYG_TEST_FAIL( "bad switch" ); | |
| 401 break; | |
| 402 } | |
| 403 } | |
| 404 | |
| 405 void | |
| 406 do_recreate( WAITOP wait ) | |
| 407 { | |
| 408 #ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE | |
| 409 static T_CSEM t_csem = { NULL, 0, 0 }; | |
| 410 #endif | |
| 411 #ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE | |
| 412 static T_CMBX t_cmbx = { NULL, 0 }; | |
| 413 #endif | |
| 414 #ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE | |
| 415 static T_CFLG t_cflg = { NULL, 0, 0 }; | |
| 416 #endif | |
| 417 #ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE | |
| 418 static T_CMPF t_cmpf = { NULL, 0, 20, 95 }; | |
| 419 #endif | |
| 420 #ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE | |
| 421 static T_CMPL t_cmpl = { NULL, 0, 2000 }; | |
| 422 #endif | |
| 423 ER ercd = E_OK; | |
| 424 switch ( wait ) { | |
| 425 case SLEEP: | |
| 426 case DELAY: | |
| 427 // do nothing for all of those | |
| 428 break; | |
| 429 case SEMGET: | |
| 430 #ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE | |
| 431 // create the semaphore | |
| 432 ercd = cre_sem( 1, &t_csem ); | |
| 433 CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" ); | |
| 434 #else | |
| 435 CYG_TEST_FAIL( "bad call to do_recreate SEMGET" ); | |
| 436 #endif | |
| 437 break; | |
| 438 case FLAGWAIT: | |
| 439 #ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE | |
| 440 // create the flag | |
| 441 ercd = cre_flg( 1, &t_cflg ); | |
| 442 CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" ); | |
| 443 #else | |
| 444 CYG_TEST_FAIL( "bad call to do_recreate FLAGWAIT" ); | |
| 445 #endif | |
| 446 break; | |
| 447 case MSGGET: | |
| 448 #ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE | |
| 449 // create the mbox | |
| 450 ercd = cre_mbx( 1, &t_cmbx ); | |
| 451 CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" ); | |
| 452 #else | |
| 453 CYG_TEST_FAIL( "bad call to do_recreate MSGGET" ); | |
| 454 #endif | |
| 455 break; | |
| 456 case MEMFIXEDGET: | |
| 457 #ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE | |
| 458 // create the mempool | |
| 459 ercd = cre_mpf( 1, &t_cmpf ); | |
| 460 CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" ); | |
| 461 #else | |
| 462 CYG_TEST_FAIL( "bad call to do_recreate MEMFIXEDGET" ); | |
| 463 #endif | |
| 464 break; | |
| 465 case MEMVARGET: | |
| 466 #ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE | |
| 467 // create the mempool | |
| 468 ercd = cre_mpl( 1, &t_cmpl ); | |
| 469 CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" ); | |
| 470 #else | |
| 471 CYG_TEST_FAIL( "bad call to do_recreate MEMVARGET" ); | |
| 472 #endif | |
| 473 break; | |
| 474 default: | |
| 475 CYG_TEST_FAIL( "bad switch" ); | |
| 476 break; | |
| 477 } | |
| 478 // this is just to use ercd to prevent warnings | |
| 479 CYG_TEST_CHECK( E_OK == ercd, "<blank> bad ercd" ); | |
| 480 } | |
| 481 | |
| 482 | |
| 483 | |
| 484 void | |
| 485 do_signal( WAITOP wait ) | |
| 486 { | |
| 487 ER ercd; | |
| 488 switch ( wait ) { | |
| 489 case SLEEP: | |
| 490 // send a wakeup | |
| 491 ercd = wup_tsk( 2 ); | |
| 492 CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); | |
| 493 break; | |
| 494 case DELAY: | |
| 495 // simply wait for task 2's delay to complete | |
| 496 ercd = dly_tsk( T1_WAIT ); | |
| 497 CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" ); | |
| 498 break; | |
| 499 case SEMGET: | |
| 500 // signal the semaphore | |
| 501 ercd = sig_sem( 1 ); | |
| 502 CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" ); | |
| 503 break; | |
| 504 case FLAGWAIT: | |
| 505 // set the flag bits | |
| 506 ercd = set_flg( 1, 0xff ); | |
| 507 CYG_TEST_CHECK( E_OK == ercd, "set_flg bad ercd" ); | |
| 508 break; | |
| 509 case MSGGET: | |
| 510 // send a message | |
| 511 ercd = snd_msg( 1, msg ); | |
| 512 CYG_TEST_CHECK( E_OK == ercd, "snd_msg bad ercd" ); | |
| 513 break; | |
| 514 case MEMFIXEDGET: | |
| 515 // release a couple of blocks we allocated earlier. I hope. | |
| 516 CYG_TEST_CHECK( NULL != vp, "no allocated block to free" ); | |
| 517 CYG_TEST_CHECK( NULL != vp1, "no allocated block to free1" ); | |
| 518 ercd = rel_blf( 1, vp ); | |
| 519 CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" ); | |
| 520 vp = NULL; | |
| 521 ercd = rel_blf( 1, vp1 ); | |
| 522 CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd1" ); | |
| 523 vp1 = NULL; | |
| 524 break; | |
| 525 case MEMVARGET: | |
| 526 // release a couple of blocks we allocated earlier. I hope. | |
| 527 CYG_TEST_CHECK( NULL != vp, "no allocated block to free" ); | |
| 528 CYG_TEST_CHECK( NULL != vp1, "no allocated block to free1" ); | |
| 529 ercd = rel_blk( 1, vp ); | |
| 530 CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" ); | |
| 531 vp = NULL; | |
| 532 ercd = rel_blk( 1, vp1 ); | |
| 533 CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd1" ); | |
| 534 vp1 = NULL; | |
| 535 break; | |
| 536 default: | |
| 537 CYG_TEST_FAIL( "bad switch" ); | |
| 538 break; | |
| 539 } | |
| 540 } | |
| 541 | |
| 542 void | |
| 543 do_delete( WAITOP wait ) | |
| 544 { | |
| 545 ER ercd = E_OK; | |
| 546 switch ( wait ) { | |
| 547 case SLEEP: | |
| 548 case DELAY: | |
| 549 CYG_TEST_FAIL( "bad call to do_delete( SLEEP or DELAY )" ); | |
| 550 break; | |
| 551 case SEMGET: | |
| 552 #ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE | |
| 553 // delete the semaphore | |
| 554 ercd = del_sem( 1 ); | |
| 555 CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" ); | |
| 556 #else | |
| 557 CYG_TEST_FAIL( "bad call to do_delete( SEMGET )" ); | |
| 558 #endif | |
| 559 break; | |
| 560 case FLAGWAIT: | |
| 561 #ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE | |
| 562 // delete the flag | |
| 563 ercd = del_flg( 1 ); | |
| 564 CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" ); | |
| 565 #else | |
| 566 CYG_TEST_FAIL( "bad call to do_delete( FLAGWAIT )" ); | |
| 567 #endif | |
| 568 break; | |
| 569 case MSGGET: | |
| 570 #ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE | |
| 571 // delete the mbox | |
| 572 ercd = del_mbx( 1 ); | |
| 573 CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" ); | |
| 574 #else | |
| 575 CYG_TEST_FAIL( "bad call to do_delete( MSGGET )" ); | |
| 576 #endif | |
| 577 break; | |
| 578 case MEMFIXEDGET: | |
| 579 #ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE | |
| 580 // delete the mempool | |
| 581 ercd = del_mpf( 1 ); | |
| 582 CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" ); | |
| 583 #else | |
| 584 CYG_TEST_FAIL( "bad call to do_delete( MEMFIXEDGET )" ); | |
| 585 #endif | |
| 586 break; | |
| 587 case MEMVARGET: | |
| 588 #ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE | |
| 589 // delete the mempool | |
| 590 ercd = del_mpl( 1 ); | |
| 591 CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" ); | |
| 592 #else | |
| 593 CYG_TEST_FAIL( "bad call to do_delete( MEMVARGET )" ); | |
| 594 #endif | |
| 595 break; | |
| 596 default: | |
| 597 CYG_TEST_FAIL( "bad switch" ); | |
| 598 break; | |
| 599 } | |
| 600 // this is just to use ercd to prevent warnings | |
| 601 CYG_TEST_CHECK( E_OK == ercd, "<blank> bad ercd" ); | |
| 602 } | |
| 603 | |
| 604 | |
| 605 | |
| 606 ER | |
| 607 do_wait( WAITOP wait, WAITTYPE type ) | |
| 608 { | |
| 609 switch ( wait ) { | |
| 610 case SLEEP: | |
| 611 return ( PLAIN == type ) ? slp_tsk() : tslp_tsk( T2_WAIT ); | |
| 612 case DELAY: | |
| 613 return dly_tsk( T2_WAIT ); // forget the type | |
| 614 case SEMGET: | |
| 615 return ( PLAIN == type ) ? wai_sem( 1 ) : twai_sem( 1, T2_WAIT ); | |
| 616 case FLAGWAIT: | |
| 617 return ( PLAIN == type ) ? | |
| 618 wai_flg( &scratch, 1, 0x55, TWF_ANDW ) : | |
| 619 twai_flg( &scratch, 1, 0xaa, TWF_ANDW, T2_WAIT ); | |
| 620 case MSGGET: | |
| 621 return ( PLAIN == type ) ? | |
| 622 rcv_msg( &msg1, 1 ) : | |
| 623 trcv_msg( &msg1, 1, T2_WAIT ); | |
| 624 case MEMFIXEDGET: | |
| 625 return ( PLAIN == type ) ? | |
| 626 get_blf( &t2vp, 1 ) : | |
| 627 tget_blf( &t2vp, 1, T2_WAIT ); | |
| 628 case MEMVARGET: | |
| 629 return ( PLAIN == type ) ? | |
| 630 get_blk( &t2vp, 1, T2_MALLOC ) : | |
| 631 tget_blk( &t2vp, 1, T2_MALLOC, T2_WAIT ); | |
| 632 default: | |
| 633 CYG_TEST_FAIL( "bad switch" ); | |
| 634 break; | |
| 635 } | |
| 636 CYG_TEST_FAIL( "Bad wait in do_wait" ); | |
| 637 return E_SYS; | |
| 638 } | |
| 639 | |
| 640 // ======================================================================== | |
| 641 void task1( unsigned int arg ) | |
| 642 { | |
| 643 ER ercd; | |
| 644 WAITOP wait; | |
| 645 WAITTYPE type; | |
| 646 KILLOP kill; | |
| 647 | |
| 648 CYG_TEST_INFO( "Task 1 running" ); | |
| 649 | |
| 650 ercd = chg_pri( 1, 8 ); | |
| 651 CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" ); | |
| 652 | |
| 653 for ( wait = START_WAITOP; wait < DONE_WAITOP ; wait++) { | |
| 654 for ( type = START_TYPE; type < DONE_TYPE ; type++ ) { | |
| 655 for ( kill = START_KILLOP; kill < DONE_KILLOP ; kill++ ) { | |
| 656 | |
| 657 // These clauses deal with a couple of special cases: | |
| 658 // [doing it this way helps keep the rest of the code | |
| 659 // nicely general and orthogonal] | |
| 660 // | |
| 661 // 1) DELAY: dly_tsk(): when this times out, the retcode is | |
| 662 // E_OK rather than E_TMOUT, and it always times out. The | |
| 663 // "signalling" method here is just to wait yourself. So we | |
| 664 // do not test DELAY with TIMED type. | |
| 665 // | |
| 666 // 2) PLAIN tests with TIMEOUT kill operations: a PLAIN test | |
| 667 // will not time out, it'll wait forever, so waiting for it | |
| 668 // so to do is pointless; further, we would check for the | |
| 669 // wrong error code. So we do not test PLAIN tests with | |
| 670 // TIMOUT kill operations. | |
| 671 // | |
| 672 // 3) SLEEP or DELAY tests with DELETE operations: there is | |
| 673 // no synchronization to delete in those cases. | |
| 674 // 3a) Individual object types are tested for delete support, | |
| 675 // and if there is none, the test is skipped. | |
| 676 | |
| 677 if ( DELAY == wait && TIMED == type ) | |
| 678 continue; | |
| 679 | |
| 680 if ( PLAIN == type && | |
| 681 ( ( TIMEOUT == kill) || | |
| 682 (SUSPEND_TIMEOUT_RESUME == kill) || | |
| 683 (SUSPEND_TIMEOUT_KILL == kill) ) ) | |
| 684 continue; | |
| 685 | |
| 686 if ( ( | |
| 687 #ifndef CYGPKG_UITRON_SEMAS_CREATE_DELETE | |
| 688 (SEMGET == wait) || | |
| 689 #endif | |
| 690 #ifndef CYGPKG_UITRON_FLAGS_CREATE_DELETE | |
| 691 (FLAGWAIT == wait) || | |
| 692 #endif | |
| 693 #ifndef CYGPKG_UITRON_MBOXES_CREATE_DELETE | |
| 694 (MSGGET == wait) || | |
| 695 #endif | |
| 696 #ifndef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE | |
| 697 (MEMFIXEDGET == wait) || | |
| 698 #endif | |
| 699 #ifndef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE | |
| 700 (MEMVARGET == wait) || | |
| 701 #endif | |
| 702 (SLEEP == wait) || | |
| 703 (DELAY == wait) | |
| 704 ) && | |
| 705 ((DELETE == kill) || | |
| 706 (SUSPEND_DELETE_RESUME == kill) || | |
| 707 (SUSPEND_DELETE_KILL == kill)) ) | |
| 708 continue; | |
| 709 | |
| 710 | |
| 711 CYG_TEST_INFO( makemsg( "T1: ", wait, type, kill ) ); | |
| 712 | |
| 713 intercom = 0; | |
| 714 | |
| 715 // prepare the synchronization objects | |
| 716 // (actually, just empty the mempools) | |
| 717 do_prep( wait ); | |
| 718 | |
| 719 // start task 2 at a higher priority than myself | |
| 720 ercd = dis_dsp(); | |
| 721 CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" ); | |
| 722 ercd = sta_tsk( 2, task2arg( wait, type, kill ) ); | |
| 723 CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" ); | |
| 724 ercd = chg_pri( 2, 5 ); | |
| 725 CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" ); | |
| 726 ercd = ena_dsp(); | |
| 727 CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" ); | |
| 728 // task 2 should run now, until it waits. | |
| 729 | |
| 730 ercd = ref_tsk( &rtsk, 2 ); | |
| 731 CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" ); | |
| 732 CYG_TEST_CHECK( TTS_WAI == rtsk.tskstat, "bad tskstat" ); | |
| 733 CYG_TEST_CHECK( 5 == rtsk.tskpri, "bad tskpri" ); | |
| 734 | |
| 735 switch ( kill ) { | |
| 736 case SIGNAL: | |
| 737 // signal the task appropriately | |
| 738 do_signal( wait ); | |
| 739 // it should now have run to completion | |
| 740 break; | |
| 741 case TIMEOUT: | |
| 742 // wait for the timeout to occur | |
| 743 ercd = dly_tsk( T1_WAIT ); | |
| 744 CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" ); | |
| 745 // it should now have run to completion | |
| 746 break; | |
| 747 case RELEASE: | |
| 748 // hit the task with a release-wait | |
| 749 ercd = rel_wai( 2 ); | |
| 750 CYG_TEST_CHECK( E_OK == ercd, "rel_wai bad ercd" ); | |
| 751 // it should now have run to completion | |
| 752 break; | |
| 753 case DELETE: | |
| 754 // delete the object appropriately | |
| 755 do_delete( wait ); | |
| 756 // it should now have run to completion | |
| 757 break; | |
| 758 case KILL: | |
| 759 // kill the task | |
| 760 ercd = ter_tsk( 2 ); | |
| 761 CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" ); | |
| 762 // it should now have terminated without running | |
| 763 break; | |
| 764 case SUSPEND_SIGNAL_RESUME: | |
| 765 // suspend the task | |
| 766 do_suspend(); | |
| 767 // signal the task appropriately | |
| 768 do_signal( wait ); | |
| 769 // resume the task | |
| 770 do_resume(); | |
| 771 // it should now have run to completion | |
| 772 break; | |
| 773 case SUSPEND_TIMEOUT_RESUME: | |
| 774 // suspend the task | |
| 775 do_suspend(); | |
| 776 // wait for the timeout to occur | |
| 777 ercd = dly_tsk( T1_WAIT ); | |
| 778 CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" ); | |
| 779 // resume the task | |
| 780 do_resume(); | |
| 781 // it should now have run to completion | |
| 782 break; | |
| 783 case SUSPEND_RELEASE_RESUME: | |
| 784 // suspend the task | |
| 785 do_suspend(); | |
| 786 // hit the task with a release-wait | |
| 787 ercd = rel_wai( 2 ); | |
| 788 CYG_TEST_CHECK( E_OK == ercd, "rel_wai bad ercd" ); | |
| 789 // resume the task | |
| 790 do_resume(); | |
| 791 // it should now have run to completion | |
| 792 break; | |
| 793 case SUSPEND_DELETE_RESUME: | |
| 794 // suspend the task | |
| 795 do_suspend(); | |
| 796 // delete the object appropriately | |
| 797 do_delete( wait ); | |
| 798 // resume the task | |
| 799 do_resume(); | |
| 800 // it should now have run to completion | |
| 801 break; | |
| 802 case SUSPEND_KILL: | |
| 803 // suspend the task | |
| 804 do_suspend(); | |
| 805 // kill the task | |
| 806 ercd = ter_tsk( 2 ); | |
| 807 CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" ); | |
| 808 // it should now have terminated without running | |
| 809 break; | |
| 810 case SUSPEND_SIGNAL_KILL: | |
| 811 // suspend the task | |
| 812 do_suspend(); | |
| 813 // signal the task appropriately | |
| 814 do_signal( wait ); | |
| 815 // kill the task | |
| 816 ercd = ter_tsk( 2 ); | |
| 817 CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" ); | |
| 818 // it should now have terminated without running | |
| 819 break; | |
| 820 case SUSPEND_TIMEOUT_KILL: | |
| 821 // suspend the task | |
| 822 do_suspend(); | |
| 823 // wait for the timeout to occur | |
| 824 ercd = dly_tsk( T1_WAIT ); | |
| 825 CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" ); | |
| 826 // kill the task | |
| 827 ercd = ter_tsk( 2 ); | |
| 828 CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" ); | |
| 829 // it should now have terminated without running | |
| 830 break; | |
| 831 case SUSPEND_RELEASE_KILL: | |
| 832 // suspend the task | |
| 833 do_suspend(); | |
| 834 // hit the task with a release-wait | |
| 835 ercd = rel_wai( 2 ); | |
| 836 CYG_TEST_CHECK( E_OK == ercd, "rel_wai bad ercd" ); | |
| 837 // kill the task | |
| 838 ercd = ter_tsk( 2 ); | |
| 839 CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" ); | |
| 840 // it should now have terminated without running | |
| 841 break; | |
| 842 case SUSPEND_DELETE_KILL: | |
| 843 // suspend the task | |
| 844 do_suspend(); | |
| 845 // delete the object appropriately | |
| 846 do_delete( wait ); | |
| 847 // kill the task | |
| 848 ercd = ter_tsk( 2 ); | |
| 849 CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" ); | |
| 850 // it should now have terminated without running | |
| 851 break; | |
| 852 default: | |
| 853 CYG_TEST_FAIL( "bad switch" ); | |
| 854 break; | |
| 855 } | |
| 856 | |
| 857 // task 2 should be dormant now, however it got there | |
| 858 ercd = ref_tsk( &rtsk, 2 ); | |
| 859 CYG_TEST_CHECK( E_OK == ercd, "ref_tsk bad ercd" ); | |
| 860 CYG_TEST_CHECK( TTS_DMT == rtsk.tskstat, "bad tskstat" ); | |
| 861 | |
| 862 if ( (SUSPEND_SIGNAL_KILL == kill) && | |
| 863 ((MEMFIXEDGET == wait) || (MEMVARGET == wait)) ) { | |
| 864 // it was a killed successful memory alloc, so we have | |
| 865 // lost the pointer to memory allocated; there is an | |
| 866 // implicit storeleak problem when the task trying | |
| 867 // to allocate is signalled then killed. | |
| 868 // Recreate the pointer from an old version: | |
| 869 CYG_TEST_CHECK( NULL == t2vp, "t2vp WAS allocated!" ); | |
| 870 t2vp = t2vp_backup; | |
| 871 } | |
| 872 | |
| 873 switch ( kill ) { | |
| 874 case KILL: | |
| 875 case SUSPEND_KILL: | |
| 876 case SUSPEND_SIGNAL_KILL: | |
| 877 case SUSPEND_TIMEOUT_KILL: | |
| 878 case SUSPEND_RELEASE_KILL: | |
| 879 case SUSPEND_DELETE_KILL: | |
| 880 // if task 2 was killed, expect only one increment | |
| 881 CYG_TEST_CHECK( 1 == intercom, "intercom bad value !1" ); | |
| 882 break; | |
| 883 default: | |
| 884 // otherwise expect two increments | |
| 885 CYG_TEST_CHECK( 2 == intercom, "intercom bad value !2" ); | |
| 886 break; | |
| 887 } | |
| 888 | |
| 889 // tidy up or recreate the synchronization objects | |
| 890 if ( (DELETE == kill) || | |
| 891 (SUSPEND_DELETE_RESUME == kill) || | |
| 892 (SUSPEND_DELETE_KILL == kill) ) | |
| 893 do_recreate( wait ); | |
| 894 else | |
| 895 do_tidyup( wait ); | |
| 896 } | |
| 897 } | |
| 898 } | |
| 899 CYG_TEST_PASS("synchronization interaction tests"); | |
| 900 | |
| 901 // all done | |
| 902 CYG_TEST_EXIT( "All done" ); | |
| 903 ext_tsk(); | |
| 904 } | |
| 905 | |
| 906 | |
| 907 | |
| 908 void task2( unsigned int arg ) | |
| 909 { | |
| 910 ER ercd; | |
| 911 WAITOP wait; | |
| 912 WAITTYPE waittype; | |
| 913 KILLOP kill; | |
| 914 | |
| 915 decodearg( arg, &wait, &waittype, &kill ); | |
| 916 | |
| 917 // CYG_TEST_INFO( makemsg( " 2: ", wait, waittype, kill ) ); | |
| 918 | |
| 919 intercom++; | |
| 920 ercd = do_wait( wait, waittype ); | |
| 921 intercom++; | |
| 922 | |
| 923 switch ( kill ) { | |
| 924 case SIGNAL: | |
| 925 case SUSPEND_SIGNAL_RESUME: | |
| 926 // we expect to have been signalled correctly | |
| 927 CYG_TEST_CHECK( E_OK == ercd, "T2 wait bad ercd" ); | |
| 928 // here we know that the op completed OK | |
| 929 if ( (MEMFIXEDGET == wait) || (MEMVARGET == wait) ) { | |
| 930 // it was a successful memory alloc of whichever type, | |
| 931 // so we can save away a copy of t2vp for working round an | |
| 932 // implicit storeleak problem when the task trying to allocate | |
| 933 // is signalled then killed: | |
| 934 CYG_TEST_CHECK( NULL != t2vp, "No t2vp allocated!" ); | |
| 935 t2vp_backup = t2vp; | |
| 936 } | |
| 937 break; | |
| 938 case TIMEOUT: | |
| 939 case SUSPEND_TIMEOUT_RESUME: | |
| 940 // we expect to have timed out - if it's a timeout op. | |
| 941 CYG_TEST_CHECK( E_TMOUT == ercd, "T2 timeout bad ercd, !E_TMOUT" ); | |
| 942 break; | |
| 943 case RELEASE: | |
| 944 case SUSPEND_RELEASE_RESUME: | |
| 945 // we expect to have suffered a release wait. | |
| 946 CYG_TEST_CHECK( E_RLWAI == ercd, "T2 release bad ercd, !E_RLWAI" ); | |
| 947 break; | |
| 948 case DELETE: | |
| 949 case SUSPEND_DELETE_RESUME: | |
| 950 // we expect to be told the object is gone | |
| 951 CYG_TEST_CHECK( E_DLT == ercd, "T2 release bad ercd, !E_DLT" ); | |
| 952 break; | |
| 953 case KILL: | |
| 954 case SUSPEND_KILL: | |
| 955 case SUSPEND_SIGNAL_KILL: | |
| 956 case SUSPEND_TIMEOUT_KILL: | |
| 957 case SUSPEND_RELEASE_KILL: | |
| 958 case SUSPEND_DELETE_KILL: | |
| 959 // we expect to have been killed here, ie. this won't execute! | |
| 960 CYG_TEST_FAIL( "Task 2 ran to completion!" ); | |
| 961 break; | |
| 962 default: | |
| 963 CYG_TEST_FAIL( "bad switch" ); | |
| 964 break; | |
| 965 } | |
| 966 } | |
| 967 | |
| 968 void task3( unsigned int arg ) | |
| 969 { | |
| 970 } | |
| 971 | |
| 972 void task4( unsigned int arg ) | |
| 973 { | |
| 974 } | |
| 975 | |
| 976 #else // not enough (or too many) uITRON objects configured in | |
| 977 #define N_A_MSG "not enough uITRON objects to run test" | |
| 978 #endif // not enough (or too many) uITRON objects configured in | |
| 979 #else // not C++ and some C++ specific options enabled | |
| 980 #define N_A_MSG "C++ specific options selected but this is C" | |
| 981 #endif // not C++ and some C++ specific options enabled | |
| 982 #else // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it | |
| 983 #define N_A_MSG "no CYGVAR_KERNEL_COUNTERS_CLOCK" | |
| 984 #endif // ! CYGVAR_KERNEL_COUNTERS_CLOCK - can't test without it | |
| 985 #else // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it | |
| 986 #define N_A_MSG "no CYGFUN_KERNEL_THREADS_TIMER" | |
| 987 #endif // ! CYGFUN_KERNEL_THREADS_TIMER - can't test without it | |
| 988 #else // ! CYGIMP_THREAD_PRIORITY - can't test without it | |
| 989 #define N_A_MSG "no CYGSEM_KERNEL_SCHED_MLQUEUE" | |
| 990 #endif // ! CYGSEM_KERNEL_SCHED_MLQUEUE - can't test without it | |
| 991 #else // ! CYGPKG_UITRON | |
| 992 #define N_A_MSG "uITRON Compatibility layer disabled" | |
| 993 #endif // CYGPKG_UITRON | |
| 994 | |
| 995 #ifdef N_A_MSG | |
| 996 void | |
| 997 cyg_start( void ) | |
| 998 { | |
| 999 CYG_TEST_INIT(); | |
| 2 | 1000 CYG_TEST_NA( N_A_MSG ); |
| 0 | 1001 } |
| 1002 #endif // N_A_MSG defined ie. we are N/A. | |
| 1003 | |
| 1004 // EOF test7.c |
