diff options
author | Jakub Tyszkowski <jakub.tyszkowski@tieto.com> | 2014-02-04 15:39:03 +0100 |
---|---|---|
committer | Szymon Janc <szymon.janc@gmail.com> | 2014-02-04 21:35:10 +0100 |
commit | bdceceb9d4c898ca179b2a15956c0d635bf25baa (patch) | |
tree | 019a43dbe059e09fb0b060042f66e5bd0bab8927 /android/test-ipc.c | |
parent | 639abb4ba9cd632fd7775ed1fd6373a08f02e032 (diff) | |
download | bluez-bdceceb9d4c898ca179b2a15956c0d635bf25baa.tar.gz |
android/unit: Add support for variable length data
This patch adds sending messages larger than just hal_hdr, and fixes
response verification which worked only for empty messages but was
failing when sending something more than just header.
Diffstat (limited to 'android/test-ipc.c')
-rw-r--r-- | android/test-ipc.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/android/test-ipc.c b/android/test-ipc.c index cb6f5183f..a2d308539 100644 --- a/android/test-ipc.c +++ b/android/test-ipc.c @@ -44,7 +44,7 @@ struct test_data { uint32_t expected_signal; - const struct hal_hdr *cmd; + const void *cmd; uint16_t cmd_size; uint8_t service; const struct ipc_handler *handlers; @@ -79,9 +79,16 @@ static gboolean cmd_watch(GIOChannel *io, GIOCondition cond, { struct context *context = user_data; const struct test_data *test_data = context->data; + const struct hal_hdr *sent_msg = test_data->cmd; uint8_t buf[128]; int sk; + struct hal_hdr success_resp = { + .service_id = sent_msg->service_id, + .opcode = sent_msg->opcode, + .len = 0, + }; + g_assert(test_data->expected_signal == 0); if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) { @@ -91,8 +98,8 @@ static gboolean cmd_watch(GIOChannel *io, GIOCondition cond, sk = g_io_channel_unix_get_fd(io); - g_assert(read(sk, buf, sizeof(buf)) == test_data->cmd_size); - g_assert(!memcmp(test_data->cmd, buf, test_data->cmd_size)); + g_assert(read(sk, buf, sizeof(buf)) == sizeof(struct hal_hdr)); + g_assert(!memcmp(&success_resp, buf, sizeof(struct hal_hdr))); context_quit(context); |