Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | /* * Copyright (c) 2012-2014 Wind River Systems, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file * @brief Test mailbox APIs * * This module tests the following mailbox APIs: * * task_mbox_put * task_mbox_get * * task_mbox_data_get * task_mbox_data_block_get * * The module does NOT test the following mailbox APIs: * * task_mbox_block_put * * Also, not all capabilities of all of the tested APIs are exercised. * Things that are not (yet) tested include: * * - Having multiple tasks sending simultaneously to a mailbox, * to ensure a mailbox can contain more than one message. * - Having multiple tasks waiting simultaneously on a mailbox, * to ensure a mailbox can have more than one waiting task. * - Having messages of differing priorities residing in a mailbox, * to ensure higher priority messages get preference. * - Having receiving tasks of differing priorities waiting on a mailbox. * to ensure higher priority tasks get preference. */ #include <zephyr.h> #include <tc_util.h> #define MSGSIZE 16 /* Standard message data size */ #define XFER_PRIO 5 /* standard message transfer priority */ #define MSG_INFO1 1234 /* Message info test value */ #define MSG_INFO2 666 /* Message info test value */ static char myData1[MSGSIZE] = "This is myData1"; static char myData2[MSGSIZE] = "This is myData2"; static char myData3[MSGSIZE] = "This is myData3"; static char myData4[MSGSIZE] = "This is myData4"; extern ktask_t msgSenderTask; extern ktask_t msgRcvrTask; extern ksem_t semSync1; extern ksem_t semSync2; #ifndef TEST_PRIV_MBX extern kmbox_t myMbox; extern kmbox_t noRcvrMbox; #else DEFINE_MAILBOX(myMbox); DEFINE_MAILBOX(noRcvrMbox); #endif extern kmemory_pool_t testPool; extern kmemory_pool_t smallBlkszPool; /** * * @brief Sets various fields in the message for the sender * * Sets the following fields in the message: * rx_task to receiverTask - destination for the message * mailbox to inMbox * * @param inMsg The message being received. * @param inMbox Mail box to receive the message. * @param receiverTask Destination for the message. * @param dataArea Pointer to (optional) buffer to send. * @param dataSize Size of (optional) buffer to send. * @param info Additional (optional) info to send. * * @return N/A */ static void setMsg_Sender(struct k_msg *inMsg, kmbox_t inMbox, ktask_t receiverTask, void *dataArea, uint32_t dataSize, uint32_t info) { inMsg->rx_task = receiverTask; inMsg->mailbox = inMbox; inMsg->tx_data = dataArea; inMsg->size = SIZEOFUNIT_TO_OCTET(dataSize); inMsg->info = info; } /** * * @brief Sets various fields in the message for the receiver * * Sets the following fields in the message: * rx_data to NULL - to allow message transfer to occur * size to MSGSIZE * tx_task to senderTask - receiver tries to get message from this source * mailbox to inMbox * * @param inMsg Message descriptor. * @param inMbox Mail box to receive from. * @param senderTask Sending task to receive from. * @param inBuffer Incoming data area * @param inBufferSize Size of incoming data area. * * @return N/A */ static void setMsg_Receiver(struct k_msg *inMsg, kmbox_t inMbox, ktask_t senderTask, void *inBuffer, uint32_t inBufferSize) { inMsg->mailbox = inMbox; inMsg->tx_task = senderTask; inMsg->rx_data = inBuffer; inMsg->size = inBufferSize; if (inBufferSize != 0 && inBuffer != NULL) { memset(inBuffer, 0, inBufferSize); } } /** * * @brief Sets rx_data field in msg and clears buffer * * @param inMsg The message being received. * @param inBuffer Incoming data area. * @param inBufferSize Size of incoming data area. * * @return N/A */ static void setMsg_RecvBuf(struct k_msg *inMsg, char *inBuffer, uint32_t inBufferSize) { inMsg->rx_data = inBuffer; inMsg->size = inBufferSize; if (inBufferSize != 0 && inBuffer != NULL) { memset(inBuffer, 0, inBufferSize); } } /** * * @brief Task that tests sending of mailbox messages * * This routine exercises the task_mbox_put() API. * * @return TC_PASS or TC_FAIL */ int MsgSenderTask(void) { int retValue; /* task_mbox_xxx interface return value */ struct k_msg MSTmsg; /* Message sender task msg */ /* Send message (no wait) to a mailbox with no receiver */ setMsg_Sender(&MSTmsg, noRcvrMbox, msgRcvrTask, myData1, MSGSIZE, 0); retValue = task_mbox_put(noRcvrMbox, XFER_PRIO, &MSTmsg, TICKS_NONE); if (RC_FAIL != retValue) { TC_ERROR("task_mbox_put to non-waiting task returned %d\n", retValue); return TC_FAIL; } TC_PRINT("%s: task_mbox_put(TICKS_NONE) to non-waiting task is OK\n", __func__); /* Send message (with timeout) to a mailbox with no receiver */ setMsg_Sender(&MSTmsg, noRcvrMbox, msgRcvrTask, myData1, MSGSIZE, 0); retValue = task_mbox_put(noRcvrMbox, XFER_PRIO, &MSTmsg, 2); if (RC_TIME != retValue) { TC_ERROR("task_mbox_put to non-waiting task returned %d\n", retValue); return TC_FAIL; } TC_PRINT("%s: task_mbox_put(timeout) to non-waiting task is OK\n", __func__); /* Wait for Receiver Task to finish using myMbox */ (void) task_sem_take(semSync1, TICKS_UNLIMITED); /* Send message (no wait) to specified task that is waiting for it */ setMsg_Sender(&MSTmsg, myMbox, msgRcvrTask, myData1, MSGSIZE, 0); /* * Transmit more data then receiver can actually handle * to ensure that "size" field gets updated properly during send */ MSTmsg.size += 10; retValue = task_mbox_put(myMbox, XFER_PRIO, &MSTmsg, TICKS_NONE); if (RC_OK != retValue) { TC_ERROR("task_mbox_put to specified waiting task returned %d\n", retValue); return TC_FAIL; } if (MSTmsg.size != MSGSIZE) { TC_ERROR("task_mbox_put to specified waiting task got wrong size (%d)\n", MSTmsg.size); return TC_FAIL; } TC_PRINT("%s: task_mbox_put(TICKS_NONE) to specified waiting task is OK\n", __func__); /* Wait for Receiver Task to start sleeping */ (void) task_sem_take(semSync2, TICKS_UNLIMITED); /* Send message to any task that is not yet waiting for it */ setMsg_Sender(&MSTmsg, myMbox, ANYTASK, myData2, MSGSIZE, MSG_INFO1); retValue = task_mbox_put(myMbox, XFER_PRIO, &MSTmsg, 5); if (RC_OK != retValue) { TC_ERROR("task_mbox_put to anonymous non-waiting task returned %d\n", retValue); return TC_FAIL; } if (MSTmsg.size != MSGSIZE) { TC_ERROR("task_mbox_put to anonymous non-waiting task " "got wrong size (%d)\n", MSTmsg.size); return TC_FAIL; } TC_PRINT("%s: task_mbox_put(timeout) to anonymous non-waiting task is OK\n", __func__); /* Send empty message to specified task */ setMsg_Sender(&MSTmsg, myMbox, msgRcvrTask, NULL, 0, MSG_INFO2); retValue = task_mbox_put(myMbox, XFER_PRIO, &MSTmsg, TICKS_UNLIMITED); if (RC_OK != retValue) { TC_ERROR("task_mbox_put of empty message returned %d\n", retValue); return TC_FAIL; } TC_PRINT("%s: task_mbox_put(TICKS_UNLIMITED) of empty message is OK\n", __func__); /* Sync with Receiver Task, since we're about to use a timeout */ task_sem_take(semSync1, TICKS_UNLIMITED); /* Send message used in 2 part receive test */ setMsg_Sender(&MSTmsg, myMbox, ANYTASK, myData3, MSGSIZE, MSG_INFO1); /* * Transmit more data then receiver can actually handle * to ensure that "size" field gets updated properly during send */ MSTmsg.size += 10; retValue = task_mbox_put(myMbox, XFER_PRIO, &MSTmsg, 5); if (RC_OK != retValue) { TC_ERROR("task_mbox_put for 2 part receive test returned %d\n", retValue); return TC_FAIL; } if (MSTmsg.size != MSGSIZE) { TC_ERROR("task_mbox_put for 2 part receive test got wrong size (%d)\n", MSTmsg.size); return TC_FAIL; } TC_PRINT("%s: task_mbox_put(timeout) for 2 part receive test is OK\n", __func__); /* Sync with Receiver Task, since he's about to use a timeout */ task_sem_give(semSync2); /* Send message used in cancelled receive test */ setMsg_Sender(&MSTmsg, myMbox, msgRcvrTask, myData4, MSGSIZE, MSG_INFO2); retValue = task_mbox_put(myMbox, XFER_PRIO, &MSTmsg, TICKS_UNLIMITED); if (RC_OK != retValue) { TC_ERROR("task_mbox_put for cancelled receive test returned %d\n", retValue); return TC_FAIL; } if (MSTmsg.size != MSGSIZE) { /* kernel bug: should really set size to 0! */ TC_ERROR("task_mbox_put for cancelled receive test got wrong size (%d)\n", MSTmsg.size); return TC_FAIL; } TC_PRINT("%s: task_mbox_put(TICKS_UNLIMITED) for cancelled receive test is OK\n", __func__); /* Send message used in block-based receive test */ setMsg_Sender(&MSTmsg, myMbox, msgRcvrTask, myData1, MSGSIZE, MSG_INFO2); retValue = task_mbox_put(myMbox, XFER_PRIO, &MSTmsg, TICKS_UNLIMITED); if (RC_OK != retValue) { TC_ERROR("task_mbox_put for block-based receive test returned %d\n", retValue); return TC_FAIL; } TC_PRINT("%s: task_mbox_put(TICKS_UNLIMITED) for block-based receive test is OK\n", __func__); /* Send message used in block-exhaustion receive test */ setMsg_Sender(&MSTmsg, myMbox, msgRcvrTask, myData2, MSGSIZE, MSG_INFO2); retValue = task_mbox_put(myMbox, XFER_PRIO, &MSTmsg, TICKS_UNLIMITED); if (RC_OK != retValue) { TC_ERROR("task_mbox_put for block-exhaustion receive test returned %d\n", retValue); return TC_FAIL; } TC_PRINT("%s: task_mbox_put(TICKS_UNLIMITED) for block-exhaustion receive test is OK\n", __func__); /* Sync with Receiver Task, since we're about to use a timeout */ task_sem_take(semSync1, TICKS_UNLIMITED); /* Send message used in long-duration receive test */ setMsg_Sender(&MSTmsg, myMbox, ANYTASK, myData3, MSGSIZE, MSG_INFO1); retValue = task_mbox_put(myMbox, XFER_PRIO, &MSTmsg, 2); if (RC_OK != retValue) { TC_ERROR("task_mbox_put for long-duration receive test returned %d\n", retValue); return TC_FAIL; } if (MSTmsg.size != MSGSIZE) { TC_ERROR("task_mbox_put for long-duration receive test got wrong size " "(%d)\n", MSTmsg.size); return TC_FAIL; } TC_PRINT("%s: task_mbox_put(timeout) for long-duration receive test is OK\n", __func__); return TC_PASS; } /** * * @brief Task that tests receiving of mailbox messages * * This routine exercises the task_mbox_get() and task_mbox_data_get[xxx] APIs. * * @return TC_PASS or TC_FAIL */ int MsgRcvrTask(void) { int retValue; /* task_mbox_xxx interface return value */ struct k_msg MRTmsg = {0, }; /* Message receiver task msg */ char rxBuffer[MSGSIZE*2]; /* Buffer to place message data in (has extra space at end for overrun testing) */ struct k_block MRTblock; /* Message receiver task memory block */ struct k_block MRTblockAlt; /* Message receiver task memory block (alternate) */ /* Receive message (no wait) from an empty mailbox */ setMsg_Receiver(&MRTmsg, myMbox, ANYTASK, rxBuffer, MSGSIZE); retValue = task_mbox_get(myMbox, &MRTmsg, TICKS_NONE); if (RC_FAIL != retValue) { TC_ERROR("task_mbox_get when no message returned %d\n", retValue); return TC_FAIL; } TC_PRINT("%s: task_mbox_get when no message is OK\n", __func__); /* Receive message (with timeout) from an empty mailbox */ setMsg_Receiver(&MRTmsg, myMbox, ANYTASK, rxBuffer, MSGSIZE); retValue = task_mbox_get(myMbox, &MRTmsg, 2); if (RC_TIME != retValue) { TC_ERROR("task_mbox_get when no message returned %d\n", retValue); return TC_FAIL; } TC_PRINT("%s: task_mbox_get(timeout) when no message is OK\n", __func__); /* Allow Sender Task to proceed once we start our receive */ task_sem_give(semSync1); /* Receive message (no timeout) from specified task */ setMsg_Receiver(&MRTmsg, myMbox, msgSenderTask, rxBuffer, MSGSIZE); retValue = task_mbox_get(myMbox, &MRTmsg, TICKS_UNLIMITED); if (RC_OK != retValue) { TC_ERROR("task_mbox_get from specified task got wrong return code (%d)\n", retValue); return TC_FAIL; } if (strcmp(MRTmsg.rx_data, myData1) != 0) { TC_ERROR("task_mbox_get from specified task got wrong data (%s)\n", MRTmsg.rx_data); return TC_FAIL; } TC_PRINT("%s: task_mbox_get(TICKS_UNLIMITED) from specified task is OK\n", __func__); /* Allow Sender Task to proceed once we go to sleep for a while */ task_sem_give(semSync2); task_sleep(2); /* Receive message (no wait) from anonymous task */ setMsg_Receiver(&MRTmsg, myMbox, ANYTASK, rxBuffer, MSGSIZE); /* * Ask for more data then is actually being sent * to ensure that "size" field gets updated properly during receive */ MRTmsg.size += MSGSIZE; retValue = task_mbox_get(myMbox, &MRTmsg, TICKS_NONE); if (RC_OK != retValue) { TC_ERROR("task_mbox_get from anonymous task got wrong return code (%d)\n", retValue); return TC_FAIL; } if (MRTmsg.info != MSG_INFO1) { TC_ERROR("task_mbox_get from anonymous task got wrong info (%d)\n", MRTmsg.info); return TC_FAIL; } if (MRTmsg.size != MSGSIZE) { TC_ERROR("task_mbox_get from anonymous task got wrong size (%d)\n", MRTmsg.size); return TC_FAIL; } if (strcmp(MRTmsg.rx_data, myData2) != 0) { TC_ERROR("task_mbox_get from anonymous task got wrong data (%s)\n", MRTmsg.rx_data); return TC_FAIL; } TC_PRINT("%s: task_mbox_get from anonymous task is OK\n", __func__); /* Receive empty message from anonymous task */ setMsg_Receiver(&MRTmsg, myMbox, ANYTASK, rxBuffer, MSGSIZE); retValue = task_mbox_get(myMbox, &MRTmsg, TICKS_UNLIMITED); if (RC_OK != retValue) { TC_ERROR("task_mbox_get of empty message got wrong return code (%d)\n", retValue); return TC_FAIL; } if (MRTmsg.info != MSG_INFO2) { TC_ERROR("task_mbox_get of empty message got wrong info (%d)\n", MRTmsg.info); return TC_FAIL; } if (MRTmsg.size != 0) { TC_ERROR("task_mbox_get of empty message got wrong size (%d)\n", MRTmsg.size); return TC_FAIL; } TC_PRINT("%s: task_mbox_get(TICKS_UNLIMITED) of empty message is OK\n", __func__); /* Sync with Sender Task, since he's about to use a timeout */ (void) task_sem_give(semSync1); /* Receive message header for 2 part receive test */ setMsg_Receiver(&MRTmsg, myMbox, msgSenderTask, NULL, MSGSIZE); retValue = task_mbox_get(myMbox, &MRTmsg, TICKS_UNLIMITED); if (RC_OK != retValue) { TC_ERROR("task_mbox_get of message header #3 returned %d\n", retValue); return TC_FAIL; } if (MRTmsg.info != MSG_INFO1) { TC_ERROR("task_mbox_get of message header #3 got wrong info (%d)\n", MRTmsg.info); return TC_FAIL; } if (MRTmsg.size != MSGSIZE) { TC_ERROR("task_mbox_get of message header #3 got wrong size (%d)\n", MRTmsg.size); return TC_FAIL; } /* Now grab the message data */ setMsg_RecvBuf(&MRTmsg, rxBuffer, MSGSIZE); task_mbox_data_get(&MRTmsg); if (strcmp(MRTmsg.rx_data, myData3) != 0) { TC_ERROR("task_mbox_data_get got wrong data #3 (%s)\n", MRTmsg.rx_data); return TC_FAIL; } TC_PRINT("%s: task_mbox_get(TICKS_UNLIMITED) of message header #3 is OK\n", __func__); TC_PRINT("%s: task_mbox_data_get of message data #3 is OK\n", __func__); /* Sync with Sender Task, since we're about to use a timeout */ (void) task_sem_take(semSync2, TICKS_UNLIMITED); /* Receive message header for cancelled receive test */ setMsg_Receiver(&MRTmsg, myMbox, msgSenderTask, NULL, MSGSIZE); retValue = task_mbox_get(myMbox, &MRTmsg, 5); if (RC_OK != retValue) { TC_ERROR("task_mbox_get of message header #4 returned %d\n", retValue); return TC_FAIL; } if (MRTmsg.info != MSG_INFO2) { TC_ERROR("task_mbox_get of message header #4 got wrong info (%d)\n", MRTmsg.info); return TC_FAIL; } if (MRTmsg.size != MSGSIZE) { TC_ERROR("task_mbox_get of message header #4 got wrong size (%d)\n", MRTmsg.size); return TC_FAIL; } /* Cancel receiving of message data */ setMsg_RecvBuf(&MRTmsg, rxBuffer, 0); task_mbox_data_get(&MRTmsg); TC_PRINT("%s: task_mbox_get(timeout) of message header #4 is OK\n", __func__); TC_PRINT("%s: task_mbox_data_get cancellation of message #4 is OK\n", __func__); /* Receive message header for block-based receive test */ setMsg_Receiver(&MRTmsg, myMbox, ANYTASK, NULL, MSGSIZE); retValue = task_mbox_get(myMbox, &MRTmsg, TICKS_UNLIMITED); if (RC_OK != retValue) { TC_ERROR("task_mbox_get of message header #1 returned %d\n", retValue); return TC_FAIL; } if (MRTmsg.size != MSGSIZE) { TC_ERROR("task_mbox_get of message header #1 got wrong size (%d)\n", MRTmsg.size); return TC_FAIL; } /* Try to grab message data using a block that's too small */ retValue = task_mbox_data_block_get(&MRTmsg, &MRTblock, smallBlkszPool, TICKS_NONE); if (RC_FAIL != retValue) { TC_ERROR("task_mbox_data_block_get that should have failed returned %d\n", retValue); return TC_FAIL; } /* Now grab message data using a block that's big enough */ retValue = task_mbox_data_block_get(&MRTmsg, &MRTblock, testPool, TICKS_NONE); if (RC_OK != retValue) { TC_ERROR("task_mbox_data_block_get returned %d\n", retValue); return TC_FAIL; } if (strcmp((char *)(MRTblock.pointer_to_data), myData1) != 0) { TC_ERROR("task_mbox_data_block_get got wrong data #1 (%s)\n", MRTblock.pointer_to_data); return TC_FAIL; } TC_PRINT("%s: task_mbox_get(TICKS_UNLIMITED) of message header #1 is OK\n", __func__); TC_PRINT("%s: task_mbox_data_block_get of message data #1 is OK\n", __func__); /* Don't free block yet ... */ /* Receive message header for block-exhaustion receive test */ setMsg_Receiver(&MRTmsg, myMbox, ANYTASK, NULL, MSGSIZE); retValue = task_mbox_get(myMbox, &MRTmsg, TICKS_UNLIMITED); if (RC_OK != retValue) { TC_ERROR("task_mbox_get of message header #2 returned %d\n", retValue); return TC_FAIL; } if (MRTmsg.size != MSGSIZE) { TC_ERROR("task_mbox_get of message header #2 got wrong size (%d)\n", MRTmsg.size); return TC_FAIL; } /* Try to grab message data using block from an empty pool */ retValue = task_mbox_data_block_get(&MRTmsg, &MRTblockAlt, testPool, 2); if (RC_TIME != retValue) { TC_ERROR("task_mbox_data_block_get that should have timed out " "returned %d\n", retValue); return TC_FAIL; } /* Free block used with previous message */ task_mem_pool_free(&MRTblock); /* Now grab message data using the newly released block */ retValue = task_mbox_data_block_get(&MRTmsg, &MRTblockAlt, testPool, TICKS_NONE); if (RC_OK != retValue) { TC_ERROR("task_mbox_data_block_get returned %d\n", retValue); return TC_FAIL; } if (strcmp((char *)(MRTblockAlt.pointer_to_data), myData2) != 0) { TC_ERROR("task_mbox_data_block_get got wrong data #2 (%s)\n", MRTblockAlt.pointer_to_data); return TC_FAIL; } TC_PRINT("%s: task_mbox_get(TICKS_UNLIMITED) of message header #2 is OK\n", __func__); TC_PRINT("%s: task_mbox_data_block_get of message data #2 is OK\n", __func__); /* Free block used with most recent message */ task_mem_pool_free(&MRTblockAlt); /* Sync with Sender Task, since he's about to use a timeout */ (void) task_sem_give(semSync1); /* Receive message header for long-duration receive test */ setMsg_Receiver(&MRTmsg, myMbox, msgSenderTask, NULL, MSGSIZE); retValue = task_mbox_get(myMbox, &MRTmsg, TICKS_UNLIMITED); if (RC_OK != retValue) { TC_ERROR("task_mbox_get of message header #3 returned %d\n", retValue); return TC_FAIL; } if (MRTmsg.info != MSG_INFO1) { TC_ERROR("task_mbox_get of message header #3 got wrong info (%d)\n", MRTmsg.info); return TC_FAIL; } if (MRTmsg.size != MSGSIZE) { TC_ERROR("task_mbox_get of message header #3 got wrong size (%d)\n", MRTmsg.size); return TC_FAIL; } /* Now sleep long enough for sender's timeout to expire */ task_sleep(10); /* Sender should still be blocked, so grab the message data */ setMsg_RecvBuf(&MRTmsg, rxBuffer, MSGSIZE); task_mbox_data_get(&MRTmsg); if (strcmp(MRTmsg.rx_data, myData3) != 0) { TC_ERROR("task_mbox_data_get got wrong data #3 (%s)\n", MRTmsg.rx_data); return TC_FAIL; } TC_PRINT("%s: task_mbox_get(TICKS_UNLIMITED) of message header #3 is OK\n", __func__); TC_PRINT("%s: task_mbox_data_get of message data #3 is OK\n", __func__); return TC_PASS; } |