diff options
author | Arve Hjønnevåg <arve@android.com> | 2018-07-25 17:24:18 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-07-25 17:24:18 -0700 |
commit | c97372e73b213650c246b48754336a474080f03a (patch) | |
tree | a603baea590afe7ebcb2a4dfb29b586ca751b168 /trusty | |
parent | 5ae98112ebff5ac34c5756a8451a8a805b7a515e (diff) | |
parent | 7b7e416649e92b93ad488d7f41153d2e14ac067e (diff) | |
download | system_core-c97372e73b213650c246b48754336a474080f03a.tar.gz system_core-c97372e73b213650c246b48754336a474080f03a.tar.bz2 system_core-c97372e73b213650c246b48754336a474080f03a.zip |
Merge "trusty: tipc_test: Read output and test result from ta2ta_ipc_test"
am: 7b7e416649
Change-Id: I17c82528a7e373dd18137c7c976e868d4718bd5f
Diffstat (limited to 'trusty')
-rw-r--r-- | trusty/libtrusty/tipc-test/tipc_test.c | 34 |
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) static int ta2ta_ipc_test(void) { + enum test_message_header { + TEST_PASSED = 0, + TEST_FAILED = 1, + TEST_MESSAGE = 2, + }; + int fd; - char rx_buf[64]; + int ret; + unsigned char rx_buf[256]; if (!opt_silent) { printf("%s:\n", __func__); @@ -601,12 +608,31 @@ static int ta2ta_ipc_test(void) return fd; } - /* wait for test to complete */ - (void) read(fd, rx_buf, sizeof(rx_buf)); + /* Wait for tests to complete and read status */ + while (true) { + ret = read(fd, rx_buf, sizeof(rx_buf)); + if (ret <= 0 || ret >= (int)sizeof(rx_buf)) { + fprintf(stderr, "%s: Read failed: %d\n", __func__, ret); + tipc_close(fd); + return -1; + } + + if (rx_buf[0] == TEST_PASSED) { + break; + } else if (rx_buf[0] == TEST_FAILED) { + break; + } else if (rx_buf[0] == TEST_MESSAGE) { + write(STDOUT_FILENO, rx_buf + 1, ret - 1); + } else { + fprintf(stderr, "%s: Bad message header: %d\n", + __func__, rx_buf[0]); + break; + } + } tipc_close(fd); - return 0; + return rx_buf[0] == TEST_PASSED ? 0 : -1; } typedef struct uuid |