diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-06-16 14:29:53 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-06-16 14:29:53 +0000 |
commit | 81d3fe28ab2acc5b9aa32abd74faa18a02d02927 (patch) | |
tree | cc79e940a6c6e48151fdd7919923eedbda7f7243 /src/transport/test_plugin_transport_http.c | |
parent | e6711956202906f06041af26590ce9e5bfa63352 (diff) | |
download | gnunet-81d3fe28ab2acc5b9aa32abd74faa18a02d02927.tar.gz gnunet-81d3fe28ab2acc5b9aa32abd74faa18a02d02927.zip |
changes to tests
Diffstat (limited to 'src/transport/test_plugin_transport_http.c')
-rw-r--r-- | src/transport/test_plugin_transport_http.c | 373 |
1 files changed, 199 insertions, 174 deletions
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index 73a9c950a..e3313ca59 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c | |||
@@ -386,6 +386,8 @@ static CURLM *multi_handle; | |||
386 | */ | 386 | */ |
387 | static GNUNET_SCHEDULER_TaskIdentifier http_task_send; | 387 | static GNUNET_SCHEDULER_TaskIdentifier http_task_send; |
388 | 388 | ||
389 | static char * servicehome; | ||
390 | |||
389 | /** | 391 | /** |
390 | * Shutdown testcase | 392 | * Shutdown testcase |
391 | */ | 393 | */ |
@@ -401,7 +403,7 @@ shutdown_clean () | |||
401 | (fail_addr_to_str == GNUNET_YES)) | 403 | (fail_addr_to_str == GNUNET_YES)) |
402 | { | 404 | { |
403 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 405 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
404 | "Phase 0: Test plugin functions failed\n"); | 406 | "Phase 0: Test plugin functions failed\n"); |
405 | fail = 1; | 407 | fail = 1; |
406 | } | 408 | } |
407 | if ( (test_no_ident.test_failed == GNUNET_YES) || | 409 | if ( (test_no_ident.test_failed == GNUNET_YES) || |
@@ -410,7 +412,7 @@ shutdown_clean () | |||
410 | (test_valid_ident.test_failed == GNUNET_YES) ) | 412 | (test_valid_ident.test_failed == GNUNET_YES) ) |
411 | { | 413 | { |
412 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 414 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
413 | "Phase 1: Test connect with wrong data failed\n"); | 415 | "Phase 1: Test connect with wrong data failed\n"); |
414 | fail = 1; | 416 | fail = 1; |
415 | } | 417 | } |
416 | if ( (fail_session_selection_any != GNUNET_NO) || | 418 | if ( (fail_session_selection_any != GNUNET_NO) || |
@@ -419,7 +421,7 @@ shutdown_clean () | |||
419 | (fail_session_selection_session_big != GNUNET_NO) ) | 421 | (fail_session_selection_session_big != GNUNET_NO) ) |
420 | { | 422 | { |
421 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 423 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
422 | "Phase 2: Test session selection failed\n"); | 424 | "Phase 2: Test session selection failed\n"); |
423 | fail = 1; | 425 | fail = 1; |
424 | } | 426 | } |
425 | if ( (fail_msgs_transmited_to_local_addrs != count_str_addr) || | 427 | if ( (fail_msgs_transmited_to_local_addrs != count_str_addr) || |
@@ -427,13 +429,13 @@ shutdown_clean () | |||
427 | (fail_msg_transmited_max_size == GNUNET_YES) ) | 429 | (fail_msg_transmited_max_size == GNUNET_YES) ) |
428 | { | 430 | { |
429 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 431 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
430 | "Phase 3: Test sending with plugin failed\n"); | 432 | "Phase 3: Test sending with plugin failed\n"); |
431 | fail = 1; | 433 | fail = 1; |
432 | } | 434 | } |
433 | if (fail != 1) | 435 | if (fail != 1) |
434 | { | 436 | { |
435 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 437 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
436 | "All tests successful\n"); | 438 | "All tests successful\n"); |
437 | } | 439 | } |
438 | 440 | ||
439 | api->disconnect(api->cls,&my_identity); | 441 | api->disconnect(api->cls,&my_identity); |
@@ -472,14 +474,21 @@ shutdown_clean () | |||
472 | 474 | ||
473 | GNUNET_free(test_addr); | 475 | GNUNET_free(test_addr); |
474 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 476 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
475 | "Unloading http plugin\n"); | 477 | "Unloading http plugin\n"); |
476 | GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_gnunet_transport_plugin_http", api)); | 478 | GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_gnunet_transport_plugin_http", api)); |
477 | 479 | ||
478 | GNUNET_SCHEDULER_shutdown(); | 480 | GNUNET_SCHEDULER_shutdown(); |
479 | GNUNET_DISK_directory_remove ("/tmp/test_gnunet_transport_plugin_http"); | 481 | GNUNET_DISK_directory_remove ("/tmp/test_gnunet_transport_plugin_http"); |
480 | 482 | ||
481 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 483 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
482 | "Exiting testcase\n"); | 484 | "Exiting testcase\n"); |
485 | |||
486 | if (servicehome != NULL) | ||
487 | { | ||
488 | GNUNET_DISK_directory_remove (servicehome); | ||
489 | GNUNET_free (servicehome); | ||
490 | } | ||
491 | |||
483 | exit(fail); | 492 | exit(fail); |
484 | return; | 493 | return; |
485 | } | 494 | } |
@@ -494,13 +503,13 @@ shutdown_clean () | |||
494 | 503 | ||
495 | static void | 504 | static void |
496 | task_send_cont (void *cls, | 505 | task_send_cont (void *cls, |
497 | const struct GNUNET_PeerIdentity * target, | 506 | const struct GNUNET_PeerIdentity * target, |
498 | int result) | 507 | int result) |
499 | { | 508 | { |
500 | if ((cls == &fail_msg_transmited_bigger_max_size) && (result == GNUNET_SYSERR)) | 509 | if ((cls == &fail_msg_transmited_bigger_max_size) && (result == GNUNET_SYSERR)) |
501 | { | 510 | { |
502 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 511 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
503 | "Message bigger max msg size was not sent!\n"); | 512 | "Message bigger max msg size was not sent!\n"); |
504 | fail_msg_transmited_bigger_max_size = GNUNET_NO; | 513 | fail_msg_transmited_bigger_max_size = GNUNET_NO; |
505 | return; | 514 | return; |
506 | } | 515 | } |
@@ -508,8 +517,8 @@ task_send_cont (void *cls, | |||
508 | if ((cls == &fail_msg_transmited_max_size) && (result == GNUNET_OK)) | 517 | if ((cls == &fail_msg_transmited_max_size) && (result == GNUNET_OK)) |
509 | { | 518 | { |
510 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 519 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
511 | "Message with max msg size succesfully sent!\n", | 520 | "Message with max msg size succesfully sent!\n", |
512 | fail_msgs_transmited_to_local_addrs); | 521 | fail_msgs_transmited_to_local_addrs); |
513 | fail_msg_transmited_max_size = GNUNET_NO; | 522 | fail_msg_transmited_max_size = GNUNET_NO; |
514 | } | 523 | } |
515 | } | 524 | } |
@@ -530,18 +539,18 @@ receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
530 | uint16_t sender_address_len) | 539 | uint16_t sender_address_len) |
531 | { | 540 | { |
532 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 541 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
533 | "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", | 542 | "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", |
534 | GNUNET_i2s(peer), | 543 | GNUNET_i2s(peer), |
535 | ntohs(message->type), | 544 | ntohs(message->type), |
536 | ntohs(message->size), | 545 | ntohs(message->size), |
537 | session); | 546 | session); |
538 | 547 | ||
539 | if ( (ntohs(message->type)>=10) && | 548 | if ( (ntohs(message->type)>=10) && |
540 | (ntohs(message->type)<20) ) | 549 | (ntohs(message->type)<20) ) |
541 | { | 550 | { |
542 | fail_msgs_transmited_to_local_addrs++; | 551 | fail_msgs_transmited_to_local_addrs++; |
543 | if (fail_msgs_transmited_to_local_addrs == count_str_addr) | 552 | if (fail_msgs_transmited_to_local_addrs == count_str_addr) |
544 | run_connection_tests(2, session); | 553 | run_connection_tests(2, session); |
545 | } | 554 | } |
546 | if ((ntohs(message->type)==20)) | 555 | if ((ntohs(message->type)==20)) |
547 | { | 556 | { |
@@ -616,8 +625,8 @@ header_function( void *ptr, size_t size, size_t nmemb, void *stream) | |||
616 | tmp[len-2]= '\0'; | 625 | tmp[len-2]= '\0'; |
617 | #if DEBUG_CURL | 626 | #if DEBUG_CURL |
618 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 627 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
619 | "Header: `%s'\n", | 628 | "Header: `%s'\n", |
620 | tmp); | 629 | tmp); |
621 | #endif | 630 | #endif |
622 | if (0==strcmp (tmp,"HTTP/1.1 100 Continue")) | 631 | if (0==strcmp (tmp,"HTTP/1.1 100 Continue")) |
623 | { | 632 | { |
@@ -651,7 +660,7 @@ send_prepare( struct HTTP_Transfer * result); | |||
651 | 660 | ||
652 | static void | 661 | static void |
653 | send_execute (void *cls, | 662 | send_execute (void *cls, |
654 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 663 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
655 | { | 664 | { |
656 | struct HTTP_Transfer *res; | 665 | struct HTTP_Transfer *res; |
657 | 666 | ||
@@ -702,50 +711,50 @@ send_execute (void *cls, | |||
702 | if (res == &test_no_ident) | 711 | if (res == &test_no_ident) |
703 | { | 712 | { |
704 | if ((res->http_result_code==404) && (buffer_in.len==208)) | 713 | if ((res->http_result_code==404) && (buffer_in.len==208)) |
705 | { | 714 | { |
706 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 715 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
707 | "Connecting to peer without any peer identification: test passed\n"); | 716 | "Connecting to peer without any peer identification: test passed\n"); |
708 | res->test_failed = GNUNET_NO; | 717 | res->test_failed = GNUNET_NO; |
709 | } | 718 | } |
710 | else | 719 | else |
711 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 720 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
712 | _("Connecting to peer without any peer identification: test failed\n")); | 721 | _("Connecting to peer without any peer identification: test failed\n")); |
713 | } | 722 | } |
714 | if (res == &test_too_short_ident) | 723 | if (res == &test_too_short_ident) |
715 | { | 724 | { |
716 | if ((res->http_result_code==404) && (buffer_in.len==208)) | 725 | if ((res->http_result_code==404) && (buffer_in.len==208)) |
717 | { | 726 | { |
718 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 727 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
719 | "Connecting to peer with too short peer identification: test passed\n"); | 728 | "Connecting to peer with too short peer identification: test passed\n"); |
720 | res->test_failed = GNUNET_NO; | 729 | res->test_failed = GNUNET_NO; |
721 | } | 730 | } |
722 | else | 731 | else |
723 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 732 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
724 | _("Connecting to peer with too short peer identification: test failed\n")); | 733 | _("Connecting to peer with too short peer identification: test failed\n")); |
725 | } | 734 | } |
726 | if (res == &test_too_long_ident) | 735 | if (res == &test_too_long_ident) |
727 | { | 736 | { |
728 | if ((res->http_result_code==404) && (buffer_in.len==208)) | 737 | if ((res->http_result_code==404) && (buffer_in.len==208)) |
729 | { | 738 | { |
730 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 739 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
731 | "Connecting to peer with too long peer identification: test passed\n"); | 740 | "Connecting to peer with too long peer identification: test passed\n"); |
732 | res->test_failed = GNUNET_NO; | 741 | res->test_failed = GNUNET_NO; |
733 | } | 742 | } |
734 | else | 743 | else |
735 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 744 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
736 | _("Connecting to peer with too long peer identification: test failed\n")); | 745 | _("Connecting to peer with too long peer identification: test failed\n")); |
737 | } | 746 | } |
738 | if (res == &test_valid_ident) | 747 | if (res == &test_valid_ident) |
739 | { | 748 | { |
740 | if ((res->http_result_code==200)) | 749 | if ((res->http_result_code==200)) |
741 | { | 750 | { |
742 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 751 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
743 | "Connecting to peer with valid peer identification: test passed\n"); | 752 | "Connecting to peer with valid peer identification: test passed\n"); |
744 | res->test_failed = GNUNET_NO; | 753 | res->test_failed = GNUNET_NO; |
745 | } | 754 | } |
746 | else | 755 | else |
747 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 756 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
748 | "Connecting to peer with valid peer identification: test failed\n"); | 757 | "Connecting to peer with valid peer identification: test failed\n"); |
749 | } | 758 | } |
750 | curl_easy_cleanup(curl_handle); | 759 | curl_easy_cleanup(curl_handle); |
751 | curl_handle=NULL; | 760 | curl_handle=NULL; |
@@ -811,12 +820,12 @@ send_prepare( struct HTTP_Transfer * result) | |||
811 | GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); | 820 | GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); |
812 | GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); | 821 | GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); |
813 | http_task_send = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 822 | http_task_send = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
814 | GNUNET_SCHEDULER_NO_TASK, | 823 | GNUNET_SCHEDULER_NO_TASK, |
815 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0), | 824 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0), |
816 | grs, | 825 | grs, |
817 | gws, | 826 | gws, |
818 | &send_execute, | 827 | &send_execute, |
819 | result); | 828 | result); |
820 | GNUNET_NETWORK_fdset_destroy (gws); | 829 | GNUNET_NETWORK_fdset_destroy (gws); |
821 | GNUNET_NETWORK_fdset_destroy (grs); | 830 | GNUNET_NETWORK_fdset_destroy (grs); |
822 | 831 | ||
@@ -829,7 +838,7 @@ send_prepare( struct HTTP_Transfer * result) | |||
829 | */ | 838 | */ |
830 | static int | 839 | static int |
831 | send_data(struct HTTP_Transfer * result, | 840 | send_data(struct HTTP_Transfer * result, |
832 | char * url) | 841 | char * url) |
833 | { | 842 | { |
834 | 843 | ||
835 | curl_handle = curl_easy_init(); | 844 | curl_handle = curl_easy_init(); |
@@ -895,9 +904,9 @@ notify_address (void *cls, | |||
895 | return; | 904 | return; |
896 | } | 905 | } |
897 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 906 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
898 | _("Transport plugin notification for address: `%s':%u\n"), | 907 | _("Transport plugin notification for address: `%s':%u\n"), |
899 | address, | 908 | address, |
900 | port); | 909 | port); |
901 | pl_addr = GNUNET_malloc (sizeof (struct Plugin_Address) ); | 910 | pl_addr = GNUNET_malloc (sizeof (struct Plugin_Address) ); |
902 | pl_addr->addrlen = addrlen; | 911 | pl_addr->addrlen = addrlen; |
903 | pl_addr->addr = GNUNET_malloc(addrlen); | 912 | pl_addr->addr = GNUNET_malloc(addrlen); |
@@ -912,9 +921,9 @@ notify_address (void *cls, | |||
912 | { | 921 | { |
913 | cur = addr_head; | 922 | cur = addr_head; |
914 | while (NULL != cur->next) | 923 | while (NULL != cur->next) |
915 | { | 924 | { |
916 | cur = cur->next; | 925 | cur = cur->next; |
917 | } | 926 | } |
918 | cur->next = pl_addr; | 927 | cur->next = pl_addr; |
919 | } | 928 | } |
920 | fail_notify_address_count++; | 929 | fail_notify_address_count++; |
@@ -923,13 +932,13 @@ notify_address (void *cls, | |||
923 | 932 | ||
924 | static void | 933 | static void |
925 | plugin_env_session_end (void *cls, | 934 | plugin_env_session_end (void *cls, |
926 | const struct GNUNET_PeerIdentity *peer, | 935 | const struct GNUNET_PeerIdentity *peer, |
927 | struct Session *session) | 936 | struct Session *session) |
928 | { | 937 | { |
929 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 938 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
930 | "Pluging tells me: session %X to peer `%s' ended\n", | 939 | "Pluging tells me: session %X to peer `%s' ended\n", |
931 | session, | 940 | session, |
932 | GNUNET_i2s(peer)); | 941 | GNUNET_i2s(peer)); |
933 | } | 942 | } |
934 | 943 | ||
935 | 944 | ||
@@ -970,13 +979,13 @@ task_timeout (void *cls, | |||
970 | 979 | ||
971 | static void | 980 | static void |
972 | pretty_printer_cb (void *cls, | 981 | pretty_printer_cb (void *cls, |
973 | const char *address) | 982 | const char *address) |
974 | { | 983 | { |
975 | if (NULL==address) | 984 | if (NULL==address) |
976 | return; | 985 | return; |
977 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 986 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
978 | "Plugin returned pretty address: `%s'\n", | 987 | "Plugin returned pretty address: `%s'\n", |
979 | address); | 988 | address); |
980 | fail_pretty_printer_count++; | 989 | fail_pretty_printer_count++; |
981 | } | 990 | } |
982 | 991 | ||
@@ -1003,71 +1012,71 @@ run_connection_tests( int phase , void * cls) | |||
1003 | 1012 | ||
1004 | if (test_no_ident.test_executed == GNUNET_NO) | 1013 | if (test_no_ident.test_executed == GNUNET_NO) |
1005 | { | 1014 | { |
1006 | /* Connecting to peer without identification */ | 1015 | /* Connecting to peer without identification */ |
1007 | const char * ident = ""; | 1016 | const char * ident = ""; |
1008 | GNUNET_asprintf (&host_str, | 1017 | GNUNET_asprintf (&host_str, |
1009 | "%s://%s/%s", | 1018 | "%s://%s/%s", |
1010 | PROTOCOL_PREFIX, | 1019 | PROTOCOL_PREFIX, |
1011 | test_addr,ident); | 1020 | test_addr,ident); |
1012 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1021 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1013 | _("Connecting to peer without any peer identification.\n")); | 1022 | _("Connecting to peer without any peer identification.\n")); |
1014 | test_no_ident.test_executed = GNUNET_YES; | 1023 | test_no_ident.test_executed = GNUNET_YES; |
1015 | send_data ( &test_no_ident, host_str); | 1024 | send_data ( &test_no_ident, host_str); |
1016 | GNUNET_free (host_str); | 1025 | GNUNET_free (host_str); |
1017 | return; | 1026 | return; |
1018 | } | 1027 | } |
1019 | if (test_too_short_ident.test_executed == GNUNET_NO) | 1028 | if (test_too_short_ident.test_executed == GNUNET_NO) |
1020 | { | 1029 | { |
1021 | const char * ident = "AAAAAAAAAA"; | 1030 | const char * ident = "AAAAAAAAAA"; |
1022 | /* Connecting to peer with too short identification */ | 1031 | /* Connecting to peer with too short identification */ |
1023 | GNUNET_asprintf (&host_str, | 1032 | GNUNET_asprintf (&host_str, |
1024 | "%s://%s/%s", | 1033 | "%s://%s/%s", |
1025 | PROTOCOL_PREFIX, | 1034 | PROTOCOL_PREFIX, |
1026 | test_addr, | 1035 | test_addr, |
1027 | ident); | 1036 | ident); |
1028 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1037 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1029 | _("Connecting to peer with too short peer identification.\n")); | 1038 | _("Connecting to peer with too short peer identification.\n")); |
1030 | test_too_short_ident.test_executed = GNUNET_YES; | 1039 | test_too_short_ident.test_executed = GNUNET_YES; |
1031 | send_data ( &test_too_short_ident, host_str); | 1040 | send_data ( &test_too_short_ident, host_str); |
1032 | GNUNET_free (host_str); | 1041 | GNUNET_free (host_str); |
1033 | return; | 1042 | return; |
1034 | } | 1043 | } |
1035 | 1044 | ||
1036 | if (test_too_long_ident.test_executed == GNUNET_NO) | 1045 | if (test_too_long_ident.test_executed == GNUNET_NO) |
1037 | { | 1046 | { |
1038 | const char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; | 1047 | const char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; |
1039 | 1048 | ||
1040 | /* Connecting to peer with too long identification */ | 1049 | /* Connecting to peer with too long identification */ |
1041 | GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident); | 1050 | GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident); |
1042 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1051 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1043 | _("Connecting to peer with too long peer identification.\n")); | 1052 | _("Connecting to peer with too long peer identification.\n")); |
1044 | test_too_long_ident.test_executed = GNUNET_YES; | 1053 | test_too_long_ident.test_executed = GNUNET_YES; |
1045 | send_data ( &test_too_long_ident, host_str); | 1054 | send_data ( &test_too_long_ident, host_str); |
1046 | GNUNET_free (host_str); | 1055 | GNUNET_free (host_str); |
1047 | return; | 1056 | return; |
1048 | } | 1057 | } |
1049 | if (test_valid_ident.test_executed == GNUNET_NO) | 1058 | if (test_valid_ident.test_executed == GNUNET_NO) |
1050 | { | 1059 | { |
1051 | struct GNUNET_CRYPTO_HashAsciiEncoded ident; | 1060 | struct GNUNET_CRYPTO_HashAsciiEncoded ident; |
1052 | GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&ident); | 1061 | GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&ident); |
1053 | GNUNET_asprintf (&host_str, | 1062 | GNUNET_asprintf (&host_str, |
1054 | "%s://%s/%s%s", | 1063 | "%s://%s/%s%s", |
1055 | PROTOCOL_PREFIX, | 1064 | PROTOCOL_PREFIX, |
1056 | test_addr, | 1065 | test_addr, |
1057 | (char *) &ident, | 1066 | (char *) &ident, |
1058 | ";0"); | 1067 | ";0"); |
1059 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1068 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1060 | _("Connecting to peer with valid peer identification.\n")); | 1069 | _("Connecting to peer with valid peer identification.\n")); |
1061 | test_valid_ident.test_executed = GNUNET_YES; | 1070 | test_valid_ident.test_executed = GNUNET_YES; |
1062 | send_data ( &test_valid_ident, host_str); | 1071 | send_data ( &test_valid_ident, host_str); |
1063 | GNUNET_free (host_str); | 1072 | GNUNET_free (host_str); |
1064 | return; | 1073 | return; |
1065 | } | 1074 | } |
1066 | } | 1075 | } |
1067 | if (phase==1) | 1076 | if (phase==1) |
1068 | { | 1077 | { |
1069 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1078 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1070 | "\nPhase 1: transmit data to all suggested addresses\n\n"); | 1079 | "\nPhase 1: transmit data to all suggested addresses\n\n"); |
1071 | /* Using one of the addresses the plugin proposed */ | 1080 | /* Using one of the addresses the plugin proposed */ |
1072 | GNUNET_assert (addr_head->addr != NULL); | 1081 | GNUNET_assert (addr_head->addr != NULL); |
1073 | 1082 | ||
@@ -1084,41 +1093,41 @@ run_connection_tests( int phase , void * cls) | |||
1084 | 1093 | ||
1085 | int count = 0; | 1094 | int count = 0; |
1086 | while (tmp_addr != NULL) | 1095 | while (tmp_addr != NULL) |
1087 | { | 1096 | { |
1088 | if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress))) | 1097 | if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress))) |
1089 | { | 1098 | { |
1090 | inet_ntop(AF_INET, (struct in_addr *) tmp_addr->addr,address,INET_ADDRSTRLEN); | 1099 | inet_ntop(AF_INET, (struct in_addr *) tmp_addr->addr,address,INET_ADDRSTRLEN); |
1091 | port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port); | 1100 | port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port); |
1092 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1101 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1093 | "Sending message to addres no. %u: `%s':%u\n", | 1102 | "Sending message to addres no. %u: `%s':%u\n", |
1094 | count, | 1103 | count, |
1095 | address, | 1104 | address, |
1096 | port); | 1105 | port); |
1097 | } | 1106 | } |
1098 | if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress))) | 1107 | if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress))) |
1099 | { | 1108 | { |
1100 | inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN); | 1109 | inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN); |
1101 | port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port); | 1110 | port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port); |
1102 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1111 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1103 | "Sending message to addres no. %u: `%s':%u\n", | 1112 | "Sending message to addres no. %u: `%s':%u\n", |
1104 | count, | 1113 | count, |
1105 | address, | 1114 | address, |
1106 | port); | 1115 | port); |
1107 | } | 1116 | } |
1108 | msg.type=htons(type); | 1117 | msg.type=htons(type); |
1109 | memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); | 1118 | memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); |
1110 | api->send(api->cls, | 1119 | api->send(api->cls, |
1111 | &my_identity, | 1120 | &my_identity, |
1112 | tmp, sizeof(struct GNUNET_MessageHeader), | 1121 | tmp, sizeof(struct GNUNET_MessageHeader), |
1113 | 0, TIMEOUT, | 1122 | 0, TIMEOUT, |
1114 | NULL, | 1123 | NULL, |
1115 | tmp_addr->addr, tmp_addr->addrlen, | 1124 | tmp_addr->addr, tmp_addr->addrlen, |
1116 | GNUNET_YES, | 1125 | GNUNET_YES, |
1117 | &task_send_cont, &fail_msgs_transmited_to_local_addrs); | 1126 | &task_send_cont, &fail_msgs_transmited_to_local_addrs); |
1118 | tmp_addr = tmp_addr->next; | 1127 | tmp_addr = tmp_addr->next; |
1119 | count++; | 1128 | count++; |
1120 | type++; | 1129 | type++; |
1121 | } | 1130 | } |
1122 | GNUNET_free(tmp); | 1131 | GNUNET_free(tmp); |
1123 | return; | 1132 | return; |
1124 | } | 1133 | } |
@@ -1129,32 +1138,32 @@ run_connection_tests( int phase , void * cls) | |||
1129 | msg = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader)); | 1138 | msg = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader)); |
1130 | 1139 | ||
1131 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1140 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1132 | "Phase 2: session selection\n\n"); | 1141 | "Phase 2: session selection\n\n"); |
1133 | size = sizeof(struct GNUNET_MessageHeader); | 1142 | size = sizeof(struct GNUNET_MessageHeader); |
1134 | msg->size=htons(size); | 1143 | msg->size=htons(size); |
1135 | msg->type = htons(20); | 1144 | msg->type = htons(20); |
1136 | api->send(api->cls, | 1145 | api->send(api->cls, |
1137 | &my_identity, | 1146 | &my_identity, |
1138 | (const char *) msg, size, | 1147 | (const char *) msg, size, |
1139 | 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, | 1148 | 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, |
1140 | &task_send_cont, NULL); | 1149 | &task_send_cont, NULL); |
1141 | 1150 | ||
1142 | msg->type = htons(21); | 1151 | msg->type = htons(21); |
1143 | api->send(api->cls, | 1152 | api->send(api->cls, |
1144 | &my_identity, | 1153 | &my_identity, |
1145 | (const char *) msg, size, | 1154 | (const char *) msg, size, |
1146 | 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, | 1155 | 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, |
1147 | &task_send_cont, NULL); | 1156 | &task_send_cont, NULL); |
1148 | 1157 | ||
1149 | /* answer on session*/ | 1158 | /* answer on session*/ |
1150 | size = sizeof( struct GNUNET_MessageHeader); | 1159 | size = sizeof( struct GNUNET_MessageHeader); |
1151 | msg->size = htons(size); | 1160 | msg->size = htons(size); |
1152 | msg->type = htons(22); | 1161 | msg->type = htons(22); |
1153 | api->send(api->cls, | 1162 | api->send(api->cls, |
1154 | &my_identity, | 1163 | &my_identity, |
1155 | (const char *) msg, size, | 1164 | (const char *) msg, size, |
1156 | 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR, | 1165 | 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR, |
1157 | &task_send_cont, NULL); | 1166 | &task_send_cont, NULL); |
1158 | GNUNET_free(msg); | 1167 | GNUNET_free(msg); |
1159 | 1168 | ||
1160 | /* answer on session with big message not fitting in mhd send buffer*/ | 1169 | /* answer on session with big message not fitting in mhd send buffer*/ |
@@ -1163,10 +1172,10 @@ run_connection_tests( int phase , void * cls) | |||
1163 | msg->size=htons(size); | 1172 | msg->size=htons(size); |
1164 | msg->type = htons(23); | 1173 | msg->type = htons(23); |
1165 | api->send(api->cls, | 1174 | api->send(api->cls, |
1166 | &my_identity, | 1175 | &my_identity, |
1167 | (const char *) msg, size, | 1176 | (const char *) msg, size, |
1168 | 0, TIMEOUT, session, NULL, 0, GNUNET_NO, | 1177 | 0, TIMEOUT, session, NULL, 0, GNUNET_NO, |
1169 | &task_send_cont, NULL); | 1178 | &task_send_cont, NULL); |
1170 | GNUNET_free(msg); | 1179 | GNUNET_free(msg); |
1171 | return; | 1180 | return; |
1172 | } | 1181 | } |
@@ -1175,7 +1184,7 @@ run_connection_tests( int phase , void * cls) | |||
1175 | { | 1184 | { |
1176 | 1185 | ||
1177 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1186 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1178 | "Phase 3: send multiple or big messages after disconnect\n\n"); | 1187 | "Phase 3: send multiple or big messages after disconnect\n\n"); |
1179 | /* disconnect from peer, so new connections are created */ | 1188 | /* disconnect from peer, so new connections are created */ |
1180 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Disconnect from peer: `%s'\n", GNUNET_i2s(&my_identity)); | 1189 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Disconnect from peer: `%s'\n", GNUNET_i2s(&my_identity)); |
1181 | api->disconnect(api->cls, &my_identity); | 1190 | api->disconnect(api->cls, &my_identity); |
@@ -1190,12 +1199,12 @@ run_connection_tests( int phase , void * cls) | |||
1190 | msg2->size = htons(2 * sizeof(struct GNUNET_MessageHeader)); | 1199 | msg2->size = htons(2 * sizeof(struct GNUNET_MessageHeader)); |
1191 | msg2->type = htons(31); | 1200 | msg2->type = htons(31); |
1192 | api->send(api->cls, | 1201 | api->send(api->cls, |
1193 | &my_identity, | 1202 | &my_identity, |
1194 | (const char *) msg, 4 * sizeof(struct GNUNET_MessageHeader), | 1203 | (const char *) msg, 4 * sizeof(struct GNUNET_MessageHeader), |
1195 | 0, TIMEOUT, NULL, | 1204 | 0, TIMEOUT, NULL, |
1196 | addr_head->addr, addr_head->addrlen, | 1205 | addr_head->addr, addr_head->addrlen, |
1197 | GNUNET_NO, | 1206 | GNUNET_NO, |
1198 | &task_send_cont, &fail_multiple_msgs_in_transmission); | 1207 | &task_send_cont, &fail_multiple_msgs_in_transmission); |
1199 | GNUNET_free(msg); | 1208 | GNUNET_free(msg); |
1200 | /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */ | 1209 | /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */ |
1201 | 1210 | ||
@@ -1204,15 +1213,15 @@ run_connection_tests( int phase , void * cls) | |||
1204 | msg->size = htons(size); | 1213 | msg->size = htons(size); |
1205 | msg->type = htons(32); | 1214 | msg->type = htons(32); |
1206 | api->send(api->cls, | 1215 | api->send(api->cls, |
1207 | &my_identity, | 1216 | &my_identity, |
1208 | (const char *) msg, size, | 1217 | (const char *) msg, size, |
1209 | 0, TIMEOUT, NULL, | 1218 | 0, TIMEOUT, NULL, |
1210 | addr_head->addr, addr_head->addrlen, | 1219 | addr_head->addr, addr_head->addrlen, |
1211 | GNUNET_NO, | 1220 | GNUNET_NO, |
1212 | &task_send_cont, &fail_msg_transmited_max_size); | 1221 | &task_send_cont, &fail_msg_transmited_max_size); |
1213 | GNUNET_free(msg); | 1222 | GNUNET_free(msg); |
1214 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1215 | "No more tests to run\n"); | 1224 | "No more tests to run\n"); |
1216 | } | 1225 | } |
1217 | } | 1226 | } |
1218 | 1227 | ||
@@ -1252,6 +1261,9 @@ run (void *cls, | |||
1252 | addr_head = NULL; | 1261 | addr_head = NULL; |
1253 | count_str_addr = 0; | 1262 | count_str_addr = 0; |
1254 | /* parse configuration */ | 1263 | /* parse configuration */ |
1264 | if (GNUNET_CONFIGURATION_have_value (c,"PATHS", "SERVICEHOME")) | ||
1265 | GNUNET_CONFIGURATION_get_value_string (c, "PATHS", "SERVICEHOME", &servicehome); | ||
1266 | |||
1255 | if ((GNUNET_OK != | 1267 | if ((GNUNET_OK != |
1256 | GNUNET_CONFIGURATION_get_value_number (c, | 1268 | GNUNET_CONFIGURATION_get_value_number (c, |
1257 | "TRANSPORT", | 1269 | "TRANSPORT", |
@@ -1305,8 +1317,8 @@ run (void *cls, | |||
1305 | setup_plugin_environment (); | 1317 | setup_plugin_environment (); |
1306 | GNUNET_asprintf (&libname, "libgnunet_plugin_transport_http"); | 1318 | GNUNET_asprintf (&libname, "libgnunet_plugin_transport_http"); |
1307 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1319 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1308 | _("Loading HTTP transport plugin `%s'\n"), | 1320 | _("Loading HTTP transport plugin `%s'\n"), |
1309 | libname); | 1321 | libname); |
1310 | api = GNUNET_PLUGIN_load (libname, &env); | 1322 | api = GNUNET_PLUGIN_load (libname, &env); |
1311 | GNUNET_free (libname); | 1323 | GNUNET_free (libname); |
1312 | if (api == NULL) | 1324 | if (api == NULL) |
@@ -1323,16 +1335,16 @@ run (void *cls, | |||
1323 | /* testing plugin functionality */ | 1335 | /* testing plugin functionality */ |
1324 | GNUNET_assert (0!=fail_notify_address_count); | 1336 | GNUNET_assert (0!=fail_notify_address_count); |
1325 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1326 | "Transport plugin returned %u addresses to connect to\n", | 1338 | "Transport plugin returned %u addresses to connect to\n", |
1327 | fail_notify_address_count); | 1339 | fail_notify_address_count); |
1328 | 1340 | ||
1329 | /* testing pretty printer with all addresses obtained from the plugin*/ | 1341 | /* testing pretty printer with all addresses obtained from the plugin*/ |
1330 | cur = addr_head; | 1342 | cur = addr_head; |
1331 | while (cur != NULL) | 1343 | while (cur != NULL) |
1332 | { | 1344 | { |
1333 | api->address_pretty_printer (api->cls, "http", | 1345 | api->address_pretty_printer (api->cls, "http", |
1334 | cur->addr,cur->addrlen, GNUNET_NO,TEST_TIMEOUT, | 1346 | cur->addr,cur->addrlen, GNUNET_NO,TEST_TIMEOUT, |
1335 | &pretty_printer_cb, NULL); | 1347 | &pretty_printer_cb, NULL); |
1336 | addr_str = api->address_to_string (api->cls, cur->addr, cur->addrlen); | 1348 | addr_str = api->address_to_string (api->cls, cur->addr, cur->addrlen); |
1337 | suggest_res = api->check_address (api->cls, cur->addr, cur->addrlen); | 1349 | suggest_res = api->check_address (api->cls, cur->addr, cur->addrlen); |
1338 | 1350 | ||
@@ -1434,13 +1446,26 @@ main (int argc, char *const *argv) | |||
1434 | #endif | 1446 | #endif |
1435 | NULL); | 1447 | NULL); |
1436 | 1448 | ||
1449 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
1450 | cfg = GNUNET_CONFIGURATION_create (); | ||
1451 | |||
1452 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, "test_plugin_transport_data_http.conf")); | ||
1453 | if (GNUNET_CONFIGURATION_have_value (cfg,"PATHS", "SERVICEHOME")) | ||
1454 | GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", &servicehome); | ||
1455 | GNUNET_DISK_directory_remove (servicehome); | ||
1456 | GNUNET_CONFIGURATION_destroy (cfg); | ||
1457 | |||
1437 | ret = (GNUNET_OK == | 1458 | ret = (GNUNET_OK == |
1438 | GNUNET_PROGRAM_run (5, | 1459 | GNUNET_PROGRAM_run (5, |
1439 | argv_prog, | 1460 | argv_prog, |
1440 | "test_gnunet_transport_plugin_http", | 1461 | "test_gnunet_transport_plugin_http", |
1441 | "testcase", options, &run, NULL)) ? GNUNET_NO : GNUNET_YES; | 1462 | "testcase", options, &run, NULL)) ? GNUNET_NO : GNUNET_YES; |
1442 | 1463 | ||
1443 | GNUNET_DISK_directory_remove ("/tmp/test_plugin_transport_http"); | 1464 | if (servicehome != NULL) |
1465 | { | ||
1466 | GNUNET_DISK_directory_remove (servicehome); | ||
1467 | GNUNET_free (servicehome); | ||
1468 | } | ||
1444 | if (ret != GNUNET_OK) | 1469 | if (ret != GNUNET_OK) |
1445 | return 1; | 1470 | return 1; |
1446 | return fail; | 1471 | return fail; |