From 81d3fe28ab2acc5b9aa32abd74faa18a02d02927 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 16 Jun 2011 14:29:53 +0000 Subject: [PATCH] changes to tests --- src/transport/plugin_transport_http.c | 4 +- src/transport/test_plugin_transport_http.c | 373 +++++++++++--------- src/transport/test_plugin_transport_https.c | 31 +- src/transport/test_quota_compliance.c | 32 +- src/transport/test_transport_api.c | 2 +- 5 files changed, 247 insertions(+), 195 deletions(-) diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 362851796..ba58f9ea7 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -3147,7 +3147,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-https", "KEY_FILE")) { - GNUNET_CONFIGURATION_get_value_string (env->cfg, + GNUNET_CONFIGURATION_get_value_filename (env->cfg, "transport-https", "KEY_FILE", &key_file); @@ -3158,7 +3158,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) /* Get private key file from config */ if (GNUNET_CONFIGURATION_have_value (env->cfg,"transport-https", "CERT_FILE")) { - GNUNET_CONFIGURATION_get_value_string (env->cfg, + GNUNET_CONFIGURATION_get_value_filename (env->cfg, "transport-https", "CERT_FILE", &cert_file); 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; */ static GNUNET_SCHEDULER_TaskIdentifier http_task_send; +static char * servicehome; + /** * Shutdown testcase */ @@ -401,7 +403,7 @@ shutdown_clean () (fail_addr_to_str == GNUNET_YES)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Phase 0: Test plugin functions failed\n"); + "Phase 0: Test plugin functions failed\n"); fail = 1; } if ( (test_no_ident.test_failed == GNUNET_YES) || @@ -410,7 +412,7 @@ shutdown_clean () (test_valid_ident.test_failed == GNUNET_YES) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Phase 1: Test connect with wrong data failed\n"); + "Phase 1: Test connect with wrong data failed\n"); fail = 1; } if ( (fail_session_selection_any != GNUNET_NO) || @@ -419,7 +421,7 @@ shutdown_clean () (fail_session_selection_session_big != GNUNET_NO) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Phase 2: Test session selection failed\n"); + "Phase 2: Test session selection failed\n"); fail = 1; } if ( (fail_msgs_transmited_to_local_addrs != count_str_addr) || @@ -427,13 +429,13 @@ shutdown_clean () (fail_msg_transmited_max_size == GNUNET_YES) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Phase 3: Test sending with plugin failed\n"); + "Phase 3: Test sending with plugin failed\n"); fail = 1; } if (fail != 1) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "All tests successful\n"); + "All tests successful\n"); } api->disconnect(api->cls,&my_identity); @@ -472,14 +474,21 @@ shutdown_clean () GNUNET_free(test_addr); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Unloading http plugin\n"); + "Unloading http plugin\n"); GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_gnunet_transport_plugin_http", api)); GNUNET_SCHEDULER_shutdown(); GNUNET_DISK_directory_remove ("/tmp/test_gnunet_transport_plugin_http"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Exiting testcase\n"); + "Exiting testcase\n"); + + if (servicehome != NULL) + { + GNUNET_DISK_directory_remove (servicehome); + GNUNET_free (servicehome); + } + exit(fail); return; } @@ -494,13 +503,13 @@ shutdown_clean () static void task_send_cont (void *cls, - const struct GNUNET_PeerIdentity * target, - int result) + const struct GNUNET_PeerIdentity * target, + int result) { if ((cls == &fail_msg_transmited_bigger_max_size) && (result == GNUNET_SYSERR)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Message bigger max msg size was not sent!\n"); + "Message bigger max msg size was not sent!\n"); fail_msg_transmited_bigger_max_size = GNUNET_NO; return; } @@ -508,8 +517,8 @@ task_send_cont (void *cls, if ((cls == &fail_msg_transmited_max_size) && (result == GNUNET_OK)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Message with max msg size succesfully sent!\n", - fail_msgs_transmited_to_local_addrs); + "Message with max msg size succesfully sent!\n", + fail_msgs_transmited_to_local_addrs); fail_msg_transmited_max_size = GNUNET_NO; } } @@ -530,18 +539,18 @@ receive (void *cls, const struct GNUNET_PeerIdentity *peer, uint16_t sender_address_len) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", - GNUNET_i2s(peer), - ntohs(message->type), - ntohs(message->size), - session); + "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", + GNUNET_i2s(peer), + ntohs(message->type), + ntohs(message->size), + session); if ( (ntohs(message->type)>=10) && (ntohs(message->type)<20) ) { fail_msgs_transmited_to_local_addrs++; if (fail_msgs_transmited_to_local_addrs == count_str_addr) - run_connection_tests(2, session); + run_connection_tests(2, session); } if ((ntohs(message->type)==20)) { @@ -616,8 +625,8 @@ header_function( void *ptr, size_t size, size_t nmemb, void *stream) tmp[len-2]= '\0'; #if DEBUG_CURL GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Header: `%s'\n", - tmp); + "Header: `%s'\n", + tmp); #endif if (0==strcmp (tmp,"HTTP/1.1 100 Continue")) { @@ -651,7 +660,7 @@ send_prepare( struct HTTP_Transfer * result); static void send_execute (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) + const struct GNUNET_SCHEDULER_TaskContext *tc) { struct HTTP_Transfer *res; @@ -702,50 +711,50 @@ send_execute (void *cls, if (res == &test_no_ident) { if ((res->http_result_code==404) && (buffer_in.len==208)) - { + { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connecting to peer without any peer identification: test passed\n"); + "Connecting to peer without any peer identification: test passed\n"); res->test_failed = GNUNET_NO; } else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Connecting to peer without any peer identification: test failed\n")); + _("Connecting to peer without any peer identification: test failed\n")); } if (res == &test_too_short_ident) { if ((res->http_result_code==404) && (buffer_in.len==208)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connecting to peer with too short peer identification: test passed\n"); + "Connecting to peer with too short peer identification: test passed\n"); res->test_failed = GNUNET_NO; } else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Connecting to peer with too short peer identification: test failed\n")); + _("Connecting to peer with too short peer identification: test failed\n")); } if (res == &test_too_long_ident) { if ((res->http_result_code==404) && (buffer_in.len==208)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connecting to peer with too long peer identification: test passed\n"); + "Connecting to peer with too long peer identification: test passed\n"); res->test_failed = GNUNET_NO; } else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Connecting to peer with too long peer identification: test failed\n")); + _("Connecting to peer with too long peer identification: test failed\n")); } if (res == &test_valid_ident) { if ((res->http_result_code==200)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connecting to peer with valid peer identification: test passed\n"); + "Connecting to peer with valid peer identification: test passed\n"); res->test_failed = GNUNET_NO; } else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Connecting to peer with valid peer identification: test failed\n"); + "Connecting to peer with valid peer identification: test failed\n"); } curl_easy_cleanup(curl_handle); curl_handle=NULL; @@ -811,12 +820,12 @@ send_prepare( struct HTTP_Transfer * result) GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); http_task_send = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0), - grs, - gws, - &send_execute, - result); + GNUNET_SCHEDULER_NO_TASK, + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0), + grs, + gws, + &send_execute, + result); GNUNET_NETWORK_fdset_destroy (gws); GNUNET_NETWORK_fdset_destroy (grs); @@ -829,7 +838,7 @@ send_prepare( struct HTTP_Transfer * result) */ static int send_data(struct HTTP_Transfer * result, - char * url) + char * url) { curl_handle = curl_easy_init(); @@ -895,9 +904,9 @@ notify_address (void *cls, return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Transport plugin notification for address: `%s':%u\n"), - address, - port); + _("Transport plugin notification for address: `%s':%u\n"), + address, + port); pl_addr = GNUNET_malloc (sizeof (struct Plugin_Address) ); pl_addr->addrlen = addrlen; pl_addr->addr = GNUNET_malloc(addrlen); @@ -912,9 +921,9 @@ notify_address (void *cls, { cur = addr_head; while (NULL != cur->next) - { - cur = cur->next; - } + { + cur = cur->next; + } cur->next = pl_addr; } fail_notify_address_count++; @@ -923,13 +932,13 @@ notify_address (void *cls, static void plugin_env_session_end (void *cls, - const struct GNUNET_PeerIdentity *peer, - struct Session *session) + const struct GNUNET_PeerIdentity *peer, + struct Session *session) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Pluging tells me: session %X to peer `%s' ended\n", - session, - GNUNET_i2s(peer)); + "Pluging tells me: session %X to peer `%s' ended\n", + session, + GNUNET_i2s(peer)); } @@ -970,13 +979,13 @@ task_timeout (void *cls, static void pretty_printer_cb (void *cls, - const char *address) + const char *address) { if (NULL==address) return; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Plugin returned pretty address: `%s'\n", - address); + "Plugin returned pretty address: `%s'\n", + address); fail_pretty_printer_count++; } @@ -1003,71 +1012,71 @@ run_connection_tests( int phase , void * cls) if (test_no_ident.test_executed == GNUNET_NO) { - /* Connecting to peer without identification */ - const char * ident = ""; - GNUNET_asprintf (&host_str, - "%s://%s/%s", - PROTOCOL_PREFIX, - test_addr,ident); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Connecting to peer without any peer identification.\n")); - test_no_ident.test_executed = GNUNET_YES; - send_data ( &test_no_ident, host_str); - GNUNET_free (host_str); - return; + /* Connecting to peer without identification */ + const char * ident = ""; + GNUNET_asprintf (&host_str, + "%s://%s/%s", + PROTOCOL_PREFIX, + test_addr,ident); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + _("Connecting to peer without any peer identification.\n")); + test_no_ident.test_executed = GNUNET_YES; + send_data ( &test_no_ident, host_str); + GNUNET_free (host_str); + return; } if (test_too_short_ident.test_executed == GNUNET_NO) { - const char * ident = "AAAAAAAAAA"; - /* Connecting to peer with too short identification */ - GNUNET_asprintf (&host_str, - "%s://%s/%s", - PROTOCOL_PREFIX, - test_addr, - ident); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Connecting to peer with too short peer identification.\n")); - test_too_short_ident.test_executed = GNUNET_YES; - send_data ( &test_too_short_ident, host_str); - GNUNET_free (host_str); - return; + const char * ident = "AAAAAAAAAA"; + /* Connecting to peer with too short identification */ + GNUNET_asprintf (&host_str, + "%s://%s/%s", + PROTOCOL_PREFIX, + test_addr, + ident); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + _("Connecting to peer with too short peer identification.\n")); + test_too_short_ident.test_executed = GNUNET_YES; + send_data ( &test_too_short_ident, host_str); + GNUNET_free (host_str); + return; } if (test_too_long_ident.test_executed == GNUNET_NO) { - const char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - - /* Connecting to peer with too long identification */ - GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Connecting to peer with too long peer identification.\n")); - test_too_long_ident.test_executed = GNUNET_YES; - send_data ( &test_too_long_ident, host_str); - GNUNET_free (host_str); - return; + const char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + + /* Connecting to peer with too long identification */ + GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + _("Connecting to peer with too long peer identification.\n")); + test_too_long_ident.test_executed = GNUNET_YES; + send_data ( &test_too_long_ident, host_str); + GNUNET_free (host_str); + return; } if (test_valid_ident.test_executed == GNUNET_NO) { - struct GNUNET_CRYPTO_HashAsciiEncoded ident; - GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&ident); - GNUNET_asprintf (&host_str, - "%s://%s/%s%s", - PROTOCOL_PREFIX, - test_addr, - (char *) &ident, - ";0"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Connecting to peer with valid peer identification.\n")); - test_valid_ident.test_executed = GNUNET_YES; - send_data ( &test_valid_ident, host_str); - GNUNET_free (host_str); - return; + struct GNUNET_CRYPTO_HashAsciiEncoded ident; + GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&ident); + GNUNET_asprintf (&host_str, + "%s://%s/%s%s", + PROTOCOL_PREFIX, + test_addr, + (char *) &ident, + ";0"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + _("Connecting to peer with valid peer identification.\n")); + test_valid_ident.test_executed = GNUNET_YES; + send_data ( &test_valid_ident, host_str); + GNUNET_free (host_str); + return; } } if (phase==1) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "\nPhase 1: transmit data to all suggested addresses\n\n"); + "\nPhase 1: transmit data to all suggested addresses\n\n"); /* Using one of the addresses the plugin proposed */ GNUNET_assert (addr_head->addr != NULL); @@ -1084,41 +1093,41 @@ run_connection_tests( int phase , void * cls) int count = 0; while (tmp_addr != NULL) - { - if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress))) - { - inet_ntop(AF_INET, (struct in_addr *) tmp_addr->addr,address,INET_ADDRSTRLEN); - port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending message to addres no. %u: `%s':%u\n", - count, - address, - port); - } - if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress))) - { - inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN); - port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending message to addres no. %u: `%s':%u\n", - count, - address, - port); - } - msg.type=htons(type); - memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); - 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); - tmp_addr = tmp_addr->next; - count++; - type++; - } + { + if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress))) + { + inet_ntop(AF_INET, (struct in_addr *) tmp_addr->addr,address,INET_ADDRSTRLEN); + port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Sending message to addres no. %u: `%s':%u\n", + count, + address, + port); + } + if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress))) + { + inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN); + port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Sending message to addres no. %u: `%s':%u\n", + count, + address, + port); + } + msg.type=htons(type); + memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); + 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); + tmp_addr = tmp_addr->next; + count++; + type++; + } GNUNET_free(tmp); return; } @@ -1129,32 +1138,32 @@ run_connection_tests( int phase , void * cls) msg = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Phase 2: session selection\n\n"); + "Phase 2: session selection\n\n"); size = sizeof(struct GNUNET_MessageHeader); msg->size=htons(size); msg->type = htons(20); api->send(api->cls, - &my_identity, - (const char *) msg, size, - 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, - &task_send_cont, NULL); + &my_identity, + (const char *) msg, size, + 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, + &task_send_cont, NULL); msg->type = htons(21); api->send(api->cls, - &my_identity, - (const char *) msg, size, - 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, - &task_send_cont, NULL); + &my_identity, + (const char *) msg, size, + 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, + &task_send_cont, NULL); /* answer on session*/ size = sizeof( struct GNUNET_MessageHeader); msg->size = htons(size); msg->type = htons(22); api->send(api->cls, - &my_identity, - (const char *) msg, size, - 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR, - &task_send_cont, NULL); + &my_identity, + (const char *) msg, size, + 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR, + &task_send_cont, NULL); GNUNET_free(msg); /* answer on session with big message not fitting in mhd send buffer*/ @@ -1163,10 +1172,10 @@ run_connection_tests( int phase , void * cls) msg->size=htons(size); msg->type = htons(23); api->send(api->cls, - &my_identity, - (const char *) msg, size, - 0, TIMEOUT, session, NULL, 0, GNUNET_NO, - &task_send_cont, NULL); + &my_identity, + (const char *) msg, size, + 0, TIMEOUT, session, NULL, 0, GNUNET_NO, + &task_send_cont, NULL); GNUNET_free(msg); return; } @@ -1175,7 +1184,7 @@ run_connection_tests( int phase , void * cls) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Phase 3: send multiple or big messages after disconnect\n\n"); + "Phase 3: send multiple or big messages after disconnect\n\n"); /* disconnect from peer, so new connections are created */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Disconnect from peer: `%s'\n", GNUNET_i2s(&my_identity)); api->disconnect(api->cls, &my_identity); @@ -1190,12 +1199,12 @@ run_connection_tests( int phase , void * cls) msg2->size = htons(2 * sizeof(struct GNUNET_MessageHeader)); msg2->type = htons(31); api->send(api->cls, - &my_identity, - (const char *) msg, 4 * sizeof(struct GNUNET_MessageHeader), - 0, TIMEOUT, NULL, - addr_head->addr, addr_head->addrlen, - GNUNET_NO, - &task_send_cont, &fail_multiple_msgs_in_transmission); + &my_identity, + (const char *) msg, 4 * sizeof(struct GNUNET_MessageHeader), + 0, TIMEOUT, NULL, + addr_head->addr, addr_head->addrlen, + GNUNET_NO, + &task_send_cont, &fail_multiple_msgs_in_transmission); GNUNET_free(msg); /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */ @@ -1204,15 +1213,15 @@ run_connection_tests( int phase , void * cls) msg->size = htons(size); msg->type = htons(32); api->send(api->cls, - &my_identity, - (const char *) msg, size, - 0, TIMEOUT, NULL, - addr_head->addr, addr_head->addrlen, - GNUNET_NO, - &task_send_cont, &fail_msg_transmited_max_size); + &my_identity, + (const char *) msg, size, + 0, TIMEOUT, NULL, + addr_head->addr, addr_head->addrlen, + GNUNET_NO, + &task_send_cont, &fail_msg_transmited_max_size); GNUNET_free(msg); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "No more tests to run\n"); + "No more tests to run\n"); } } @@ -1252,6 +1261,9 @@ run (void *cls, addr_head = NULL; count_str_addr = 0; /* parse configuration */ + if (GNUNET_CONFIGURATION_have_value (c,"PATHS", "SERVICEHOME")) + GNUNET_CONFIGURATION_get_value_string (c, "PATHS", "SERVICEHOME", &servicehome); + if ((GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", @@ -1305,8 +1317,8 @@ run (void *cls, setup_plugin_environment (); GNUNET_asprintf (&libname, "libgnunet_plugin_transport_http"); GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Loading HTTP transport plugin `%s'\n"), - libname); + _("Loading HTTP transport plugin `%s'\n"), + libname); api = GNUNET_PLUGIN_load (libname, &env); GNUNET_free (libname); if (api == NULL) @@ -1323,16 +1335,16 @@ run (void *cls, /* testing plugin functionality */ GNUNET_assert (0!=fail_notify_address_count); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transport plugin returned %u addresses to connect to\n", - fail_notify_address_count); + "Transport plugin returned %u addresses to connect to\n", + fail_notify_address_count); /* testing pretty printer with all addresses obtained from the plugin*/ cur = addr_head; while (cur != NULL) { api->address_pretty_printer (api->cls, "http", - cur->addr,cur->addrlen, GNUNET_NO,TEST_TIMEOUT, - &pretty_printer_cb, NULL); + cur->addr,cur->addrlen, GNUNET_NO,TEST_TIMEOUT, + &pretty_printer_cb, NULL); addr_str = api->address_to_string (api->cls, cur->addr, cur->addrlen); suggest_res = api->check_address (api->cls, cur->addr, cur->addrlen); @@ -1434,13 +1446,26 @@ main (int argc, char *const *argv) #endif NULL); + struct GNUNET_CONFIGURATION_Handle *cfg; + cfg = GNUNET_CONFIGURATION_create (); + + GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, "test_plugin_transport_data_http.conf")); + if (GNUNET_CONFIGURATION_have_value (cfg,"PATHS", "SERVICEHOME")) + GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", &servicehome); + GNUNET_DISK_directory_remove (servicehome); + GNUNET_CONFIGURATION_destroy (cfg); + ret = (GNUNET_OK == GNUNET_PROGRAM_run (5, argv_prog, "test_gnunet_transport_plugin_http", "testcase", options, &run, NULL)) ? GNUNET_NO : GNUNET_YES; - GNUNET_DISK_directory_remove ("/tmp/test_plugin_transport_http"); + if (servicehome != NULL) + { + GNUNET_DISK_directory_remove (servicehome); + GNUNET_free (servicehome); + } if (ret != GNUNET_OK) return 1; return fail; diff --git a/src/transport/test_plugin_transport_https.c b/src/transport/test_plugin_transport_https.c index 12371a162..809bc9cb8 100644 --- a/src/transport/test_plugin_transport_https.c +++ b/src/transport/test_plugin_transport_https.c @@ -389,6 +389,8 @@ static GNUNET_SCHEDULER_TaskIdentifier http_task_send; static char * key_file; static char * cert_file; +static char * servicehome; + /** * Shutdown testcase */ @@ -486,6 +488,13 @@ shutdown_clean () GNUNET_free (cert_file); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Exiting testcase\n"); + + if (servicehome != NULL) + { + GNUNET_DISK_directory_remove (servicehome); + GNUNET_free (servicehome); + } + exit(fail); return; } @@ -1167,6 +1176,10 @@ run (void *cls, addr_head = NULL; count_str_addr = 0; /* parse configuration */ + if (GNUNET_CONFIGURATION_have_value (c,"PATHS", "SERVICEHOME")) + GNUNET_CONFIGURATION_get_value_string (c, "PATHS", "SERVICEHOME", &servicehome); + + if ((GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", @@ -1388,13 +1401,27 @@ main (int argc, char *const *argv) #endif NULL); + struct GNUNET_CONFIGURATION_Handle *cfg; + cfg = GNUNET_CONFIGURATION_create (); + + GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, "test_plugin_transport_data_http.conf")); + if (GNUNET_CONFIGURATION_have_value (cfg,"PATHS", "SERVICEHOME")) + GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", &servicehome); + GNUNET_DISK_directory_remove (servicehome); + GNUNET_CONFIGURATION_destroy (cfg); + ret = (GNUNET_OK == GNUNET_PROGRAM_run (5, argv_prog, "test_gnunet_transport_plugin.https", "testcase", options, &run, NULL)) ? GNUNET_NO : GNUNET_YES; - - GNUNET_DISK_directory_remove ("/tmp/test_gnunet_transport_plugin.https"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("\ndelete\n\n")); + if (servicehome != NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("\ndelete\n\n")); + GNUNET_DISK_directory_remove (servicehome); + GNUNET_free (servicehome); + } if (GNUNET_OK != ret) return 1; return fail; diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index 48a78f19d..ef4f999be 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c @@ -33,6 +33,7 @@ #include "gnunet_server_lib.h" #include "gnunet_transport_service.h" #include "transport.h" +#include "transport-testing.h" #define VERBOSE GNUNET_NO @@ -59,16 +60,6 @@ #define MTYPE 11111 -struct PeerContext -{ - struct GNUNET_CONFIGURATION_Handle *cfg; - struct GNUNET_TRANSPORT_Handle *th; - struct GNUNET_PeerIdentity id; -#if START_ARM - struct GNUNET_OS_Process *arm_proc; -#endif -}; - /** * Handle for a transmission-ready request. */ @@ -655,6 +646,11 @@ static void setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); + GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); + if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME")) + GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome); + GNUNET_DISK_directory_remove (p->servicehome); + #if START_ARM p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", @@ -665,7 +661,6 @@ setup_peer (struct PeerContext *p, const char *cfgname) "-c", cfgname, NULL); #endif - GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive_new, @@ -897,9 +892,6 @@ main (int argc, char *argv[]) GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","noplugin","none"); } - GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer1"); - GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer2"); - fprintf(stderr, "Running `%s'\n", logger); GNUNET_log_setup ("test-quota-compliance", #if VERBOSE @@ -926,9 +918,17 @@ main (int argc, char *argv[]) ret = ok; stop_arm (&p1); stop_arm (&p2); + + if ((p1.servicehome != NULL) && (p2.servicehome != NULL)) + { + GNUNET_DISK_directory_remove (p1.servicehome); + GNUNET_DISK_directory_remove (p2.servicehome); + GNUNET_free(p1.servicehome); + GNUNET_free(p2.servicehome); + } + GNUNET_free(logger); - GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer1"); - GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer2"); + return ret; } diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 95583c03c..853ce9aa5 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c @@ -37,7 +37,7 @@ #include "transport.h" #include "transport-testing.h" -#define VERBOSE GNUNET_YES +#define VERBOSE GNUNET_NO #define VERBOSE_ARM GNUNET_NO -- 2.25.1