Code

t/unit/: Create one test binary for each *_test.c file.
authorSebastian Harl <sh@tokkee.org>
Sat, 28 Feb 2015 17:45:39 +0000 (18:45 +0100)
committerSebastian Harl <sh@tokkee.org>
Sat, 28 Feb 2015 17:45:39 +0000 (18:45 +0100)
That'll allow to run more stuff in parallel or single tests more selectively.

27 files changed:
.gitignore
t/Makefile.am
t/unit/core/data_test.c
t/unit/core/object_test.c
t/unit/core/store_json_test.c
t/unit/core/store_lookup_test.c
t/unit/core/store_test.c
t/unit/core/time_test.c
t/unit/frontend/connection_test.c
t/unit/frontend/parser_test.c
t/unit/frontend/query_test.c
t/unit/frontend/sock_test.c
t/unit/libsysdb_net_test.c [deleted file]
t/unit/libsysdb_test.c [deleted file]
t/unit/libsysdb_test.h [deleted file]
t/unit/libsysdb_testutils.c [deleted file]
t/unit/libsysdb_testutils.h [deleted file]
t/unit/testutils.c [new file with mode: 0644]
t/unit/testutils.h [new file with mode: 0644]
t/unit/utils/avltree_test.c
t/unit/utils/channel_test.c
t/unit/utils/dbi_test.c
t/unit/utils/llist_test.c
t/unit/utils/os_test.c
t/unit/utils/proto_test.c
t/unit/utils/strbuf_test.c
t/unit/utils/unixsock_test.c

index dbdf2bb49d8398a41277e73926272957c75ac291..002520ff88266eaecdb23d07b474e9a5deb3ac32 100644 (file)
@@ -59,9 +59,8 @@ sysdb.h
 # integration/unit testing output
 t/integration/*.sh.log
 t/integration/*.sh.trs
-t/unit/libsysdb_test
-t/unit/libsysdb_net_test
-t/unit/*.log
-t/unit/*.trs
+t/unit/*/*_test
+t/unit/*/*_test.log
+t/unit/*/*_test.trs
 test-driver
 test-suite.log
index 8fccbd222174ecd149c796e6d9abdbf83ec9dbca..f01e35bc9e9d35bd247a71548b0ba5dd9cba5154 100644 (file)
@@ -25,41 +25,107 @@ check_LTLIBRARIES =
 LOG_COMPILER = $(abs_srcdir)/testwrapper.sh
 
 if UNIT_TESTING
-TESTS += unit/libsysdb_test unit/libsysdb_net_test
-check_PROGRAMS += unit/libsysdb_test unit/libsysdb_net_test
-endif
+UNIT_TESTS = \
+               unit/core/data_test \
+               unit/core/object_test \
+               unit/core/store_json_test \
+               unit/core/store_lookup_test \
+               unit/core/store_test \
+               unit/core/time_test \
+               unit/frontend/connection_test \
+               unit/frontend/parser_test \
+               unit/frontend/query_test \
+               unit/frontend/sock_test \
+               unit/utils/avltree_test \
+               unit/utils/channel_test \
+               unit/utils/dbi_test \
+               unit/utils/llist_test \
+               unit/utils/os_test \
+               unit/utils/proto_test \
+               unit/utils/strbuf_test
+
+UNIT_TEST_SOURCES = unit/testutils.c unit/testutils.h
+UNIT_TEST_CFLAGS = $(AM_CFLAGS) @CHECK_CFLAGS@ -I$(top_srcdir)/t/unit
+UNIT_TEST_LDADD = $(top_builddir)/src/libsysdb.la @CHECK_LIBS@
 
-unit_libsysdb_test_SOURCES = \
-               unit/libsysdb_test.c unit/libsysdb_test.h \
-               unit/libsysdb_testutils.c unit/libsysdb_testutils.h \
-               unit/core/data_test.c \
-               unit/core/object_test.c \
-               unit/core/store_test.c \
-               unit/core/store_json_test.c \
-               unit/core/store_lookup_test.c \
-               unit/core/time_test.c \
-               unit/frontend/connection_test.c \
-               unit/frontend/parser_test.c \
-               unit/frontend/sock_test.c \
-               unit/frontend/query_test.c \
-               unit/utils/avltree_test.c \
-               unit/utils/channel_test.c \
-               unit/utils/dbi_test.c \
-               unit/utils/llist_test.c \
-               unit/utils/os_test.c \
-               unit/utils/proto_test.c \
-               unit/utils/strbuf_test.c
-unit_libsysdb_test_CFLAGS = $(AM_CFLAGS) @CHECK_CFLAGS@ -I$(top_srcdir)/t/unit
-unit_libsysdb_test_LDADD = $(top_builddir)/src/libsysdb.la @CHECK_LIBS@
-
-unit_libsysdb_net_test_SOURCES = \
-               unit/libsysdb_net_test.c unit/libsysdb_test.h \
-               unit/libsysdb_testutils.c unit/libsysdb_testutils.h
 if BUILD_WITH_FOPENCOOKIE
