[libsoup/wip/ci-pkcs11] WIP




commit f49ff6e4b5c808d50699a219aeca0d53b123073a
Author: Patrick Griffis <pgriffis igalia com>
Date:   Sat May 1 18:58:21 2021 -0500

    WIP

 tests/ssl-test.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
---
diff --git a/tests/ssl-test.c b/tests/ssl-test.c
index 4f1828c6..e3a00f92 100644
--- a/tests/ssl-test.c
+++ b/tests/ssl-test.c
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
 
 #include "test-utils.h"
+#include "soup-connection.h"
+#include "soup-message-private.h"
 #include "soup-server-message-private.h"
 
 #if HAVE_GNUTLS
@@ -298,6 +300,32 @@ request_certificate_password_async_cb (SoupMessage  *msg,
         return TRUE;
 }
 
+static void
+run_loop_until_connection_destroyed (SoupMessage *msg)
+{
+        SoupConnection *conn = soup_message_get_connection (msg);
+        GSocket *socket;
+        GWeakRef socket_ref;
+        GObject *object;
+
+        if (!conn)
+                return;
+
+        /* The mock pkcs11 module only supports one session at a time so
+         * this will ensure the GTlsClientConnection is fully closed before
+         * continuing. */
+
+        socket = soup_connection_get_socket (conn);
+        g_weak_ref_init (&socket_ref, socket);
+
+        while ((object = g_weak_ref_get (&socket_ref))) {
+                g_object_unref (object);
+                g_main_context_iteration (g_main_context_default (), FALSE);
+        }
+
+        g_weak_ref_clear (&socket_ref);
+}
+
 static void
 do_tls_interaction_msg_test (gconstpointer data)
 {
@@ -423,6 +451,7 @@ do_tls_interaction_msg_test (gconstpointer data)
         g_assert_no_error (error);
         g_clear_error (&error);
         g_bytes_unref (body);
+        run_loop_until_connection_destroyed (msg);
         g_object_unref (msg);
 
         /* Handling the request-certificate-password signal asynchronously */
@@ -438,6 +467,7 @@ do_tls_interaction_msg_test (gconstpointer data)
         g_assert_no_error (error);
         g_clear_error (&error);
         g_bytes_unref (body);
+        run_loop_until_connection_destroyed (msg);
         g_object_unref (msg);
 
         g_signal_handlers_disconnect_by_data (server, tls_db);


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