Changeset 99e7ab89 in rtems
- Timestamp:
- 01/05/00 17:21:12 (24 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- f388d36
- Parents:
- b302d527
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/tests/psxtests/psxmsgq01/init.c
rb302d527 r99e7ab89 36 36 } 37 37 38 typedef enum { 39 DEFAULT_SIZE_TYPE, 40 TEST_SIZE_TYPE, 41 MAX_SIZE, 42 TYPES_OF_TEST_SIZES 43 } TEST_MQ_SIZE_TYPES; 44 45 38 46 /* 39 47 * Opens CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES then leaves size queues … … 66 74 attr.mq_maxmsg = -1; 67 75 puts( "mq_open - Create with maxmsg (-1) (EINVAL)" ); 68 n_mq2 = mq_open("mq2", O_CREAT , O_RDONLY, &attr);76 n_mq2 = mq_open("mq2", O_CREAT | O_RDONLY, 0x777, &attr); 69 77 fatal_directive_status( 70 78 (int) n_mq2, (int ) (-1), "mq_open error return status" ); … … 73 81 attr.mq_msgsize = -1; 74 82 puts( "mq_open - Create with msgsize (-1) (EINVAL)" ); 75 n_mq2 = mq_open("mq2", O_CREAT , O_RDONLY, &attr);83 n_mq2 = mq_open("mq2", O_CREAT | O_RDONLY, 0x777, &attr); 76 84 fatal_directive_status( 77 85 (int) n_mq2, (int ) (-1), "mq_open error return status" ); 78 86 fatal_directive_status( errno, EINVAL, "mq_open errno EINVAL"); 79 87 80 81 88 puts( "mq_open - Open new mq without create flag (ENOENT)" ); 82 n_mq2 = mq_open("mq3", O_EXCL , O_RDONLY, NULL);89 n_mq2 = mq_open("mq3", O_EXCL | O_RDONLY, 0x777, NULL); 83 90 fatal_directive_status( 84 91 (int) n_mq2, (int ) (-1), "mq_open error return status" ); … … 95 102 96 103 puts( "mq_open - Open with too long of a name (ENAMETOOLONG)" ); 97 n_mq2 = mq_open( Get_Too_Long_Name(), O_CREAT , O_RDONLY, NULL );104 n_mq2 = mq_open( Get_Too_Long_Name(), O_CREAT | O_RDONLY, 0x777, NULL ); 98 105 fatal_directive_status( 99 106 (int) n_mq2, (int ) (-1), "mq_open error return status" ); … … 106 113 puts( "mq_open - SUCCESSFUL" ); 107 114 for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES; i++) { 108 mqs[i] = mq_open( Get_Queue_Name(i), O_CREAT , O_RDONLY, NULL );115 mqs[i] = mq_open( Get_Queue_Name(i), O_CREAT | O_RDWR, 0x777, NULL ); 109 116 assert( mqs[i] != (-1) ); 110 117 /*XXX - Isn't there a more general check */ … … 126 133 * XXX EACCES - queue exists permissions specified by o_flag are denied. 127 134 puts( "mq_open - open mq as write (EACCES)" ); 128 n_mq2 = mq_open("mq1", O_CREAT , O_WRONLY, NULL);135 n_mq2 = mq_open("mq1", O_CREAT | O_WRONLY, 0x777, NULL); 129 136 fatal_directive_status( 130 137 (int) n_mq2, (int ) (-1), "mq_open error return status" ); … … 133 140 134 141 puts( "mq_open - Create an Existing mq (EEXIST)" ); 135 n_mq2 = mq_open("mq1", O_CREAT | O_EXCL , O_RDONLY, NULL);142 n_mq2 = mq_open("mq1", O_CREAT | O_EXCL | O_RDONLY, 0x777, NULL); 136 143 fatal_directive_status( 137 144 (int) n_mq2, (int ) (-1), "mq_open error return status" ); … … 144 151 145 152 puts( "mq_open - system is out of resources (ENFILE)" ); 146 n_mq2 = mq_open( Get_Queue_Name(i), O_CREAT , O_RDONLY, NULL );153 n_mq2 = mq_open( Get_Queue_Name(i), O_CREAT | O_RDONLY, 0x777, NULL ); 147 154 fatal_directive_status( 148 155 (int) n_mq2, (int ) (-1), "mq_open error return status" ); … … 165 172 166 173 void validate_mq_unlink_error_codes( 167 mqd_t *mqs, /* Must be large enough for Maximum to be opened. */168 int size /* Number still open */174 mqd_t *mqs, 175 int size /* Number still open in mqs */ 169 176 ) 170 177 { … … 178 185 * XXX ENAMETOOLONG - Not checked in either sem_unlink or mq_unlink is 179 186 * this an error? 180 for ( i=0; i< PATH_MAX+1; i++ ) 181 name[i] = 'N'; 182 puts( "mq_open - Open with too long of a name (ENAMETOOLONG)" ); 183 n_mq2 = mq_open( Get_Too_Long_Name(), O_CREAT, O_RDONLY, NULL ); 184 fatal_directive_status( 185 (int) n_mq2, (int ) (-1), "mq_open error return status" ); 186 fatal_directive_status( errno, ENAMETOOLONG, "mq_open errno ENAMETOOLONG"); 187 */ 187 */ 188 189 puts( "mq_unlink - mq_unlink with too long of a name (ENAMETOOLONG)" ); 190 status = mq_unlink( Get_Too_Long_Name() ); 191 fatal_directive_status( status, -1, "mq_unlink error return status"); 192 fatal_directive_status( errno, ENAMETOOLONG, "mq_unlink errno ENAMETOOLONG"); 188 193 189 194 puts( "mq_unlink - UNSUCCESSFUL (ENOENT)" ); … … 191 196 fatal_directive_status( status, -1, "mq_unlink error return status"); 192 197 fatal_directive_status( errno, ENOENT, "mq_unlink errno ENOENT"); 198 199 /* 200 * XXX - These errors are not in the POSIX manual but may occur. 201 */ 202 203 puts( "mq_unlink (NULL) - EINVAL" ); 204 status = mq_unlink( NULL ); 205 fatal_directive_status( status, -1, "mq_unlink error return status"); 206 fatal_directive_status( errno, EINVAL, "mq_unlink errno value"); 207 208 puts( "mq_unlink (\"\") - EINVAL" ); 209 status = mq_unlink( "" ); 210 fatal_directive_status( status, -1, "mq_unlink error return status"); 211 fatal_directive_status( errno, EINVAL, "mq_unlink errno value"); 193 212 } 194 213 195 214 void validate_mq_close_error_codes( 196 mqd_t *mqs, /* Must be large enough for Maximum to be opened. */197 int size /* Number still open */215 mqd_t *mqs, 216 int size /* Number still open in mqs */ 198 217 ) 199 218 { … … 204 223 fatal_directive_status( status, -1, "mq_close error return status"); 205 224 fatal_directive_status( errno, EBADF, "mq_close errno EBADF"); 206 225 } 226 227 /* 228 * Returns the number of messages queued after the test on the 229 * first queue. 230 */ 231 232 int validate_mq_send_error_codes( 233 mqd_t *mqs, 234 int size /* Number still open in mqs */ 235 ) 236 { 237 int status; 238 int i; 239 mqd_t n_mq1; 240 struct mq_attr attr; 241 242 attr.mq_maxmsg = 3; 243 attr.mq_msgsize = 8; 244 245 /* 246 * XXX - EBADF Not a valid message descriptor. 247 * Write to a invalid message descriptor 248 * XXX - Write to a read only queue 249 */ 250 251 puts( "mq_send - Closed message queue (EBADF)" ); 252 status = mq_send( mqs[size], "", 1, 0 ); 253 fatal_directive_status( status, -1, "mq_send error return status"); 254 fatal_directive_status( errno, EBADF, "mq_send errno EBADF"); 255 256 puts( "mq_open - Open a read only queue" ); 257 n_mq1 = mq_open("read_only", O_CREAT | O_RDONLY, 0x777, &attr); 258 assert( n_mq1 != (-1) ); 259 /*XXX - Isn't there a more general check */ 260 261 puts( "mq_send - Read only message queue (EBADF)" ); 262 status = mq_send( n_mq1, "", 1, 0 ); 263 fatal_directive_status( status, -1, "mq_send error return status"); 264 fatal_directive_status( errno, EBADF, "mq_send errno EBADF"); 265 266 status = mq_close( n_mq1 ); 267 fatal_directive_status( status, 0, "mq_close message queue"); 268 269 status = mq_unlink( "read_only" ); 270 fatal_directive_status( status, 0, "mq_unlink message queue"); 271 272 /* 273 * XXX - EINTR 274 * Signal interrupted the call. 275 276 puts( "mq_send - UNSUCCESSFUL (EINTR)" ); 277 status = mq_send( mqs, "", 0xffff, 0 ); 278 fatal_directive_status( status, -1, "mq_send error return status"); 279 fatal_directive_status( errno, E, "mq_send errno E"); 280 */ 281 282 /* 283 * XXX - EINVAL priority is out of range. 284 */ 285 286 puts( "mq_send - Priority out of range (EINVAL)" ); 287 status = mq_send( mqs[0], "", 1, MQ_PRIO_MAX + 1 ); 288 fatal_directive_status( status, -1, "mq_send error return status"); 289 fatal_directive_status( errno, EINVAL, "mq_send errno EINVAL"); 290 291 /* 292 * XXX - EMSGSIZE - Message size larger than msg_len 293 */ 294 295 puts( "mq_send - Message longer than msg_len (EMSGSIZE)" ); 296 status = mq_send( mqs[0], "", 0xffff, 0 ); 297 fatal_directive_status( status, -1, "mq_send error return status"); 298 fatal_directive_status( errno, EMSGSIZE, "mq_send errno EMSGSIZE"); 299 300 /* 301 * ENOSYS - send is supported should never happen. 302 */ 303 304 305 /* 306 * XXX - EAGAIN 307 * O_NONBLOCK and message queue is full. 308 * This is validated in the read/write test. 309 */ 310 311 i=0; 312 do { 313 status = mq_send( mqs[0], "", 1, 0 ); 314 i++; 315 } while (status == 0); 316 fatal_directive_status( status, -1, "mq_send error return status"); 317 fatal_directive_status( errno, EAGAIN, "mq_send errno EAGAIN"); 318 319 return i-1; 320 } 321 322 void validate_mq_receive_error_codes( 323 mqd_t *mqs, 324 int size /* Number still open in mqs */ 325 ) 326 { 327 int status; 328 329 /* 330 * EAGAIN - 331 */ 332 333 /* 334 * EBADF - 335 */ 336 337 /* 338 * EMSGSIZE - 339 */ 340 341 /* 342 * EINTR - 343 */ 344 345 /* 346 * EBADMSG - a data corruption problem. 347 * XXX - Can not cause. 348 */ 349 350 /* 351 puts( "mq_ - UNSUCCESSFUL ()" ); 352 status = mq_( ); 353 fatal_directive_status( status, -1, "mq_ error return status"); 354 fatal_directive_status( errno, E, "mq_c errno E"); 355 356 */ 357 /* 358 * ENOSYS - 359 */ 360 361 } 362 363 void non_blocking_mq_read_write( 364 mqd_t *mqs, 365 int size /* Number still open in mqs */ 366 ) 367 { 368 /* 369 int status; 370 char *messages[] = { 371 "Msg 1", 372 "Test 2", 373 "12345678901234567890" 374 }; 375 376 status = mq_send( mqs[0], messages[0], strlen( messages[0] ), 0 ); 377 fatal_directive_status( status, 0, "mq_send error return status" ); 378 379 puts( "mq_send - UNSUCCESSFUL ()" ); 380 do { 381 status = mq_send( ); 382 fatal_directive_status( status, -1, "mq_send error return status"); 383 fatal_directive_status( errno, E, "mq_send errno E"); 384 } 385 */ 207 386 } 208 387 … … 212 391 { 213 392 int status; 214 int value;215 int i;216 393 mqd_t mqs[CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES]; 217 mqd_t mq2;218 394 mqd_t n_mq1; 219 395 mqd_t n_mq2; 220 struct timespec waittime; 221 char failure_msg[80]; 222 struct mq_attr attr; 396 char *messages[] = { 397 "Msg 1", 398 "Test 2", 399 "12345678901234567890" 400 }; 223 401 224 402 puts( "\n\n*** POSIX MESSAGE QUEUE TEST ***" ); … … 228 406 validate_mq_close_error_codes( mqs, 2 ); 229 407 408 validate_mq_send_error_codes( mqs, 2 ); 409 validate_mq_receive_error_codes( mqs, 2 ); 410 411 230 412 /* 231 413 * Validate a second open returns the same message queue. … … 233 415 234 416 puts( "mq_open - Open an existing mq ( same id )" ); 235 n_mq 2= mq_open("mq1", 0 );236 fatal_directive_status( 237 (int) n_mq 2, (int ) mqs[0], "mq_open error return status" );417 n_mq1 = mq_open("mq1", 0 ); 418 fatal_directive_status( 419 (int) n_mq1, (int ) mqs[0], "mq_open error return status" ); 238 420 239 421 /* … … 252 434 253 435 /* 254 * Validate it n_mq2 (the last open for mq1 name can be 255 * correctly closed and unlinked. 256 */ 257 258 puts( "Init: mq_unlink - mq1 (2) SUCCESSFUL" ); 436 * Validate it "mq1" can be closed and unlinked. 437 */ 438 439 puts( "mq_unlink - mq1 SUCCESSFUL" ); 259 440 status = mq_unlink( "mq1" ); 260 441 fatal_directive_status( status, 0, "mq_unlink locked message queue"); 261 442 262 puts( " Init: mq_close (2)- SUCCESSFUL" );443 puts( "mq_close mq1 - SUCCESSFUL" ); 263 444 status = mq_close( n_mq2 ); 264 445 fatal_directive_status( status, 0, "mq_close message queue"); 265 266 267 puts( "Init: mq_unlink - UNSUCCESSFUL (ENOENT)" ); 446 status = mq_close( n_mq1 ); 447 fatal_directive_status( status, 0, "mq_close message queue"); 448 status = mq_close( mqs[0] ); 449 fatal_directive_status( status, 0, "mq_close message queue"); 450 451 puts( "mq_unlink - UNSUCCESSFUL (ENOENT)" ); 268 452 status = mq_unlink("mq1"); 269 453 fatal_directive_status( status, -1, "mq_unlink error return status"); 270 454 fatal_directive_status( errno, ENOENT, "mq_close errno EINVAL"); 271 272 273 /*274 * Validate we can unlink (2)275 */276 277 puts( "Init: mq_unlink (NULL) - EINVAL" );278 status = mq_unlink( NULL );279 fatal_directive_status( status, -1, "mq_unlink error return status");280 fatal_directive_status( errno, EINVAL, "mq_unlink errno value");281 282 puts( "Init: mq_unlink (\"\") - EINVAL" );283 status = mq_unlink( "" );284 fatal_directive_status( status, -1, "mq_unlink error return status");285 fatal_directive_status( errno, EINVAL, "mq_unlink errno value");286 455 287 456 /* 288 457 * XXX - Cant' create location OBJECTS_ERROR or OBJECTS_REMOTE. 289 458 * mq_close and mq_unlink. 290 */ 291 459 * XXX - Don't think we need this save until yellow line tested. 292 460 puts( "Init: mq_unlink - UNSUCCESSFUL (ENOENT)" ); 293 461 status = mq_unlink("mq3"); … … 295 463 fatal_directive_status( errno, ENOENT, "mq_unlink errno ENOENT"); 296 464 assert( (status == -1) && (errno == ENOENT) ); 297 465 */ 298 466 299 467 … … 313 481 return NULL; /* just so the compiler thinks we returned something */ 314 482 } 483 484 -
testsuites/psxtests/psxmsgq01/init.c
rb302d527 r99e7ab89 36 36 } 37 37 38 typedef enum { 39 DEFAULT_SIZE_TYPE, 40 TEST_SIZE_TYPE, 41 MAX_SIZE, 42 TYPES_OF_TEST_SIZES 43 } TEST_MQ_SIZE_TYPES; 44 45 38 46 /* 39 47 * Opens CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES then leaves size queues … … 66 74 attr.mq_maxmsg = -1; 67 75 puts( "mq_open - Create with maxmsg (-1) (EINVAL)" ); 68 n_mq2 = mq_open("mq2", O_CREAT , O_RDONLY, &attr);76 n_mq2 = mq_open("mq2", O_CREAT | O_RDONLY, 0x777, &attr); 69 77 fatal_directive_status( 70 78 (int) n_mq2, (int ) (-1), "mq_open error return status" ); … … 73 81 attr.mq_msgsize = -1; 74 82 puts( "mq_open - Create with msgsize (-1) (EINVAL)" ); 75 n_mq2 = mq_open("mq2", O_CREAT , O_RDONLY, &attr);83 n_mq2 = mq_open("mq2", O_CREAT | O_RDONLY, 0x777, &attr); 76 84 fatal_directive_status( 77 85 (int) n_mq2, (int ) (-1), "mq_open error return status" ); 78 86 fatal_directive_status( errno, EINVAL, "mq_open errno EINVAL"); 79 87 80 81 88 puts( "mq_open - Open new mq without create flag (ENOENT)" ); 82 n_mq2 = mq_open("mq3", O_EXCL , O_RDONLY, NULL);89 n_mq2 = mq_open("mq3", O_EXCL | O_RDONLY, 0x777, NULL); 83 90 fatal_directive_status( 84 91 (int) n_mq2, (int ) (-1), "mq_open error return status" ); … … 95 102 96 103 puts( "mq_open - Open with too long of a name (ENAMETOOLONG)" ); 97 n_mq2 = mq_open( Get_Too_Long_Name(), O_CREAT , O_RDONLY, NULL );104 n_mq2 = mq_open( Get_Too_Long_Name(), O_CREAT | O_RDONLY, 0x777, NULL ); 98 105 fatal_directive_status( 99 106 (int) n_mq2, (int ) (-1), "mq_open error return status" ); … … 106 113 puts( "mq_open - SUCCESSFUL" ); 107 114 for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES; i++) { 108 mqs[i] = mq_open( Get_Queue_Name(i), O_CREAT , O_RDONLY, NULL );115 mqs[i] = mq_open( Get_Queue_Name(i), O_CREAT | O_RDWR, 0x777, NULL ); 109 116 assert( mqs[i] != (-1) ); 110 117 /*XXX - Isn't there a more general check */ … … 126 133 * XXX EACCES - queue exists permissions specified by o_flag are denied. 127 134 puts( "mq_open - open mq as write (EACCES)" ); 128 n_mq2 = mq_open("mq1", O_CREAT , O_WRONLY, NULL);135 n_mq2 = mq_open("mq1", O_CREAT | O_WRONLY, 0x777, NULL); 129 136 fatal_directive_status( 130 137 (int) n_mq2, (int ) (-1), "mq_open error return status" ); … … 133 140 134 141 puts( "mq_open - Create an Existing mq (EEXIST)" ); 135 n_mq2 = mq_open("mq1", O_CREAT | O_EXCL , O_RDONLY, NULL);142 n_mq2 = mq_open("mq1", O_CREAT | O_EXCL | O_RDONLY, 0x777, NULL); 136 143 fatal_directive_status( 137 144 (int) n_mq2, (int ) (-1), "mq_open error return status" ); … … 144 151 145 152 puts( "mq_open - system is out of resources (ENFILE)" ); 146 n_mq2 = mq_open( Get_Queue_Name(i), O_CREAT , O_RDONLY, NULL );153 n_mq2 = mq_open( Get_Queue_Name(i), O_CREAT | O_RDONLY, 0x777, NULL ); 147 154 fatal_directive_status( 148 155 (int) n_mq2, (int ) (-1), "mq_open error return status" ); … … 165 172 166 173 void validate_mq_unlink_error_codes( 167 mqd_t *mqs, /* Must be large enough for Maximum to be opened. */168 int size /* Number still open */174 mqd_t *mqs, 175 int size /* Number still open in mqs */ 169 176 ) 170 177 { … … 178 185 * XXX ENAMETOOLONG - Not checked in either sem_unlink or mq_unlink is 179 186 * this an error? 180 for ( i=0; i< PATH_MAX+1; i++ ) 181 name[i] = 'N'; 182 puts( "mq_open - Open with too long of a name (ENAMETOOLONG)" ); 183 n_mq2 = mq_open( Get_Too_Long_Name(), O_CREAT, O_RDONLY, NULL ); 184 fatal_directive_status( 185 (int) n_mq2, (int ) (-1), "mq_open error return status" ); 186 fatal_directive_status( errno, ENAMETOOLONG, "mq_open errno ENAMETOOLONG"); 187 */ 187 */ 188 189 puts( "mq_unlink - mq_unlink with too long of a name (ENAMETOOLONG)" ); 190 status = mq_unlink( Get_Too_Long_Name() ); 191 fatal_directive_status( status, -1, "mq_unlink error return status"); 192 fatal_directive_status( errno, ENAMETOOLONG, "mq_unlink errno ENAMETOOLONG"); 188 193 189 194 puts( "mq_unlink - UNSUCCESSFUL (ENOENT)" ); … … 191 196 fatal_directive_status( status, -1, "mq_unlink error return status"); 192 197 fatal_directive_status( errno, ENOENT, "mq_unlink errno ENOENT"); 198 199 /* 200 * XXX - These errors are not in the POSIX manual but may occur. 201 */ 202 203 puts( "mq_unlink (NULL) - EINVAL" ); 204 status = mq_unlink( NULL ); 205 fatal_directive_status( status, -1, "mq_unlink error return status"); 206 fatal_directive_status( errno, EINVAL, "mq_unlink errno value"); 207 208 puts( "mq_unlink (\"\") - EINVAL" ); 209 status = mq_unlink( "" ); 210 fatal_directive_status( status, -1, "mq_unlink error return status"); 211 fatal_directive_status( errno, EINVAL, "mq_unlink errno value"); 193 212 } 194 213 195 214 void validate_mq_close_error_codes( 196 mqd_t *mqs, /* Must be large enough for Maximum to be opened. */197 int size /* Number still open */215 mqd_t *mqs, 216 int size /* Number still open in mqs */ 198 217 ) 199 218 { … … 204 223 fatal_directive_status( status, -1, "mq_close error return status"); 205 224 fatal_directive_status( errno, EBADF, "mq_close errno EBADF"); 206 225 } 226 227 /* 228 * Returns the number of messages queued after the test on the 229 * first queue. 230 */ 231 232 int validate_mq_send_error_codes( 233 mqd_t *mqs, 234 int size /* Number still open in mqs */ 235 ) 236 { 237 int status; 238 int i; 239 mqd_t n_mq1; 240 struct mq_attr attr; 241 242 attr.mq_maxmsg = 3; 243 attr.mq_msgsize = 8; 244 245 /* 246 * XXX - EBADF Not a valid message descriptor. 247 * Write to a invalid message descriptor 248 * XXX - Write to a read only queue 249 */ 250 251 puts( "mq_send - Closed message queue (EBADF)" ); 252 status = mq_send( mqs[size], "", 1, 0 ); 253 fatal_directive_status( status, -1, "mq_send error return status"); 254 fatal_directive_status( errno, EBADF, "mq_send errno EBADF"); 255 256 puts( "mq_open - Open a read only queue" ); 257 n_mq1 = mq_open("read_only", O_CREAT | O_RDONLY, 0x777, &attr); 258 assert( n_mq1 != (-1) ); 259 /*XXX - Isn't there a more general check */ 260 261 puts( "mq_send - Read only message queue (EBADF)" ); 262 status = mq_send( n_mq1, "", 1, 0 ); 263 fatal_directive_status( status, -1, "mq_send error return status"); 264 fatal_directive_status( errno, EBADF, "mq_send errno EBADF"); 265 266 status = mq_close( n_mq1 ); 267 fatal_directive_status( status, 0, "mq_close message queue"); 268 269 status = mq_unlink( "read_only" ); 270 fatal_directive_status( status, 0, "mq_unlink message queue"); 271 272 /* 273 * XXX - EINTR 274 * Signal interrupted the call. 275 276 puts( "mq_send - UNSUCCESSFUL (EINTR)" ); 277 status = mq_send( mqs, "", 0xffff, 0 ); 278 fatal_directive_status( status, -1, "mq_send error return status"); 279 fatal_directive_status( errno, E, "mq_send errno E"); 280 */ 281 282 /* 283 * XXX - EINVAL priority is out of range. 284 */ 285 286 puts( "mq_send - Priority out of range (EINVAL)" ); 287 status = mq_send( mqs[0], "", 1, MQ_PRIO_MAX + 1 ); 288 fatal_directive_status( status, -1, "mq_send error return status"); 289 fatal_directive_status( errno, EINVAL, "mq_send errno EINVAL"); 290 291 /* 292 * XXX - EMSGSIZE - Message size larger than msg_len 293 */ 294 295 puts( "mq_send - Message longer than msg_len (EMSGSIZE)" ); 296 status = mq_send( mqs[0], "", 0xffff, 0 ); 297 fatal_directive_status( status, -1, "mq_send error return status"); 298 fatal_directive_status( errno, EMSGSIZE, "mq_send errno EMSGSIZE"); 299 300 /* 301 * ENOSYS - send is supported should never happen. 302 */ 303 304 305 /* 306 * XXX - EAGAIN 307 * O_NONBLOCK and message queue is full. 308 * This is validated in the read/write test. 309 */ 310 311 i=0; 312 do { 313 status = mq_send( mqs[0], "", 1, 0 ); 314 i++; 315 } while (status == 0); 316 fatal_directive_status( status, -1, "mq_send error return status"); 317 fatal_directive_status( errno, EAGAIN, "mq_send errno EAGAIN"); 318 319 return i-1; 320 } 321 322 void validate_mq_receive_error_codes( 323 mqd_t *mqs, 324 int size /* Number still open in mqs */ 325 ) 326 { 327 int status; 328 329 /* 330 * EAGAIN - 331 */ 332 333 /* 334 * EBADF - 335 */ 336 337 /* 338 * EMSGSIZE - 339 */ 340 341 /* 342 * EINTR - 343 */ 344 345 /* 346 * EBADMSG - a data corruption problem. 347 * XXX - Can not cause. 348 */ 349 350 /* 351 puts( "mq_ - UNSUCCESSFUL ()" ); 352 status = mq_( ); 353 fatal_directive_status( status, -1, "mq_ error return status"); 354 fatal_directive_status( errno, E, "mq_c errno E"); 355 356 */ 357 /* 358 * ENOSYS - 359 */ 360 361 } 362 363 void non_blocking_mq_read_write( 364 mqd_t *mqs, 365 int size /* Number still open in mqs */ 366 ) 367 { 368 /* 369 int status; 370 char *messages[] = { 371 "Msg 1", 372 "Test 2", 373 "12345678901234567890" 374 }; 375 376 status = mq_send( mqs[0], messages[0], strlen( messages[0] ), 0 ); 377 fatal_directive_status( status, 0, "mq_send error return status" ); 378 379 puts( "mq_send - UNSUCCESSFUL ()" ); 380 do { 381 status = mq_send( ); 382 fatal_directive_status( status, -1, "mq_send error return status"); 383 fatal_directive_status( errno, E, "mq_send errno E"); 384 } 385 */ 207 386 } 208 387 … … 212 391 { 213 392 int status; 214 int value;215 int i;216 393 mqd_t mqs[CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES]; 217 mqd_t mq2;218 394 mqd_t n_mq1; 219 395 mqd_t n_mq2; 220 struct timespec waittime; 221 char failure_msg[80]; 222 struct mq_attr attr; 396 char *messages[] = { 397 "Msg 1", 398 "Test 2", 399 "12345678901234567890" 400 }; 223 401 224 402 puts( "\n\n*** POSIX MESSAGE QUEUE TEST ***" ); … … 228 406 validate_mq_close_error_codes( mqs, 2 ); 229 407 408 validate_mq_send_error_codes( mqs, 2 ); 409 validate_mq_receive_error_codes( mqs, 2 ); 410 411 230 412 /* 231 413 * Validate a second open returns the same message queue. … … 233 415 234 416 puts( "mq_open - Open an existing mq ( same id )" ); 235 n_mq 2= mq_open("mq1", 0 );236 fatal_directive_status( 237 (int) n_mq 2, (int ) mqs[0], "mq_open error return status" );417 n_mq1 = mq_open("mq1", 0 ); 418 fatal_directive_status( 419 (int) n_mq1, (int ) mqs[0], "mq_open error return status" ); 238 420 239 421 /* … … 252 434 253 435 /* 254 * Validate it n_mq2 (the last open for mq1 name can be 255 * correctly closed and unlinked. 256 */ 257 258 puts( "Init: mq_unlink - mq1 (2) SUCCESSFUL" ); 436 * Validate it "mq1" can be closed and unlinked. 437 */ 438 439 puts( "mq_unlink - mq1 SUCCESSFUL" ); 259 440 status = mq_unlink( "mq1" ); 260 441 fatal_directive_status( status, 0, "mq_unlink locked message queue"); 261 442 262 puts( " Init: mq_close (2)- SUCCESSFUL" );443 puts( "mq_close mq1 - SUCCESSFUL" ); 263 444 status = mq_close( n_mq2 ); 264 445 fatal_directive_status( status, 0, "mq_close message queue"); 265 266 267 puts( "Init: mq_unlink - UNSUCCESSFUL (ENOENT)" ); 446 status = mq_close( n_mq1 ); 447 fatal_directive_status( status, 0, "mq_close message queue"); 448 status = mq_close( mqs[0] ); 449 fatal_directive_status( status, 0, "mq_close message queue"); 450 451 puts( "mq_unlink - UNSUCCESSFUL (ENOENT)" ); 268 452 status = mq_unlink("mq1"); 269 453 fatal_directive_status( status, -1, "mq_unlink error return status"); 270 454 fatal_directive_status( errno, ENOENT, "mq_close errno EINVAL"); 271 272 273 /*274 * Validate we can unlink (2)275 */276 277 puts( "Init: mq_unlink (NULL) - EINVAL" );278 status = mq_unlink( NULL );279 fatal_directive_status( status, -1, "mq_unlink error return status");280 fatal_directive_status( errno, EINVAL, "mq_unlink errno value");281 282 puts( "Init: mq_unlink (\"\") - EINVAL" );283 status = mq_unlink( "" );284 fatal_directive_status( status, -1, "mq_unlink error return status");285 fatal_directive_status( errno, EINVAL, "mq_unlink errno value");286 455 287 456 /* 288 457 * XXX - Cant' create location OBJECTS_ERROR or OBJECTS_REMOTE. 289 458 * mq_close and mq_unlink. 290 */ 291 459 * XXX - Don't think we need this save until yellow line tested. 292 460 puts( "Init: mq_unlink - UNSUCCESSFUL (ENOENT)" ); 293 461 status = mq_unlink("mq3"); … … 295 463 fatal_directive_status( errno, ENOENT, "mq_unlink errno ENOENT"); 296 464 assert( (status == -1) && (errno == ENOENT) ); 297 465 */ 298 466 299 467 … … 313 481 return NULL; /* just so the compiler thinks we returned something */ 314 482 } 483 484
Note: See TracChangeset
for help on using the changeset viewer.