|
@@ -403,6 +403,17 @@ static char *read_conn(struct mg_connection *conn, int *size) {
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+extern unsigned long mg_memory_debug_blockCount;
|
|
|
+extern unsigned long mg_memory_debug_totalMemUsed;
|
|
|
+
|
|
|
+static void ut_mg_stop(struct mg_context *ctx) {
|
|
|
+ /* mg_stop for unit_test */
|
|
|
+ mg_stop(ctx);
|
|
|
+ ASSERT(mg_memory_debug_blockCount == 0);
|
|
|
+ ASSERT(mg_memory_debug_totalMemUsed == 0);
|
|
|
+ mg_sleep(31000); /* This is required to ensure the operating system already allows to use the port again */
|
|
|
+}
|
|
|
+
|
|
|
static void test_mg_download(int use_ssl) {
|
|
|
|
|
|
const char *test_data = "123456789A123456789B";
|
|
@@ -571,7 +582,7 @@ static void test_mg_download(int use_ssl) {
|
|
|
mg_close_connection(conn);
|
|
|
|
|
|
/* Stop the test server */
|
|
|
- mg_stop(ctx);
|
|
|
+ ut_mg_stop(ctx);
|
|
|
}
|
|
|
|
|
|
static int websocket_data_handler(const struct mg_connection *conn, int flags, char *data, size_t data_len, void *cbdata)
|
|
@@ -628,7 +639,7 @@ static void test_mg_websocket_client_connect(int use_ssl) {
|
|
|
"/", "http://websocket.org", websocket_data_handler, NULL, NULL);
|
|
|
ASSERT(conn != NULL);
|
|
|
|
|
|
- mg_stop(ctx);
|
|
|
+ ut_mg_stop(ctx);
|
|
|
}
|
|
|
|
|
|
static int alloc_printf(char **buf, size_t size, char *fmt, ...) {
|
|
@@ -722,7 +733,7 @@ static void test_mg_upload(void) {
|
|
|
mg_close_connection(conn);
|
|
|
#endif
|
|
|
|
|
|
- mg_stop(ctx);
|
|
|
+ ut_mg_stop(ctx);
|
|
|
}
|
|
|
|
|
|
static void test_base64_encode(void) {
|
|
@@ -889,7 +900,7 @@ static void test_request_replies(void) {
|
|
|
tests[i].request)) != NULL);
|
|
|
mg_close_connection(conn);
|
|
|
}
|
|
|
- mg_stop(ctx);
|
|
|
+ ut_mg_stop(ctx);
|
|
|
|
|
|
#ifndef NO_SSL
|
|
|
ASSERT((ctx = mg_start(&CALLBACKS, NULL, OPTIONS)) != NULL);
|
|
@@ -898,7 +909,7 @@ static void test_request_replies(void) {
|
|
|
tests[i].request)) != NULL);
|
|
|
mg_close_connection(conn);
|
|
|
}
|
|
|
- mg_stop(ctx);
|
|
|
+ ut_mg_stop(ctx);
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -947,7 +958,7 @@ static void test_request_handlers(void) {
|
|
|
mg_sleep(1000);
|
|
|
mg_close_connection(conn);
|
|
|
|
|
|
- mg_stop(ctx);
|
|
|
+ ut_mg_stop(ctx);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -985,7 +996,7 @@ static void test_api_calls(void) {
|
|
|
ASSERT((conn = mg_download("localhost", atoi(HTTP_PORT), 0,
|
|
|
ebuf, sizeof(ebuf), "%s", request)) != NULL);
|
|
|
mg_close_connection(conn);
|
|
|
- mg_stop(ctx);
|
|
|
+ ut_mg_stop(ctx);
|
|
|
}
|
|
|
|
|
|
static void test_url_decode(void) {
|
|
@@ -1164,7 +1175,7 @@ int __cdecl main(void) {
|
|
|
ctx = mg_start(NULL, NULL, OPTIONS);
|
|
|
REQUIRE(ctx != NULL);
|
|
|
mg_sleep(1000);
|
|
|
- mg_stop(ctx);
|
|
|
+ ut_mg_stop(ctx);
|
|
|
|
|
|
/* create test data */
|
|
|
fetch_data = (char *) mg_malloc(fetch_data_size);
|