aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-05-10 19:15:03 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-05-10 19:15:03 +0400
commit1fd435e5d4fc3c51fae8a1a184b347bdf6039d26 (patch)
treef17ee669ea0d5bfa497b3c952e8d7bed9885501a /test
parent683b90f4c6c744557f7429ce6ff77c0f7d2175e1 (diff)
downloadrspamd-1fd435e5d4fc3c51fae8a1a184b347bdf6039d26.tar.gz
rspamd-1fd435e5d4fc3c51fae8a1a184b347bdf6039d26.zip
* Rework build process:
- add librspamdserver - link this library to all daemons and utils of rspamd - use subdirectories more often * Rework global variables logic - move them to the main process * Fix logging to handle utf-8 correctly * Add statshow utility and make it working * Move printf functions to separate source file
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt29
-rw-r--r--test/rspamd_dns_test.c1
-rw-r--r--test/rspamd_test_suite.c15
3 files changed, 19 insertions, 26 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 4255e7bf0..c6011d2a8 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -7,27 +7,11 @@ SET(TESTSRC rspamd_expression_test.c
rspamd_url_test.c
rspamd_dns_test.c)
-SET(TESTDEPENDS ../src/mem_pool.c
- ../src/hash.c
- ../src/url.c
- ../src/trie.c
- ../src/util.c
- ../src/radix.c
- ../src/fuzzy.c
- ../src/map.c
- ../src/logger.c
- ../src/memcached.c
- ../src/message.c
- ../src/html.c
- ../src/expressions.c
- ../src/statfile.c
- ../src/events.c
- ../src/upstream.c
- ../src/dns.c)
-
-ADD_EXECUTABLE(rspamd-test EXCLUDE_FROM_ALL ${TESTDEPENDS} ${CONTRIBSRC} ${TESTSRC})
+ADD_EXECUTABLE(rspamd-test EXCLUDE_FROM_ALL ${TESTSRC})
SET_TARGET_PROPERTIES(rspamd-test PROPERTIES LINKER_LANGUAGE C)
SET_TARGET_PROPERTIES(rspamd-test PROPERTIES COMPILE_FLAGS "-DRSPAMD_TEST")
+TARGET_LINK_LIBRARIES(rspamd-test rspamd_lua)
+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})
@@ -38,4 +22,9 @@ ELSE(GMIME2_FOUND)
ENDIF(GMIME2_FOUND)
IF(ENABLE_STATIC MATCHES "ON")
TARGET_LINK_LIBRARIES(rspamd-test ${PCRE_LIBRARIES})
-ENDIF(ENABLE_STATIC MATCHES "ON") \ No newline at end of file
+ENDIF(ENABLE_STATIC MATCHES "ON")
+IF(ENABLE_LUAJIT MATCHES "ON")
+ TARGET_LINK_LIBRARIES(rspamd-test "${LUAJIT_LIBRARY}")
+ELSE(ENABLE_LUAJIT MATCHES "ON")
+ TARGET_LINK_LIBRARIES(rspamd-test "${LUA_LIBRARY}")
+ENDIF(ENABLE_LUAJIT MATCHES "ON") \ No newline at end of file
diff --git a/test/rspamd_dns_test.c b/test/rspamd_dns_test.c
index 822463948..c0b48080e 100644
--- a/test/rspamd_dns_test.c
+++ b/test/rspamd_dns_test.c
@@ -3,6 +3,7 @@
#include "tests.h"
#include "../src/dns.h"
#include "../src/logger.h"
+#include "../src/main.h"
#include "../src/events.h"
#include "../src/cfg_file.h"
diff --git a/test/rspamd_test_suite.c b/test/rspamd_test_suite.c
index 0d300bc3a..423086506 100644
--- a/test/rspamd_test_suite.c
+++ b/test/rspamd_test_suite.c
@@ -3,9 +3,8 @@
#include "../src/cfg_file.h"
#include "tests.h"
-rspamd_hash_t *counters = NULL;
-
static gboolean do_debug;
+struct rspamd_main *rspamd_main = NULL;
static GOptionEntry entries[] =
{
@@ -32,7 +31,11 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL);
- cfg = (struct config_file *)g_malloc (sizeof (struct config_file));
+ rspamd_main = (struct rspamd_main *)g_malloc (sizeof (struct rspamd_main));
+ memset (rspamd_main, 0, sizeof (struct rspamd_main));
+ rspamd_main->server_pool = memory_pool_new (memory_pool_get_size ());
+ rspamd_main->cfg = (struct config_file *)g_malloc (sizeof (struct config_file));
+ cfg = rspamd_main->cfg;
bzero (cfg, sizeof (struct config_file));
cfg->cfg_pool = memory_pool_new (memory_pool_get_size ());
@@ -43,9 +46,9 @@ 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, cfg);
- (void)open_log ();
- g_log_set_default_handler (rspamd_glib_log_function, cfg);
+ rspamd_set_logger (RSPAMD_LOG_CONSOLE, TYPE_MAIN, rspamd_main);
+ (void)open_log (rspamd_main->logger);
+ g_log_set_default_handler (rspamd_glib_log_function, rspamd_main->logger);
g_test_add_func ("/rspamd/memcached", rspamd_memcached_test_func);
g_test_add_func ("/rspamd/mem_pool", rspamd_mem_pool_test_func);