about summary refs log tree commit diff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/Makefile.in68
-rw-r--r--src/tests/test-dhcp-options.c478
-rw-r--r--src/tests/test-policy-hosts.c595
3 files changed, 888 insertions, 253 deletions
diff --git a/src/tests/Makefile.in b/src/tests/Makefile.in
index 75fb715d..40d1d6ab 100644
--- a/src/tests/Makefile.in
+++ b/src/tests/Makefile.in
@@ -61,6 +61,9 @@ test_dhcp_options_DEPENDENCIES =  \
 	$(top_builddir)/src/dhcp-manager/libdhcp-manager.la \
 	$(top_builddir)/src/libtest-dhcp.la $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_1)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
 am_test_policy_hosts_OBJECTS =  \
 	test_policy_hosts-test-policy-hosts.$(OBJEXT)
 test_policy_hosts_OBJECTS = $(am_test_policy_hosts_OBJECTS)
@@ -73,13 +76,26 @@ am__depfiles_maybe = depfiles
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
 CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
 SOURCES = $(test_dhcp_options_SOURCES) $(test_policy_hosts_SOURCES)
 DIST_SOURCES = $(test_dhcp_options_SOURCES) \
 	$(test_policy_hosts_SOURCES)
@@ -90,6 +106,7 @@ ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
 ALL_LINGUAS = @ALL_LINGUAS@
 AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
@@ -110,6 +127,7 @@ DBUS_SYS_DIR = @DBUS_SYS_DIR@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
 DHCLIENT_PATH = @DHCLIENT_PATH@
+DHCLIENT_VERSION = @DHCLIENT_VERSION@
 DHCPCD_PATH = @DHCPCD_PATH@
 DISABLE_DEPRECATED = @DISABLE_DEPRECATED@
 DSYMUTIL = @DSYMUTIL@
@@ -151,6 +169,7 @@ INTLTOOL_MERGE = @INTLTOOL_MERGE@
 INTLTOOL_PERL = @INTLTOOL_PERL@
 INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
 IPTABLES_PATH = @IPTABLES_PATH@
+KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
 LIBDL = @LIBDL@
@@ -190,6 +209,8 @@ PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
 POFILES = @POFILES@
 POLKIT_CFLAGS = @POLKIT_CFLAGS@
 POLKIT_LIBS = @POLKIT_LIBS@
@@ -246,7 +267,6 @@ libdir = @libdir@
 libexecdir = @libexecdir@
 localedir = @localedir@
 localstatedir = @localstatedir@
-lt_ECHO = @lt_ECHO@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
@@ -258,6 +278,7 @@ sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
 sysconfdir = @sysconfdir@
+systemdsystemunitdir = @systemdsystemunitdir@
 target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
@@ -346,10 +367,10 @@ clean-noinstPROGRAMS:
 	rm -f $$list
 test-dhcp-options$(EXEEXT): $(test_dhcp_options_OBJECTS) $(test_dhcp_options_DEPENDENCIES) 
 	@rm -f test-dhcp-options$(EXEEXT)
-	$(LINK) $(test_dhcp_options_OBJECTS) $(test_dhcp_options_LDADD) $(LIBS)
+	$(AM_V_CCLD)$(LINK) $(test_dhcp_options_OBJECTS) $(test_dhcp_options_LDADD) $(LIBS)
 test-policy-hosts$(EXEEXT): $(test_policy_hosts_OBJECTS) $(test_policy_hosts_DEPENDENCIES) 
 	@rm -f test-policy-hosts$(EXEEXT)
-	$(LINK) $(test_policy_hosts_OBJECTS) $(test_policy_hosts_LDADD) $(LIBS)
+	$(AM_V_CCLD)$(LINK) $(test_policy_hosts_OBJECTS) $(test_policy_hosts_LDADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -361,53 +382,60 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_policy_hosts-test-policy-hosts.Po@am__quote@
 
 .c.o:
-@am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
 @am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
+@am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
 
 .c.obj:
-@am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
 @am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
+@am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .c.lo:
-@am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
 @am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
 @am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
+@am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
 
 test_dhcp_options-test-dhcp-options.o: test-dhcp-options.c
-@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dhcp_options_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_dhcp_options-test-dhcp-options.o -MD -MP -MF $(DEPDIR)/test_dhcp_options-test-dhcp-options.Tpo -c -o test_dhcp_options-test-dhcp-options.o `test -f 'test-dhcp-options.c' || echo '$(srcdir)/'`test-dhcp-options.c
-@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/test_dhcp_options-test-dhcp-options.Tpo $(DEPDIR)/test_dhcp_options-test-dhcp-options.Po
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dhcp_options_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_dhcp_options-test-dhcp-options.o -MD -MP -MF $(DEPDIR)/test_dhcp_options-test-dhcp-options.Tpo -c -o test_dhcp_options-test-dhcp-options.o `test -f 'test-dhcp-options.c' || echo '$(srcdir)/'`test-dhcp-options.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/test_dhcp_options-test-dhcp-options.Tpo $(DEPDIR)/test_dhcp_options-test-dhcp-options.Po
+@am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='test-dhcp-options.c' object='test_dhcp_options-test-dhcp-options.o' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dhcp_options_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_dhcp_options-test-dhcp-options.o `test -f 'test-dhcp-options.c' || echo '$(srcdir)/'`test-dhcp-options.c
 
 test_dhcp_options-test-dhcp-options.obj: test-dhcp-options.c
-@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dhcp_options_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_dhcp_options-test-dhcp-options.obj -MD -MP -MF $(DEPDIR)/test_dhcp_options-test-dhcp-options.Tpo -c -o test_dhcp_options-test-dhcp-options.obj `if test -f 'test-dhcp-options.c'; then $(CYGPATH_W) 'test-dhcp-options.c'; else $(CYGPATH_W) '$(srcdir)/test-dhcp-options.c'; fi`
-@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/test_dhcp_options-test-dhcp-options.Tpo $(DEPDIR)/test_dhcp_options-test-dhcp-options.Po
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dhcp_options_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_dhcp_options-test-dhcp-options.obj -MD -MP -MF $(DEPDIR)/test_dhcp_options-test-dhcp-options.Tpo -c -o test_dhcp_options-test-dhcp-options.obj `if test -f 'test-dhcp-options.c'; then $(CYGPATH_W) 'test-dhcp-options.c'; else $(CYGPATH_W) '$(srcdir)/test-dhcp-options.c'; fi`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/test_dhcp_options-test-dhcp-options.Tpo $(DEPDIR)/test_dhcp_options-test-dhcp-options.Po
+@am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='test-dhcp-options.c' object='test_dhcp_options-test-dhcp-options.obj' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dhcp_options_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_dhcp_options-test-dhcp-options.obj `if test -f 'test-dhcp-options.c'; then $(CYGPATH_W) 'test-dhcp-options.c'; else $(CYGPATH_W) '$(srcdir)/test-dhcp-options.c'; fi`
 
 test_policy_hosts-test-policy-hosts.o: test-policy-hosts.c
-@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_policy_hosts_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_policy_hosts-test-policy-hosts.o -MD -MP -MF $(DEPDIR)/test_policy_hosts-test-policy-hosts.Tpo -c -o test_policy_hosts-test-policy-hosts.o `test -f 'test-policy-hosts.c' || echo '$(srcdir)/'`test-policy-hosts.c
-@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/test_policy_hosts-test-policy-hosts.Tpo $(DEPDIR)/test_policy_hosts-test-policy-hosts.Po
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_policy_hosts_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_policy_hosts-test-policy-hosts.o -MD -MP -MF $(DEPDIR)/test_policy_hosts-test-policy-hosts.Tpo -c -o test_policy_hosts-test-policy-hosts.o `test -f 'test-policy-hosts.c' || echo '$(srcdir)/'`test-policy-hosts.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/test_policy_hosts-test-policy-hosts.Tpo $(DEPDIR)/test_policy_hosts-test-policy-hosts.Po
+@am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='test-policy-hosts.c' object='test_policy_hosts-test-policy-hosts.o' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_policy_hosts_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_policy_hosts-test-policy-hosts.o `test -f 'test-policy-hosts.c' || echo '$(srcdir)/'`test-policy-hosts.c
 
 test_policy_hosts-test-policy-hosts.obj: test-policy-hosts.c
-@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_policy_hosts_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_policy_hosts-test-policy-hosts.obj -MD -MP -MF $(DEPDIR)/test_policy_hosts-test-policy-hosts.Tpo -c -o test_policy_hosts-test-policy-hosts.obj `if test -f 'test-policy-hosts.c'; then $(CYGPATH_W) 'test-policy-hosts.c'; else $(CYGPATH_W) '$(srcdir)/test-policy-hosts.c'; fi`
-@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/test_policy_hosts-test-policy-hosts.Tpo $(DEPDIR)/test_policy_hosts-test-policy-hosts.Po
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_policy_hosts_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_policy_hosts-test-policy-hosts.obj -MD -MP -MF $(DEPDIR)/test_policy_hosts-test-policy-hosts.Tpo -c -o test_policy_hosts-test-policy-hosts.obj `if test -f 'test-policy-hosts.c'; then $(CYGPATH_W) 'test-policy-hosts.c'; else $(CYGPATH_W) '$(srcdir)/test-policy-hosts.c'; fi`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/test_policy_hosts-test-policy-hosts.Tpo $(DEPDIR)/test_policy_hosts-test-policy-hosts.Po
+@am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='test-policy-hosts.c' object='test_policy_hosts-test-policy-hosts.obj' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_policy_hosts_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_policy_hosts-test-policy-hosts.obj `if test -f 'test-policy-hosts.c'; then $(CYGPATH_W) 'test-policy-hosts.c'; else $(CYGPATH_W) '$(srcdir)/test-policy-hosts.c'; fi`
diff --git a/src/tests/test-dhcp-options.c b/src/tests/test-dhcp-options.c
index dd1f9149..aa85f87e 100644
--- a/src/tests/test-dhcp-options.c
+++ b/src/tests/test-dhcp-options.c
@@ -250,300 +250,406 @@ test_wins_options (const char *client)
 	g_hash_table_destroy (options);
 }
 
