aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorcebka@mailsupport.rambler.ru <cebka@mailsupport.rambler.ru>2008-09-23 11:47:56 +0400
committercebka@mailsupport.rambler.ru <cebka@mailsupport.rambler.ru>2008-09-23 11:47:56 +0400
commit193acf73e51b24ccca8048ebb6aaec2971594268 (patch)
treea094617b2bb6c5d867584830f2ac4c6fa5f7b8fa /test
parent2b65ae425b9dca345bea158471b358d3c17b9704 (diff)
downloadrspamd-193acf73e51b24ccca8048ebb6aaec2971594268.tar.gz
rspamd-193acf73e51b24ccca8048ebb6aaec2971594268.zip
* Small updates to memory pool library
- fix cases when new chunk is allocated - add memory pool allocator statistics - let it work in multi-threaded environment - add strdup function for convinience * Use memory pool allocator more widely to avoid memory leaks in future and optimize performance * Task pool chunk size is now pre-defined constant (16 Kb currently)
Diffstat (limited to 'test')
-rw-r--r--test/rspamd_mem_pool_test.c7
-rw-r--r--test/rspamd_url_test.c5
2 files changed, 8 insertions, 4 deletions
diff --git a/test/rspamd_mem_pool_test.c b/test/rspamd_mem_pool_test.c
index 5b2bf3721..50e539cf7 100644
--- a/test/rspamd_mem_pool_test.c
+++ b/test/rspamd_mem_pool_test.c
@@ -11,6 +11,7 @@ void
rspamd_mem_pool_test_func ()
{
memory_pool_t *pool;
+ memory_pool_stat_t st;
char *tmp, *tmp2;
pool = memory_pool_new (sizeof (TEST_BUF));
@@ -24,4 +25,10 @@ rspamd_mem_pool_test_func ()
g_assert (strncmp (tmp2, TEST2_BUF, sizeof (TEST2_BUF)) == 0);
memory_pool_delete (pool);
+ memory_pool_stat (&st);
+
+ /* Check allocator stat */
+ g_assert (st.bytes_allocated == sizeof (TEST_BUF) * 3);
+ g_assert (st.chunks_allocated == 2);
+ g_assert (st.chunks_freed == 2);
}
diff --git a/test/rspamd_url_test.c b/test/rspamd_url_test.c
index 43545252d..02aaa4a35 100644
--- a/test/rspamd_url_test.c
+++ b/test/rspamd_url_test.c
@@ -83,6 +83,7 @@ rspamd_url_test_func ()
html->len = strlen (test_html);
bzero (&task, sizeof (task));
TAILQ_INIT (&task.urls);
+ task.task_pool = memory_pool_new (8192);
g_test_timer_start ();
g_test_message ("Testing text URL regexp parser");
@@ -97,8 +98,6 @@ rspamd_url_test_func ()
while (!TAILQ_EMPTY (&task.urls)) {
url = TAILQ_FIRST (&task.urls);
TAILQ_REMOVE (&task.urls, url, next);
- g_free (url->string);
- g_free (url);
}
g_assert (i == 39);
@@ -117,8 +116,6 @@ rspamd_url_test_func ()
while (!TAILQ_EMPTY (&task.urls)) {
url = TAILQ_FIRST (&task.urls);
TAILQ_REMOVE (&task.urls, url, next);
- g_free (url->string);
- g_free (url);
}
g_assert (i == 1);
msg_debug ("Time elapsed: %.2f", g_test_timer_elapsed ());