aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2012-03-01 20:14:32 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2012-03-01 20:14:32 +0400
commit9d703560099beea2b2b53c533e7f71dc926293b2 (patch)
treed60df5c9d3f7dbb9931dc1243362d1808f1ff459 /test
parent7dcf9f9bade26ca02b8706a2e4cb2066f6ba7b00 (diff)
downloadrspamd-9d703560099beea2b2b53c533e7f71dc926293b2.tar.gz
rspamd-9d703560099beea2b2b53c533e7f71dc926293b2.zip
Separate librspamdserver API from plugins and workers functions.
Make tests compileable again.
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt4
-rw-r--r--test/rspamd_dns_test.c9
-rw-r--r--test/rspamd_fuzzy_test.c3
-rw-r--r--test/rspamd_test_suite.c10
4 files changed, 19 insertions, 7 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index c6011d2a8..c15f77b75 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -15,6 +15,10 @@ TARGET_LINK_LIBRARIES(rspamd-test rspamdserver)
TARGET_LINK_LIBRARIES(rspamd-test event)
TARGET_LINK_LIBRARIES(rspamd-test ${GLIB2_LIBRARIES})
TARGET_LINK_LIBRARIES(rspamd-test ${CMAKE_REQUIRED_LIBRARIES})
+IF(HAVE_LIBEVENT2)
+ TARGET_LINK_LIBRARIES(rspamd-test event_pthreads)
+ENDIF(HAVE_LIBEVENT2)
+INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/src")
IF(GMIME2_FOUND)
TARGET_LINK_LIBRARIES(rspamd-test ${GMIME2_LIBRARIES})
ELSE(GMIME2_FOUND)
diff --git a/test/rspamd_dns_test.c b/test/rspamd_dns_test.c
index c0b48080e..839c00a79 100644
--- a/test/rspamd_dns_test.c
+++ b/test/rspamd_dns_test.c
@@ -8,6 +8,7 @@
#include "../src/cfg_file.h"
static guint requests = 0;
+extern struct event_base *base;
static void
test_dns_cb (struct rspamd_dns_reply *reply, gpointer arg)
@@ -49,7 +50,7 @@ test_dns_cb (struct rspamd_dns_reply *reply, gpointer arg)
}
}
-void
+gboolean
session_fin (gpointer unused)
{
struct timeval tv;
@@ -57,6 +58,8 @@ session_fin (gpointer unused)
tv.tv_sec = 0;
tv.tv_usec = 0;
event_loopexit (&tv);
+
+ return TRUE;
}
void
@@ -76,9 +79,9 @@ rspamd_dns_test_func ()
pool = memory_pool_new (memory_pool_get_size ());
event_init ();
- s = new_async_session (pool, session_fin, NULL);
+ s = new_async_session (pool, session_fin, NULL, NULL, NULL);
- resolver = dns_resolver_init (cfg);
+ resolver = dns_resolver_init (base, cfg);
requests ++;
g_assert (make_dns_request (resolver, s, pool, test_dns_cb, NULL, DNS_REQUEST_A, "google.com"));
diff --git a/test/rspamd_fuzzy_test.c b/test/rspamd_fuzzy_test.c
index 004ebf3c0..7805e4f42 100644
--- a/test/rspamd_fuzzy_test.c
+++ b/test/rspamd_fuzzy_test.c
@@ -39,7 +39,7 @@ rspamd_fuzzy_test_func ()
memory_pool_t *pool;
fuzzy_hash_t *h1, *h2, *h3, *h4, *h5;
f_str_t f1, f2, f3, f4, f5;
- int diff1, diff2;
+ int diff2;
pool = memory_pool_new (1024);
f1.begin = s1;
@@ -59,7 +59,6 @@ rspamd_fuzzy_test_func ()
h4 = fuzzy_init (&f4, pool);
h5 = fuzzy_init (&f5, pool);
- diff1 = fuzzy_compare_hashes (h3, h4) + fuzzy_compare_hashes (h2, h4);
diff2 = fuzzy_compare_hashes (h2, h5);
msg_debug ("rspamd_fuzzy_test_func: s1, s2 difference between strings is %d", fuzzy_compare_hashes (h1, h2));
msg_debug ("rspamd_fuzzy_test_func: s1, s3 difference between strings is %d", fuzzy_compare_hashes (h1, h3));
diff --git a/test/rspamd_test_suite.c b/test/rspamd_test_suite.c
index 423086506..f035fcb81 100644
--- a/test/rspamd_test_suite.c
+++ b/test/rspamd_test_suite.c
@@ -5,6 +5,8 @@
static gboolean do_debug;
struct rspamd_main *rspamd_main = NULL;
+struct event_base *base = NULL;
+worker_t *workers[] = { NULL };
static GOptionEntry entries[] =
{
@@ -15,7 +17,7 @@ static GOptionEntry entries[] =
int
main (int argc, char **argv)
{
- struct config_file *cfg;
+ struct config_file *cfg;
GError *error = NULL;
GOptionContext *context;
@@ -39,6 +41,8 @@ main (int argc, char **argv)
bzero (cfg, sizeof (struct config_file));
cfg->cfg_pool = memory_pool_new (memory_pool_get_size ());
+ base = event_init ();
+
if (do_debug) {
cfg->log_level = G_LOG_LEVEL_DEBUG;
}
@@ -46,11 +50,13 @@ main (int argc, char **argv)
cfg->log_level = G_LOG_LEVEL_INFO;
}
/* First set logger to console logger */
- rspamd_set_logger (RSPAMD_LOG_CONSOLE, TYPE_MAIN, rspamd_main);
+ rspamd_set_logger (RSPAMD_LOG_CONSOLE, g_quark_from_static_string("rspamd-test"), rspamd_main);
(void)open_log (rspamd_main->logger);
g_log_set_default_handler (rspamd_glib_log_function, rspamd_main->logger);
+#if 0
g_test_add_func ("/rspamd/memcached", rspamd_memcached_test_func);
+#endif
g_test_add_func ("/rspamd/mem_pool", rspamd_mem_pool_test_func);
g_test_add_func ("/rspamd/fuzzy", rspamd_fuzzy_test_func);
g_test_add_func ("/rspamd/url", rspamd_url_test_func);