summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_testserver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_testserver.c')
-rw-r--r--src/testing/testing_api_cmd_testserver.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/testing/testing_api_cmd_testserver.c b/src/testing/testing_api_cmd_testserver.c
index ee32fd77..e80dcd78 100644
--- a/src/testing/testing_api_cmd_testserver.c
+++ b/src/testing/testing_api_cmd_testserver.c
@@ -47,8 +47,15 @@ struct TestserverState
*/
uint16_t port;
+ /**
+ * Array where we remember all of the requests this
+ * server answered.
+ */
struct RequestCtx **rcs;
+ /**
+ * Length of the @a rcs array
+ */
unsigned int rcs_length;
};
@@ -80,6 +87,9 @@ struct RequestCtx
*/
size_t body_size;
+ /**
+ * Set to true when we are done with the request.
+ */
bool done;
};
@@ -150,7 +160,7 @@ handler_cb (void *cls,
"Taler-test-header");
if (NULL != hdr)
rc->header = GNUNET_strdup (hdr);
- if (NULL != hdr)
+ if (NULL != url)
rc->url = GNUNET_strdup (url);
GNUNET_array_append (ts->rcs,
ts->rcs_length,
@@ -195,9 +205,6 @@ handler_cb (void *cls,
rc->body = body;
rc->body_size += *upload_data_size;
*upload_data_size = 0;
- GNUNET_array_append (ts->rcs,
- ts->rcs_length,
- rc);
return MHD_YES;
}
@@ -276,28 +283,30 @@ testserver_cleanup (void *cls,
struct TestserverState *ser = cls;
(void) cmd;
+ if (NULL != ser->mhd)
+ {
+ MHD_stop_daemon (ser->mhd);
+ ser->mhd = NULL;
+ }
for (unsigned int i = 0; i<ser->rcs_length; i++)
{
struct RequestCtx *rc = ser->rcs[i];
+ GNUNET_assert (rc->done);
GNUNET_free (rc->url);
GNUNET_free (rc->http_method);
GNUNET_free (rc->header);
GNUNET_free (rc->body);
+ GNUNET_free (rc);
}
GNUNET_array_grow (ser->rcs,
ser->rcs_length,
0);
- if (NULL != ser->mhd)
- {
- MHD_stop_daemon (ser->mhd);
- ser->mhd = NULL;
- }
GNUNET_free (ser);
}
-static int
+static enum GNUNET_GenericReturnValue
traits_testserver (void *cls,
const void **ret,
const char *trait,
@@ -306,24 +315,26 @@ traits_testserver (void *cls,
struct TestserverState *ser = cls;
if (index >= ser->rcs_length)
- return MHD_NO;
+ return GNUNET_NO;
{
- struct RequestCtx *rc = ser->rcs[index];
+ const struct RequestCtx *rc = ser->rcs[index];
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_urls (index,
- &rc->url),
+ (const char **) &rc->url),
TALER_TESTING_make_trait_http_methods (index,
- &rc->http_method),
+ (const char **) &rc->http_method),
TALER_TESTING_make_trait_http_header (index,
- &rc->header),
+ (const char **) &rc->header),
TALER_TESTING_make_trait_http_body (index,
- &rc->body),
+ (const void **) &rc->body),
TALER_TESTING_make_trait_http_body_size (index,
&rc->body_size),
TALER_TESTING_trait_end (),
};
+ if (! rc->done)
+ return GNUNET_NO;
return TALER_TESTING_get_trait (traits,
ret,
trait,