summary refs log tree commit diff
path: root/src/settings/plugins/ifnet/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings/plugins/ifnet/tests')
-rw-r--r--src/settings/plugins/ifnet/tests/Makefile.am18
-rw-r--r--src/settings/plugins/ifnet/tests/Makefile.in53
-rw-r--r--src/settings/plugins/ifnet/tests/test_all.c68
3 files changed, 52 insertions, 87 deletions
diff --git a/src/settings/plugins/ifnet/tests/Makefile.am b/src/settings/plugins/ifnet/tests/Makefile.am
index f66a6a3d..66409a54 100644
--- a/src/settings/plugins/ifnet/tests/Makefile.am
+++ b/src/settings/plugins/ifnet/tests/Makefile.am
@@ -4,22 +4,17 @@ if ENABLE_TESTS
 
 AM_CPPFLAGS= \
 	-I$(srcdir)/../ \
-	-I$(top_srcdir)/libnm-glib \
-	-I$(top_srcdir)/libnm-util \
-	-I$(top_builddir)/libnm-util \
 	-I$(top_srcdir)/include \
-	-I$(top_builddir)/include \
+	-I$(top_srcdir)/libnm-core \
+	-I$(top_builddir)/libnm-core \
 	-I$(top_srcdir)/src \
-	-I$(top_srcdir)/src/config \
-	-I$(top_srcdir)/src/logging \
 	-I$(top_srcdir)/src/settings \
 	-I$(top_srcdir)/src/platform \
 	-DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \
+	-DNETWORKMANAGER_COMPILATION \
 	-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
 	$(CHECK_CFLAGS) \
 	$(GLIB_CFLAGS) \
-	$(DBUS_CFLAGS) \
-	$(POLKIT_CFLAGS) \
 	$(CODE_COVERAGE_CFLAGS) \
 	-DTEST_WPA_SUPPLICANT_CONF='"$(srcdir)/wpa_supplicant.conf"' \
 	-DSYSCONFDIR=\"nonexistent\"
@@ -30,8 +25,7 @@ check_ifnet_SOURCES = \
 	../connection_parser.c \
 	../net_parser.c \
 	../net_utils.c \
-	../wpa_parser.c \
-	../errors.c
+	../wpa_parser.c
 
 check_ifnet_LDFLAGS = \
 	$(CODE_COVERAGE_LDFLAGS)
@@ -41,6 +35,8 @@ check_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la
 check-local: check_ifnet
 	$(abs_builddir)/check_ifnet $(abs_srcdir) $(abs_builddir)
 
+endif
+
 EXTRA_DIST = \
 	hostname \
 	net \
@@ -48,5 +44,3 @@ EXTRA_DIST = \
 	nm-system-settings.conf \
 	wpa_supplicant.conf \
 	test_ca_cert.pem
-
-endif
diff --git a/src/settings/plugins/ifnet/tests/Makefile.in b/src/settings/plugins/ifnet/tests/Makefile.in
index cd604237..8293c869 100644
--- a/src/settings/plugins/ifnet/tests/Makefile.in
+++ b/src/settings/plugins/ifnet/tests/Makefile.in
@@ -104,11 +104,11 @@ CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 PROGRAMS = $(noinst_PROGRAMS)
 am__check_ifnet_SOURCES_DIST = test_all.c ../connection_parser.c \
-	../net_parser.c ../net_utils.c ../wpa_parser.c ../errors.c
+	../net_parser.c ../net_utils.c ../wpa_parser.c
 @ENABLE_TESTS_TRUE@am_check_ifnet_OBJECTS = test_all.$(OBJEXT) \
 @ENABLE_TESTS_TRUE@	connection_parser.$(OBJEXT) \
 @ENABLE_TESTS_TRUE@	net_parser.$(OBJEXT) net_utils.$(OBJEXT) \
-@ENABLE_TESTS_TRUE@	wpa_parser.$(OBJEXT) errors.$(OBJEXT)
+@ENABLE_TESTS_TRUE@	wpa_parser.$(OBJEXT)
 check_ifnet_OBJECTS = $(am_check_ifnet_OBJECTS)
 @ENABLE_TESTS_TRUE@check_ifnet_DEPENDENCIES =  \
 @ENABLE_TESTS_TRUE@	$(top_builddir)/src/libNetworkManager.la
@@ -189,6 +189,8 @@ AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
+BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@
+BLUEZ5_LIBS = @BLUEZ5_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -312,6 +314,7 @@ NEWT_CFLAGS = @NEWT_CFLAGS@
 NEWT_LIBS = @NEWT_LIBS@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@
 NM_MAJOR_VERSION = @NM_MAJOR_VERSION@
 NM_MICRO_VERSION = @NM_MICRO_VERSION@
 NM_MINOR_VERSION = @NM_MINOR_VERSION@
