X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=test%2Fchannels-udp.c;h=40d5605de17f1502f1caeb6b23639811ab6a74fb;hb=4b6c01b1d5383b1a7417244a31ad4652aab2d5db;hp=0c24a9376e04f979fb80921154e1e7169f6ac863;hpb=ce4dfa68147745b116ee316b012653b11a328cd9;p=meshlink diff --git a/test/channels-udp.c b/test/channels-udp.c index 0c24a937..40d5605d 100644 --- a/test/channels-udp.c +++ b/test/channels-udp.c @@ -55,10 +55,10 @@ static void client_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chann // We expect always the same amount of data from the server. assert(mesh->priv); struct client *client = mesh->priv; - assert(len == 512 || len == 2000); + assert(len == 512 || len == 65536); client->received += len; - if(len == 2000) { + if(len == 65536) { client->got_large_packet = true; } } @@ -100,7 +100,10 @@ static bool accept_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint return false; } -int main() { +int main(void) { + init_sync_flag(&accept_flag); + init_sync_flag(&close_flag); + meshlink_set_log_cb(NULL, MESHLINK_WARNING, log_cb); // Open four new meshlink instance, the server and three peers. @@ -140,11 +143,12 @@ int main() { assert(clients[i].channel); } - // Send a packet larger than the MTU + // Check that we can send up to 65535 bytes without errors - char large_data[2000] = ""; + char large_data[65536] = ""; for(int i = 0; i < 3; i++) { + assert(meshlink_channel_send(server, channels[i], large_data, sizeof(large_data) + 1) == -1); assert(meshlink_channel_send(server, channels[i], large_data, sizeof(large_data)) == sizeof(large_data)); } @@ -163,7 +167,7 @@ int main() { } const struct timespec req = {0, 2000000}; - clock_nanosleep(CLOCK_MONOTONIC, 0, &req, NULL); + nanosleep(&req, NULL); } // Let the clients close the channels @@ -183,7 +187,7 @@ int main() { for(int i = 0; i < 3; i++) { assert(clients[i].received >= 1000000); - assert(clients[i].received <= 1282000); + assert(clients[i].received <= 1345536); assert(clients[i].got_large_packet); }