From: Sebastian Harl Date: Sat, 28 Feb 2015 17:45:39 +0000 (+0100) Subject: t/unit/: Create one test binary for each *_test.c file. X-Git-Tag: sysdb-0.8.0~154 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=967d9181f6329ca00b910c0c458b1c6b60f2a0d6;ds=sidebyside t/unit/: Create one test binary for each *_test.c file. That'll allow to run more stuff in parallel or single tests more selectively. --- diff --git a/.gitignore b/.gitignore index dbdf2bb..002520f 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/t/Makefile.am b/t/Makefile.am index 8fccbd2..f01e35b 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -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 diff --git a/t/unit/core/data_test.c b/t/unit/core/data_test.c index cf26035..71dae2a 100644 --- a/t/unit/core/data_test.c +++ b/t/unit/core/data_test.c @@ -25,8 +25,12 @@ * 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 #include @@ -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 : */ diff --git a/t/unit/core/object_test.c b/t/unit/core/object_test.c index 73d7c86..d0a7865 100644 --- a/t/unit/core/object_test.c +++ b/t/unit/core/object_test.c @@ -25,8 +25,12 @@ * 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 @@ -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 : */ diff --git a/t/unit/core/store_json_test.c b/t/unit/core/store_json_test.c index 9dc1570..ff6a18e 100644 --- a/t/unit/core/store_json_test.c +++ b/t/unit/core/store_json_test.c @@ -25,8 +25,12 @@ * 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 @@ -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 : */ diff --git a/t/unit/core/store_lookup_test.c b/t/unit/core/store_lookup_test.c index 3846bb3..c55184f 100644 --- a/t/unit/core/store_lookup_test.c +++ b/t/unit/core/store_lookup_test.c @@ -25,10 +25,14 @@ * 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 @@ -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 : */ diff --git a/t/unit/core/store_test.c b/t/unit/core/store_test.c index aab93aa..7ea53bc 100644 --- a/t/unit/core/store_test.c +++ b/t/unit/core/store_test.c @@ -25,9 +25,13 @@ * 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 #include @@ -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 : */ diff --git a/t/unit/core/time_test.c b/t/unit/core/time_test.c index 19b2cc0..9fee9db 100644 --- a/t/unit/core/time_test.c +++ b/t/unit/core/time_test.c @@ -25,8 +25,12 @@ * 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 @@ -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 : */ diff --git a/t/unit/frontend/connection_test.c b/t/unit/frontend/connection_test.c index 8c5f882..b4cc187 100644 --- a/t/unit/frontend/connection_test.c +++ b/t/unit/frontend/connection_test.c @@ -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 : */ diff --git a/t/unit/frontend/parser_test.c b/t/unit/frontend/parser_test.c index 48a1a97..c35ea4e 100644 --- a/t/unit/frontend/parser_test.c +++ b/t/unit/frontend/parser_test.c @@ -25,11 +25,15 @@ * 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 #include @@ -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 : */ diff --git a/t/unit/frontend/query_test.c b/t/unit/frontend/query_test.c index a360374..0f25493 100644 --- a/t/unit/frontend/query_test.c +++ b/t/unit/frontend/query_test.c @@ -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 @@ -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 : */ diff --git a/t/unit/frontend/sock_test.c b/t/unit/frontend/sock_test.c index 6d69ed9..14b2090 100644 --- a/t/unit/frontend/sock_test.c +++ b/t/unit/frontend/sock_test.c @@ -30,7 +30,7 @@ #endif #include "frontend/sock.h" -#include "libsysdb_test.h" +#include "testutils.h" #include @@ -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 index ae213c0..0000000 --- a/t/unit/libsysdb_net_test.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * SysDB - t/unit/libsysdb_net_test.c - * Copyright (C) 2013 Sebastian 'tokkee' Harl - * 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 -#include -#include - -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 index f69efcb..0000000 --- a/t/unit/libsysdb_test.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SysDB - t/unit/libsysdb_test.c - * Copyright (C) 2013 Sebastian 'tokkee' Harl - * 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 -#include -#include - -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 index e819b74..0000000 --- a/t/unit/libsysdb_test.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * SysDB - t/unit/libsysdb_test.h - * Copyright (C) 2013 Sebastian 'tokkee' Harl - * 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 -#include - -#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 index 6f6692d..0000000 --- a/t/unit/libsysdb_testutils.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SysDB - t/unit/libsysdb_testutils.c - * Copyright (C) 2014 Sebastian 'tokkee' Harl - * 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 -#include -#include - -int -sdb_regmatches(const char *regex, const char *string) -{ - regex_t reg; - int status; - - status = regcomp(®, regex, REG_EXTENDED | REG_NOSUB); - if (status) - return status; - - status = regexec(®, string, /* matches = */ 0, NULL, /* flags = */ 0); - regfree(®); - 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 index 63ef460..0000000 --- a/t/unit/libsysdb_testutils.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SysDB - t/unit/libsysdb_testutils.h - * Copyright (C) 2014 Sebastian 'tokkee' Harl - * 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 index 0000000..3b941fc --- /dev/null +++ b/t/unit/testutils.c @@ -0,0 +1,54 @@ +/* + * SysDB - t/unit/libsysdb_testutils.c + * Copyright (C) 2014 Sebastian 'tokkee' Harl + * 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 +#include +#include + +int +sdb_regmatches(const char *regex, const char *string) +{ + regex_t reg; + int status; + + status = regcomp(®, regex, REG_EXTENDED | REG_NOSUB); + if (status) + return status; + + status = regexec(®, string, /* matches = */ 0, NULL, /* flags = */ 0); + regfree(®); + 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 index 0000000..3bdf0a1 --- /dev/null +++ b/t/unit/testutils.h @@ -0,0 +1,78 @@ +/* + * SysDB - t/unit/libsysdb_testutils.h + * Copyright (C) 2014 Sebastian 'tokkee' Harl + * 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 +#include +#include + +#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 : */ + diff --git a/t/unit/utils/avltree_test.c b/t/unit/utils/avltree_test.c index 4f6933a..9be5e09 100644 --- a/t/unit/utils/avltree_test.c +++ b/t/unit/utils/avltree_test.c @@ -25,8 +25,12 @@ * 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 @@ -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 : */ diff --git a/t/unit/utils/channel_test.c b/t/unit/utils/channel_test.c index 0354397..6285faf 100644 --- a/t/unit/utils/channel_test.c +++ b/t/unit/utils/channel_test.c @@ -25,8 +25,12 @@ * 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 #include @@ -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 : */ diff --git a/t/unit/utils/dbi_test.c b/t/unit/utils/dbi_test.c index a1ac30a..db467fd 100644 --- a/t/unit/utils/dbi_test.c +++ b/t/unit/utils/dbi_test.c @@ -29,7 +29,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ -#include "libsysdb_test.h" +#include "testutils.h" #include "utils/dbi.h" #include @@ -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 : */ diff --git a/t/unit/utils/llist_test.c b/t/unit/utils/llist_test.c index 71a6c8c..d6869fa 100644 --- a/t/unit/utils/llist_test.c +++ b/t/unit/utils/llist_test.c @@ -25,8 +25,12 @@ * 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 @@ -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 : */ diff --git a/t/unit/utils/os_test.c b/t/unit/utils/os_test.c index 9525f49..333c310 100644 --- a/t/unit/utils/os_test.c +++ b/t/unit/utils/os_test.c @@ -30,7 +30,7 @@ #endif #include "utils/os.h" -#include "libsysdb_test.h" +#include "testutils.h" #include @@ -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 : */ diff --git a/t/unit/utils/proto_test.c b/t/unit/utils/proto_test.c index d82a40b..01b6350 100644 --- a/t/unit/utils/proto_test.c +++ b/t/unit/utils/proto_test.c @@ -25,9 +25,13 @@ * 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 #include @@ -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 : */ diff --git a/t/unit/utils/strbuf_test.c b/t/unit/utils/strbuf_test.c index cb86a3e..c15c1e9 100644 --- a/t/unit/utils/strbuf_test.c +++ b/t/unit/utils/strbuf_test.c @@ -25,8 +25,12 @@ * 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 @@ -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 : */ diff --git a/t/unit/utils/unixsock_test.c b/t/unit/utils/unixsock_test.c index 82a1daf..321a96e 100644 --- a/t/unit/utils/unixsock_test.c +++ b/t/unit/utils/unixsock_test.c @@ -35,7 +35,7 @@ #endif #include "utils/unixsock.h" -#include "libsysdb_test.h" +#include "testutils.h" #include @@ -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 : */