#include "transport.h"
#include <curl/curl.h>
-#define VERBOSE GNUNET_YES
-#define DEBUG GNUNET_YES
+#define VERBOSE GNUNET_NO
+#define DEBUG GNUNET_NO
#define DEBUG_CURL GNUNET_NO
#define PLUGIN libgnunet_plugin_transport_template
size_t size;
+ unsigned int test_failed;
+
};
struct Plugin_Address * addr_head;
/**
* Did the test pass or fail?
*/
-static int fail_send_data;
-static struct HTTP_Transfer no_ident;
+static struct HTTP_Transfer testtransfer_no_ident;
static void
shutdown_clean ()
{
+ if ((fail_notify_address == GNUNET_NO) && (fail_pretty_printer == GNUNET_NO) && (fail_addr_to_str == GNUNET_NO) && (testtransfer_no_ident.test_failed == GNUNET_NO))
+ fail = 0;
+ else
+ fail = 1;
+
curl_multi_cleanup(multi_handle);
if (NULL != curl_handle)
return size * nmemb;
}
-static size_t send_prepare( void );
+static size_t send_prepare( struct HTTP_Transfer * result);
static void send_execute (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
-
+ struct HTTP_Transfer *res;
int running;
struct CURLMsg *msg;
CURLMcode mret;
+ res = (struct HTTP_Transfer *) cls;
http_task_send = GNUNET_SCHEDULER_NO_TASK;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
__LINE__,
curl_easy_strerror (msg->data.result));
/* sending msg failed*/
- fail_send_data = GNUNET_YES;
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send completed\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send completed with code %u\n", res->data_size);
/* sending completed */
- fail_send_data = GNUNET_NO;
}
-
+ if ( (cls == &testtransfer_no_ident) && (res->http_result_code==404) && (res->data_size==208))
+ res->test_failed = GNUNET_NO;
curl_easy_cleanup(curl_handle);
curl_handle=NULL;
}
}
while (mret == CURLM_CALL_MULTI_PERFORM);
- send_prepare();
+ send_prepare(cls);
}
/**
* @param ses session to send data to
* @return bytes sent to peer
*/
-static size_t send_prepare( void )
+static size_t send_prepare( struct HTTP_Transfer * result)
{
fd_set rs;
fd_set ws;
grs,
gws,
&send_execute,
- NULL);
+ result);
GNUNET_NETWORK_fdset_destroy (gws);
GNUNET_NETWORK_fdset_destroy (grs);
curl_multi_add_handle(multi_handle, curl_handle);
- send_prepare();
+ send_prepare(result);
return GNUNET_OK;
}
fail_pretty_printer = GNUNET_YES;
fail_notify_address = GNUNET_YES;
fail_addr_to_str = GNUNET_YES;
- fail_send_data = GNUNET_YES;
+
addr_head = NULL;
count_str_addr = 0;
/* parse configuration */
msg->size = 2048;
msg->pos = 0;
msg->buf = GNUNET_malloc (2048);
- no_ident.size=2048;
+ testtransfer_no_ident.size=2048;
+ testtransfer_no_ident.test_failed = GNUNET_YES;
- res = send_data (msg, &no_ident, "http://localhost:12389/");
+ /* Connecting to peer without identification */
+ res = send_data (msg, &testtransfer_no_ident, "http://localhost:12389/");
- /* testing finished, shutting down */
- if ((fail_notify_address == GNUNET_NO) && (fail_pretty_printer == GNUNET_NO) && (fail_addr_to_str == GNUNET_NO) && (fail_send_data == GNUNET_NO))
- fail = 0;
- else
- fail = 1;
- //shutdown_clean();
+ /* Add more tests */
+
+ /* testing finished */
return;
}