diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-06-16 09:04:35 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-06-16 09:04:35 +0000 |
commit | b778d1dc7836038f1b5e89c081c92aec46ba76e4 (patch) | |
tree | 7b670b3dea6242b15435697efcd0c59dd353be4a /src/transport/test_plugin_transport_http.c | |
parent | 41fd564b9d6067332824f8d9f49fc0f97c883716 (diff) | |
download | gnunet-b778d1dc7836038f1b5e89c081c92aec46ba76e4.tar.gz gnunet-b778d1dc7836038f1b5e89c081c92aec46ba76e4.zip |
Diffstat (limited to 'src/transport/test_plugin_transport_http.c')
-rw-r--r-- | src/transport/test_plugin_transport_http.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index 882560745..468a2c883 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c | |||
@@ -351,18 +351,26 @@ shutdown_clean () | |||
351 | struct Plugin_Address * tmp; | 351 | struct Plugin_Address * tmp; |
352 | 352 | ||
353 | /* Evaluate results */ | 353 | /* Evaluate results */ |
354 | if ((fail_notify_address == GNUNET_NO) && (fail_pretty_printer == GNUNET_NO) && (fail_addr_to_str == GNUNET_NO) && | 354 | fail = 0; |
355 | (test_no_ident.test_failed == GNUNET_NO) && (test_too_short_ident.test_failed == GNUNET_NO) && (test_too_long_ident.test_failed == GNUNET_NO) && | 355 | if ((fail_notify_address == GNUNET_YES) || (fail_pretty_printer == GNUNET_YES) || (fail_addr_to_str == GNUNET_YES)) |
356 | (test_valid_ident.test_failed == GNUNET_NO) && (fail_msgs_transmited_to_local_addrs == count_str_addr)) | ||
357 | { | 356 | { |
358 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Tests successful\n"); | 357 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test plugin functions failed\n"); |
359 | fail = 0; | 358 | fail = 1; |
360 | } | 359 | } |
361 | else | 360 | if ((test_no_ident.test_failed == GNUNET_YES) || (test_too_short_ident.test_failed == GNUNET_YES) || (test_too_long_ident.test_failed == GNUNET_YES)) |
361 | { | ||
362 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test connect with wrong data failed\n"); | ||
363 | fail = 1; | ||
364 | } | ||
365 | if ((test_valid_ident.test_failed == GNUNET_YES) || (fail_msgs_transmited_to_local_addrs != count_str_addr)) | ||
362 | { | 366 | { |
363 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Tests failed\n"); | 367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test sending with plugin failed\n"); |
364 | fail = 1; | 368 | fail = 1; |
365 | } | 369 | } |
370 | if (fail != 1) | ||
371 | { | ||
372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All tests successful\n"); | ||
373 | } | ||
366 | 374 | ||
367 | curl_multi_cleanup(multi_handle); | 375 | curl_multi_cleanup(multi_handle); |
368 | 376 | ||
@@ -873,16 +881,15 @@ static void run_connection_tests( void ) | |||
873 | if (test_no_ident.test_executed == GNUNET_NO) | 881 | if (test_no_ident.test_executed == GNUNET_NO) |
874 | { | 882 | { |
875 | /* Connecting to peer without identification */ | 883 | /* Connecting to peer without identification */ |
884 | |||
876 | host_str = GNUNET_malloc (strlen ("http://localhost:12389/")+1); | 885 | host_str = GNUNET_malloc (strlen ("http://localhost:12389/")+1); |
877 | GNUNET_asprintf (&host_str, "http://localhost:%u/",port); | 886 | GNUNET_asprintf (&host_str, "http://localhost:%u/",port); |
878 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer without any peer identification.\n")); | 887 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer without any peer identification.\n")); |
879 | test_no_ident.test_executed = GNUNET_YES; | 888 | test_no_ident.test_executed = GNUNET_YES; |
880 | send_data ( &test_no_ident, host_str); | 889 | send_data ( &test_no_ident, host_str); |
881 | GNUNET_free (host_str); | 890 | GNUNET_free (host_str); |
882 | |||
883 | return; | 891 | return; |
884 | } | 892 | } |
885 | |||
886 | if (test_too_short_ident.test_executed == GNUNET_NO) | 893 | if (test_too_short_ident.test_executed == GNUNET_NO) |
887 | { | 894 | { |
888 | char * ident = "AAAAAAAAAA"; | 895 | char * ident = "AAAAAAAAAA"; |
@@ -893,7 +900,6 @@ static void run_connection_tests( void ) | |||
893 | test_too_short_ident.test_executed = GNUNET_YES; | 900 | test_too_short_ident.test_executed = GNUNET_YES; |
894 | send_data ( &test_too_short_ident, host_str); | 901 | send_data ( &test_too_short_ident, host_str); |
895 | GNUNET_free (host_str); | 902 | GNUNET_free (host_str); |
896 | |||
897 | return; | 903 | return; |
898 | } | 904 | } |
899 | 905 | ||
@@ -904,18 +910,15 @@ static void run_connection_tests( void ) | |||
904 | /* Connecting to peer with too long identification */ | 910 | /* Connecting to peer with too long identification */ |
905 | host_str = GNUNET_malloc (strlen ("http://localhost:12389/") + strlen (ident)); | 911 | host_str = GNUNET_malloc (strlen ("http://localhost:12389/") + strlen (ident)); |
906 | GNUNET_asprintf (&host_str, "http://localhost:%u/%s",port,ident); | 912 | GNUNET_asprintf (&host_str, "http://localhost:%u/%s",port,ident); |
907 | |||
908 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer with too long peer identification.\n")); | 913 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer with too long peer identification.\n")); |
909 | test_too_long_ident.test_executed = GNUNET_YES; | 914 | test_too_long_ident.test_executed = GNUNET_YES; |
910 | send_data ( &test_too_long_ident, host_str); | 915 | send_data ( &test_too_long_ident, host_str); |
911 | GNUNET_free (host_str); | 916 | GNUNET_free (host_str); |
912 | |||
913 | return; | 917 | return; |
914 | } | 918 | } |
915 | if (test_valid_ident.test_executed == GNUNET_NO) | 919 | if (test_valid_ident.test_executed == GNUNET_NO) |
916 | { | 920 | { |
917 | struct GNUNET_CRYPTO_HashAsciiEncoded result; | 921 | struct GNUNET_CRYPTO_HashAsciiEncoded result; |
918 | |||
919 | GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&result); | 922 | GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&result); |
920 | host_str = GNUNET_malloc (strlen ("http://localhost:12389/") + strlen ((const char *) &result)); | 923 | host_str = GNUNET_malloc (strlen ("http://localhost:12389/") + strlen ((const char *) &result)); |
921 | GNUNET_asprintf (&host_str, "http://localhost:%u/%s",port,(char *) &result); | 924 | GNUNET_asprintf (&host_str, "http://localhost:%u/%s",port,(char *) &result); |
@@ -924,7 +927,6 @@ static void run_connection_tests( void ) | |||
924 | test_valid_ident.test_executed = GNUNET_YES; | 927 | test_valid_ident.test_executed = GNUNET_YES; |
925 | send_data ( &test_valid_ident, host_str); | 928 | send_data ( &test_valid_ident, host_str); |
926 | GNUNET_free (host_str); | 929 | GNUNET_free (host_str); |
927 | |||
928 | return; | 930 | return; |
929 | } | 931 | } |
930 | /* Using one of the addresses the plugin proposed */ | 932 | /* Using one of the addresses the plugin proposed */ |
@@ -1027,7 +1029,7 @@ run (void *cls, | |||
1027 | "transport-http", | 1029 | "transport-http", |
1028 | "PORT", | 1030 | "PORT", |
1029 | &port)) || | 1031 | &port)) || |
1030 | (port > 65535) ) | 1032 | (port > 65535) || (port == 0)) |
1031 | { | 1033 | { |
1032 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 1034 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
1033 | "http", | 1035 | "http", |
@@ -1035,6 +1037,7 @@ run (void *cls, | |||
1035 | ("Require valid port number for transport plugin `%s' in configuration!\n"), | 1037 | ("Require valid port number for transport plugin `%s' in configuration!\n"), |
1036 | "transport-http"); | 1038 | "transport-http"); |
1037 | } | 1039 | } |
1040 | |||
1038 | max_connect_per_transport = (uint32_t) tneigh; | 1041 | max_connect_per_transport = (uint32_t) tneigh; |
1039 | my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | 1042 | my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); |
1040 | GNUNET_free (keyfile); | 1043 | GNUNET_free (keyfile); |
@@ -1046,9 +1049,14 @@ run (void *cls, | |||
1046 | fail = 1; | 1049 | fail = 1; |
1047 | return; | 1050 | return; |
1048 | } | 1051 | } |
1052 | |||
1049 | GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); | 1053 | GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); |
1050 | GNUNET_CRYPTO_hash (&my_public_key, | 1054 | GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), &my_identity.hashPubKey); |
1051 | sizeof (my_public_key), &my_identity.hashPubKey); | 1055 | |
1056 | /* assertions before start */ | ||
1057 | GNUNET_assert ((port > 0) && (port <= 65535)); | ||
1058 | GNUNET_assert(&my_public_key != NULL); | ||
1059 | GNUNET_assert(&my_identity.hashPubKey != NULL); | ||
1052 | 1060 | ||
1053 | /* load plugins... */ | 1061 | /* load plugins... */ |
1054 | setup_plugin_environment (); | 1062 | setup_plugin_environment (); |