@@ -331,6 +334,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
@@ -357,7 +361,7 @@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@
 SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@
 SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@
 SYSTEM_CA_PATH = @SYSTEM_CA_PATH@
-UDEV_BASE_DIR = @UDEV_BASE_DIR@
+UDEV_DIR = @UDEV_DIR@
 USE_NLS = @USE_NLS@
 UUID_CFLAGS = @UUID_CFLAGS@
 UUID_LIBS = @UUID_LIBS@
@@ -438,22 +442,17 @@ with_resolvconf = @with_resolvconf@
 with_valgrind = @with_valgrind@
 @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \
 @ENABLE_TESTS_TRUE@	-I$(srcdir)/../ \
-@ENABLE_TESTS_TRUE@	-I$(top_srcdir)/libnm-glib \
-@ENABLE_TESTS_TRUE@	-I$(top_srcdir)/libnm-util \
-@ENABLE_TESTS_TRUE@	-I$(top_builddir)/libnm-util \
 @ENABLE_TESTS_TRUE@	-I$(top_srcdir)/include \
-@ENABLE_TESTS_TRUE@	-I$(top_builddir)/include \
+@ENABLE_TESTS_TRUE@	-I$(top_srcdir)/libnm-core \
+@ENABLE_TESTS_TRUE@	-I$(top_builddir)/libnm-core \
 @ENABLE_TESTS_TRUE@	-I$(top_srcdir)/src \
-@ENABLE_TESTS_TRUE@	-I$(top_srcdir)/src/config \
-@ENABLE_TESTS_TRUE@	-I$(top_srcdir)/src/logging \
 @ENABLE_TESTS_TRUE@	-I$(top_srcdir)/src/settings \
 @ENABLE_TESTS_TRUE@	-I$(top_srcdir)/src/platform \
 @ENABLE_TESTS_TRUE@	-DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \
+@ENABLE_TESTS_TRUE@	-DNETWORKMANAGER_COMPILATION \
 @ENABLE_TESTS_TRUE@	-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
 @ENABLE_TESTS_TRUE@	$(CHECK_CFLAGS) \
 @ENABLE_TESTS_TRUE@	$(GLIB_CFLAGS) \
-@ENABLE_TESTS_TRUE@	$(DBUS_CFLAGS) \
-@ENABLE_TESTS_TRUE@	$(POLKIT_CFLAGS) \
 @ENABLE_TESTS_TRUE@	$(CODE_COVERAGE_CFLAGS) \
 @ENABLE_TESTS_TRUE@	-DTEST_WPA_SUPPLICANT_CONF='"$(srcdir)/wpa_supplicant.conf"' \
 @ENABLE_TESTS_TRUE@	-DSYSCONFDIR=\"nonexistent\"
@@ -463,20 +462,19 @@ with_valgrind = @with_valgrind@
 @ENABLE_TESTS_TRUE@	../connection_parser.c \
 @ENABLE_TESTS_TRUE@	../net_parser.c \
 @ENABLE_TESTS_TRUE@	../net_utils.c \
-@ENABLE_TESTS_TRUE@	../wpa_parser.c \
-@ENABLE_TESTS_TRUE@	../errors.c
+@ENABLE_TESTS_TRUE@	../wpa_parser.c
 
 @ENABLE_TESTS_TRUE@check_ifnet_LDFLAGS = \
 @ENABLE_TESTS_TRUE@	$(CODE_COVERAGE_LDFLAGS)
 
 @ENABLE_TESTS_TRUE@check_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la
-@ENABLE_TESTS_TRUE@EXTRA_DIST = \
-@ENABLE_TESTS_TRUE@	hostname \
-@ENABLE_TESTS_TRUE@	net \
-@ENABLE_TESTS_TRUE@	net.all \
-@ENABLE_TESTS_TRUE@	nm-system-settings.conf \
-@ENABLE_TESTS_TRUE@	wpa_supplicant.conf \
-@ENABLE_TESTS_TRUE@	test_ca_cert.pem
+EXTRA_DIST = \
+	hostname \
+	net \
+	net.all \
+	nm-system-settings.conf \
+	wpa_supplicant.conf \
+	test_ca_cert.pem
 
 all: all-am
 
@@ -533,7 +531,6 @@ distclean-compile:
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connection_parser.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errors.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_parser.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_utils.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_all.Po@am__quote@
@@ -616,20 +613,6 @@ wpa_parser.obj: ../wpa_parser.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o wpa_parser.obj `if test -f '../wpa_parser.c'; then $(CYGPATH_W) '../wpa_parser.c'; else $(CYGPATH_W) '$(srcdir)/../wpa_parser.c'; fi`
 