-unit_libsysdb_net_test_SOURCES += unit/utils/unixsock_test.c
+UNIT_TESTS += unit/utils/unixsock_test
+unit_utils_unixsock_test_SOURCES = $(UNIT_TEST_SOURCES) unit/utils/unixsock_test.c
+unit_utils_unixsock_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_utils_unixsock_test_LDADD = $(UNIT_TEST_LDADD)
+endif
+
+unit_core_data_test_SOURCES = $(UNIT_TEST_SOURCES) unit/core/data_test.c
+unit_core_data_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_core_data_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_core_object_test_SOURCES = $(UNIT_TEST_SOURCES) unit/core/object_test.c
+unit_core_object_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_core_object_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_core_store_json_test_SOURCES = $(UNIT_TEST_SOURCES) unit/core/store_json_test.c
+unit_core_store_json_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_core_store_json_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_core_store_lookup_test_SOURCES = $(UNIT_TEST_SOURCES) unit/core/store_lookup_test.c
+unit_core_store_lookup_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_core_store_lookup_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_core_store_test_SOURCES = $(UNIT_TEST_SOURCES) unit/core/store_test.c
+unit_core_store_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_core_store_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_core_time_test_SOURCES = $(UNIT_TEST_SOURCES) unit/core/time_test.c
+unit_core_time_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_core_time_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_frontend_connection_test_SOURCES = $(UNIT_TEST_SOURCES) unit/frontend/connection_test.c
+unit_frontend_connection_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_frontend_connection_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_frontend_parser_test_SOURCES = $(UNIT_TEST_SOURCES) unit/frontend/parser_test.c
+unit_frontend_parser_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_frontend_parser_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_frontend_query_test_SOURCES = $(UNIT_TEST_SOURCES) unit/frontend/query_test.c
+unit_frontend_query_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_frontend_query_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_frontend_sock_test_SOURCES = $(UNIT_TEST_SOURCES) unit/frontend/sock_test.c
+unit_frontend_sock_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_frontend_sock_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_utils_avltree_test_SOURCES = $(UNIT_TEST_SOURCES) unit/utils/avltree_test.c
+unit_utils_avltree_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_utils_avltree_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_utils_channel_test_SOURCES = $(UNIT_TEST_SOURCES) unit/utils/channel_test.c
+unit_utils_channel_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_utils_channel_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_utils_dbi_test_SOURCES = $(UNIT_TEST_SOURCES) unit/utils/dbi_test.c
+unit_utils_dbi_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_utils_dbi_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_utils_llist_test_SOURCES = $(UNIT_TEST_SOURCES) unit/utils/llist_test.c
+unit_utils_llist_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_utils_llist_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_utils_os_test_SOURCES = $(UNIT_TEST_SOURCES) unit/utils/os_test.c
+unit_utils_os_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_utils_os_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_utils_proto_test_SOURCES = $(UNIT_TEST_SOURCES) unit/utils/proto_test.c
+unit_utils_proto_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_utils_proto_test_LDADD = $(UNIT_TEST_LDADD)
+
+unit_utils_strbuf_test_SOURCES = $(UNIT_TEST_SOURCES) unit/utils/strbuf_test.c
+unit_utils_strbuf_test_CFLAGS = $(UNIT_TEST_CFLAGS)
+unit_utils_strbuf_test_LDADD = $(UNIT_TEST_LDADD)
+
+TESTS += $(UNIT_TESTS)
+check_PROGRAMS += $(UNIT_TESTS)
 endif
-unit_libsysdb_net_test_CFLAGS = $(AM_CFLAGS) @CHECK_CFLAGS@ -I$(top_srcdir)/t/unit
-unit_libsysdb_net_test_LDADD = $(top_builddir)/src/libsysdb.la @CHECK_LIBS@
 
 #
 # integration tests