-static Option classless_routes_options[] = {
-	/* For dhclient */
-	{ "new_rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 8 10 10 17 66 41" },
-	/* For dhcpcd */
-	{ "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.0.0/8 10.17.66.41" },
-	{ NULL, NULL }
-};
+static void
+ip4_test_route (const char *test,
+                NMIP4Config *ip4_config,
+                guint route_num,
+                const char *expected_dest,
+                const char *expected_gw,
+                guint expected_prefix)
+{
+	NMIP4Route *route;
+	struct in_addr tmp;
+
+	route = nm_ip4_config_get_route (ip4_config, route_num);
+	ASSERT (inet_pton (AF_INET, expected_dest, &tmp) > 0,
+	        test, "couldn't convert expected route destination #1");
+	ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
+	        test, "unexpected route %d destination", route_num + 1);
+
+	ASSERT (inet_pton (AF_INET, expected_gw, &tmp) > 0,
+	        test, "couldn't convert expected route next hop %d",
+	        route_num + 1);
+	ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
+	        test, "unexpected route %d next hop", route_num + 1);
+
+	ASSERT (nm_ip4_route_get_prefix (route) == expected_prefix,
+	        test, "unexpected route %d prefix", route_num + 1);
+	ASSERT (nm_ip4_route_get_metric (route) == 0,
+	        test, "unexpected route %d metric", route_num + 1);
+}
 
 static void
-test_classless_static_routes (const char *client)
+ip4_test_gateway (const char *test,
+                  NMIP4Config *ip4_config,
+                  const char *expected_gw)
+{
+	NMIP4Address *addr;
+	struct in_addr tmp;
+
+	ASSERT (nm_ip4_config_get_num_addresses (ip4_config) == 1,
+	        test, "unexpected number of IP addresses");
+	addr = nm_ip4_config_get_address (ip4_config, 0);
+	ASSERT (inet_pton (AF_INET, expected_gw, &tmp) > 0,
+	        test, "couldn't convert expected IP gateway");
+	ASSERT (nm_ip4_address_get_gateway (addr) == tmp.s_addr,
+	        test, "unexpected IP gateway");
+}
+
+static void
+test_classless_static_routes_1 (const char *client)
 {
 	GHashTable *options;
 	NMIP4Config *ip4_config;
-	NMIP4Route *route;
-	struct in_addr tmp;
 	const char *expected_route1_dest = "192.168.10.0";
 	const char *expected_route1_gw = "192.168.1.1";
 	const char *expected_route2_dest = "10.0.0.0";
 	const char *expected_route2_gw = "10.17.66.41";
+	static Option data[] = {
+		/* dhclient custom format */
+		{ "new_rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 8 10 10 17 66 41" },
+		{ NULL, NULL }
+	};
 
 	options = fill_table (generic_options, NULL);
-	options = fill_table (classless_routes_options, options);
+	options = fill_table (data, options);
 
 	ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
 	ASSERT (ip4_config != NULL,
-	        "dhcp-rfc3442", "failed to parse DHCP4 options");
+	        "dhcp-classless-1", "failed to parse DHCP4 options");
 
 	/* IP4 routes */
 	ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 2,
-	        "dhcp-rfc3442", "unexpected number of IP routes");
+	        "dhcp-classless-1", "unexpected number of IP routes");
+	ip4_test_route ("dhcp-classless-1", ip4_config, 0,
+	                expected_route1_dest, expected_route1_gw, 24);
+	ip4_test_route ("dhcp-classless-1", ip4_config, 1,
+	                expected_route2_dest, expected_route2_gw, 8);
 
-	/* Route #1 */
-	route = nm_ip4_config_get_route (ip4_config, 0);
-	ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0,
-	        "dhcp-rfc3442", "couldn't convert expected route destination #1");
-	ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
-	        "dhcp-rfc3442", "unexpected route #1 destination");
-
-	ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0,
-	        "dhcp-rfc3442", "couldn't convert expected route next hop #1");
-	ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
-	        "dhcp-rfc3442", "unexpected route #1 next hop");
+	g_hash_table_destroy (options);
+}
 
-	ASSERT (nm_ip4_route_get_prefix (route) == 24,
-	        "dhcp-rfc3442", "unexpected route #1 prefix");
-	ASSERT (nm_ip4_route_get_metric (route) == 0,
-	        "dhcp-rfc3442", "unexpected route #1 metric");
+static void
+test_classless_static_routes_2 (const char *client)
+{
+	GHashTable *options;
+	NMIP4Config *ip4_config;
+	const char *expected_route1_dest = "192.168.10.0";
+	const char *expected_route1_gw = "192.168.1.1";
+	const char *expected_route2_dest = "10.0.0.0";
+	const char *expected_route2_gw = "10.17.66.41";
+	static Option data[] = {
+		/* dhcpcd format */
+		{ "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.0.0/8 10.17.66.41" },
+		{ NULL, NULL }
+	};
 
-	/* Route #2 */
-	route = nm_ip4_config_get_route (ip4_config, 1);
-	ASSERT (inet_pton (AF_INET, expected_route2_dest, &tmp) > 0,
-	        "dhcp-rfc3442", "couldn't convert expected route destination #2");
-	ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
-	        "dhcp-rfc3442", "unexpected route #2 destination");
+	options = fill_table (generic_options, NULL);
+	options = fill_table (data, options);
 
