[glib-networking/wip/tlssplit: 5/5] Split tests to take into account the backend



commit c113fe27db5ad57a9c545dc7daf1fea80144ea22
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue Aug 18 10:42:49 2015 +0200

    Split tests to take into account the backend

 tls/tests/Makefile.am     |   36 ++++++++++++++++++++++++++----------
 tls/tests/certificate.c   |    5 +++--
 tls/tests/connection.c    |   17 +++++++++++++++--
 tls/tests/file-database.c |    5 +++--
 4 files changed, 47 insertions(+), 16 deletions(-)
---
diff --git a/tls/tests/Makefile.am b/tls/tests/Makefile.am
index 8d3d903..24217bf 100644
--- a/tls/tests/Makefile.am
+++ b/tls/tests/Makefile.am
@@ -1,22 +1,41 @@
 include $(top_srcdir)/glib-networking.mk
 
 AM_CPPFLAGS +=                                 \
-       $(GNUTLS_CFLAGS)                        \
        -I$(top_srcdir)/tls                     \
        -I$(top_builddir)/tls                   \
        -DSRCDIR=\""$(abs_srcdir)"\"            \
        -DTOP_BUILDDIR=\""$(top_builddir)"\"
 
 LDADD  = \
-       $(GLIB_LIBS) \
-       $(GNUTLS_LIBS)
+       $(GLIB_LIBS)
 
-test_programs =       \
-       certificate   \
-       file-database \
-       connection    \
+test_programs =
+
+if HAVE_GNUTLS
+test_programs +=             \
+       certificate-gnutls   \
+       file-database-gnutls \
+       connection-gnutls    \
        $(NULL)
 
+certificate_gnutls_SOURCES = certificate.c
+certificate_gnutls_CPPFLAGS = $(AM_CPPFLAGS) $(GNUTLS_CFLAGS) -DBACKEND=\""gnutls"\" -DWITH_BACKEND_GNUTLS
+certificate_gnutls_LDADD = $(GLIB_LIBS) $(GNUTLS_LIBS)
+
+connection_gnutls_SOURCES = connection.c
+connection_gnutls_CPPFLAGS = $(AM_CPPFLAGS) $(GNUTLS_CFLAGS) -DBACKEND=\""gnutls"\" -DWITH_BACKEND_GNUTLS
+connection_gnutls_LDADD = $(GLIB_LIBS) $(GNUTLS_LIBS)
+if HAVE_PKCS11
+connection_gnutls_SOURCES += mock-interaction.c mock-interaction.h
+connection_gnutls_LDADD += $(top_builddir)/tls/pkcs11/libgiopkcs11.la $(PKCS11_LIBS)
+endif
+
+file_database_gnutls_SOURCES = file-database.c
+file_database_gnutls_CPPFLAGS = $(AM_CPPFLAGS) $(GNUTLS_CFLAGS) -DBACKEND=\""gnutls"\" -DWITH_BACKEND_GNUTLS
+file_database_gnutls_LDADD = $(GLIB_LIBS) $(GNUTLS_LIBS)
+
+endif
+
 if HAVE_PKCS11
 
 test_programs +=           \
@@ -34,9 +53,6 @@ pkcs11_slot_SOURCES = pkcs11-slot.c \
        mock-pkcs11.c mock-pkcs11.h \
        mock-interaction.c mock-interaction.h
 
-connection_SOURCES = connection.c \
-       mock-interaction.c mock-interaction.h
-
 endif
 
 testfiles_data =                               \
