]> source.dussan.org Git - rspamd.git/commitdiff
Improve test suite by using standard glib test options.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 21 Aug 2013 14:12:24 +0000 (15:12 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 21 Aug 2013 14:12:24 +0000 (15:12 +0100)
test/rspamd_rcl_test.c
test/rspamd_test_suite.c
test/test.cfg [new file with mode: 0644]

index 0c338035f24c13ef0e4521f1a4ada9ea8a5e4961..089f964528b79cb1a22d1fc2b42d72cfa535ee66 100644 (file)
@@ -49,6 +49,8 @@ const gchar *rcl_test_valid[] = {
                "key3 = 111some,"
                "key4: s1,"
                "\"key5\": \"\\n\\r123\"",
+               /* Macros */
+               "section1 {key = value; .include \"./test.cfg\"}",
                NULL
 };
 
index d249ee1fed6ab73b93c2f499fbd4a7382fe222c4..7fb655347b535ee60aed35baafd2071c31747ce2 100644 (file)
@@ -3,36 +3,20 @@
 #include "../src/cfg_file.h"
 #include "tests.h"
 
-static gboolean do_debug;
 struct rspamd_main             *rspamd_main = NULL;
 struct event_base              *base = NULL;
 worker_t *workers[] = { NULL };
 
-static GOptionEntry entries[] =
-{
-  { "debug", 'd', 0, G_OPTION_ARG_NONE, &do_debug, "Turn on debug messages", NULL },
-  { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
-};
 
 int
 main (int argc, char **argv)
 {
        struct config_file            *cfg;
-       GError                         *error = NULL;
-       GOptionContext                 *context;
-
-       context = g_option_context_new ("- run rspamd test suite");
-       g_option_context_set_summary (context, "Summary:\n  Rspamd test suite version " RVERSION);
-       g_option_context_add_main_entries (context, entries, NULL);
-       if (!g_option_context_parse (context, &argc, &argv, &error)) {
-               fprintf (stderr, "option parsing failed: %s\n", error->message);
-               exit (1);
-       }
-
-       g_mem_set_vtable(glib_mem_profiler_table);
 
        g_test_init (&argc, &argv, NULL);
 
+       g_mem_set_vtable (glib_mem_profiler_table);
+
        rspamd_main = (struct rspamd_main *)g_malloc (sizeof (struct rspamd_main));
 
 #if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION <= 30))
@@ -48,7 +32,7 @@ main (int argc, char **argv)
 
        base = event_init ();
 
-       if (do_debug) {
+       if (g_test_verbose ()) {
                cfg->log_level = G_LOG_LEVEL_DEBUG;
        }
        else {
diff --git a/test/test.cfg b/test/test.cfg
new file mode 100644 (file)
index 0000000..880b363
--- /dev/null
@@ -0,0 +1,5 @@
+section2  {
+       param = "value";
+       param2 = value
+       array = [ 100500, 10s, 50mb ]
+}