-errors.o: ../errors.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT errors.o -MD -MP -MF $(DEPDIR)/errors.Tpo -c -o errors.o `test -f '../errors.c' || echo '$(srcdir)/'`../errors.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/errors.Tpo $(DEPDIR)/errors.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='../errors.c' object='errors.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o errors.o `test -f '../errors.c' || echo '$(srcdir)/'`../errors.c
-
-errors.obj: ../errors.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT errors.obj -MD -MP -MF $(DEPDIR)/errors.Tpo -c -o errors.obj `if test -f '../errors.c'; then $(CYGPATH_W) '../errors.c'; else $(CYGPATH_W) '$(srcdir)/../errors.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/errors.Tpo $(DEPDIR)/errors.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='../errors.c' object='errors.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o errors.obj `if test -f '../errors.c'; then $(CYGPATH_W) '../errors.c'; else $(CYGPATH_W) '$(srcdir)/../errors.c'; fi`
-
 mostlyclean-libtool:
 	-rm -f *.lo
 
diff --git a/src/settings/plugins/ifnet/tests/test_all.c b/src/settings/plugins/ifnet/tests/test_all.c
index c320ed5f..9c399128 100644
--- a/src/settings/plugins/ifnet/tests/test_all.c
+++ b/src/settings/plugins/ifnet/tests/test_all.c
@@ -20,6 +20,8 @@
  * Copyright (C) 1999-2010 Gentoo Foundation, Inc.
  */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <glib.h>
@@ -55,7 +57,7 @@ nm_config_get_dhcp_client (NMConfig *config)
 }
 
 static void
-test_getdata ()
+test_getdata (void)
 {
 	ASSERT (ifnet_get_data ("eth1", "config")
 		&& strcmp (ifnet_get_data ("eth1", "config"), "( \"dhcp\" )") == 0,
@@ -103,7 +105,7 @@ test_write_hostname (const char *temp_path)
 }
 
 static void
-test_is_static ()
+test_is_static (void)
 {
 	ASSERT (is_static_ip4 ("eth1") == FALSE, "is static",
 		"a dhcp interface is recognized as static");
@@ -114,7 +116,7 @@ test_is_static ()
 }
 
 static void
-test_has_default_route ()
+test_has_default_route (void)
 {
 	ASSERT (has_default_ip4_route ("eth0"),
 		"has default route", "eth0 should have a default ipv4 route");
@@ -126,7 +128,7 @@ test_has_default_route ()
 }
 
 static void
-test_has_ip6_address ()
+test_has_ip6_address (void)
 {
 	ASSERT (has_ip6_address ("eth2"), "has ip6 address",
 		"eth2 should have a ipv6 address");
@@ -136,7 +138,7 @@ test_has_ip6_address ()
 }
 
 static void
-test_is_ip4_address ()
+test_is_ip4_address (void)
 {
 	gchar *address1 = "192.168.4.232/24";
 	gchar *address2 = "192.168.100.{1..254}/24";
@@ -151,7 +153,7 @@ test_is_ip4_address ()
 }
 
 static void
-test_is_ip6_address ()
+test_is_ip6_address (void)
 {
 	gchar *address1 = "4321:0:1:2:3:4:567:89ac/24";
 
@@ -160,43 +162,30 @@ test_is_ip6_address ()
 }
 
 static void
-check_ip_block (ip_block * iblock, gchar * ip, gchar * netmask, gchar * gateway)
+check_ip_block (ip_block * iblock, gchar * ip, guint32 prefix, gchar * gateway)
 {
-	char *str;
-	guint32 tmp_ip4_addr;
-
-	str = malloc (INET_ADDRSTRLEN);
-	tmp_ip4_addr = iblock->ip;
-	inet_ntop (AF_INET, &tmp_ip4_addr, str, INET_ADDRSTRLEN);
-	ASSERT (strcmp (ip, str) == 0, "check ip",
-		"ip expected:%s, find:%s", ip, str);
-	tmp_ip4_addr = iblock->netmask;
-	inet_ntop (AF_INET, &tmp_ip4_addr, str, INET_ADDRSTRLEN);
-	ASSERT (strcmp (netmask, str) == 0, "check netmask",
-		"netmask expected:%s, find:%s", netmask, str);
-	tmp_ip4_addr = iblock->gateway;
-	inet_ntop (AF_INET, &tmp_ip4_addr, str, INET_ADDRSTRLEN);
-	ASSERT (strcmp (gateway, str) == 0, "check gateway",
-		"gateway expected:%s, find:%s", gateway, str);
-	free (str);
+	ASSERT (strcmp (ip, iblock->ip) == 0, "check ip",
+		"ip expected:%s, find:%s", ip, iblock->ip);
+	ASSERT (prefix == iblock->prefix, "check netmask",
+		"prefix expected:%d, find:%d", prefix, iblock->prefix);
+	ASSERT (g_strcmp0 (gateway, iblock->next_hop) == 0, "check gateway",
+		"gateway expected:%s, find:%s", gateway, iblock->next_hop);
 }
 
 static void
-test_convert_ipv4_config_block ()
+test_convert_ipv4_config_block (void)
 {
 	ip_block *iblock = convert_ip4_config_block ("eth0");
 	ip_block *tmp = iblock;
 
 	ASSERT (iblock != NULL, "convert ipv4 block",
 		"block eth0 should not be NULL");
-	check_ip_block (iblock, "202.117.16.121", "255.255.255.0",
-			"202.117.16.1");
+	check_ip_block (iblock, "202.117.16.121", 24, "202.117.16.1");
 	iblock = iblock->next;
 	destroy_ip_block (tmp);
 	ASSERT (iblock != NULL, "convert ipv4 block",
 		"block eth0 should have a second IP address");
-	check_ip_block (iblock, "192.168.4.121", "255.255.255.0",
-			"202.117.16.1");
+	check_ip_block (iblock, "192.168.4.121", 24, "202.117.16.1");
 	destroy_ip_block (iblock);
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
@@ -206,7 +195,7 @@ test_convert_ipv4_config_block ()
 	ASSERT (iblock != NULL
 		&& iblock->next == NULL,
 		"convert error IPv4 address", "should only get one address");
-	check_ip_block (iblock, "192.168.4.121", "255.255.255.0", "0.0.0.0");
+	check_ip_block (iblock, "192.168.4.121", 24, NULL);
 	destroy_ip_block (iblock);
 
 	g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
@@ -214,17 +203,16 @@ test_convert_ipv4_config_block ()
 	iblock = convert_ip4_config_block ("eth3");
 	ASSERT (iblock == NULL, "convert config_block",
 		"convert error configuration");
-	destroy_ip_block (iblock);
 }
 
 static void
-test_convert_ipv4_routes_block ()
+test_convert_ipv4_routes_block (void)
 {
 	ip_block *iblock = convert_ip4_routes_block ("eth0");
 	ip_block *tmp = iblock;
 
 	ASSERT (iblock != NULL, "convert ip4 routes", "should get one route");
-	check_ip_block (iblock, "192.168.4.0", "255.255.255.0", "192.168.4.1");
+	check_ip_block (iblock, "192.168.4.0", 24, "192.168.4.1");
 	iblock = iblock->next;
 	destroy_ip_block (tmp);
 	ASSERT (iblock == NULL, "convert ip4 routes",
@@ -234,7 +222,7 @@ test_convert_ipv4_routes_block ()
 	tmp = iblock;
 
 	ASSERT (iblock != NULL, "convert ip4 routes", "should get one route");
-	check_ip_block (iblock, "10.0.0.0", "255.0.0.0", "192.168.0.1");
+	check_ip_block (iblock, "10.0.0.0", 8, "192.168.0.1");
 	iblock = iblock->next;
 	destroy_ip_block (tmp);
 	ASSERT (iblock == NULL, "convert ip4 routes",
@@ -242,7 +230,7 @@ test_convert_ipv4_routes_block ()
 }
 
 static void
-test_wpa_parser ()
+test_wpa_parser (void)
 {
 	const char *value;
 
@@ -261,7 +249,7 @@ test_wpa_parser ()
 }
 
 static void
-test_strip_string ()
+test_strip_string (void)
 {
 	gchar *str = "( \"default via     202.117.16.1\" )";
 	gchar *result = g_strdup (str);
@@ -277,7 +265,7 @@ test_strip_string ()
 }
 
 static void
-test_is_unmanaged ()
+test_is_unmanaged (void)
 {
 	ASSERT (is_managed ("eth0"), "test_is_unmanaged",
 		"eth0 should be managed");
@@ -286,7 +274,7 @@ test_is_unmanaged ()
 }
 
 static void
-test_new_connection ()
+test_new_connection (void)
 {
 	GError *error = NULL;
 	NMConnection *connection;
@@ -409,7 +397,7 @@ test_add_connection (const char *basepath)
 }
 
 static void
-test_delete_connection ()
+test_delete_connection (void)
 {
 	GError *error = NULL;
 	NMConnection *connection;
@@ -438,7 +426,7 @@ test_delete_connection ()
 }
 
 static void
-test_missing_config ()
+test_missing_config (void)
 {
 	GError *error = NULL;
 	NMConnection *connection;