diff --git a/tls/tests/certificate.c b/tls/tests/certificate.c
index 7d3f031..792b93b 100644
--- a/tls/tests/certificate.c
+++ b/tls/tests/certificate.c
@@ -541,8 +541,9 @@ main (int   argc,
   g_test_init (&argc, &argv, NULL);
 
   g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
-  g_setenv ("GIO_EXTRA_MODULES", TOP_BUILDDIR "/tls/gnutls/.libs", TRUE);
-  g_setenv ("GIO_USE_TLS", "gnutls", TRUE);
+  g_setenv ("GIO_EXTRA_MODULES", TOP_BUILDDIR "/tls/" BACKEND "/.libs", TRUE);
+  g_setenv ("GIO_USE_TLS", BACKEND, TRUE);
+  g_assert (g_ascii_strcasecmp (G_OBJECT_TYPE_NAME (g_tls_backend_get_default ()), "GTlsBackend" BACKEND) == 
0);
 
   g_test_add ("/tls/certificate/create-pem", TestCertificate, NULL,
               setup_certificate, test_create_pem, teardown_certificate);
diff --git a/tls/tests/connection.c b/tls/tests/connection.c
index 2d2d1e8..bc67727 100644
--- a/tls/tests/connection.c
+++ b/tls/tests/connection.c
@@ -21,7 +21,9 @@
 
 #include "config.h"
 
+#ifdef WITH_BACKEND_GNUTLS
 #include "mock-interaction.h"
+#endif
 
 #include <gio/gio.h>
 #include <gnutls/gnutls.h>
@@ -615,6 +617,7 @@ test_client_auth_failure (TestConnection *test,
   g_assert (accepted_changed == TRUE);
 }
 
+#ifdef WITH_BACKEND_GNUTLS
 static void
 test_client_auth_request_cert (TestConnection *test,
                                gconstpointer   data)
@@ -704,6 +707,7 @@ test_client_auth_request_fail (TestConnection *test,
   g_io_stream_close (test->server_connection, NULL, NULL);
   g_io_stream_close (test->client_connection, NULL, NULL);
 }
+#endif
 
 static void
 test_connection_no_database (TestConnection *test,
@@ -1049,6 +1053,7 @@ test_simultaneous_async (TestConnection *test,
   g_assert_cmpstr (test->buf, ==, TEST_DATA);
 }
 
+#ifdef WITH_BACKEND_GNUTLS
 static gboolean
 check_gnutls_has_rehandshaking_bug (void)
 {
@@ -1061,16 +1066,19 @@ check_gnutls_has_rehandshaking_bug (void)
          !strcmp (version, "3.3.9") ||
           !strcmp (version, "3.3.10"));
 }
+#endif
 
 static void
 test_simultaneous_async_rehandshake (TestConnection *test,
                                     gconstpointer   data)
 {
+#ifdef WITH_BACKEND_GNUTLS
   if (check_gnutls_has_rehandshaking_bug ())
     {
       g_test_skip ("test would fail due to gnutls bug 108690");
       return;
     }
+#endif
 
   test->rehandshake = TRUE;
   test_simultaneous_async (test, data);
@@ -1166,11 +1174,13 @@ static void
 test_simultaneous_sync_rehandshake (TestConnection *test,
                                    gconstpointer   data)
 {
+#ifdef WITH_BACKEND_GNUTLS
   if (check_gnutls_has_rehandshaking_bug ())
     {
       g_test_skip ("test would fail due to gnutls bug 108690");
       return;
     }
+#endif
 
   test->rehandshake = TRUE;
   test_simultaneous_sync (test, data);
@@ -1492,8 +1502,9 @@ main (int   argc,
   g_test_bug_base ("http://bugzilla.gnome.org/";);
 
   g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
-  g_setenv ("GIO_EXTRA_MODULES", TOP_BUILDDIR "/tls/gnutls/.libs", TRUE);
-  g_setenv ("GIO_USE_TLS", "gnutls", TRUE);
+  g_setenv ("GIO_EXTRA_MODULES", TOP_BUILDDIR "/tls/" BACKEND "/.libs", TRUE);
+  g_setenv ("GIO_USE_TLS", BACKEND, TRUE);
+  g_assert (g_ascii_strcasecmp (G_OBJECT_TYPE_NAME (g_tls_backend_get_default ()), "GTlsBackend" BACKEND) == 
0);
 
   g_test_add ("/tls/connection/basic", TestConnection, NULL,
               setup_connection, test_basic_connection, teardown_connection);
@@ -1505,10 +1516,12 @@ main (int   argc,
               setup_connection, test_client_auth_rehandshake, teardown_connection);
   g_test_add ("/tls/connection/client-auth-failure", TestConnection, NULL,
               setup_connection, test_client_auth_failure, teardown_connection);
+#ifdef WITH_BACKEND_GNUTLS
   g_test_add ("/tls/connection/client-auth-request-cert", TestConnection, NULL,
               setup_connection, test_client_auth_request_cert, teardown_connection);
   g_test_add ("/tls/connection/client-auth-request-fail", TestConnection, NULL,
               setup_connection, test_client_auth_request_fail, teardown_connection);
+#endif
   g_test_add ("/tls/connection/no-database", TestConnection, NULL,
               setup_connection, test_connection_no_database, teardown_connection);
   g_test_add ("/tls/connection/failed", TestConnection, NULL,
diff --git a/tls/tests/file-database.c b/tls/tests/file-database.c
index 1416e73..e0342ff 100644
--- a/tls/tests/file-database.c
+++ b/tls/tests/file-database.c
@@ -532,8 +532,9 @@ main (int   argc,
   g_test_init (&argc, &argv, NULL);
 
   g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
-  g_setenv ("GIO_EXTRA_MODULES", TOP_BUILDDIR "/tls/gnutls/.libs", TRUE);
-  g_setenv ("GIO_USE_TLS", "gnutls", TRUE);
+  g_setenv ("GIO_EXTRA_MODULES", TOP_BUILDDIR "/tls/" BACKEND "/.libs", TRUE);
+  g_setenv ("GIO_USE_TLS", BACKEND, TRUE);
+  g_assert (g_ascii_strcasecmp (G_OBJECT_TYPE_NAME (g_tls_backend_get_default ()), "GTlsBackend" BACKEND) == 
0);
 
   g_test_add_func ("/tls/backend/default-database-is-singleton",
                    test_default_database_is_singleton);


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