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



commit d584717195773a12014b0d74c9290fe151335622
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 90542d8..a2ba9d0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,6 +41,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 eb9c9b6..8812331 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_VPNC_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 f49c804..5bb7bd1 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);
+#if NM_VPNC_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 406c4e9..9ce5f4f 100644
--- a/shared/nm-default.h
+++ b/shared/nm-default.h
@@ -78,10 +78,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 VPNC_EDITOR_PLUGIN_ERROR                     NM_SETTING_VPN_ERROR
 #define VPNC_EDITOR_PLUGIN_ERROR_FAILED              NM_SETTING_VPN_ERROR_UNKNOWN


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