-	ASSERT (inet_pton (AF_INET, expected_route2_gw, &tmp) > 0,
-	        "dhcp-rfc3442", "couldn't convert expected route next hop #2");
-	ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
-	        "dhcp-rfc3442", "unexpected route #2 next hop");
+	ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
+	ASSERT (ip4_config != NULL,
+	        "dhcp-classless-2", "failed to parse DHCP4 options");
 
-	ASSERT (nm_ip4_route_get_prefix (route) == 8,
-	        "dhcp-rfc3442", "unexpected route #2 prefix");
-	ASSERT (nm_ip4_route_get_metric (route) == 0,
-	        "dhcp-rfc3442", "unexpected route #2 metric");
+	/* IP4 routes */
+	ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 2,
+	        "dhcp-classless-2", "unexpected number of IP routes");
+	ip4_test_route ("dhcp-classless-2", ip4_config, 0,
+	                expected_route1_dest, expected_route1_gw, 24);
+	ip4_test_route ("dhcp-classless-2", ip4_config, 1,
+	                expected_route2_dest, expected_route2_gw, 8);
 
 	g_hash_table_destroy (options);
 }
 
-static Option invalid_classless_routes1[] = {
-	/* For dhclient */
-	{ "new_rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 45 10 17 66 41" },
-	/* For dhcpcd */
-	{ "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.adfadf/44 10.17.66.41" },
-	{ NULL, NULL }
-};
+static void
+test_fedora_dhclient_classless_static_routes (const char *client)
+{
+	GHashTable *options;
+	NMIP4Config *ip4_config;
+	const char *expected_route1_dest = "129.210.177.128";
+	const char *expected_route1_gw = "192.168.0.113";
+	const char *expected_route2_dest = "2.0.0.0";
+	const char *expected_route2_gw = "10.34.255.6";
+	const char *expected_gateway = "192.168.0.113";
+	static Option data[] = {
+		/* Fedora dhclient format */
+		{ "new_classless_static_routes", "0 192.168.0.113 25.129.210.177.132 192.168.0.113 7.2 10.34.255.6" },
+		{ NULL, NULL }
+	};
+
+	options = fill_table (generic_options, NULL);
+	options = fill_table (data, options);
+
+	ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
+	ASSERT (ip4_config != NULL,
+	        "dhcp-fedora-dhclient-classless", "failed to parse DHCP4 options");
+
+	/* IP4 routes */
+	ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 2,
+	        "dhcp-fedora-dhclient-classless", "unexpected number of IP routes");
+	ip4_test_route ("dhcp-fedora-dhclient-classless", ip4_config, 0,
+	                expected_route1_dest, expected_route1_gw, 25);
+	ip4_test_route ("dhcp-fedora-dhclient-classless", ip4_config, 1,
+	                expected_route2_dest, expected_route2_gw, 7);
+
+	/* Gateway */
+	ip4_test_gateway ("dhcp-fedora-dhclient-classless", ip4_config, expected_gateway);
+
+	g_hash_table_destroy (options);
+}
 
 static void
-test_invalid_classless_routes1 (const char *client)
+test_dhclient_invalid_classless_routes_1 (const char *client)
 {
 	GHashTable *options;
 	NMIP4Config *ip4_config;
-	NMIP4Route *route;
-	struct in_addr tmp;
 	const char *expected_route1_dest = "192.168.10.0";
 	const char *expected_route1_gw = "192.168.1.1";
+	static Option data[] = {
+		/* dhclient format */
+		{ "new_rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 45 10 17 66 41" },
+		{ NULL, NULL }
+	};
 
 	options = fill_table (generic_options, NULL);
-	options = fill_table (invalid_classless_routes1, options);
+	options = fill_table (data, options);
 
 	ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
 	ASSERT (ip4_config != NULL,
-	        "dhcp-rfc3442-invalid-1", "failed to parse DHCP4 options");
+	        "dhcp-dhclient-classless-invalid-1", "failed to parse DHCP4 options");
 
 	/* IP4 routes */
 	ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1,
-	        "dhcp-rfc3442-invalid-1", "unexpected number of IP routes");
+	        "dhcp-dhclient-classless-invalid-1", "unexpected number of IP routes");
 
-	/* Route #1 */
-	route = nm_ip4_config_get_route (ip4_config, 0);
-	ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0,
-	        "dhcp-rfc3442-invalid-1", "couldn't convert expected route destination #1");
-	ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
-	        "dhcp-rfc3442-invalid-1", "unexpected route #1 destination");
+	ip4_test_route ("dhcp-dhclient-classless-invalid-1", ip4_config, 0,
+	                expected_route1_dest, expected_route1_gw, 24);
 
-	ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0,
-	        "dhcp-rfc3442-invalid-1", "couldn't convert expected route next hop #1");
-	ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
-	        "dhcp-rfc3442-invalid-1", "unexpected route #1 next hop");
+	g_hash_table_destroy (options);
+}
 
-	ASSERT (nm_ip4_route_get_prefix (route) == 24,
-	        "dhcp-rfc3442-invalid-1", "unexpected route #1 prefix");
-	ASSERT (nm_ip4_route_get_metric (route) == 0,
-	        "dhcp-rfc3442-invalid-1", "unexpected route #1 metric");
+static void
+test_dhcpcd_invalid_classless_routes_1 (const char *client)
+{
+	GHashTable *options;
+	NMIP4Config *ip4_config;
+	const char *expected_route1_dest = "10.1.1.5";
+	const char *expected_route1_gw = "10.1.1.1";
+	const char *expected_route2_dest = "100.99.88.56";
+	const char *expected_route2_gw = "10.1.1.1";
+	static Option data[] = {
+		/* dhcpcd format */
+		{ "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.adfadf/44 10.17.66.41" },
+		{ NULL, NULL }
+	};
+
+	options = fill_table (generic_options, NULL);
+	options = fill_table (data, options);
+
+	ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
+	ASSERT (ip4_config != NULL,
+	        "dhcp-dhcpcd-classless-invalid-1", "failed to parse DHCP4 options");
+
+	/* Test falling back to old-style static routes if the classless static
+	 * routes are invalid.
+	 */
+	ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 2,
+	        "dhcp-dhcpcdp-classless-invalid-1", "unexpected number of routes");
+	ip4_test_route ("dhcp-dhcpcdp-classless-invalid-1", ip4_config, 0,
+	                expected_route1_dest, expected_route1_gw, 32);
+	ip4_test_route ("dhcp-dhcpcdp-classless-invalid-1", ip4_config, 1,
+	                expected_route2_dest, expected_route2_gw, 32);
 
 	g_hash_table_destroy (options);
 }
 
-static Option invalid_classless_routes2[] = {
-	/* For dhclient */
-	{ "new_rfc3442_classless_static_routes", "45 10 17 66 41 24 192 168 10 192 168 1 1" },
-	/* For dhcpcd */
-	{ "new_classless_static_routes", "10.0.adfadf/44 10.17.66.41 192.168.10.0/24 192.168.1.1" },
-	{ NULL, NULL }
-};
-
 static void
-test_invalid_classless_routes2 (const char *client)
+test_dhclient_invalid_classless_routes_2 (const char *client)
 {
 	GHashTable *options;
 	NMIP4Config *ip4_config;
-	NMIP4Route *route;
-	struct in_addr tmp;
 	const char *expected_route1_dest = "10.1.1.5";
 	const char *expected_route1_gw = "10.1.1.1";
 	const char *expected_route2_dest = "100.99.88.56";
 	const char *expected_route2_gw = "10.1.1.1";
+	static Option data[] = {
+		{ "new_rfc3442_classless_static_routes", "45 10 17 66 41 24 192 168 10 192 168 1 1" },
+		{ NULL, NULL }
+	};
 
 	options = fill_table (generic_options, NULL);
-	options = fill_table (invalid_classless_routes2, options);
+	options = fill_table (data, options);
 
 	ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
 	ASSERT (ip4_config != NULL,
-	        "dhcp-rfc3442-invalid-2", "failed to parse DHCP4 options");
+	        "dhcp-dhclient-classless-invalid-2", "failed to parse DHCP4 options");
 
 	/* Test falling back to old-style static routes if the classless static
 	 * routes are invalid.
 	 */
