diff options
-rw-r--r-- | Makefile.am | 147 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/Makefile.am | 6 | ||||
-rw-r--r-- | src/nm-core-utils.c | 25 | ||||
-rw-r--r-- | src/nm-core-utils.h | 17 | ||||
-rw-r--r-- | src/tests/Makefile.am | 168 | ||||
-rw-r--r-- | src/tests/test-utils.c | 26 |
7 files changed, 182 insertions, 209 deletions
diff --git a/Makefile.am b/Makefile.am index ae7bddd146..5a360cacd9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,7 +53,6 @@ statedir=$(localstatedir)/lib/NetworkManager SUBDIRS = \ . \ - src \ dispatcher \ clients \ data \ @@ -932,6 +931,23 @@ check_ltlibraries += src/libNetworkManagerTest.la ############################################################################### +src_libsystemd_nm_la_cppflags = \ + -I$(top_srcdir)/shared/ \ + -I$(top_builddir)/shared/ \ + -I$(top_srcdir)/libnm-core \ + -I$(top_builddir)/libnm-core \ + -I$(srcdir)/src \ + -I$(top_srcdir)/src/systemd/sd-adapt/ \ + -I$(top_srcdir)/src/systemd/src/systemd/ \ + -I$(top_srcdir)/src/systemd/src/basic/ \ + -I$(top_srcdir)/src/systemd/src/shared/ \ + -I$(top_srcdir)/src/systemd/src/libsystemd-network/ \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD \ + $(GLIB_CFLAGS) + +src_libsystemd_nm_la_libadd = \ + $(GLIB_LIBS) + src_libsystemd_nm_la_SOURCES = \ src/systemd/nm-sd.c \ src/systemd/nm-sd.h \ @@ -1065,22 +1081,8 @@ src_libsystemd_nm_la_SOURCES = \ src/systemd/src/systemd/sd-lldp.h \ src/systemd/src/systemd/sd-ndisc.h -src_libsystemd_nm_la_CPPFLAGS = \ - -I$(top_srcdir)/shared/ \ - -I$(top_builddir)/shared/ \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(srcdir)/src \ - -I$(top_srcdir)/src/systemd/sd-adapt/ \ - -I$(top_srcdir)/src/systemd/src/systemd/ \ - -I$(top_srcdir)/src/systemd/src/basic/ \ - -I$(top_srcdir)/src/systemd/src/shared/ \ - -I$(top_srcdir)/src/systemd/src/libsystemd-network/ \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD \ - $(GLIB_CFLAGS) - -src_libsystemd_nm_la_LIBADD = \ - $(GLIB_LIBS) +src_libsystemd_nm_la_CPPFLAGS = $(src_libsystemd_nm_la_cppflags) +src_libsystemd_nm_la_LIBADD = $(src_libsystemd_nm_la_libadd) ############################################################################### @@ -2612,7 +2614,7 @@ endif src_platform_tests_libnm_platform_tests_la_LDFLAGS = \ $(CODE_COVERAGE_LDFLAGS) src_platform_tests_libnm_platform_tests_la_LIBADD = \ - src/libNetworkManagerTest.la + src/libNetworkManagerTest.la \ $(GLIB_LIBS) \ $(GUDEV_LIBS) \ $(LIBNL_LIBS) @@ -2624,7 +2626,7 @@ src_platform_tests_ldflags = \ $(CODE_COVERAGE_LDFLAGS) src_platform_tests_libadd = \ - src/platform/tests/libnm-platform-tests.la + src/platform/tests/libnm-platform-tests.la \ $(GLIB_LIBS) \ $(GUDEV_LIBS) \ $(LIBNL_LIBS) @@ -2833,6 +2835,113 @@ EXTRA_DIST += \ src/tests/config/conf.d/90-last.conf ############################################################################### +# src/tests +############################################################################### + +src_tests_cppflags = \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ + -I$(top_srcdir)/libnm-core \ + -I$(top_builddir)/libnm-core \ + -I$(top_srcdir)/src/platform \ + -I$(top_srcdir)/src/dhcp-manager \ + -I$(top_srcdir)/src/devices \ + -I$(top_srcdir)/src \ + -I$(top_builddir)/src \ + -DG_LOG_DOMAIN=\""NetworkManager"\" \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ + $(GLIB_CFLAGS) \ + $(CODE_COVERAGE_CFLAGS) + +src_tests_ldflags = \ + $(CODE_COVERAGE_LDFLAGS) + +src_tests_ldadd = \ + src/libNetworkManager.la + +check_programs += \ + src/tests/test-general \ + src/tests/test-general-with-expect \ + src/tests/test-ip4-config \ + src/tests/test-ip6-config \ + src/tests/test-route-manager-linux \ + src/tests/test-route-manager-fake \ + src/tests/test-dcb \ + src/tests/test-systemd \ + src/tests/test-resolvconf-capture \ + src/tests/test-wired-defname \ + src/tests/test-utils + +src_tests_test_ip4_config_CPPFLAGS = $(src_tests_cppflags) +src_tests_test_ip4_config_LDFLAGS = $(src_tests_ldflags) +src_tests_test_ip4_config_LDADD = $(src_tests_ldadd) + +src_tests_test_ip6_config_CPPFLAGS = $(src_tests_cppflags) +src_tests_test_ip6_config_LDFLAGS = $(src_tests_ldflags) +src_tests_test_ip6_config_LDADD = $(src_tests_ldadd) + +src_tests_test_dcb_CPPFLAGS = $(src_tests_cppflags) +src_tests_test_dcb_LDFLAGS = $(src_tests_ldflags) +src_tests_test_dcb_LDADD = $(src_tests_ldadd) + +src_tests_test_resolvconf_capture_CPPFLAGS = $(src_tests_cppflags) +src_tests_test_resolvconf_capture_LDFLAGS = $(src_tests_ldflags) +src_tests_test_resolvconf_capture_LDADD = $(src_tests_ldadd) + +src_tests_test_general_CPPFLAGS = $(src_tests_cppflags) +src_tests_test_general_LDFLAGS = $(src_tests_ldflags) +src_tests_test_general_LDADD = $(src_tests_ldadd) + +src_tests_test_general_with_expect_CPPFLAGS = $(src_tests_cppflags) +src_tests_test_general_with_expect_LDFLAGS = $(src_tests_ldflags) +src_tests_test_general_with_expect_LDADD = $(src_tests_ldadd) + +src_tests_test_wired_defname_CPPFLAGS = $(src_tests_cppflags) +src_tests_test_wired_defname_LDFLAGS = $(src_tests_ldflags) +src_tests_test_wired_defname_LDADD = $(src_tests_ldadd) + +src_tests_test_utils_CPPFLAGS = $(src_tests_cppflags) +src_tests_test_utils_LDFLAGS = $(src_tests_ldflags) +src_tests_test_utils_LDADD = $(src_tests_ldadd) + + +src_tests_test_route_manager_cppflags = \ + -I$(top_srcdir)/src/platform/tests \ + $(src_tests_cppflags) \ + $(GUDEV_CFLAGS) + +src_tests_test_route_manager_ldflags = \ + $(CODE_COVERAGE_LDFLAGS) + +src_tests_test_route_manager_ldadd = \ + src/platform/tests/libnm-platform-tests.la \ + $(GLIB_LIBS) \ + $(GUDEV_LIBS) \ + $(LIBNL_LIBS) + +src_tests_test_route_manager_cppflags_fake = $(src_tests_test_route_manager_cppflags) -DSETUP=nm_fake_platform_setup +src_tests_test_route_manager_cppflags_linux = $(src_tests_test_route_manager_cppflags) -DSETUP=nm_linux_platform_setup + +src_tests_test_route_manager_fake_SOURCES = src/tests/test-route-manager.c +src_tests_test_route_manager_fake_CPPFLAGS = $(src_tests_test_route_manager_cppflags_fake) +src_tests_test_route_manager_fake_LDFLAGS = $(src_tests_test_route_manager_ldflags) +src_tests_test_route_manager_fake_LDADD = $(src_tests_test_route_manager_ldadd) + +src_tests_test_route_manager_linux_SOURCES = src/tests/test-route-manager.c +src_tests_test_route_manager_linux_CPPFLAGS = $(src_tests_test_route_manager_cppflags_linux) +src_tests_test_route_manager_linux_LDFLAGS = $(src_tests_test_route_manager_ldflags) +src_tests_test_route_manager_linux_LDADD = $(src_tests_test_route_manager_ldadd) + + +src_tests_test_systemd_CPPFLAGS = $(src_libsystemd_nm_la_cppflags) +src_tests_test_systemd_LDADD = \ + src/libsystemd-nm.la \ + $(src_libsystemd_nm_la_libadd) + +EXTRA_DIST += \ + src/tests/test-secret-agent.py + +############################################################################### girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) diff --git a/configure.ac b/configure.ac index 7cf36dd975..80b66a1337 100644 --- a/configure.ac +++ b/configure.ac @@ -1134,8 +1134,6 @@ AM_CONDITIONAL(SETTING_DOCS_AVAILABLE, test "$build_setting_docs" = "yes" -o "$h AC_CONFIG_FILES([ Makefile shared/nm-version-macros.h -src/Makefile -src/tests/Makefile libnm/libnm.pc libnm-util/libnm-util.pc libnm-util/Makefile diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index 190260c5c7..0000000000 --- a/src/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -SUBDIRS = - -if ENABLE_TESTS -SUBDIRS += \ - tests -endif diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c index c2f6d1ea27..984e3ec2ed 100644 --- a/src/nm-core-utils.c +++ b/src/nm-core-utils.c @@ -3135,6 +3135,19 @@ _set_stable_privacy (guint8 stable_type, return TRUE; } +gboolean +nm_utils_ipv6_addr_set_stable_privacy_impl (guint8 stable_type, + struct in6_addr *addr, + const char *ifname, + const char *network_id, + guint dad_counter, + guint8 *secret_key, + gsize key_len, + GError **error) +{ + return _set_stable_privacy (stable_type, addr, ifname, network_id, dad_counter, secret_key, key_len, error); +} + #define RFC7217_IDGEN_RETRIES 3 /** * nm_utils_ipv6_addr_set_stable_privacy: @@ -3288,6 +3301,18 @@ _hw_addr_gen_stable_eth (NMUtilsStableType stable_type, } char * +nm_utils_hw_addr_gen_stable_eth_impl (NMUtilsStableType stable_type, + const char *stable_id, + const guint8 *secret_key, + gsize key_len, + const char *ifname, + const char *current_mac_address, + const char *generate_mac_address_mask) +{ + return _hw_addr_gen_stable_eth (stable_type, stable_id, secret_key, key_len, ifname, current_mac_address, generate_mac_address_mask); +} + +char * nm_utils_hw_addr_gen_stable_eth (NMUtilsStableType stable_type, const char *stable_id, const char *ifname, diff --git a/src/nm-core-utils.h b/src/nm-core-utils.h index 9e4f8f7895..929031a1b8 100644 --- a/src/nm-core-utils.h +++ b/src/nm-core-utils.h @@ -363,6 +363,16 @@ typedef enum { /*< skip >*/ NM_UTILS_STABLE_TYPE_STABLE_ID = 1, } NMUtilsStableType; + +gboolean nm_utils_ipv6_addr_set_stable_privacy_impl (guint8 stable_type, + struct in6_addr *addr, + const char *ifname, + const char *network_id, + guint dad_counter, + guint8 *secret_key, + gsize key_len, + GError **error); + gboolean nm_utils_ipv6_addr_set_stable_privacy (NMUtilsStableType id_type, struct in6_addr *addr, const char *ifname, @@ -372,6 +382,13 @@ gboolean nm_utils_ipv6_addr_set_stable_privacy (NMUtilsStableType id_type, char *nm_utils_hw_addr_gen_random_eth (const char *current_mac_address, const char *generate_mac_address_mask); +char *nm_utils_hw_addr_gen_stable_eth_impl (NMUtilsStableType stable_type, + const char *stable_id, + const guint8 *secret_key, + gsize key_len, + const char *ifname, + const char *current_mac_address, + const char *generate_mac_address_mask); char *nm_utils_hw_addr_gen_stable_eth (NMUtilsStableType stable_type, const char *stable_id, const char *ifname, diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am deleted file mode 100644 index 293b8a2c73..0000000000 --- a/src/tests/Makefile.am +++ /dev/null @@ -1,168 +0,0 @@ -@GNOME_CODE_COVERAGE_RULES@ - -AM_CPPFLAGS = \ - -I$(top_srcdir)/shared \ - -I$(top_builddir)/shared \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -I$(top_srcdir)/src/platform \ - -I$(top_srcdir)/src/dhcp-manager \ - -I$(top_srcdir)/src/devices \ - -I$(top_srcdir)/src \ - -I$(top_builddir)/src \ - -DG_LOG_DOMAIN=\""NetworkManager"\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ - $(GLIB_CFLAGS) \ - $(CODE_COVERAGE_CFLAGS) - -AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) - -noinst_PROGRAMS = \ - test-general \ - test-general-with-expect \ - test-ip4-config \ - test-ip6-config \ - test-route-manager-linux \ - test-route-manager-fake \ - test-dcb \ - test-systemd \ - test-resolvconf-capture \ - test-wired-defname \ - test-utils - -####### ip4 config test ####### - -test_ip4_config_SOURCES = \ - test-ip4-config.c - -test_ip4_config_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### ip6 config test ####### - -test_ip6_config_SOURCES = \ - test-ip6-config.c - -test_ip6_config_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### route manager test ####### - -test_route_manager_fake_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - $(GUDEV_CFLAGS) \ - -I$(top_srcdir)/src/platform/tests \ - -DSETUP=nm_fake_platform_setup \ - -DKERNEL_HACKS=0 - -test_route_manager_fake_SOURCES = \ - $(top_srcdir)/src/platform/tests/test-common.c \ - test-route-manager.c - -test_route_manager_fake_LDADD = \ - $(top_builddir)/src/libNetworkManagerTest.la - -test_route_manager_linux_SOURCES = \ - $(top_srcdir)/src/platform/tests/test-common.c \ - test-route-manager.c - -test_route_manager_linux_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - $(GUDEV_CFLAGS) \ - -I$(top_srcdir)/src/platform/tests \ - -DSETUP=nm_linux_platform_setup \ - -DKERNEL_HACKS=1 - -test_route_manager_linux_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### DCB test ####### - -test_dcb_SOURCES = \ - test-dcb.c - -test_dcb_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### resolv.conf capture test ####### - -test_resolvconf_capture_SOURCES = \ - test-resolvconf-capture.c - -test_resolvconf_capture_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### general test ####### - -test_general_SOURCES = \ - test-general.c - -test_general_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### general-with-expect test ####### - -test_general_with_expect_SOURCES = \ - test-general-with-expect.c - -test_general_with_expect_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### wired defname test ####### - -test_wired_defname_SOURCES = \ - test-wired-defname.c - -test_wired_defname_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### systemd test ####### - -test_systemd_CFLAGS = \ - "-I$(srcdir)/../" \ - "-I$(srcdir)/../platform" \ - $(NULL) - -test_systemd_SOURCES = \ - test-systemd.c - -test_systemd_LDADD = \ - $(top_builddir)/src/libsystemd-nm.la - -####### utils test ####### - -test_utils_SOURCES = \ - test-utils.c - -test_utils_DEPENDENCIES = \ - $(top_srcdir)/src/NetworkManagerUtils.c - -test_utils_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DPREFIX=\"/nonexistent\" \ - -DLOCALSTATEDIR=\"$(localstatedir)\" \ - -DNMSTATEDIR=\"/nonsense\" - -test_utils_LDADD = \ - $(top_builddir)/src/libNetworkManager.la - -####### secret agent interface test ####### - -EXTRA_DIST = test-secret-agent.py - -########################################### - -@NM_LOG_COMPILER@ -TESTS = \ - test-ip4-config \ - test-ip6-config \ - test-route-manager-fake \ - test-route-manager-linux \ - test-dcb \ - test-resolvconf-capture \ - test-general \ - test-general-with-expect \ - test-systemd \ - test-wired-defname \ - test-utils - diff --git a/src/tests/test-utils.c b/src/tests/test-utils.c index 000a9d1ef4..cd05a36d9f 100644 --- a/src/tests/test-utils.c +++ b/src/tests/test-utils.c @@ -24,8 +24,6 @@ #include <errno.h> #include <arpa/inet.h> -#include "nm-core-utils.c" - #include "nm-test-utils-core.h" static void @@ -34,25 +32,25 @@ test_stable_privacy (void) struct in6_addr addr1; inet_pton (AF_INET6, "1234::", &addr1); - _set_stable_privacy (NM_UTILS_STABLE_TYPE_UUID, &addr1, "eth666", "6b138152-9f3e-4b97-aaf7-e6e553f2a24e", 0, (guint8 *) "key", 3, NULL); + nm_utils_ipv6_addr_set_stable_privacy_impl (NM_UTILS_STABLE_TYPE_UUID, &addr1, "eth666", "6b138152-9f3e-4b97-aaf7-e6e553f2a24e", 0, (guint8 *) "key", 3, NULL); nmtst_assert_ip6_address (&addr1, "1234::4ceb:14cd:3d54:793f"); /* We get an address without the UUID. */ inet_pton (AF_INET6, "1::", &addr1); - _set_stable_privacy (NM_UTILS_STABLE_TYPE_UUID, &addr1, "eth666", NULL, 384, (guint8 *) "key", 3, NULL); + nm_utils_ipv6_addr_set_stable_privacy_impl (NM_UTILS_STABLE_TYPE_UUID, &addr1, "eth666", NULL, 384, (guint8 *) "key", 3, NULL); nmtst_assert_ip6_address (&addr1, "1::11aa:2530:9144:dafa"); /* We get a different address in a different network. */ inet_pton (AF_INET6, "2::", &addr1); - _set_stable_privacy (NM_UTILS_STABLE_TYPE_UUID, &addr1, "eth666", NULL, 384, (guint8 *) "key", 3, NULL); + nm_utils_ipv6_addr_set_stable_privacy_impl (NM_UTILS_STABLE_TYPE_UUID, &addr1, "eth666", NULL, 384, (guint8 *) "key", 3, NULL); nmtst_assert_ip6_address (&addr1, "2::338e:8d:c11:8726"); inet_pton (AF_INET6, "1234::", &addr1); - _set_stable_privacy (NM_UTILS_STABLE_TYPE_STABLE_ID, &addr1, "eth666", "6b138152-9f3e-4b97-aaf7-e6e553f2a24e", 0, (guint8 *) "key", 3, NULL); + nm_utils_ipv6_addr_set_stable_privacy_impl (NM_UTILS_STABLE_TYPE_STABLE_ID, &addr1, "eth666", "6b138152-9f3e-4b97-aaf7-e6e553f2a24e", 0, (guint8 *) "key", 3, NULL); nmtst_assert_ip6_address (&addr1, "1234::ad4c:ae44:3d30:af1e"); inet_pton (AF_INET6, "1234::", &addr1); - _set_stable_privacy (NM_UTILS_STABLE_TYPE_STABLE_ID, &addr1, "eth666", "stable-id-1", 0, (guint8 *) "key", 3, NULL); + nm_utils_ipv6_addr_set_stable_privacy_impl (NM_UTILS_STABLE_TYPE_STABLE_ID, &addr1, "eth666", "stable-id-1", 0, (guint8 *) "key", 3, NULL); nmtst_assert_ip6_address (&addr1, "1234::4944:67b0:7a6c:1cf"); } @@ -77,13 +75,13 @@ _do_test_hw_addr (NMUtilsStableType stable_type, g_assert (nm_utils_hwaddr_valid (*e, ETH_ALEN)); } - generated = _hw_addr_gen_stable_eth (stable_type, - stable_id, - secret_key, - key_len, - ifname, - current_mac_address, - generate_mac_address_mask); + generated = nm_utils_hw_addr_gen_stable_eth_impl (stable_type, + stable_id, + secret_key, + key_len, + ifname, + current_mac_address, + generate_mac_address_mask); g_assert (generated); g_assert (nm_utils_hwaddr_valid (generated, ETH_ALEN)); |