@@ -72,7 +138,6 @@ TESTS += \
                integration/query.sh \
                integration/matching.sh \
                integration/filter.sh
-endif
 
 check_LTLIBRARIES += integration/mock_plugin.la
 integration_mock_plugin_la_SOURCES = integration/mock_plugin.c
@@ -85,6 +150,7 @@ integration_mock_timeseries_la_SOURCES = integration/mock_timeseries.c
 # -rpath is a work-around to enforce a shared library
 integration_mock_timeseries_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version \
                -rpath /nonexistent
+endif
 
 test: check
 
index cf2603575bc0fa3a3ff47f5de1f2225e2d167e53..71dae2acbb65f673d011d935e562eba65243a495 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif
+
 #include "core/data.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <assert.h>
 #include <check.h>
@@ -2184,13 +2188,9 @@ START_TEST(test_parse)
 }
 END_TEST
 
-Suite *
-core_data_suite(void)
+TEST_MAIN("core::data")
 {
-       Suite *s = suite_create("core::data");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        tcase_add_test(tc, test_data);
        tcase_add_test(tc, test_cmp);
        tcase_add_test(tc, test_strcmp);
@@ -2200,10 +2200,9 @@ core_data_suite(void)
        tcase_add_test(tc, test_expr_eval);
        tcase_add_test(tc, test_format);
        tcase_add_test(tc, test_parse);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* core_data_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index 73d7c86e1f1b21c18de0746ec250132df1001706..d0a78656f1f7074966d8c9a75d90ce25ab4be887 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif
+
 #include "core/object.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <check.h>
 
@@ -319,21 +323,16 @@ START_TEST(test_obj_cmp)
 }
 END_TEST
 
-Suite *
-core_object_suite(void)
+TEST_MAIN("core::object")
 {
-       Suite *s = suite_create("core::object");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        tcase_add_test(tc, test_obj_create);
        tcase_add_test(tc, test_obj_wrapper);
        tcase_add_test(tc, test_obj_ref);
        tcase_add_test(tc, test_obj_cmp);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* core_object_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index 9dc157068183b49c2e2c4e1e74276bcccee9c064..ff6a18edc3ae8f095988129231430b893a0a5b03 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif
+
 #include "core/store.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <assert.h>
 
@@ -422,19 +426,14 @@ START_TEST(test_store_tojson)
 }
 END_TEST
 
-Suite *
-core_store_json_suite(void)
+TEST_MAIN("core::store_json")
 {
-       Suite *s = suite_create("core::store_json");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        TC_ADD_LOOP_TEST(tc, store_tojson);
        tcase_add_unchecked_fixture(tc, populate, sdb_store_clear);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* core_store_json_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index 3846bb3d2b8adb1f39eeb218ebb7c3fe18cd6f4e..c55184f63670bc00c85b48ffadf4f8f6a1501789 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif
+
 #include "core/store.h"
 #include "core/store-private.h"
 #include "frontend/parser.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <assert.h>
 
@@ -632,23 +636,18 @@ START_TEST(test_scan)
 }
 END_TEST
 
-Suite *
-core_store_lookup_suite(void)
+TEST_MAIN("core::store_lookup")
 {
-       Suite *s = suite_create("core::store_lookup");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        tcase_add_checked_fixture(tc, populate, sdb_store_clear);
        TC_ADD_LOOP_TEST(tc, cmp_name);
        TC_ADD_LOOP_TEST(tc, cmp_attr);
        TC_ADD_LOOP_TEST(tc, cmp_obj);
        TC_ADD_LOOP_TEST(tc, scan);
        tcase_add_test(tc, test_store_match_op);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* core_store_lookup_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index aab93aab1671a6995818b3da64fede48ec4d37b5..7ea53bcaf76d25bb8efd70e12ea4f13db6dadb8d 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif
+
 #include "core/store.h"
 #include "core/store-private.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <check.h>
 #include <string.h>
@@ -738,13 +742,9 @@ START_TEST(test_scan)
 }
 END_TEST
 
