summaryrefslogtreecommitdiffstats
path: root/trusty
diff options
context:
space:
mode:
authorArve Hjønnevåg2018-07-25 19:17:54 -0500
committerGerrit Code Review2018-07-25 19:17:54 -0500
commit7b7e416649e92b93ad488d7f41153d2e14ac067e (patch)
treedb044dd7109d0297cc8dd53776956f7e1c904349 /trusty
parente663c78d9276318300549e739e1316bc04e65066 (diff)
parentb6d6075983e28fd744a8071dcb6c0816a0d6444c (diff)
downloadplatform-system-core-7b7e416649e92b93ad488d7f41153d2e14ac067e.tar.gz
platform-system-core-7b7e416649e92b93ad488d7f41153d2e14ac067e.tar.xz
platform-system-core-7b7e416649e92b93ad488d7f41153d2e14ac067e.zip
Merge "trusty: tipc_test: Read output and test result from ta2ta_ipc_test"
Diffstat (limited to 'trusty')
-rw-r--r--trusty/libtrusty/tipc-test/tipc_test.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/trusty/libtrusty/tipc-test/tipc_test.c b/trusty/libtrusty/tipc-test/tipc_test.c
index 1fb34c939..d20d4eebf 100644
--- a/trusty/libtrusty/tipc-test/tipc_test.c
+++ b/trusty/libtrusty/tipc-test/tipc_test.c
@@ -587,8 +587,15 @@ static int blocked_read_test(uint repeat)
587 587
588static int ta2ta_ipc_test(void) 588static int ta2ta_ipc_test(void)
589{ 589{
590 enum test_message_header {
591 TEST_PASSED = 0,
592 TEST_FAILED = 1,
593 TEST_MESSAGE = 2,
594 };
595
590 int fd; 596 int fd;
591 char rx_buf[64]; 597 int ret;
598 unsigned char rx_buf[256];
592 599
593 if (!opt_silent) { 600 if (!opt_silent) {
594 printf("%s:\n", __func__); 601 printf("%s:\n", __func__);
@@ -601,12 +608,31 @@ static int ta2ta_ipc_test(void)
601 return fd; 608 return fd;
602 } 609 }
603 610
604 /* wait for test to complete */ 611 /* Wait for tests to complete and read status */
605 (void) read(fd, rx_buf, sizeof(rx_buf)); 612 while (true) {
613 ret = read(fd, rx_buf, sizeof(rx_buf));
614 if (ret <= 0 || ret >= (int)sizeof(rx_buf)) {
615 fprintf(stderr, "%s: Read failed: %d\n", __func__, ret);
616 tipc_close(fd);
617 return -1;
618 }
619
620 if (rx_buf[0] == TEST_PASSED) {
621 break;
622 } else if (rx_buf[0] == TEST_FAILED) {
623 break;
624 } else if (rx_buf[0] == TEST_MESSAGE) {
625 write(STDOUT_FILENO, rx_buf + 1, ret - 1);
626 } else {
627 fprintf(stderr, "%s: Bad message header: %d\n",
628 __func__, rx_buf[0]);
629 break;
630 }
631 }
606 632
607 tipc_close(fd); 633 tipc_close(fd);
608 634
609 return 0; 635 return rx_buf[0] == TEST_PASSED ? 0 : -1;
610} 636}
611 637
612typedef struct uuid 638typedef struct uuid