[network-manager-vpnc/th/vpn-editor-split-bgo766170: 11/23] properties/tests: enable properties tests for libnm-glib based library



commit 7eee712a718dc3b550f2596bcfd37754bed3cc6f
Author: Thomas Haller <thaller redhat com>
Date:   Mon May 9 11:43:16 2016 +0200

    properties/tests: enable properties tests for libnm-glib based library

 .gitignore                            |    1 +
 properties/tests/Makefile.am          |   41 +++++++++++++++++++++++-----
 properties/tests/test-import-export.c |   47 +++++++++++++++++++++-----------
 shared/nm-default.h                   |   15 +++++++---
 4 files changed, 76 insertions(+), 28 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index f327b7a..3157698 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,6 +42,7 @@ auth-dialog/nm-vpnc-auth-dialog.desktop.in
 nm-vpnc-service.name
 nm-vpnc.desktop
 properties/tests/test-import-export
+properties/tests/test-import-export-glib
 src/nm-vpnc-service
 src/nm-vpnc-service-vpnc-helper
 src/test-vpnc-output
diff --git a/properties/tests/Makefile.am b/properties/tests/Makefile.am
index 26416a6..6fef490 100644
--- a/properties/tests/Makefile.am
+++ b/properties/tests/Makefile.am
@@ -1,7 +1,17 @@
 SUBDIRS = pcf
 
+AM_CFLAGS = \
+       -I${top_srcdir}/shared \
+       -I${top_srcdir}/properties \
+       -DTEST_SRCDIR="\"$(abs_srcdir)\"" \
+       -DTEST_BUILDDIR="\"$(abs_builddir)\""
+
 noinst_PROGRAMS = \
        test-import-export
+if WITH_LIBNM_GLIB
+noinst_PROGRAMS += test-import-export-glib
+endif
+
 
 test_import_export_SOURCES = \
        test-import-export.c
@@ -10,21 +20,36 @@ test_import_export_CPPFLAGS = \
        $(GLIB_CFLAGS) \
        $(GTK_CFLAGS) \
        $(LIBNM_CFLAGS) \
-       $(LIBNMA_CFLAGS) \
-       $(DBUS_CFLAGS) \
-       -I"$(top_srcdir)/shared/" \
-       -I"$(top_srcdir)/properties/" \
-       -DTEST_SRCDIR="\"$(abs_srcdir)\"" \
-       -DTEST_BUILDDIR="\"$(abs_builddir)\""
-
+       $(LIBNMA_CFLAGS)
 
 test_import_export_LDADD = \
        $(GTHREAD_LIBS) \
        $(GTK_LIBS) \
-       $(DBUS_LIBS) \
        $(LIBNM_LIBS) \
        $(LIBNMA_LIBS) \
        $(top_builddir)/properties/libnm-vpn-plugin-vpnc.la
 
+
+test_import_export_glib_SOURCES = \
+       test-import-export.c
+
+test_import_export_glib_CPPFLAGS = \
+       -DNM_VPN_OLD \
+       $(GLIB_CFLAGS) \
+       $(GTK_CFLAGS) \
+       $(LIBNM_GLIB_CFLAGS) \
+       $(LIBNM_GTK_CFLAGS)
+
+test_import_export_glib_LDADD = \
+       $(GTHREAD_LIBS) \
+       $(GTK_LIBS) \
+       $(LIBNM_GLIB_LIBS) \
+       $(LIBNM_GTK_LIBS) \
+       $(top_builddir)/properties/libnm-vpnc-properties.la
+
+
 TESTS = \
        test-import-export
+if WITH_LIBNM_GLIB
+TESTS += test-import-export-glib
+endif
diff --git a/properties/tests/test-import-export.c b/properties/tests/test-import-export.c
index 50adf68..5e2d759 100644
--- a/properties/tests/test-import-export.c
+++ b/properties/tests/test-import-export.c
@@ -149,10 +149,7 @@ test_basic_import (void)
        NMSettingConnection *s_con;
        NMSettingIPConfig *s_ip4;
        NMSettingVpn *s_vpn;
-       NMIPRoute *route;
        const char *expected_id = "Basic VPN";
-       const char *expected_route1_dest = "10.0.0.0";
-       const char *expected_route2_dest = "172.16.0.0";
 
        connection = get_basic_connection ("basic-import", plugin, SRCDIR, "basic.pcf");
 
@@ -179,19 +176,37 @@ test_basic_import (void)
        g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip4), ==, 0);
        g_assert_cmpint (nm_setting_ip_config_get_num_routes (s_ip4), ==, 2);
 
