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