-
-	/* Routes */
 	ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 2,
-	        "dhcp-rfc3442-invalid-2", "unexpected number of routes");
+	        "dhcp-dhclient-classless-invalid-2", "unexpected number of routes");
+	ip4_test_route ("dhcp-dhclient-classless-invalid-2", ip4_config, 0,
+	                expected_route1_dest, expected_route1_gw, 32);
+	ip4_test_route ("dhcp-dhclient-classless-invalid-2", ip4_config, 1,
+	                expected_route2_dest, expected_route2_gw, 32);
 
-	/* Route #1 */
-	route = nm_ip4_config_get_route (ip4_config, 0);
-	ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0,
-	        "dhcp-rfc3442-invalid-2", "couldn't convert expected route destination #1");
-	ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
-	        "dhcp-rfc3442-invalid-2", "unexpected route #1 destination");
+	g_hash_table_destroy (options);
+}
 
-	ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0,
-	        "dhcp-rfc3442-invalid-2", "couldn't convert expected route next hop #1");
-	ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
-	        "dhcp-rfc3442-invalid-2", "unexpected route #1 next hop");
+static void
+test_dhcpcd_invalid_classless_routes_2 (const char *client)
+{
+	GHashTable *options;
+	NMIP4Config *ip4_config;
+	const char *expected_route1_dest = "10.1.1.5";
+	const char *expected_route1_gw = "10.1.1.1";
+	const char *expected_route2_dest = "100.99.88.56";
+	const char *expected_route2_gw = "10.1.1.1";
+	static Option data[] = {
+		{ "new_classless_static_routes", "10.0.adfadf/44 10.17.66.41 192.168.10.0/24 192.168.1.1" },
+		{ NULL, NULL }
+	};
 
-	ASSERT (nm_ip4_route_get_prefix (route) == 32,
-	        "dhcp-rfc3442-invalid-2", "unexpected route #1 prefix");
-	ASSERT (nm_ip4_route_get_metric (route) == 0,
-	        "dhcp-rfc3442-invalid-2", "unexpected route #1 metric");
+	options = fill_table (generic_options, NULL);
+	options = fill_table (data, options);
 
-	/* Route #2 */
-	route = nm_ip4_config_get_route (ip4_config, 1);
-	ASSERT (inet_pton (AF_INET, expected_route2_dest, &tmp) > 0,
-	        "dhcp-rfc3442-invalid-2", "couldn't convert expected route destination #2");
-	ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
-	        "dhcp-rfc3442-invalid-2", "unexpected route #2 destination");
+	ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
+	ASSERT (ip4_config != NULL,
+	        "dhcp-dhcpcd-classless-invalid-2", "failed to parse DHCP4 options");
 
-	ASSERT (inet_pton (AF_INET, expected_route2_gw, &tmp) > 0,
-	        "dhcp-rfc3442-invalid-2", "couldn't convert expected route next hop #2");
-	ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
-	        "dhcp-rfc3442-invalid-2", "unexpected route #2 next hop");
+	/* Test falling back to old-style static routes if the classless static
+	 * routes are invalid.
+	 */
 
-	ASSERT (nm_ip4_route_get_prefix (route) == 32,
-	        "dhcp-rfc3442-invalid-2", "unexpected route #2 prefix");
-	ASSERT (nm_ip4_route_get_metric (route) == 0,
-	        "dhcp-rfc3442-invalid-2", "unexpected route #2 metric");
+	/* Routes */
+	ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 2,
+	        "dhcp-dhcpcd-classless-invalid-2", "unexpected number of routes");
+	ip4_test_route ("dhcp-dhcpcd-classless-invalid-2", ip4_config, 0,
+	                expected_route1_dest, expected_route1_gw, 32);
+	ip4_test_route ("dhcp-dhcpcd-classless-invalid-2", ip4_config, 1,
+	                expected_route2_dest, expected_route2_gw, 32);
 
 	g_hash_table_destroy (options);
 }
 
-static Option invalid_classless_routes3[] = {
-	/* For dhclient */
-	{ "new_rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 32 128 10 17 66 41" },
-	/* For dhcpcd */
-	{ "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 128/32 10.17.66.41" },
-	{ NULL, NULL }
-};
-
 static void
-test_invalid_classless_routes3 (const char *client)
+test_dhclient_invalid_classless_routes_3 (const char *client)
 {
 	GHashTable *options;
 	NMIP4Config *ip4_config;
-	NMIP4Route *route;
-	struct in_addr tmp;
 	const char *expected_route1_dest = "192.168.10.0";
 	const char *expected_route1_gw = "192.168.1.1";
+	static Option data[] = {
+		{ "new_rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 32 128 10 17 66 41" },
+		{ NULL, NULL }
+	};
 
 	options = fill_table (generic_options, NULL);
-	options = fill_table (invalid_classless_routes3, options);
+	options = fill_table (data, options);
 
 	ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
 	ASSERT (ip4_config != NULL,
-	        "dhcp-rfc3442-invalid-3", "failed to parse DHCP4 options");
+	        "dhcp-dhclient-classless-invalid-3", "failed to parse DHCP4 options");
 
 	/* IP4 routes */
 	ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1,
-	        "dhcp-rfc3442-invalid-3", "unexpected number of IP routes");
+	        "dhcp-dhclient-classless-invalid-3", "unexpected number of IP routes");
+	ip4_test_route ("dhcp-dhclient-classless-invalid-3", ip4_config, 0,
+	                expected_route1_dest, expected_route1_gw, 24);
 
-	/* Route #1 */
-	route = nm_ip4_config_get_route (ip4_config, 0);
-	ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0,
-	        "dhcp-rfc3442-invalid-3", "couldn't convert expected route destination #1");
-	ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
-	        "dhcp-rfc3442-invalid-3", "unexpected route #1 destination");
+	g_hash_table_destroy (options);
+}
 
-	ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0,
-	        "dhcp-rfc3442-invalid-3", "couldn't convert expected route next hop #1");
-	ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
-	        "dhcp-rfc3442-invalid-3", "unexpected route #1 next hop");
+static void
+test_dhcpcd_invalid_classless_routes_3 (const char *client)
+{
+	GHashTable *options;
+	NMIP4Config *ip4_config;
+	const char *expected_route1_dest = "192.168.10.0";
+	const char *expected_route1_gw = "192.168.1.1";
+	static Option data[] = {
+		{ "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 128/32 10.17.66.41" },
+		{ NULL, NULL }
+	};
 
-	ASSERT (nm_ip4_route_get_prefix (route) == 24,
-	        "dhcp-rfc3442-invalid-3", "unexpected route #1 prefix");
-	ASSERT (nm_ip4_route_get_metric (route) == 0,
-	        "dhcp-rfc3442-invalid-3", "unexpected route #1 metric");
+	options = fill_table (generic_options, NULL);
+	options = fill_table (data, options);
+
+	ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
+	ASSERT (ip4_config != NULL,
+	        "dhcp-dhcpcd-classless-invalid-3", "failed to parse DHCP4 options");
+
+	/* IP4 routes */
+	ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1,
+	        "dhcp-dhcpcd-classless-invalid-3", "unexpected number of IP routes");
+	ip4_test_route ("dhcp-dhcpcd-classless-invalid-3", ip4_config, 0,
+	                expected_route1_dest, expected_route1_gw, 24);
 
 	g_hash_table_destroy (options);
 }
 
