From 83c20878a6ef6e1e3a1abad17961e02137f16ab5 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sat, 5 Oct 2019 14:32:19 +0200 Subject: [PATCH] Fix the channels-no-partial test case. --- src/utcp | 2 +- test/channels-no-partial.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/utcp b/src/utcp index b92868c9..eb0a013a 160000 --- a/src/utcp +++ b/src/utcp @@ -1 +1 @@ -Subproject commit b92868c9f1e00601c1cb5cccc6dc01fdb79de4ca +Subproject commit eb0a013a9b6c957aee0aecebc7d451dfd6851661 diff --git a/test/channels-no-partial.c b/test/channels-no-partial.c index caa308fb..8216a556 100644 --- a/test/channels-no-partial.c +++ b/test/channels-no-partial.c @@ -36,13 +36,17 @@ int main(int argc, char *argv[]) { meshlink_node_t *b = meshlink_get_node(mesh_a, "b"); assert(b); - meshlink_channel_t *channel = meshlink_channel_open_ex(mesh_a, b, 1, NULL, NULL, 0, MESHLINK_CHANNEL_NO_PARTIAL); + meshlink_channel_t *channel = meshlink_channel_open_ex(mesh_a, b, 1, NULL, NULL, 0, MESHLINK_CHANNEL_TCP | MESHLINK_CHANNEL_NO_PARTIAL); assert(channel); + // Stop a to ensure we get deterministic behaviour for the channel send queue. + + meshlink_stop(mesh_a); + // Verify that no partial sends succeed. // If rejected sends would fit an empty send buffer, 0 should be returned, otherwise -1. - char buf[256] = ""; + char buf[512] = "data"; meshlink_set_channel_sndbuf(mesh_a, channel, 256); assert(meshlink_channel_send(mesh_a, channel, buf, 257) == -1); @@ -56,6 +60,10 @@ int main(int argc, char *argv[]) { assert(meshlink_channel_send(mesh_a, channel, buf, 29) == 0); assert(meshlink_channel_send(mesh_a, channel, buf, 513) == -1); + // Restart a to ensure it gets to flush the channel send queue. + + meshlink_start(mesh_a); + assert_after(!meshlink_channel_get_sendq(mesh_a, channel), 30); assert(meshlink_channel_send(mesh_a, channel, buf, 512) == 512); -- 2.39.5