-Suite *
-core_store_suite(void)
+TEST_MAIN("core::store")
 {
-       Suite *s = suite_create("core::store");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        tcase_add_test(tc, test_store_host);
        tcase_add_test(tc, test_store_get_host);
        tcase_add_test(tc, test_store_attr);
@@ -757,10 +757,9 @@ core_store_suite(void)
        tcase_add_test(tc, test_interval);
        tcase_add_test(tc, test_scan);
        tcase_add_unchecked_fixture(tc, NULL, sdb_store_clear);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* core_store_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index 19b2cc081e4027665ef9310b06d6df1d148a2409..9fee9dbd46303987b02b3a814010f80d59612296 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif
+
 #include "core/time.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <check.h>
 
@@ -123,19 +127,14 @@ START_TEST(test_strpunit)
 }
 END_TEST
 
-Suite *
-core_time_suite(void)
+TEST_MAIN("core::time")
 {
-       Suite *s = suite_create("core::time");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        TC_ADD_LOOP_TEST(tc, strfinterval);
        TC_ADD_LOOP_TEST(tc, strpunit);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* core_time_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index 8c5f88297cc6802e0dc9db663a81f5936a7e4c6e..b4cc1878555198425a44e7b3bb4abe9acd691de5 100644 (file)
@@ -32,7 +32,7 @@
 #include "frontend/connection.h"
 #include "frontend/connection-private.h"
 #include "utils/os.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include "utils/strbuf.h"
 
@@ -436,10 +436,8 @@ START_TEST(test_conn_io)
 }
 END_TEST
 
-Suite *
-fe_conn_suite(void)
+TEST_MAIN("frontend::connection")
 {
-       Suite *s = suite_create("frontend::connection");
        TCase *tc;
 
        char *tmp = sdb_get_current_user();
@@ -451,10 +449,9 @@ fe_conn_suite(void)
        tcase_add_test(tc, test_conn_accept);
        tcase_add_test(tc, test_conn_setup);
        tcase_add_test(tc, test_conn_io);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* fe_conn_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index 48a1a97856b0304e159d2c26bddbb5ad340f18c2..c35ea4e658b1c82be983ceb311baee8f4daabbb9 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif
+
 #include "frontend/connection.h"
 #include "frontend/parser.h"
 #include "core/store-private.h"
 #include "core/object.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <check.h>
 #include <limits.h>
@@ -787,20 +791,15 @@ START_TEST(test_parse_expr)
 }
 END_TEST
 
-Suite *
-fe_parser_suite(void)
+TEST_MAIN("frontend::parser")
 {
-       Suite *s = suite_create("frontend::parser");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        TC_ADD_LOOP_TEST(tc, parse);
        TC_ADD_LOOP_TEST(tc, parse_matcher);
        TC_ADD_LOOP_TEST(tc, parse_expr);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* util_parser_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index a36037452ddbfd3fdfdffc7a2468c83e4c878664..0f25493b397aa8991179553a27644c11a88a8d51 100644 (file)
@@ -32,7 +32,7 @@
 #include "frontend/connection.h"
 #include "frontend/parser.h"
 #include "frontend/connection-private.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <check.h>
 
@@ -388,19 +388,14 @@ START_TEST(test_exec_fetch)
 }
 END_TEST
 
-Suite *
-fe_query_suite(void)
+TEST_MAIN("frontend::query")
 {
-       Suite *s = suite_create("frontend::query");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        tcase_add_checked_fixture(tc, populate, sdb_store_clear);
        tcase_add_loop_test(tc, test_exec_fetch, 0, SDB_STATIC_ARRAY_LEN(exec_fetch_data));
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* fe_query_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index 6d69ed9ca4a2428c0615a8e4b7e7cafe7c185781..14b20907ca9051b680ddd7eec3ee7a05c218f384 100644 (file)
@@ -30,7 +30,7 @@
 #endif
 
 #include "frontend/sock.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <check.h>
 
@@ -168,19 +168,14 @@ START_TEST(test_listen_and_serve)
 }
 END_TEST
 