-static Option gw_in_classless_routes[] = {
-	/* For dhclient */
-	{ "new_rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 0 192 2 3 4" },
-	/* For dhcpcd */
-	{ "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 0.0.0.0/0 192.2.3.4" },
-	{ NULL, NULL }
-};
-
 static void
-test_gateway_in_classless_routes (const char *client)
+test_dhclient_gw_in_classless_routes (const char *client)
 {
 	GHashTable *options;
 	NMIP4Config *ip4_config;
-	NMIP4Address *addr;
-	NMIP4Route *route;
-	struct in_addr tmp;
 	const char *expected_route1_dest = "192.168.10.0";
 	const char *expected_route1_gw = "192.168.1.1";
 	const char *expected_gateway = "192.2.3.4";
+	static Option data[] = {
+		{ "new_rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 0 192 2 3 4" },
+		{ NULL, NULL }
+	};
 
 	options = fill_table (generic_options, NULL);
-	options = fill_table (gw_in_classless_routes, options);
+	options = fill_table (data, options);
 
 	ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
 	ASSERT (ip4_config != NULL,
-	        "dhcp-rfc3442-gateway", "failed to parse DHCP4 options");
+	        "dhcp-dhclient-classless-gateway", "failed to parse DHCP4 options");
 
 	/* IP4 routes */
 	ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1,
-	        "dhcp-rfc3442-gateway", "unexpected number of IP routes");
+	        "dhcp-dhclient-classless-gateway", "unexpected number of IP routes");
+	ip4_test_route ("dhcp-dhclient-classless-gateway", ip4_config, 0,
+	                expected_route1_dest, expected_route1_gw, 24);
 
-	/* Route #1 */
-	route = nm_ip4_config_get_route (ip4_config, 0);
-	ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0,
-	        "dhcp-rfc3442-gateway", "couldn't convert expected route destination #1");
-	ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
-	        "dhcp-rfc3442-gateway", "unexpected route #1 destination");
+	/* Gateway */
+	ip4_test_gateway ("dhcp-dhclient-classless-gateway", ip4_config, expected_gateway);
 
-	ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0,
-	        "dhcp-rfc3442-gateway", "couldn't convert expected route next hop #1");
-	ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
-	        "dhcp-rfc3442-gateway", "unexpected route #1 next hop");
+	g_hash_table_destroy (options);
+}
 
-	ASSERT (nm_ip4_route_get_prefix (route) == 24,
-	        "dhcp-rfc3442-gateway", "unexpected route #1 prefix");
-	ASSERT (nm_ip4_route_get_metric (route) == 0,
-	        "dhcp-rfc3442-gateway", "unexpected route #1 metric");
+static void
+test_dhcpcd_gw_in_classless_routes (const char *client)
+{
+	GHashTable *options;
+	NMIP4Config *ip4_config;
+	const char *expected_route1_dest = "192.168.10.0";
+	const char *expected_route1_gw = "192.168.1.1";
+	const char *expected_gateway = "192.2.3.4";
+	static Option data[] = {
+		{ "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 0.0.0.0/0 192.2.3.4" },
+		{ NULL, NULL }
+	};
 
-	/* Address */
-	ASSERT (nm_ip4_config_get_num_addresses (ip4_config) == 1,
-	        "dhcp-rfc3442-gateway", "unexpected number of IP addresses");
-	addr = nm_ip4_config_get_address (ip4_config, 0);
-	ASSERT (inet_pton (AF_INET, expected_gateway, &tmp) > 0,
-	        "dhcp-rfc3442-gateway", "couldn't convert expected IP gateway");
-	ASSERT (nm_ip4_address_get_gateway (addr) == tmp.s_addr,
-	        "dhcp-rfc3442-gateway", "unexpected IP gateway");
+	options = fill_table (generic_options, NULL);
+	options = fill_table (data, options);
+
+	ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
+	ASSERT (ip4_config != NULL,
+	        "dhcp-dhcpcd-classless-gateway", "failed to parse DHCP4 options");
+
+	/* IP4 routes */
+	ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1,
+	        "dhcp-dhcpcd-classless-gateway", "unexpected number of IP routes");
+	ip4_test_route ("dhcp-dhcpcd-classless-gateway", ip4_config, 0,
+	                expected_route1_dest, expected_route1_gw, 24);
+
+	/* Gateway */
+	ip4_test_gateway ("dhcp-dhcpcd-classless-gateway", ip4_config, expected_gateway);
 
 	g_hash_table_destroy (options);
 }
@@ -694,11 +800,17 @@ int main (int argc, char **argv)
 
 		test_generic_options (client);
 		test_wins_options (client);
-		test_classless_static_routes (client);
-		test_invalid_classless_routes1 (client);
-		test_invalid_classless_routes2 (client);
-		test_invalid_classless_routes3 (client);
-		test_gateway_in_classless_routes (client);
+		test_classless_static_routes_1 (client);
+		test_classless_static_routes_2 (client);
+		test_fedora_dhclient_classless_static_routes (client);
+		test_dhclient_invalid_classless_routes_1 (client);
+		test_dhcpcd_invalid_classless_routes_1 (client);
+		test_dhclient_invalid_classless_routes_2 (client);
+		test_dhcpcd_invalid_classless_routes_2 (client);
+		test_dhclient_invalid_classless_routes_3 (client);
+		test_dhcpcd_invalid_classless_routes_3 (client);
+		test_dhclient_gw_in_classless_routes (client);
+		test_dhcpcd_gw_in_classless_routes (client);
 		test_escaped_domain_searches (client);
 		test_invalid_escaped_domain_searches (client);
 		test_ip4_missing_prefix (client, "192.168.1.10", 24);
diff --git a/src/tests/test-policy-hosts.c b/src/tests/test-policy-hosts.c
index e14f15e5..8865c426 100644
--- a/src/tests/test-policy-hosts.c
+++ b/src/tests/test-policy-hosts.c
@@ -23,12 +23,17 @@
 
 #include "nm-policy-hosts.h"
 
