diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-06-16 15:56:24 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-06-16 15:56:24 +0000 |
commit | 7e9b0bef0dc2a0915f411b167f0253d9a35f796a (patch) | |
tree | 499abd50c2df08a5801109190ca20be5d09d6963 /src/transport/test_plugin_transport_http.c | |
parent | 4d438e6898c262ed7627030f88a0710e1053e287 (diff) | |
download | gnunet-7e9b0bef0dc2a0915f411b167f0253d9a35f796a.tar.gz gnunet-7e9b0bef0dc2a0915f411b167f0253d9a35f796a.zip |
Diffstat (limited to 'src/transport/test_plugin_transport_http.c')
-rw-r--r-- | src/transport/test_plugin_transport_http.c | 72 |
1 files changed, 53 insertions, 19 deletions
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index d8e0b4f1f..3d1c8d5e5 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c | |||
@@ -42,7 +42,7 @@ | |||
42 | #include "transport.h" | 42 | #include "transport.h" |
43 | #include <curl/curl.h> | 43 | #include <curl/curl.h> |
44 | 44 | ||
45 | #define VERBOSE GNUNET_NO | 45 | #define VERBOSE GNUNET_YES |
46 | #define DEBUG GNUNET_NO | 46 | #define DEBUG GNUNET_NO |
47 | #define DEBUG_CURL GNUNET_NO | 47 | #define DEBUG_CURL GNUNET_NO |
48 | #define HTTP_BUFFER_SIZE 2048 | 48 | #define HTTP_BUFFER_SIZE 2048 |
@@ -305,6 +305,16 @@ static int fail_addr_to_str; | |||
305 | static int fail_msgs_transmited_to_local_addrs; | 305 | static int fail_msgs_transmited_to_local_addrs; |
306 | 306 | ||
307 | /** | 307 | /** |
308 | * Test: transmit msg of max. size | ||
309 | */ | ||
310 | static int fail_msg_transmited_bigger_max_size; | ||
311 | |||
312 | /** | ||
313 | * Test: transmit msg of max. size | ||
314 | */ | ||
315 | static int fail_msg_transmited_max_size; | ||
316 | |||
317 | /** | ||
308 | * Test: connect to peer without peer identification | 318 | * Test: connect to peer without peer identification |
309 | */ | 319 | */ |
310 | static struct HTTP_Transfer test_no_ident; | 320 | static struct HTTP_Transfer test_no_ident; |
@@ -362,12 +372,12 @@ shutdown_clean () | |||
362 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test plugin functions failed\n"); | 372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test plugin functions failed\n"); |
363 | fail = 1; | 373 | fail = 1; |
364 | } | 374 | } |
365 | if ((test_no_ident.test_failed == GNUNET_YES) || (test_too_short_ident.test_failed == GNUNET_YES) || (test_too_long_ident.test_failed == GNUNET_YES)) | 375 | if ((test_no_ident.test_failed == GNUNET_YES) || (test_too_short_ident.test_failed == GNUNET_YES) || (test_too_long_ident.test_failed == GNUNET_YES) || (test_valid_ident.test_failed == GNUNET_YES)) |
366 | { | 376 | { |
367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test connect with wrong data failed\n"); | 377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test connect with wrong data failed\n"); |
368 | fail = 1; | 378 | fail = 1; |
369 | } | 379 | } |
370 | if ((test_valid_ident.test_failed == GNUNET_YES) || (fail_msgs_transmited_to_local_addrs != count_str_addr)) | 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)) |
371 | { | 381 | { |
372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test sending with plugin failed\n"); | 382 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test sending with plugin failed\n"); |
373 | fail = 1; | 383 | fail = 1; |
@@ -437,23 +447,29 @@ static void task_send_cont (void *cls, | |||
437 | struct Plugin_Address * tmp_addr; | 447 | struct Plugin_Address * tmp_addr; |
438 | tmp_addr = addr_head; | 448 | tmp_addr = addr_head; |
439 | 449 | ||
440 | while (tmp_addr != NULL) | 450 | if ((cls == &fail_msgs_transmited_to_local_addrs) && (result == GNUNET_OK)) |
441 | { | 451 | { |
442 | if (cls == tmp_addr) | 452 | fail_msgs_transmited_to_local_addrs++; |
443 | if (result == GNUNET_OK) fail_msgs_transmited_to_local_addrs++; | 453 | if (fail_msgs_transmited_to_local_addrs == count_str_addr) |
444 | tmp_addr = tmp_addr->next; | 454 | { |
455 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message sent to %u addresses!\n",fail_msgs_transmited_to_local_addrs); | ||
456 | } | ||
457 | return; | ||
445 | } | 458 | } |
446 | 459 | ||
447 | if (fail_msgs_transmited_to_local_addrs == count_str_addr) | 460 | if ((cls == &fail_msg_transmited_bigger_max_size) && (result == GNUNET_SYSERR)) |
461 | { | ||
462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message bigger max msg size was not sent!\n"); | ||
463 | fail_msg_transmited_bigger_max_size = GNUNET_NO; | ||
464 | return; | ||
465 | } | ||
448 | 466 | ||
467 | if ((cls == &fail_msg_transmited_max_size) && (result == GNUNET_OK)) | ||
449 | { | 468 | { |
450 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message sent to %u addresses!\n",fail_msgs_transmited_to_local_addrs); | 469 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message with max msg size succesfully sent!\n",fail_msgs_transmited_to_local_addrs); |
470 | fail_msg_transmited_max_size = GNUNET_NO; | ||
451 | shutdown_clean(); | 471 | shutdown_clean(); |
452 | } | 472 | } |
453 | |||
454 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message was sent!\n"); | ||
455 | fail = GNUNET_NO; | ||
456 | //shutdown_clean(); | ||
457 | } | 473 | } |
458 | 474 | ||
459 | #if 0 | 475 | #if 0 |
@@ -874,7 +890,6 @@ static void pretty_printer_cb (void *cls, | |||
874 | static void run_connection_tests( ) | 890 | static void run_connection_tests( ) |
875 | { | 891 | { |
876 | char * host_str = NULL; | 892 | char * host_str = NULL; |
877 | GNUNET_log (GNUNET_ERROR_TYPE_INFO,"Addr: %s\n",test_addr); | ||
878 | /* resetting buffers */ | 893 | /* resetting buffers */ |
879 | buffer_in.size = HTTP_BUFFER_SIZE; | 894 | buffer_in.size = HTTP_BUFFER_SIZE; |
880 | buffer_in.pos = 0; | 895 | buffer_in.pos = 0; |
@@ -944,15 +959,13 @@ static void run_connection_tests( ) | |||
944 | char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader)); | 959 | char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader)); |
945 | char address[INET6_ADDRSTRLEN]; | 960 | char address[INET6_ADDRSTRLEN]; |
946 | unsigned int port; | 961 | unsigned int port; |
962 | unsigned int type = 10; | ||
947 | 963 | ||
948 | msg.size=htons(sizeof(struct GNUNET_MessageHeader)); | 964 | msg.size=htons(sizeof(struct GNUNET_MessageHeader)); |
949 | msg.type=htons(13); | ||
950 | memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); | ||
951 | |||
952 | tmp_addr = addr_head; | 965 | tmp_addr = addr_head; |
953 | /* send a message to all addresses advertised by plugin */ | 966 | /* send a message to all addresses advertised by plugin */ |
954 | int count = 0; | ||
955 | 967 | ||
968 | int count = 0; | ||
956 | while (tmp_addr != NULL) | 969 | while (tmp_addr != NULL) |
957 | { | 970 | { |
958 | if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress))) | 971 | if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress))) |
@@ -972,11 +985,31 @@ static void run_connection_tests( ) | |||
972 | GNUNET_break (0); | 985 | GNUNET_break (0); |
973 | return; | 986 | return; |
974 | } | 987 | } |
975 | api->send(api->cls, &my_identity, tmp, sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,tmp_addr->addr, tmp_addr->addrlen, GNUNET_YES, &task_send_cont, tmp_addr); | 988 | msg.type=htons(type); |
989 | memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); | ||
990 | api->send(api->cls, &my_identity, tmp, sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,tmp_addr->addr, tmp_addr->addrlen, GNUNET_YES, &task_send_cont, &fail_msgs_transmited_to_local_addrs); | ||
976 | tmp_addr = tmp_addr->next; | 991 | tmp_addr = tmp_addr->next; |
977 | count ++; | 992 | count ++; |
993 | type ++; | ||
978 | } | 994 | } |
979 | 995 | ||
996 | /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE )*/ | ||
997 | GNUNET_free(tmp); | ||
998 | tmp = GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE); | ||
999 | uint16_t t2 = (uint16_t)GNUNET_SERVER_MAX_MESSAGE_SIZE; | ||
1000 | msg.size = htons(t2); | ||
1001 | 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); | ||
1003 | |||
1004 | |||
1005 | /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */ | ||
1006 | GNUNET_free(tmp); | ||
1007 | tmp = GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE-1); | ||
1008 | uint16_t t = (uint16_t)GNUNET_SERVER_MAX_MESSAGE_SIZE-1; | ||
1009 | msg.size = htons(t); | ||
1010 | memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); | ||
1011 | api->send(api->cls, &my_identity, tmp, GNUNET_SERVER_MAX_MESSAGE_SIZE-1, 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_YES, &task_send_cont, &fail_msg_transmited_max_size); | ||
1012 | GNUNET_free(tmp); | ||
980 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No more tests to run\n"); | 1013 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No more tests to run\n"); |
981 | } | 1014 | } |
982 | 1015 | ||
@@ -1009,6 +1042,7 @@ run (void *cls, | |||
1009 | fail_notify_address = GNUNET_YES; | 1042 | fail_notify_address = GNUNET_YES; |
1010 | fail_addr_to_str = GNUNET_YES; | 1043 | fail_addr_to_str = GNUNET_YES; |
1011 | fail_msgs_transmited_to_local_addrs = 0; | 1044 | fail_msgs_transmited_to_local_addrs = 0; |
1045 | fail_msg_transmited_max_size = GNUNET_YES; | ||
1012 | 1046 | ||
1013 | addr_head = NULL; | 1047 | addr_head = NULL; |
1014 | count_str_addr = 0; | 1048 | count_str_addr = 0; |