-Suite *
-fe_sock_suite(void)
+TEST_MAIN("frontend::sock")
 {
-       Suite *s = suite_create("frontend::sock");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        tcase_add_checked_fixture(tc, setup, teardown);
        tcase_add_test(tc, test_listen_and_serve);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* util_unixsock_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
diff --git a/t/unit/libsysdb_net_test.c b/t/unit/libsysdb_net_test.c
deleted file mode 100644 (file)
index ae213c0..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SysDB - t/unit/libsysdb_net_test.c
- * Copyright (C) 2013 Sebastian 'tokkee' Harl <sh@tokkee.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * testing component involving networking operations
- */
-
-#if HAVE_CONFIG_H
-#      include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#include "libsysdb_test.h"
-
-#include <check.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-main(void)
-{
-       int failed = 0;
-       size_t i;
-
-       suite_creator_t creators[] = {
-#ifdef HAVE_FOPENCOOKIE
-               { util_unixsock_suite, NULL },
-#else
-               { NULL, "Skipping util::unixsock; missing fopencookie" },
-#endif /* HAVE_FOPENCOOKIE */
-       };
-
-       putenv("TZ=UTC");
-
-       for (i = 0; i < SDB_STATIC_ARRAY_LEN(creators); ++i) {
-               SRunner *sr;
-               Suite *s;
-
-               if (creators[i].msg)
-                       printf("%s\n", creators[i].msg);
-
-               if (!creators[i].creator)
-                       continue;
-
-               s = creators[i].creator();
-               sr = srunner_create(s);
-               srunner_run_all(sr, CK_NORMAL);
-               failed += srunner_ntests_failed(sr);
-               srunner_free(sr);
-       }
-
-       return failed;
-} /* main */
-
-/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
-
diff --git a/t/unit/libsysdb_test.c b/t/unit/libsysdb_test.c
deleted file mode 100644 (file)
index f69efcb..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * SysDB - t/unit/libsysdb_test.c
- * Copyright (C) 2013 Sebastian 'tokkee' Harl <sh@tokkee.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if HAVE_CONFIG_H
-#      include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#include "libsysdb_test.h"
-
-#include <check.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-main(void)
-{
-       int failed = 0;
-       size_t i;
-
-       suite_creator_t creators[] = {
-               { core_data_suite, NULL },
-               { core_object_suite, NULL },
-               { core_store_suite, NULL },
-               { core_store_lookup_suite, NULL },
-               { core_store_json_suite, NULL },
-               { core_time_suite, NULL },
-               { fe_conn_suite, NULL },
-               { fe_parser_suite, NULL },
-               { fe_sock_suite, NULL },
-               { fe_query_suite, NULL },
-               { util_avltree_suite, NULL },
-               { util_channel_suite, NULL },
-               { util_dbi_suite, NULL },
-               { util_llist_suite, NULL },
-               { util_os_suite, NULL },
-               { util_proto_suite, NULL },
-               { util_strbuf_suite, NULL },
-       };
-
-       putenv("TZ=UTC");
-
-       for (i = 0; i < SDB_STATIC_ARRAY_LEN(creators); ++i) {
-               SRunner *sr;
-               Suite *s;
-
-               if (creators[i].msg)
-                       printf("%s\n", creators[i].msg);
-
-               if (!creators[i].creator)
-                       continue;
-
-               s = creators[i].creator();
-               sr = srunner_create(s);
-               srunner_run_all(sr, CK_NORMAL);
-               failed += srunner_ntests_failed(sr);
-               srunner_free(sr);
-       }
-
-       return failed;
-} /* main */
-
-/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
-
diff --git a/t/unit/libsysdb_test.h b/t/unit/libsysdb_test.h
deleted file mode 100644 (file)
index e819b74..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * SysDB - t/unit/libsysdb_test.h
- * Copyright (C) 2013 Sebastian 'tokkee' Harl <sh@tokkee.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef T_LIBSYSDB_H
-#define T_LIBSYSDB_H 1
-
-#include "sysdb.h"
-#include "core/object.h"
-
-#include "libsysdb_testutils.h"
-
-#include <check.h>
-#include <string.h>
-
-#define TC_ADD_LOOP_TEST(tc, name) \
-       tcase_add_loop_test((tc), test_ ## name, \
-                       0, SDB_STATIC_ARRAY_LEN(name ## _data))
-
-/*
- * test-related data-types
- */
-
-typedef struct {
-       Suite *(*creator)(void);
-       const char *msg;
-} suite_creator_t;
-
-/*
- * test suites
- */
-
-/* t/core/data_test */
-Suite *
-core_data_suite(void);
-
-/* t/core/object_test */
-Suite *
-core_object_suite(void);
-
-/* t/core/store_test */
-Suite *
-core_store_suite(void);
-
-/* t/core/store_json */
-Suite *
-core_store_json_suite(void);
-
-/* t/core/store_lookup_test */
-Suite *
-core_store_lookup_suite(void);
-
-/* t/core/time_test */
-Suite *
-core_time_suite(void);
-
-/* t/frontend/connection_test */
-Suite *
-fe_conn_suite(void);
-
-/* t/frontend/parser_test */
-Suite *
-fe_parser_suite(void);
-
-/* t/frontend/sock_test */
-Suite *
-fe_sock_suite(void);
-
-/* t/frontend/query_test */
-Suite *
-fe_query_suite(void);
-
-/* t/utils/avltree_test */
-Suite *
-util_avltree_suite(void);
-
-/* t/utils/channel_test */
-Suite *
-util_channel_suite(void);
-
-/* t/utils/dbi_test */
-Suite *
-util_dbi_suite(void);
-
-/* t/utils/llist_test */
-Suite *
-util_llist_suite(void);
-
-/* t/utils/os_test */
-Suite *
-util_os_suite(void);
-
-/* t/utils/proto_test */
-Suite *
-util_proto_suite(void);
-
-/* t/utils/strbuf_test */
-Suite *
-util_strbuf_suite(void);
-
-/* t/utils/unixsock_test */
-Suite *
-util_unixsock_suite(void);
-
-#endif /* T_LIBSYSDB_H */
-
-/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
-
diff --git a/t/unit/libsysdb_testutils.c b/t/unit/libsysdb_testutils.c
deleted file mode 100644 (file)
index 6f6692d..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * SysDB - t/unit/libsysdb_testutils.c
- * Copyright (C) 2014 Sebastian 'tokkee' Harl <sh@tokkee.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if HAVE_CONFIG_H
-#      include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#include "libsysdb_testutils.h"
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include <regex.h>
-
-int
-sdb_regmatches(const char *regex, const char *string)
-{
-       regex_t reg;
-       int status;
-
-       status = regcomp(&reg, regex, REG_EXTENDED | REG_NOSUB);
-       if (status)
-               return status;
-
-       status = regexec(&reg, string, /* matches = */ 0, NULL, /* flags = */ 0);
-       regfree(&reg);
-       return status;
-} /* sdb_regmatches */
-
-/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
-
diff --git a/t/unit/libsysdb_testutils.h b/t/unit/libsysdb_testutils.h
deleted file mode 100644 (file)
index 63ef460..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * SysDB - t/unit/libsysdb_testutils.h
- * Copyright (C) 2014 Sebastian 'tokkee' Harl <sh@tokkee.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Utility functions for test suites.
- */
-
-#ifndef T_LIBSYSDB_UTILS_H
-#define T_LIBSYSDB_UTILS_H 1
-
-/*
- * sdb_regmatches:
- * Check if a regex matches a string.
- *
- * Returns:
- *  - 0 if the regex matches
- *  - a non-zero error value else (see regcomp(3) for details)
- */
-int
-sdb_regmatches(const char *regex, const char *string);
-
-#endif /* T_LIBSYSDB_UTILS_H */
-
-/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
-
diff --git a/t/unit/testutils.c b/t/unit/testutils.c
new file mode 100644 (file)
index 0000000..3b941fc
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * SysDB - t/unit/libsysdb_testutils.c
+ * Copyright (C) 2014 Sebastian 'tokkee' Harl <sh@tokkee.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "testutils.h"
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <regex.h>
+
+int
+sdb_regmatches(const char *regex, const char *string)
+{
+       regex_t reg;
+       int status;
+
+       status = regcomp(&reg, regex, REG_EXTENDED | REG_NOSUB);
+       if (status)
+               return status;
+
+       status = regexec(&reg, string, /* matches = */ 0, NULL, /* flags = */ 0);
+       regfree(&reg);
+       return status;
+} /* sdb_regmatches */
+
+/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
+
diff --git a/t/unit/testutils.h b/t/unit/testutils.h
new file mode 100644 (file)
index 0000000..3bdf0a1
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * SysDB - t/unit/libsysdb_testutils.h
+ * Copyright (C) 2014 Sebastian 'tokkee' Harl <sh@tokkee.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Utility functions for test suites.
+ */
+
+#ifndef T_LIBSYSDB_UTILS_H
+#define T_LIBSYSDB_UTILS_H 1
+
+#include "sysdb.h"
+
+#include <check.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define TEST_MAIN(name) \
+       int main(void) \
+       { \
+               SRunner *sr; \
+               Suite *s; \
+               int failed; \
+               putenv("TZ=UTC"); \
+               s = suite_create(name); \
+
+#define TC_ADD_LOOP_TEST(tc, name) \
+       tcase_add_loop_test((tc), test_ ## name, \
+                       0, SDB_STATIC_ARRAY_LEN(name ## _data))
+
+#define ADD_TCASE(tc) suite_add_tcase(s, (tc))
+
+#define TEST_MAIN_END \
+               sr = srunner_create(s); \
+               srunner_run_all(sr, CK_NORMAL); \
+               failed = srunner_ntests_failed(sr); \
+               srunner_free(sr); \
+               return failed == 0 ? 0 : 1; \
+       }
+
+/*
+ * sdb_regmatches:
+ * Check if a regex matches a string.
+ *
+ * Returns:
+ *  - 0 if the regex matches
+ *  - a non-zero error value else (see regcomp(3) for details)
+ */
+int
+sdb_regmatches(const char *regex, const char *string);
+
+#endif /* T_LIBSYSDB_UTILS_H */
+
+/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
+
index 4f6933acf6acb94e185acf0f39fd3c8e55a48b77..9be5e0960821626be4e842350da7314723306015 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif
+
 #include "utils/avltree.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <check.h>
 
@@ -236,22 +240,17 @@ START_TEST(test_iter)
 }
 END_TEST
 
-Suite *
-util_avltree_suite(void)
+TEST_MAIN("utils::avltree")
 {
-       Suite *s = suite_create("utils::avltree");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        tcase_add_checked_fixture(tc, setup, teardown);
        tcase_add_test(tc, test_null);
        tcase_add_test(tc, test_insert);
        tcase_add_test(tc, test_lookup);
        tcase_add_test(tc, test_iter);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* util_avltree_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index 0354397aae8edab4e3e62c1a2648a7ab6a05e07a..6285fafd9fbc0aef38e16cc6d37de2e6daaeffd0 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif
+
 #include "utils/channel.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <check.h>
 #include <errno.h>
@@ -339,34 +343,29 @@ START_TEST(test_write_read_string)
 }
 END_TEST
 
-Suite *
-util_channel_suite(void)
+TEST_MAIN("utils::channel")
 {
-       Suite *s = suite_create("utils::channel");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        tcase_add_test(tc, test_create);
        tcase_add_test(tc, test_write_read);
        tcase_add_test(tc, test_select);
-       suite_add_tcase(s, tc);
+       ADD_TCASE(tc);
 
        tc = tcase_create("integer");
        tcase_add_checked_fixture(tc, setup_int, teardown);
        tcase_add_test(tc, test_write_int);
        tcase_add_test(tc, test_read_int);
        tcase_add_test(tc, test_write_read_int);
-       suite_add_tcase(s, tc);
+       ADD_TCASE(tc);
 
        tc = tcase_create("string");
        tcase_add_checked_fixture(tc, setup_string, teardown);
        tcase_add_test(tc, test_write_string);
        tcase_add_test(tc, test_read_string);
        tcase_add_test(tc, test_write_read_string);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* util_llist_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index a1ac30a37983afa98c60228ed846ad567bb13e6d..db467fdfdb0dbd08dae33b67337732ef3577bc8d 100644 (file)
@@ -29,7 +29,7 @@
 #      include "config.h"
 #endif /* HAVE_CONFIG_H */
 
-#include "libsysdb_test.h"
+#include "testutils.h"
 #include "utils/dbi.h"
 
 #include <check.h>
@@ -676,25 +676,16 @@ START_TEST(test_sdb_dbi_exec_query)
 }
 END_TEST
 
-/*
- * test API
- */
-
-Suite *
-util_dbi_suite(void)
+TEST_MAIN("utils::dbi")
 {
-       Suite *s = suite_create("utils::dbi");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        tcase_add_checked_fixture(tc, setup, teardown);
        tcase_add_test(tc, test_sdb_dbi_client_connect);
        tcase_add_test(tc, test_sdb_dbi_client_check_conn);
        tcase_add_test(tc, test_sdb_dbi_exec_query);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* util_llist_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index 71a6c8c9332a16564dd2518ac1b21069768d6cfb..d6869fa946c1b486f491a467308dc9151cc41de5 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif
+
 #include "utils/llist.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <check.h>
 
@@ -370,13 +374,9 @@ START_TEST(test_iter_remove)
 }
 END_TEST
 
-Suite *
-util_llist_suite(void)
+TEST_MAIN("utils::llist")
 {
-       Suite *s = suite_create("utils::llist");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        tcase_add_checked_fixture(tc, setup, teardown);
        tcase_add_test(tc, test_clone);
        tcase_add_test(tc, test_destroy);
@@ -390,10 +390,9 @@ util_llist_suite(void)
        tcase_add_test(tc, test_shift);
        tcase_add_test(tc, test_iter);
        tcase_add_test(tc, test_iter_remove);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* util_llist_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index 9525f49184cd4c2963edbfee7d4e542505494f98..333c310126b23affb0cbcd0d62f483f90f72fdd1 100644 (file)
@@ -30,7 +30,7 @@
 #endif
 
 #include "utils/os.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <errno.h>
 
@@ -103,18 +103,13 @@ START_TEST(test_mkdir_remove)
 }
 END_TEST
 
-Suite *
-util_os_suite(void)
+TEST_MAIN("utils::os")
 {
-       Suite *s = suite_create("utils::os");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        tcase_add_test(tc, test_mkdir_remove);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* util_os_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index d82a40b64e2a4cc2a0c5c472baff4817b5d54dec..01b63502bd5bab44c68cbcea7c6f5577fd63a418 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif
+
 #include "core/store.h"
 #include "utils/proto.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <check.h>
 #include <stdbool.h>
@@ -524,22 +528,17 @@ START_TEST(test_marshal_attribute)
 }
 END_TEST
 
-Suite *
-util_proto_suite(void)
+TEST_MAIN("utils::proto")
 {
-       Suite *s = suite_create("utils::proto");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        tcase_add_test(tc, test_marshal_data);
        tcase_add_test(tc, test_marshal_host);
        tcase_add_test(tc, test_marshal_service);
        tcase_add_test(tc, test_marshal_metric);
        tcase_add_test(tc, test_marshal_attribute);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* util_proto_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index cb86a3e1ef3edd75ba03f26da11996c5532c5c49..c15c1e9cb21a9b6821d8bfe8b57ed490ea320483 100644 (file)
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#      include "config.h"
+#endif
+
 #include "utils/strbuf.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <check.h>
 
@@ -613,16 +617,12 @@ START_TEST(test_len)
 }
 END_TEST
 
-Suite *
-util_strbuf_suite(void)
+TEST_MAIN("utils::strbuf")
 {
-       Suite *s = suite_create("utils::strbuf");
-       TCase *tc;
-
-       tc = tcase_create("empty");
+       TCase *tc = tcase_create("empty");
        tcase_add_test(tc, test_null);
        tcase_add_test(tc, test_empty);
-       suite_add_tcase(s, tc);
+       ADD_TCASE(tc);
 
        tc = tcase_create("core");
        tcase_add_checked_fixture(tc, setup, teardown);
@@ -637,10 +637,9 @@ util_strbuf_suite(void)
        tcase_add_test(tc, test_clear);
        tcase_add_test(tc, test_string);
        tcase_add_test(tc, test_len);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* util_strbuf_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
index 82a1daf7b6986a4ae4746dcfd151947a6db39aa5..321a96e7d5d7fd389dc9afa51339ec51718d0132 100644 (file)
@@ -35,7 +35,7 @@
 #endif
 
 #include "utils/unixsock.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
 
 #include <check.h>
 
@@ -362,22 +362,17 @@ START_TEST(test_sdb_unixsock_client_recv)
 }
 END_TEST
 
-Suite *
-util_unixsock_suite(void)
+TEST_MAIN("utils::unixsock")
 {
-       Suite *s = suite_create("utils::unixsock");
-       TCase *tc;
-
-       tc = tcase_create("core");
+       TCase *tc = tcase_create("core");
        tcase_add_checked_fixture(tc, setup, teardown);
        tcase_add_test(tc, test_sdb_unixsock_client_create);
        tcase_add_test(tc, test_sdb_unixsock_client_connect);
        tcase_add_test(tc, test_sdb_unixsock_client_send);
        tcase_add_test(tc, test_sdb_unixsock_client_recv);
-       suite_add_tcase(s, tc);
-
-       return s;
-} /* util_unixsock_suite */
+       ADD_TCASE(tc);
+}
+TEST_MAIN_END
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */