From 04eb0afd2895a9b6f4be743dba1d390ebe3ffccb Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 18 Oct 2016 09:36:53 +0200 Subject: [PATCH] build: merge "src/platform/tests/Makefile.am" into toplevel Makefile --- Makefile.am | 117 ++++++++++++++++++++++++++ configure.ac | 2 - src/Makefile.am | 1 - src/devices/tests/test-arping.c | 2 + src/devices/tests/test-lldp.c | 2 + src/platform/Makefile.am | 1 - src/platform/tests/Makefile.am | 132 ------------------------------ src/platform/tests/test-address.c | 2 + src/platform/tests/test-cleanup.c | 2 + src/platform/tests/test-common.c | 14 +++- src/platform/tests/test-common.h | 6 +- src/platform/tests/test-link.c | 5 +- src/platform/tests/test-route.c | 2 + src/tests/test-route-manager.c | 2 + 14 files changed, 147 insertions(+), 143 deletions(-) delete mode 100644 src/platform/Makefile.am delete mode 100644 src/platform/tests/Makefile.am diff --git a/Makefile.am b/Makefile.am index 8e06ddf2e4..8bf6af07bf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2578,6 +2578,123 @@ src_dnsmasq_manager_tests_test_dnsmasq_utils_CPPFLAGS = \ src_dnsmasq_manager_tests_test_dnsmasq_utils_LDADD = \ src/libNetworkManager.la +############################################################################### +# src/platform/tests +############################################################################### + +src_platform_tests_cppflags = \ + -I${top_srcdir} \ + -I${top_srcdir}/shared \ + -I${top_builddir}/shared \ + -I${top_srcdir}/src \ + -I${top_builddir}/src \ + -I${top_srcdir}/libnm-core \ + -I${top_builddir}/libnm-core \ + -I${srcdir}/src/platform \ + -DG_LOG_DOMAIN=\""NetworkManager"\" \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ + $(GLIB_CFLAGS) \ + $(GUDEV_CFLAGS) \ + $(CODE_COVERAGE_CFLAGS) \ + $(LIBNL_CFLAGS) + +check_ltlibraries += \ + src/platform/tests/libnm-platform-tests.la + +src_platform_tests_libnm_platform_tests_la_SOURCES = \ + src/platform/tests/test-common.c \ + src/platform/tests/test-common.h +src_platform_tests_libnm_platform_tests_la_CPPFLAGS = $(src_platform_tests_cppflags) +if REQUIRE_ROOT_TESTS +src_platform_tests_libnm_platform_tests_la_CPPFLAGS += -DREQUIRE_ROOT_TESTS=1 +endif +src_platform_tests_libnm_platform_tests_la_LDFLAGS = \ + $(CODE_COVERAGE_LDFLAGS) +src_platform_tests_libnm_platform_tests_la_LIBADD = \ + src/libNetworkManagerTest.la + $(GLIB_LIBS) \ + $(GUDEV_LIBS) \ + $(LIBNL_LIBS) + +src_platform_tests_cppflags_linux = $(src_platform_tests_cppflags) -DSETUP=nm_linux_platform_setup +src_platform_tests_cppflags_fake = $(src_platform_tests_cppflags) -DSETUP=nm_fake_platform_setup + +src_platform_tests_ldflags = \ + $(CODE_COVERAGE_LDFLAGS) + +src_platform_tests_libadd = \ + src/platform/tests/libnm-platform-tests.la + $(GLIB_LIBS) \ + $(GUDEV_LIBS) \ + $(LIBNL_LIBS) + +noinst_PROGRAMS += \ + src/platform/tests/monitor + +check_programs += \ + src/platform/tests/test-link-fake \ + src/platform/tests/test-link-linux \ + src/platform/tests/test-address-fake \ + src/platform/tests/test-address-linux \ + src/platform/tests/test-general \ + src/platform/tests/test-nmp-object \ + src/platform/tests/test-route-fake \ + src/platform/tests/test-route-linux \ + src/platform/tests/test-cleanup-fake \ + src/platform/tests/test-cleanup-linux + +src_platform_tests_monitor_CPPFLAGS = $(src_platform_tests_cppflags) +src_platform_tests_monitor_LDFLAGS = $(src_platform_tests_ldflags) +src_platform_tests_monitor_LDADD = $(src_platform_tests_libadd) + +src_platform_tests_test_link_fake_SOURCES = src/platform/tests/test-link.c +src_platform_tests_test_link_fake_CPPFLAGS = $(src_platform_tests_cppflags_fake) +src_platform_tests_test_link_fake_LDFLAGS = $(src_platform_tests_ldflags) +src_platform_tests_test_link_fake_LDADD = $(src_platform_tests_libadd) + +src_platform_tests_test_link_linux_SOURCES = src/platform/tests/test-link.c +src_platform_tests_test_link_linux_CPPFLAGS = $(src_platform_tests_cppflags_linux) +src_platform_tests_test_link_linux_LDFLAGS = $(src_platform_tests_ldflags) +src_platform_tests_test_link_linux_LDADD = $(src_platform_tests_libadd) + +src_platform_tests_test_address_fake_SOURCES = src/platform/tests/test-address.c +src_platform_tests_test_address_fake_CPPFLAGS = $(src_platform_tests_cppflags_fake) +src_platform_tests_test_address_fake_LDFLAGS = $(src_platform_tests_ldflags) +src_platform_tests_test_address_fake_LDADD = $(src_platform_tests_libadd) + +src_platform_tests_test_address_linux_SOURCES = src/platform/tests/test-address.c +src_platform_tests_test_address_linux_CPPFLAGS = $(src_platform_tests_cppflags_linux) +src_platform_tests_test_address_linux_LDFLAGS = $(src_platform_tests_ldflags) +src_platform_tests_test_address_linux_LDADD = $(src_platform_tests_libadd) + +src_platform_tests_test_route_fake_SOURCES = src/platform/tests/test-route.c +src_platform_tests_test_route_fake_CPPFLAGS = $(src_platform_tests_cppflags_fake) +src_platform_tests_test_route_fake_LDFLAGS = $(src_platform_tests_ldflags) +src_platform_tests_test_route_fake_LDADD = $(src_platform_tests_libadd) + +src_platform_tests_test_route_linux_SOURCES = src/platform/tests/test-route.c +src_platform_tests_test_route_linux_CPPFLAGS = $(src_platform_tests_cppflags_linux) +src_platform_tests_test_route_linux_LDFLAGS = $(src_platform_tests_ldflags) +src_platform_tests_test_route_linux_LDADD = $(src_platform_tests_libadd) + +src_platform_tests_test_cleanup_fake_SOURCES = src/platform/tests/test-cleanup.c +src_platform_tests_test_cleanup_fake_CPPFLAGS = $(src_platform_tests_cppflags_fake) +src_platform_tests_test_cleanup_fake_LDFLAGS = $(src_platform_tests_ldflags) +src_platform_tests_test_cleanup_fake_LDADD = $(src_platform_tests_libadd) + +src_platform_tests_test_cleanup_linux_SOURCES = src/platform/tests/test-cleanup.c +src_platform_tests_test_cleanup_linux_CPPFLAGS = $(src_platform_tests_cppflags_linux) +src_platform_tests_test_cleanup_linux_LDFLAGS = $(src_platform_tests_ldflags) +src_platform_tests_test_cleanup_linux_LDADD = $(src_platform_tests_libadd) + +src_platform_tests_test_nmp_object_CPPFLAGS = $(src_platform_tests_cppflags) +src_platform_tests_test_nmp_object_LDFLAGS = $(src_platform_tests_ldflags) +src_platform_tests_test_nmp_object_LDADD = src/libNetworkManagerTest.la + +src_platform_tests_test_general_CPPFLAGS = $(src_platform_tests_cppflags) +src_platform_tests_test_general_LDFLAGS = $(src_platform_tests_ldflags) +src_platform_tests_test_general_LDADD = src/libNetworkManagerTest.la + ############################################################################### girdir = $(datadir)/gir-1.0 diff --git a/configure.ac b/configure.ac index 3274d112ba..742c904ab0 100644 --- a/configure.ac +++ b/configure.ac @@ -1139,8 +1139,6 @@ src/tests/Makefile src/tests/config/Makefile src/supplicant-manager/tests/Makefile src/supplicant-manager/tests/certs/Makefile -src/platform/Makefile -src/platform/tests/Makefile src/rdisc/Makefile src/rdisc/tests/Makefile src/devices/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 81e0177510..9d300e18db 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,7 +2,6 @@ SUBDIRS = if ENABLE_TESTS SUBDIRS += \ - platform \ devices \ rdisc \ supplicant-manager/tests \ diff --git a/src/devices/tests/test-arping.c b/src/devices/tests/test-arping.c index 244d0715ec..87561a7fcb 100644 --- a/src/devices/tests/test-arping.c +++ b/src/devices/tests/test-arping.c @@ -125,6 +125,8 @@ fixture_teardown (test_fixture *fixture, gconstpointer user_data) nm_platform_link_delete (NM_PLATFORM_GET, fixture->ifindex1); } +NMTstpSetupFunc const _nmtstp_setup_platform_func = SETUP; + void _nmtstp_init_tests (int *argc, char ***argv) { diff --git a/src/devices/tests/test-lldp.c b/src/devices/tests/test-lldp.c index 02b003fb9d..7fc090fea3 100644 --- a/src/devices/tests/test-lldp.c +++ b/src/devices/tests/test-lldp.c @@ -432,6 +432,8 @@ _test_recv_fixture_teardown (TestRecvFixture *fixture, gconstpointer user_data) /*****************************************************************************/ +NMTstpSetupFunc const _nmtstp_setup_platform_func = SETUP; + void _nmtstp_init_tests (int *argc, char ***argv) { diff --git a/src/platform/Makefile.am b/src/platform/Makefile.am deleted file mode 100644 index 3c6155b9c6..0000000000 --- a/src/platform/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = tests diff --git a/src/platform/tests/Makefile.am b/src/platform/tests/Makefile.am deleted file mode 100644 index 43b3121676..0000000000 --- a/src/platform/tests/Makefile.am +++ /dev/null @@ -1,132 +0,0 @@ -AM_CPPFLAGS = \ - -I${top_srcdir} \ - -I${top_srcdir}/shared \ - -I${top_builddir}/shared \ - -I${top_srcdir}/src \ - -I${top_builddir}/src \ - -I${top_srcdir}/libnm-core \ - -I${top_builddir}/libnm-core \ - -I${srcdir}/.. \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(GUDEV_CFLAGS) \ - $(LIBNL_CFLAGS) - -if REQUIRE_ROOT_TESTS -AM_CPPFLAGS += -DREQUIRE_ROOT_TESTS=1 -endif - -PLATFORM_SOURCES = \ - ../nm-platform.c \ - ../nm-fake-platform.c \ - ../nm-linux-platform.c -TEST_SOURCES = \ - test-common.c \ - test-common.h \ - $(PLATFORM_SOURCES) -AM_CFLAGS = $(CODE_COVERAGE_CFLAGS) -AM_LDFLAGS = $(GLIB_LIBS) $(GUDEV_LIBS) $(LIBNL_LIBS) $(CODE_COVERAGE_LDFLAGS) -PLATFORM_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -@GNOME_CODE_COVERAGE_RULES@ - -noinst_PROGRAMS = \ - monitor \ - test-link-fake \ - test-link-linux \ - test-address-fake \ - test-address-linux \ - test-general \ - test-nmp-object \ - test-route-fake \ - test-route-linux \ - test-cleanup-fake \ - test-cleanup-linux - -EXTRA_DIST = test-common.h - -monitor_SOURCES = monitor.c $(PLATFORM_SOURCES) -monitor_LDADD = $(PLATFORM_LDADD) - -test_link_fake_SOURCES = $(TEST_SOURCES) test-link.c -test_link_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 -test_link_fake_LDADD = $(PLATFORM_LDADD) - -test_link_linux_SOURCES = $(TEST_SOURCES) test-link.c -test_link_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 -test_link_linux_LDADD = $(PLATFORM_LDADD) - -test_address_fake_SOURCES = $(TEST_SOURCES) test-address.c -test_address_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 -test_address_fake_LDADD = $(PLATFORM_LDADD) - -test_address_linux_SOURCES = $(TEST_SOURCES) test-address.c -test_address_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 -test_address_linux_LDADD = $(PLATFORM_LDADD) - -test_route_fake_SOURCES = $(TEST_SOURCES) test-route.c -test_route_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 -test_route_fake_LDADD = $(PLATFORM_LDADD) - -test_route_linux_SOURCES = $(TEST_SOURCES) test-route.c -test_route_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 -test_route_linux_LDADD = $(PLATFORM_LDADD) - -test_cleanup_fake_SOURCES = $(TEST_SOURCES) test-cleanup.c -test_cleanup_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 -test_cleanup_fake_LDADD = $(PLATFORM_LDADD) - -test_cleanup_linux_SOURCES = $(TEST_SOURCES) test-cleanup.c -test_cleanup_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 -test_cleanup_linux_LDADD = $(PLATFORM_LDADD) - -test_nmp_object_SOURCES = \ - test-nmp-object.c -test_nmp_object_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -test_general_SOURCES = \ - test-general.c -test_general_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - - -@NM_LOG_COMPILER@ -TESTS = \ - test-address-fake \ - test-address-linux \ - test-cleanup-fake \ - test-cleanup-linux \ - test-general \ - test-link-fake \ - test-link-linux \ - test-nmp-object \ - test-route-fake \ - test-route-linux - diff --git a/src/platform/tests/test-address.c b/src/platform/tests/test-address.c index 05a1444814..4c139ef007 100644 --- a/src/platform/tests/test-address.c +++ b/src/platform/tests/test-address.c @@ -354,6 +354,8 @@ test_ip4_address_peer_zero (void) /*****************************************************************************/ +NMTstpSetupFunc const _nmtstp_setup_platform_func = SETUP; + void _nmtstp_init_tests (int *argc, char ***argv) { diff --git a/src/platform/tests/test-cleanup.c b/src/platform/tests/test-cleanup.c index 3b52487a56..4ac4929895 100644 --- a/src/platform/tests/test-cleanup.c +++ b/src/platform/tests/test-cleanup.c @@ -106,6 +106,8 @@ test_cleanup_internal (void) g_array_unref (routes6); } +NMTstpSetupFunc const _nmtstp_setup_platform_func = SETUP; + void _nmtstp_init_tests (int *argc, char ***argv) { diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c index 1ae2c7f40a..5a1bc6736f 100644 --- a/src/platform/tests/test-common.c +++ b/src/platform/tests/test-common.c @@ -32,12 +32,18 @@ /*****************************************************************************/ +void +nmtstp_setup_platform (void) +{ + g_assert (_nmtstp_setup_platform_func); + _nmtstp_setup_platform_func (); +} + gboolean nmtstp_is_root_test (void) { - NM_PRAGMA_WARNING_DISABLE("-Wtautological-compare") - return (SETUP == nm_linux_platform_setup); - NM_PRAGMA_WARNING_REENABLE + g_assert (_nmtstp_setup_platform_func); + return _nmtstp_setup_platform_func == nm_linux_platform_setup; } gboolean @@ -1663,7 +1669,7 @@ main (int argc, char **argv) } } - SETUP (); + nmtstp_setup_platform (); _nmtstp_setup_tests (); diff --git a/src/platform/tests/test-common.h b/src/platform/tests/test-common.h index 153592cf3c..c3af382ada 100644 --- a/src/platform/tests/test-common.h +++ b/src/platform/tests/test-common.h @@ -207,8 +207,12 @@ void nmtstp_link_del (NMPlatform *platform, int ifindex, const char *name); +typedef void (*NMTstpSetupFunc) (void); +extern NMTstpSetupFunc const _nmtstp_setup_platform_func; + +void nmtstp_setup_platform (void); + /*****************************************************************************/ void _nmtstp_init_tests (int *argc, char ***argv); void _nmtstp_setup_tests (void); - diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c index bc6e5775f3..0877824fa5 100644 --- a/src/platform/tests/test-link.c +++ b/src/platform/tests/test-link.c @@ -1883,8 +1883,7 @@ _test_netns_setup (gpointer fixture, gconstpointer test_data) static void _test_netns_teardown (gpointer fixture, gconstpointer test_data) { - /* re-create platform instance */ - SETUP (); + nmtstp_setup_platform (); } static NMPlatform * @@ -2323,6 +2322,8 @@ test_netns_bind_to_path (gpointer fixture, gconstpointer test_data) /*****************************************************************************/ +NMTstpSetupFunc const _nmtstp_setup_platform_func = SETUP; + void _nmtstp_init_tests (int *argc, char ***argv) { diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c index 360404e944..8174167bc5 100644 --- a/src/platform/tests/test-route.c +++ b/src/platform/tests/test-route.c @@ -328,6 +328,8 @@ test_ip4_zero_gateway (void) /*****************************************************************************/ +NMTstpSetupFunc const _nmtstp_setup_platform_func = SETUP; + void _nmtstp_init_tests (int *argc, char ***argv) { diff --git a/src/tests/test-route-manager.c b/src/tests/test-route-manager.c index b81c263c08..c42544aa16 100644 --- a/src/tests/test-route-manager.c +++ b/src/tests/test-route-manager.c @@ -912,6 +912,8 @@ fixture_teardown (test_fixture *fixture, gconstpointer user_data) /*****************************************************************************/ +NMTstpSetupFunc const _nmtstp_setup_platform_func = SETUP; + void _nmtstp_init_tests (int *argc, char ***argv) {