diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-06-16 09:35:48 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-06-16 09:35:48 +0000 |
commit | 8aba932e572ee124f5a1b64f150fa360179cd8f1 (patch) | |
tree | 7309d3e7365649e4c54ec1a176cf51940e336b15 /src/transport/test_plugin_transport_http.c | |
parent | b778d1dc7836038f1b5e89c081c92aec46ba76e4 (diff) | |
download | gnunet-8aba932e572ee124f5a1b64f150fa360179cd8f1.tar.gz gnunet-8aba932e572ee124f5a1b64f150fa360179cd8f1.zip |
Diffstat (limited to 'src/transport/test_plugin_transport_http.c')
-rw-r--r-- | src/transport/test_plugin_transport_http.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index 468a2c883..5bbb49084 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c | |||
@@ -218,6 +218,11 @@ static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key; | |||
218 | static long long unsigned int port; | 218 | static long long unsigned int port; |
219 | 219 | ||
220 | /** | 220 | /** |
221 | * Peer's port | ||
222 | */ | ||
223 | static char * test_addr; | ||
224 | |||
225 | /** | ||
221 | * Our scheduler. | 226 | * Our scheduler. |
222 | */ | 227 | */ |
223 | struct GNUNET_SCHEDULER_Handle *sched; | 228 | struct GNUNET_SCHEDULER_Handle *sched; |
@@ -404,6 +409,8 @@ shutdown_clean () | |||
404 | GNUNET_SCHEDULER_cancel(sched,ti_timeout); | 409 | GNUNET_SCHEDULER_cancel(sched,ti_timeout); |
405 | ti_timeout = GNUNET_SCHEDULER_NO_TASK; | 410 | ti_timeout = GNUNET_SCHEDULER_NO_TASK; |
406 | } | 411 | } |
412 | |||
413 | GNUNET_free(test_addr); | ||
407 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unloading http plugin\n"); | 414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unloading http plugin\n"); |
408 | GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_http", api)); | 415 | GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_http", api)); |
409 | 416 | ||
@@ -560,7 +567,7 @@ static size_t header_function( void *ptr, size_t size, size_t nmemb, void *strea | |||
560 | 567 | ||
561 | static size_t send_prepare( struct HTTP_Transfer * result); | 568 | static size_t send_prepare( struct HTTP_Transfer * result); |
562 | 569 | ||
563 | static void run_connection_tests( void ); | 570 | static void run_connection_tests( ); |
564 | 571 | ||
565 | static void send_execute (void *cls, | 572 | static void send_execute (void *cls, |
566 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 573 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -864,10 +871,10 @@ static void pretty_printer_cb (void *cls, | |||
864 | /** | 871 | /** |
865 | * Runs every single test to test the plugin | 872 | * Runs every single test to test the plugin |
866 | */ | 873 | */ |
867 | static void run_connection_tests( void ) | 874 | static void run_connection_tests( ) |
868 | { | 875 | { |
869 | static char * host_str; | 876 | char * host_str = NULL; |
870 | 877 | GNUNET_log (GNUNET_ERROR_TYPE_INFO,"Addr: %s\n",test_addr); | |
871 | /* resetting buffers */ | 878 | /* resetting buffers */ |
872 | buffer_in.size = HTTP_BUFFER_SIZE; | 879 | buffer_in.size = HTTP_BUFFER_SIZE; |
873 | buffer_in.pos = 0; | 880 | buffer_in.pos = 0; |
@@ -881,9 +888,9 @@ static void run_connection_tests( void ) | |||
881 | if (test_no_ident.test_executed == GNUNET_NO) | 888 | if (test_no_ident.test_executed == GNUNET_NO) |
882 | { | 889 | { |
883 | /* Connecting to peer without identification */ | 890 | /* Connecting to peer without identification */ |
884 | 891 | char * ident = ""; | |
885 | host_str = GNUNET_malloc (strlen ("http://localhost:12389/")+1); | 892 | host_str = GNUNET_malloc (strlen ("http:///")+ 1 + strlen (test_addr)+ strlen (ident)); |
886 | GNUNET_asprintf (&host_str, "http://localhost:%u/",port); | 893 | GNUNET_asprintf (&host_str, "http://%s/%s",test_addr,ident); |
887 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer without any peer identification.\n")); | 894 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer without any peer identification.\n")); |
888 | test_no_ident.test_executed = GNUNET_YES; | 895 | test_no_ident.test_executed = GNUNET_YES; |
889 | send_data ( &test_no_ident, host_str); | 896 | send_data ( &test_no_ident, host_str); |
@@ -894,8 +901,8 @@ static void run_connection_tests( void ) | |||
894 | { | 901 | { |
895 | char * ident = "AAAAAAAAAA"; | 902 | char * ident = "AAAAAAAAAA"; |
896 | /* Connecting to peer with too short identification */ | 903 | /* Connecting to peer with too short identification */ |
897 | host_str = GNUNET_malloc (strlen ("http://localhost:12389/") + strlen (ident)); | 904 | host_str = GNUNET_malloc (strlen ("http:///")+ 1 + strlen (test_addr)+ strlen (ident)); |
898 | GNUNET_asprintf (&host_str, "http://localhost:%u/%s",port,ident); | 905 | GNUNET_asprintf (&host_str, "http://%s/%s",test_addr,ident); |
899 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer with too short peer identification.\n")); | 906 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer with too short peer identification.\n")); |
900 | test_too_short_ident.test_executed = GNUNET_YES; | 907 | test_too_short_ident.test_executed = GNUNET_YES; |
901 | send_data ( &test_too_short_ident, host_str); | 908 | send_data ( &test_too_short_ident, host_str); |
@@ -908,8 +915,8 @@ static void run_connection_tests( void ) | |||
908 | char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; | 915 | char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; |
909 | 916 | ||
910 | /* Connecting to peer with too long identification */ | 917 | /* Connecting to peer with too long identification */ |
911 | host_str = GNUNET_malloc (strlen ("http://localhost:12389/") + strlen (ident)); | 918 | host_str = GNUNET_malloc (strlen ("http:///")+ 1 + strlen (test_addr)+ strlen (ident)); |
912 | GNUNET_asprintf (&host_str, "http://localhost:%u/%s",port,ident); | 919 | GNUNET_asprintf (&host_str, "http://%s/%s",test_addr,ident); |
913 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer with too long peer identification.\n")); | 920 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer with too long peer identification.\n")); |
914 | test_too_long_ident.test_executed = GNUNET_YES; | 921 | test_too_long_ident.test_executed = GNUNET_YES; |
915 | send_data ( &test_too_long_ident, host_str); | 922 | send_data ( &test_too_long_ident, host_str); |
@@ -918,10 +925,10 @@ static void run_connection_tests( void ) | |||
918 | } | 925 | } |
919 | if (test_valid_ident.test_executed == GNUNET_NO) | 926 | if (test_valid_ident.test_executed == GNUNET_NO) |
920 | { | 927 | { |
921 | struct GNUNET_CRYPTO_HashAsciiEncoded result; | 928 | struct GNUNET_CRYPTO_HashAsciiEncoded ident; |
922 | GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&result); | 929 | GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&ident); |
923 | host_str = GNUNET_malloc (strlen ("http://localhost:12389/") + strlen ((const char *) &result)); | 930 | host_str = GNUNET_malloc (strlen ("http:///")+ 1 + strlen (test_addr)+ strlen ((char *) &ident)); |
924 | GNUNET_asprintf (&host_str, "http://localhost:%u/%s",port,(char *) &result); | 931 | GNUNET_asprintf (&host_str, "http://%s/%s",test_addr,(char *) &ident); |
925 | 932 | ||
926 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer with valid peer identification.\n")); | 933 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer with valid peer identification.\n")); |
927 | test_valid_ident.test_executed = GNUNET_YES; | 934 | test_valid_ident.test_executed = GNUNET_YES; |
@@ -1090,11 +1097,10 @@ run (void *cls, | |||
1090 | GNUNET_assert (GNUNET_OK == suggest_res); | 1097 | GNUNET_assert (GNUNET_OK == suggest_res); |
1091 | GNUNET_assert (NULL != addr_str); | 1098 | GNUNET_assert (NULL != addr_str); |
1092 | count_str_addr++; | 1099 | count_str_addr++; |
1093 | 1100 | GNUNET_free ( (char *) addr_str); | |
1094 | cur = cur->next; | 1101 | cur = cur->next; |
1095 | } | 1102 | } |
1096 | 1103 | GNUNET_assert (fail_pretty_printer_count > 0); | |
1097 | |||
1098 | GNUNET_assert (fail_pretty_printer_count==fail_notify_address_count); | 1104 | GNUNET_assert (fail_pretty_printer_count==fail_notify_address_count); |
1099 | GNUNET_assert (fail_pretty_printer_count==count_str_addr); | 1105 | GNUNET_assert (fail_pretty_printer_count==count_str_addr); |
1100 | fail_pretty_printer=GNUNET_NO; | 1106 | fail_pretty_printer=GNUNET_NO; |
@@ -1149,6 +1155,7 @@ run (void *cls, | |||
1149 | test_valid_ident.test_executed = GNUNET_NO; | 1155 | test_valid_ident.test_executed = GNUNET_NO; |
1150 | test_valid_ident.test_failed = GNUNET_YES; | 1156 | test_valid_ident.test_failed = GNUNET_YES; |
1151 | 1157 | ||
1158 | test_addr = (char *) api->address_to_string (NULL,addr_head->addr,addr_head->addrlen); | ||
1152 | run_connection_tests(); | 1159 | run_connection_tests(); |
1153 | 1160 | ||
1154 | /* testing finished */ | 1161 | /* testing finished */ |