-#define FALLBACK_HOSTNAME "localhost.localdomain"
+#define FALLBACK_HOSTNAME4 "localhost.localdomain"
+#define FALLBACK_HOSTNAME6 "localhost6.localdomain6"
+
+#define DEBUG 0
 
 static void
 test_generic (const char *before,
               const char *after,
               const char *hostname,
+              const char *ip4_addr,
+              const char *ip6_addr,
               gboolean expect_error)
 {
 	char **lines;
@@ -40,7 +45,11 @@ test_generic (const char *before,
 	newc = nm_policy_get_etc_hosts ((const char **) lines,
 	                                strlen (before),
 	                                hostname,
-	                                FALLBACK_HOSTNAME,
+	                                NULL,
+	                                FALLBACK_HOSTNAME4,
+	                                FALLBACK_HOSTNAME6,
+	                                ip4_addr,
+	                                ip6_addr,
 	                                &error);
 	g_strfreev (lines);
 
@@ -50,17 +59,27 @@ test_generic (const char *before,
 		g_clear_error (&error);
 	} else if (after == NULL) {
 		/* No change to /etc/hosts required */
+#if DEBUG
+		if (newc != NULL) {
+			g_message ("\n- NEW ---------------------------------\n"
+			           "%s"
+			           "+ EXPECTED NONE +++++++++++++++++++++++++\n",
+			           newc->str);
+		}
+#endif
 		g_assert (newc == NULL);
 		g_assert (error == NULL);
 	} else {
 		g_assert (newc != NULL);
 		g_assert (error == NULL);
 
-#if 0
-		g_message ("\n--------------------------------------\n"
+#if DEBUG
+		g_message ("\n- NEW ---------------------------------\n"
 		           "%s"
-		           "--------------------------------------",
-		           newc->str);
+		           "+ EXPECTED ++++++++++++++++++++++++++++++\n"
+		           "%s"
+		           "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
+		           newc->str, after);
 #endif
 		g_assert (strlen (newc->str) == strlen (after));
 		g_assert (strcmp (newc->str, after) == 0);
@@ -80,7 +99,7 @@ static const char *generic_before = \
 static void
 test_hosts_generic (void)
 {
-	test_generic (generic_before, NULL, "localhost.localdomain", FALSE);
+	test_generic (generic_before, NULL, "localhost.localdomain", NULL, NULL, FALSE);
 }
 
 /*******************************************/
@@ -93,20 +112,19 @@ static const char *generic_no_boilerplate_before = \
 static void
 test_hosts_generic_no_boilerplate (void)
 {
-	test_generic (generic_no_boilerplate_before, NULL, "localhost.localdomain", FALSE);
+	test_generic (generic_no_boilerplate_before, NULL, "localhost.localdomain", NULL, NULL, FALSE);
 }
 
 /*******************************************/
 
 static const char *generic_no_boilerplate_no_lh_before = \
 	"127.0.0.1	localhost.localdomain\n"
-	"::1		localhost6.localdomain6 localhost6\n"
+	"::1		localhost6.localdomain6	localhost6\n"
 	"127.0.0.1	lcmd.us.intellitxt.com\n";
 
 static const char *generic_no_boilerplate_no_lh_after = \
-	"127.0.0.1	localhost\n"
-	"127.0.0.1	localhost.localdomain\n"
-	"::1		localhost6.localdomain6 localhost6\n"
+	"127.0.0.1	localhost.localdomain	localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
 	"127.0.0.1	lcmd.us.intellitxt.com\n";
 
 static void
@@ -115,6 +133,8 @@ test_hosts_generic_no_boilerplate_no_lh (void)
 	test_generic (generic_no_boilerplate_no_lh_before,
 	              generic_no_boilerplate_no_lh_after,
 	              "localhost.localdomain",
+	              NULL,
+	              NULL,
 	              FALSE);
 }
 
@@ -128,7 +148,7 @@ static const char *generic_no_boilerplate_no_lh_no_host_before = \
 
 static const char *generic_no_boilerplate_no_lh_no_host_after = \
 	"127.0.0.1	comet	localhost.localdomain	localhost\n"
-	"::1		localhost6.localdomain6 localhost6\n"
+	"::1	comet	localhost6.localdomain6	localhost6\n"
 	"127.0.0.1	lcmd.us.intellitxt.com\n";
 
 static void
@@ -137,6 +157,8 @@ test_hosts_generic_no_boilerplate_no_lh_no_host (void)
 	test_generic (generic_no_boilerplate_no_lh_no_host_before,
 	              generic_no_boilerplate_no_lh_no_host_after,
 	              "comet",
+	              NULL,
+	              NULL,
 	              FALSE);
 }
 
@@ -148,35 +170,58 @@ static const char *named_generic_before = \
 	"::1		localhost6.localdomain6 localhost6\n"
 	"127.0.0.1	lcmd.us.intellitxt.com\n";
 
+static const char *named_generic_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	playboy	localhost.localdomain	localhost\n"
+	"::1	playboy	localhost6.localdomain6	localhost6\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
 static void
 test_hosts_named_generic (void)
 {
-	test_generic (named_generic_before, NULL, "playboy", FALSE);
+	test_generic (named_generic_before, named_generic_after, "playboy", NULL, NULL, FALSE);
 }
 
 /*******************************************/
 
-static const char *named_non127_before = \
+static const char *named4_non127_before = \
 	"# Do not remove the following line, or various programs\n"
 	"# that require network functionality will fail.\n"
 	"127.0.0.1	localhost.localdomain localhost\n"
-	"::1		localhost6.localdomain6 localhost6\n"
+	"::1	tomcat	localhost6.localdomain6 localhost6\n"
 	"127.0.0.1	lcmd.us.intellitxt.com\n"
 	"192.168.1.2	tomcat\n";
 
 static void
-test_hosts_named_non127 (void)
+test_hosts_named4_non127 (void)
 {
-	test_generic (named_non127_before, NULL, "tomcat", FALSE);
+	test_generic (named4_non127_before, NULL, "tomcat", "192.168.1.2", NULL, FALSE);
 }
 
 /*******************************************/
 
-static const char *named2_non127_before = \
+static const char *named6_non127_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	tomcat localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6 localhost6\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n"
+	"3001:abba::3234 tomcat\n";
+
+static void
+test_hosts_named6_non127 (void)
+{
+	test_generic (named6_non127_before, NULL, "tomcat", NULL, "3001:abba::3234", FALSE);
+}
+
+/*******************************************/
+
+static const char *named4_non127_more_before = \
 	"# Do not remove the following line, or various programs\n"
 	"# that require network functionality will fail.\n"
 	"127.0.0.1	localhost.localdomain localhost\n"
-	"::1		localhost6.localdomain6 localhost6\n"
+	"::1	tomcat	localhost6.localdomain6 localhost6\n"
 	"127.0.0.1	lcmd.us.intellitxt.com\n"
 	"192.168.1.2	tomcat\n"
 	"127.0.0.1	lcmd.us.intellitxt.com\n"
@@ -184,9 +229,28 @@ static const char *named2_non127_before = \
 	"127.0.0.1	cdn5.tribalfusion.com\n";
 
 static void
-test_hosts_named2_non127 (void)
+test_hosts_named4_non127_more (void)
+{
+	test_generic (named4_non127_more_before, NULL, "tomcat", "192.168.1.2", NULL, FALSE);
+}
+
+/*******************************************/
+
+static const char *named6_non127_more_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	tomcat localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6 localhost6\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n"
+	"3001:abba::3234	tomcat\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n"
+	"127.0.0.1	srx.main.ebayrtm.com\n"
+	"127.0.0.1	cdn5.tribalfusion.com\n";
+
+static void
+test_hosts_named6_non127_more (void)
 {
-	test_generic (named2_non127_before, NULL, "tomcat", FALSE);
+	test_generic (named6_non127_more_before, NULL, "tomcat", NULL, "3001:abba::3234", FALSE);
 }
 
 /*******************************************/
@@ -203,14 +267,14 @@ static const char *named_no_lh_after = \
 	"# Do not remove the following line, or various programs\n"
 	"# that require network functionality will fail.\n"
 	"127.0.0.1	localhost.localdomain	localhost\n"
-	"::1		localhost6.localdomain6 localhost6\n"
+	"::1	tomcat	localhost6.localdomain6	localhost6\n"
 	"127.0.0.1	lcmd.us.intellitxt.com\n"
 	"192.168.1.2	tomcat\n";
 
 static void
 test_hosts_named_no_localhost (void)
 {
-	test_generic (named_no_lh_before, named_no_lh_after, "tomcat", FALSE);
+	test_generic (named_no_lh_before, named_no_lh_after, "tomcat", "192.168.1.2", NULL, FALSE);
 }
 
 /*******************************************/
@@ -225,15 +289,14 @@ static const char *no_lh_before = \
 static const char *no_lh_after = \
 	"# Do not remove the following line, or various programs\n"
 	"# that require network functionality will fail.\n"
-	"127.0.0.1	localhost.localdomain	localhost\n"
-	"127.0.0.1	tomcat\n"
-	"::1		localhost6.localdomain6 localhost6\n"
+	"127.0.0.1	tomcat	localhost.localdomain	localhost\n"
+	"::1	tomcat	localhost6.localdomain6	localhost6\n"
 	"127.0.0.1	lcmd.us.intellitxt.com\n";
 
 static void
 test_hosts_no_localhost (void)
 {
-	test_generic (no_lh_before, no_lh_after, "tomcat", FALSE);
+	test_generic (no_lh_before, no_lh_after, "tomcat", NULL, NULL, FALSE);
 }
 
 /*******************************************/
@@ -247,12 +310,12 @@ static const char *named_last_before = \
 static void
 test_hosts_named_last (void)
 {
-	test_generic (named_last_before, NULL, "sparcbook.ausil.us", FALSE);
+	test_generic (named_last_before, NULL, "sparcbook.ausil.us", NULL, NULL, FALSE);
 }
 
 /*******************************************/
 
-static const char *no_host_before = \
+static const char *no_host4_before = \
 	"# Do not remove the following line, or various programs\n"
 	"# that require network functionality will fail.\n"
 	"::1		localhost6.localdomain6 localhost6\n"
@@ -262,11 +325,11 @@ static const char *no_host_before = \
 	"127.0.0.1	cdn5.tribalfusion.com\n"
 	"127.0.0.1	a.tribalfusion.com\n";
 
-static const char *no_host_after = \
+static const char *no_host4_after = \
 	"# Do not remove the following line, or various programs\n"
 	"# that require network functionality will fail.\n"
 	"127.0.0.1	comet	localhost.localdomain	localhost\n"
-	"::1		localhost6.localdomain6 localhost6\n"
+	"::1	comet	localhost6.localdomain6	localhost6\n"
 	"\n"
 	"127.0.0.1	lcmd.us.intellitxt.com\n"
 	"127.0.0.1	srx.main.ebayrtm.com\n"
@@ -274,9 +337,264 @@ static const char *no_host_after = \
 	"127.0.0.1	a.tribalfusion.com\n";
 
 static void
-test_hosts_no_host (void)
+test_hosts_no_host4 (void)
+{
+	test_generic (no_host4_before, no_host4_after, "comet", NULL, NULL, FALSE);
+}
+
+/*******************************************/
+
+static const char *no_host6_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static const char *no_host6_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	comet	localhost.localdomain	localhost\n"
+	"::1	comet	localhost6.localdomain6	localhost6\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static void
+test_hosts_no_host6 (void)
+{
+	test_generic (no_host6_before, no_host6_after, "comet", NULL, NULL, FALSE);
+}
+
+/*******************************************/
+
+static const char *named46_non127_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"192.168.1.2 comet\n"
+	"3001:abba::3234 comet\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static void
+test_hosts_named46_non127 (void)
+{
+	test_generic (named46_non127_before, NULL, "comet", "192.168.1.2", "3001:abba::3234", FALSE);
+}
+
+/*******************************************/
+
+static const char *named46_non127_long_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"192.168.1.2 comet.space	comet\n"
+	"3001:abba::3234 comet.space	comet\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static void
+test_hosts_named46_non127_long (void)
+{
+	test_generic (named46_non127_long_before, NULL, "comet.space", "192.168.1.2", "3001:abba::3234", FALSE);
+}
+
+/*******************************************/
+
+static const char *named46_non127_other4_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"192.168.1.3	comet\n"
+	"3001:abba::3234	comet\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static const char *named46_non127_other4_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"192.168.1.2	comet	# Added by NetworkManager\n"
+	"127.0.0.1	localhost.localdomain	localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"192.168.1.3	comet\n"
+	"3001:abba::3234	comet\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static void
+test_hosts_named46_non127_other4 (void)
+{
+	test_generic (named46_non127_other4_before, named46_non127_other4_after, "comet", "192.168.1.2", "3001:abba::3234", FALSE);
+}
+
+/*******************************************/
+
+static const char *named46_non127_other4_long_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"192.168.1.3	comet.space\n"
+	"3001:abba::3234	comet.space\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static const char *named46_non127_other4_long_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"192.168.1.2	comet.space	comet	# Added by NetworkManager\n"
+	"127.0.0.1	localhost.localdomain	localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"192.168.1.3	comet.space\n"
+	"3001:abba::3234	comet.space\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static void
+test_hosts_named46_non127_other4_long (void)
+{
+	test_generic (named46_non127_other4_long_before, named46_non127_other4_long_after, "comet.space", "192.168.1.2", "3001:abba::3234", FALSE);
+}
+
+/*******************************************/
+
+static const char *named46_non127_other6_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"192.168.1.2	comet\n"
+	"3001:abba::9675	comet\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static const char *named46_non127_other6_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"3001:abba::3234	comet	# Added by NetworkManager\n"
+	"127.0.0.1	localhost.localdomain	localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"192.168.1.2	comet\n"
+	"3001:abba::9675	comet\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static void
+test_hosts_named46_non127_other6 (void)
+{
+	test_generic (named46_non127_other6_before, named46_non127_other6_after, "comet", "192.168.1.2", "3001:abba::3234", FALSE);
+}
+
+/*******************************************/
+
+static const char *named46_non127_other6_long_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"192.168.1.2	comet.space\n"
+	"3001:abba::9675	comet.space\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static const char *named46_non127_other6_long_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"3001:abba::3234	comet.space	comet	# Added by NetworkManager\n"
+	"127.0.0.1	localhost.localdomain	localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"192.168.1.2	comet.space\n"
+	"3001:abba::9675	comet.space\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static void
+test_hosts_named46_non127_other6_long (void)
+{
+	test_generic (named46_non127_other6_long_before, named46_non127_other6_long_after, "comet.space", "192.168.1.2", "3001:abba::3234", FALSE);
+}
+
+/*******************************************/
+
+static const char *unnamed46_non127_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static const char *unnamed46_non127_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"192.168.1.2	comet	# Added by NetworkManager\n"
+	"3001:abba::3234	comet	# Added by NetworkManager\n"
+	"127.0.0.1	localhost.localdomain	localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static void
+test_hosts_unnamed46_non127 (void)
 {
-	test_generic (no_host_before, no_host_after, "comet", FALSE);
+	test_generic (unnamed46_non127_before, unnamed46_non127_after, "comet", "192.168.1.2", "3001:abba::3234", FALSE);
+}
+
+/*******************************************/
+
+static const char *unnamed46_non127_long_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static const char *unnamed46_non127_long_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"192.168.1.2	comet.space	comet	# Added by NetworkManager\n"
+	"3001:abba::3234	comet.space	comet	# Added by NetworkManager\n"
+	"127.0.0.1	localhost.localdomain	localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static void
+test_hosts_unnamed46_non127_long (void)
+{
+	test_generic (unnamed46_non127_long_before, unnamed46_non127_long_after, "comet.space", "192.168.1.2", "3001:abba::3234", FALSE);
+}
+
+/*******************************************/
+
+static const char *named46_non127_wrong_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"192.168.1.3	comet	# Added by NetworkManager\n"
+	"3001:abba::9876	comet	# Added by NetworkManager\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static const char *named46_non127_wrong_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"192.168.1.2	comet	# Added by NetworkManager\n"
+	"3001:abba::3234	comet	# Added by NetworkManager\n"
+	"127.0.0.1	localhost.localdomain	localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n";
+
+static void
+test_hosts_named46_non127_wrong (void)
+{
+	test_generic (named46_non127_wrong_before, named46_non127_wrong_after, "comet", "192.168.1.2", "3001:abba::3234", FALSE);
 }
 
 /*******************************************/
@@ -301,24 +619,178 @@ static const char *long_before = \
 	"127.0.0.1	ad.doubleclick.net\n"
 	"127.0.0.1	oascentral.movietickets.com\n"
 	"127.0.0.1	view.atdmt.com\n"
-	"127.0.0.1	ads.chumcity.com\n"
-	"127.0.0.1	ads.as4x.tmcs.net\n"
-	"127.0.0.1	n4403ad.doubleclick.net\n"
-	"127.0.0.1	www.assoc-amazon.com\n"
-	"127.0.0.1	s25.sitemeter.com\n"
-	"127.0.0.1	adlog.com.com\n"
-	"127.0.0.1	ahs.laptopmag.com\n"
-	"127.0.0.1	altfarm.mediaplex.com\n"
-	"127.0.0.1	ads.addynamix.com\n"
-	"127.0.0.1	srx.main.ebayrtm.com\n"
-	"127.0.0.1	cdn5.tribalfusion.com\n"
-	"127.0.0.1	a.tribalfusion.com\n";
+	"127.0.0.1	ads.chumcity.com\n";
 
+static const char *long_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	comet	localhost.localdomain	localhost\n"
+	"::1	comet	localhost6.localdomain6	localhost6\n"
+	"\n"
+	"127.0.0.1	lcmd.us.intellitxt.com\n"
+	"127.0.0.1	adserver.adtech.de\n"
+	"127.0.0.1	a.as-us.falkag.net\n"
+	"127.0.0.1	a.as-eu.falkag.net\n"
+	"127.0.0.1	ads.doubleclick.com\n"
+	"\n"
+	"# random comment\n"
+	"127.0.0.1	m1.2mdn.net\n"
+	"127.0.0.1	ds.serving-sys.com\n"
+	"127.0.0.1	pagead2.googlesyndication.com\n"
+	"127.0.0.1	ad.doubleclick.com\n"
+	"127.0.0.1	ad.doubleclick.net\n"
+	"127.0.0.1	oascentral.movietickets.com\n"
+	"127.0.0.1	view.atdmt.com\n"
+	"127.0.0.1	ads.chumcity.com\n";
 
 static void
 test_hosts_long (void)
 {
-	test_generic (long_before, NULL, "comet", FALSE);
+	test_generic (long_before, long_after, "comet", NULL, NULL, FALSE);
+}
+
+/*******************************************/
+
+static const char *custom4_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost pintglass\n"
+	"::1	localhost6.localdomain6	localhost6\n";
+
+static const char *custom4_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	comet	localhost.localdomain	localhost	pintglass\n"
+	"::1	comet	localhost6.localdomain6	localhost6\n";
+
+static void
+test_hosts_custom4 (void)
+{
+	test_generic (custom4_before, custom4_after, "comet", NULL, NULL, FALSE);
+}
+
+/*******************************************/
+
+static const char *custom6_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6	localhost6	pintglass\n";
+
+static const char *custom6_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	comet	localhost.localdomain	localhost\n"
+	"::1	comet	localhost6.localdomain6	localhost6	pintglass\n";
+
+static void
+test_hosts_custom6 (void)
+{
+	test_generic (custom6_before, custom6_after, "comet", NULL, NULL, FALSE);
+}
+
+/*******************************************/
+
+static const char *custom46_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost shotglass\n"
+	"::1	localhost6.localdomain6	localhost6 pintglass\n";
+
+static const char *custom46_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	comet	localhost.localdomain	localhost	shotglass\n"
+	"::1	comet	localhost6.localdomain6	localhost6	pintglass\n";
+
+static void
+test_hosts_custom46 (void)
+{
+	test_generic (custom46_before, custom46_after, "comet", NULL, NULL, FALSE);
+}
+
+/*******************************************/
+
+static const char *custom46_mixed_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	localhost.localdomain localhost shotglass\n"
+	"::1	localhost6.localdomain6	localhost6 pintglass\n";
+
+static const char *custom46_mixed_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	comet	localhost.localdomain	localhost	shotglass\n"
+	"::1	comet	localhost6.localdomain6	localhost6	pintglass\n";
+
+static void
+test_hosts_custom46_mixed (void)
+{
+	test_generic (custom46_mixed_before, custom46_mixed_after, "comet", NULL, NULL, FALSE);
+}
+
+/*******************************************/
+
+static const char *stale4_removed_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"1.2.3.4	comet	# Added by NetworkManager\n"
+	"127.0.0.1	localhost.localdomain localhost\n"
+	"::1	comet	localhost6.localdomain6	localhost6\n";
+
+static const char *stale4_removed_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	comet	localhost.localdomain	localhost\n"
+	"::1	comet	localhost6.localdomain6	localhost6\n";
+
+static void
+test_hosts_stale4_removed (void)
+{
+	test_generic (stale4_removed_before, stale4_removed_after, "comet", NULL, NULL, FALSE);
+}
+
+/*******************************************/
+
+static const char *stale6_removed_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"3001:abba::3234	comet	# Added by NetworkManager\n"
+	"127.0.0.1	comet	localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n";
+
+static const char *stale6_removed_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	comet	localhost.localdomain	localhost\n"
+	"::1	comet	localhost6.localdomain6	localhost6\n";
+
+static void
+test_hosts_stale6_removed (void)
+{
+	test_generic (stale6_removed_before, stale6_removed_after, "comet", NULL, NULL, FALSE);
+}
+
+/*******************************************/
+
+static const char *stale46_removed_before = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"1.2.3.4	comet	# Added by NetworkManager\n"
+	"3001:abba::3234	comet	# Added by NetworkManager\n"
+	"127.0.0.1	localhost.localdomain localhost\n"
+	"::1	localhost6.localdomain6	localhost6\n";
+
+static const char *stale46_removed_after = \
+	"# Do not remove the following line, or various programs\n"
+	"# that require network functionality will fail.\n"
+	"127.0.0.1	comet	localhost.localdomain	localhost\n"
+	"::1	comet	localhost6.localdomain6	localhost6\n";
+
+static void
+test_hosts_stale46_removed (void)
+{
+	test_generic (stale46_removed_before, stale46_removed_after, "comet", NULL, NULL, FALSE);
 }
 
 /*******************************************/
@@ -363,7 +835,11 @@ test_find_token (void)
 	}
 }
 
