diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-06-21 16:29:45 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-06-21 16:29:45 +0000 |
commit | 5d702d02c5f2cf86400c469f4eb162a0f63d6cd8 (patch) | |
tree | 3a30250bd16aff46ead918e9bbf97a3ad529a71e /src/transport/test_plugin_transport_http.c | |
parent | 1bf55b33a415d584ae338a0afea5b51d059f11ab (diff) | |
download | gnunet-5d702d02c5f2cf86400c469f4eb162a0f63d6cd8.tar.gz gnunet-5d702d02c5f2cf86400c469f4eb162a0f63d6cd8.zip |
added support for multiple messages in a transfer
Diffstat (limited to 'src/transport/test_plugin_transport_http.c')
-rw-r--r-- | src/transport/test_plugin_transport_http.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index 3d1c8d5e5..63e8be3a1 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c | |||
@@ -315,6 +315,11 @@ static int fail_msg_transmited_bigger_max_size; | |||
315 | static int fail_msg_transmited_max_size; | 315 | static int fail_msg_transmited_max_size; |
316 | 316 | ||
317 | /** | 317 | /** |
318 | * Test: transmit 2 msgs. in in send operation | ||
319 | */ | ||
320 | static int fail_multiple_msgs_in_transmission; | ||
321 | |||
322 | /** | ||
318 | * Test: connect to peer without peer identification | 323 | * Test: connect to peer without peer identification |
319 | */ | 324 | */ |
320 | static struct HTTP_Transfer test_no_ident; | 325 | static struct HTTP_Transfer test_no_ident; |
@@ -377,7 +382,7 @@ shutdown_clean () | |||
377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test connect with wrong data failed\n"); | 382 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test connect with wrong data failed\n"); |
378 | fail = 1; | 383 | fail = 1; |
379 | } | 384 | } |
380 | if ((fail_msgs_transmited_to_local_addrs != count_str_addr) || (fail_msg_transmited_max_size == GNUNET_YES) || (fail_msg_transmited_bigger_max_size == GNUNET_YES)) | 385 | if ((fail_msgs_transmited_to_local_addrs != count_str_addr) || (fail_msg_transmited_max_size == GNUNET_YES) || (fail_msg_transmited_bigger_max_size == GNUNET_YES) || (fail_multiple_msgs_in_transmission != GNUNET_NO)) |
381 | { | 386 | { |
382 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test sending with plugin failed\n"); | 387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test sending with plugin failed\n"); |
383 | fail = 1; | 388 | fail = 1; |
@@ -513,6 +518,10 @@ receive (void *cls, | |||
513 | uint16_t sender_address_len) | 518 | uint16_t sender_address_len) |
514 | { | 519 | { |
515 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' (`%s') with type %u and length %u\n", GNUNET_i2s(peer), sender_address, ntohs(message->type), ntohs(message->size)); | 520 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' (`%s') with type %u and length %u\n", GNUNET_i2s(peer), sender_address, ntohs(message->type), ntohs(message->size)); |
521 | if ((ntohs(message->type) == 40) && (fail_multiple_msgs_in_transmission == 1)) | ||
522 | fail_multiple_msgs_in_transmission++; | ||
523 | if ((ntohs(message->type) == 41) && (fail_multiple_msgs_in_transmission == 2)) | ||
524 | fail_multiple_msgs_in_transmission = GNUNET_NO; | ||
516 | return GNUNET_TIME_UNIT_ZERO; | 525 | return GNUNET_TIME_UNIT_ZERO; |
517 | } | 526 | } |
518 | 527 | ||
@@ -993,6 +1002,29 @@ static void run_connection_tests( ) | |||
993 | type ++; | 1002 | type ++; |
994 | } | 1003 | } |
995 | 1004 | ||
1005 | /* send a multiple GNUNET_messages at a time*/ | ||
1006 | GNUNET_free(tmp); | ||
1007 | tmp = GNUNET_malloc(4 * sizeof(struct GNUNET_MessageHeader)); | ||
1008 | struct GNUNET_MessageHeader * msg1 = (struct GNUNET_MessageHeader *) tmp; | ||
1009 | msg1->size = htons(2 * sizeof(struct GNUNET_MessageHeader)); | ||
1010 | msg1->type = htons(40); | ||
1011 | struct GNUNET_MessageHeader * msg2 = &msg1[2]; | ||
1012 | msg2->size = htons(2 * sizeof(struct GNUNET_MessageHeader)); | ||
1013 | msg2->type = htons(41); | ||
1014 | api->send(api->cls, &my_identity, tmp, 4 * sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_YES, &task_send_cont, &fail_multiple_msgs_in_transmission); | ||
1015 | |||
1016 | |||
1017 | /* send a multiple GNUNET_messages at a time, second message has incorrect size*/ | ||
1018 | GNUNET_free(tmp); | ||
1019 | tmp = GNUNET_malloc(4 * sizeof(struct GNUNET_MessageHeader)); | ||
1020 | msg1 = (struct GNUNET_MessageHeader *) tmp; | ||
1021 | msg1->size = htons(2 * sizeof(struct GNUNET_MessageHeader)); | ||
1022 | msg1->type = htons(40); | ||
1023 | msg2 = &msg1[2]; | ||
1024 | msg2->size = htons(3 * sizeof(struct GNUNET_MessageHeader)); | ||
1025 | msg2->type = htons(41); | ||
1026 | api->send(api->cls, &my_identity, tmp, 4 * sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_YES, &task_send_cont, NULL); | ||
1027 | |||
996 | /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE )*/ | 1028 | /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE )*/ |
997 | GNUNET_free(tmp); | 1029 | GNUNET_free(tmp); |
998 | tmp = GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE); | 1030 | tmp = GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE); |
@@ -1001,7 +1033,6 @@ static void run_connection_tests( ) | |||
1001 | memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); | 1033 | memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); |
1002 | api->send(api->cls, &my_identity, tmp, GNUNET_SERVER_MAX_MESSAGE_SIZE, 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_YES, &task_send_cont, &fail_msg_transmited_bigger_max_size); | 1034 | api->send(api->cls, &my_identity, tmp, GNUNET_SERVER_MAX_MESSAGE_SIZE, 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_YES, &task_send_cont, &fail_msg_transmited_bigger_max_size); |
1003 | 1035 | ||
1004 | |||
1005 | /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */ | 1036 | /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */ |
1006 | GNUNET_free(tmp); | 1037 | GNUNET_free(tmp); |
1007 | tmp = GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE-1); | 1038 | tmp = GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE-1); |
@@ -1043,6 +1074,7 @@ run (void *cls, | |||
1043 | fail_addr_to_str = GNUNET_YES; | 1074 | fail_addr_to_str = GNUNET_YES; |
1044 | fail_msgs_transmited_to_local_addrs = 0; | 1075 | fail_msgs_transmited_to_local_addrs = 0; |
1045 | fail_msg_transmited_max_size = GNUNET_YES; | 1076 | fail_msg_transmited_max_size = GNUNET_YES; |
1077 | fail_multiple_msgs_in_transmission = GNUNET_YES; | ||
1046 | 1078 | ||
1047 | addr_head = NULL; | 1079 | addr_head = NULL; |
1048 | count_str_addr = 0; | 1080 | count_str_addr = 0; |