-       /* Route #1 */
-       route = nm_setting_ip_config_get_route (s_ip4, 0);
-       g_assert_cmpstr (nm_ip_route_get_dest (route), ==, expected_route1_dest);
-       g_assert (!nm_ip_route_get_next_hop (route));
-       g_assert_cmpint (nm_ip_route_get_prefix (route), ==, 8);
-       g_assert_cmpint (nm_ip_route_get_metric (route), ==, -1);
-
-       /* Route #2 */
-       route = nm_setting_ip_config_get_route (s_ip4, 1);
-       g_assert_cmpstr (nm_ip_route_get_dest (route), ==, expected_route2_dest);
-       g_assert (!nm_ip_route_get_next_hop (route));
-       g_assert_cmpint (nm_ip_route_get_prefix (route), ==, 16);
-       g_assert_cmpint (nm_ip_route_get_metric (route), ==, -1);
+#ifdef NM_VPN_OLD
+       {
+               NMIP4Route *route;
+
+               route = nm_setting_ip4_config_get_route (s_ip4, 0);
+               g_assert (!nm_ip4_route_get_next_hop (route));
+               g_assert_cmpint (nm_ip4_route_get_prefix (route), ==, 8);
+               g_assert_cmpint (nm_ip4_route_get_metric (route), ==, 0);
+
+               route = nm_setting_ip4_config_get_route (s_ip4, 1);
+               g_assert_cmpint (nm_ip4_route_get_dest (route), ==, nmtst_inet4_from_string ("172.16.0.0"));
+               g_assert (!nm_ip4_route_get_next_hop (route));
+               g_assert_cmpint (nm_ip4_route_get_prefix (route), ==, 16);
+               g_assert_cmpint (nm_ip4_route_get_metric (route), ==, 0);
+       }
+#else
+       {
+               NMIPRoute *route;
+
+               route = nm_setting_ip_config_get_route (s_ip4, 0);
+               g_assert (!nm_ip_route_get_next_hop (route));
+               g_assert_cmpint (nm_ip_route_get_prefix (route), ==, 8);
+               g_assert_cmpint (nm_ip_route_get_metric (route), ==, -1);
+
+               route = nm_setting_ip_config_get_route (s_ip4, 1);
+               g_assert_cmpstr (nm_ip_route_get_dest (route), ==, "172.16.0.0");
+               g_assert (!nm_ip_route_get_next_hop (route));
+               g_assert_cmpint (nm_ip_route_get_prefix (route), ==, 16);
+               g_assert_cmpint (nm_ip_route_get_metric (route), ==, -1);
+       }
+#endif
 
        /* VPN setting */
        s_vpn = nm_connection_get_setting_vpn (connection);
diff --git a/shared/nm-default.h b/shared/nm-default.h
index 9d5aa5f..c8317db 100644
--- a/shared/nm-default.h
+++ b/shared/nm-default.h
@@ -79,10 +79,17 @@
 #define NM_SETTING_IP_CONFIG_METHOD NM_SETTING_IP4_CONFIG_METHOD
 #define NMSettingIPConfig NMSettingIP4Config
 
-#define nm_setting_ip_config_get_num_routes nm_setting_ip4_config_get_num_routes
-#define nm_setting_ip_config_add_route      nm_setting_ip4_config_add_route
-#define nm_setting_ip_config_get_route      nm_setting_ip4_config_get_route
-#define NM_SETTING_IP_CONFIG_NEVER_DEFAULT  NM_SETTING_IP4_CONFIG_NEVER_DEFAULT
+#define nm_setting_ip_config_get_num_routes         nm_setting_ip4_config_get_num_routes
+#define nm_setting_ip_config_add_route              nm_setting_ip4_config_add_route
+#define nm_setting_ip_config_get_route              nm_setting_ip4_config_get_route
+#define nm_setting_ip_config_get_num_addresses      nm_setting_ip4_config_get_num_addresses
+#define nm_setting_ip_config_get_num_dns_searches   nm_setting_ip4_config_get_num_dns_searches
+#define nm_setting_ip_config_get_never_default      nm_setting_ip4_config_get_never_default
+#define nm_setting_ip_config_get_dhcp_hostname      nm_setting_ip4_config_get_dhcp_hostname
+#define nm_setting_ip_config_get_method             nm_setting_ip4_config_get_method
+#define nm_setting_ip_config_get_dhcp_hostname      nm_setting_ip4_config_get_dhcp_hostname
+#define nm_setting_ip_config_get_num_dns            nm_setting_ip4_config_get_num_dns
+#define NM_SETTING_IP_CONFIG_NEVER_DEFAULT          NM_SETTING_IP4_CONFIG_NEVER_DEFAULT
 
 #define NMV_EDITOR_PLUGIN_ERROR                     NM_SETTING_VPN_ERROR
 #define NMV_EDITOR_PLUGIN_ERROR_FAILED              NM_SETTING_VPN_ERROR_UNKNOWN


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]