+#if GLIB_CHECK_VERSION(2,25,12)
+typedef GTestFixtureFunc TCFunc;
+#else
 typedef void (*TCFunc)(void);
+#endif
 
 #define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL)
 
@@ -381,13 +857,32 @@ int main (int argc, char **argv)
 	g_test_suite_add (suite, TESTCASE (test_hosts_generic_no_boilerplate_no_lh, NULL));
 	g_test_suite_add (suite, TESTCASE (test_hosts_generic_no_boilerplate_no_lh_no_host, NULL));
 	g_test_suite_add (suite, TESTCASE (test_hosts_named_generic, NULL));
-	g_test_suite_add (suite, TESTCASE (test_hosts_named_non127, NULL));
-	g_test_suite_add (suite, TESTCASE (test_hosts_named2_non127, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_named4_non127, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_named6_non127, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_named4_non127_more, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_named6_non127_more, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127_long, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127_other4, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127_other4_long, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127_other6, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127_other6_long, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_named46_non127_wrong, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_unnamed46_non127, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_unnamed46_non127_long, NULL));
 	g_test_suite_add (suite, TESTCASE (test_hosts_named_no_localhost, NULL));
 	g_test_suite_add (suite, TESTCASE (test_hosts_no_localhost, NULL));
 	g_test_suite_add (suite, TESTCASE (test_hosts_named_last, NULL));
-	g_test_suite_add (suite, TESTCASE (test_hosts_no_host, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_no_host4, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_no_host6, NULL));
 	g_test_suite_add (suite, TESTCASE (test_hosts_long, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_custom4, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_custom6, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_custom46, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_custom46_mixed, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_stale4_removed, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_stale6_removed, NULL));
+	g_test_suite_add (suite, TESTCASE (test_hosts_stale46_removed, NULL));
 
 	return g_test_run ();
 }