[glib-networking/wip/tingping/pkcs11-spy] tests: Add more verbose PKCS11 logging with pkcs11-spy



commit 5c7a02f7f9fdfb02f6d56cda5ffbb515774f6e4a
Author: Patrick Griffis <tingping tingping se>
Date:   Wed Nov 20 14:16:27 2019 -0800

    tests: Add more verbose PKCS11 logging with pkcs11-spy

 tls/tests/connection.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
---
diff --git a/tls/tests/connection.c b/tls/tests/connection.c
index 5c02932..adea183 100644
--- a/tls/tests/connection.c
+++ b/tls/tests/connection.c
@@ -2532,6 +2532,7 @@ main (int   argc,
   int ret;
 #ifdef BACKEND_IS_GNUTLS
   char *module_path;
+  const char *spy_path;
 #endif
 
   g_test_init (&argc, &argv, NULL);
@@ -2544,6 +2545,24 @@ main (int   argc,
 
 #ifdef BACKEND_IS_GNUTLS
   module_path = g_build_filename (g_getenv ("G_TEST_BUILDDIR"), "mock-pkcs11.so", NULL);
+
+  /* This just adds extra logging which is useful for debugging */
+  spy_path = g_getenv ("PKCS11SPY_PATH");
+  if (!spy_path)
+    {
+      spy_path = "/usr/lib64/pkcs11-spy.so"; /* Fedora's path */
+      if (!g_file_test (spy_path, G_FILE_TEST_EXISTS))
+        spy_path = "/usr/lib/x86_64-linux-gnu/pkcs11-spy.so"; /* Debian/Ubuntu's path */
+    }
+
+  if (g_file_test (spy_path, G_FILE_TEST_EXISTS))
+    {
+      g_debug ("Using PKCS #11 Spy");
+      g_setenv ("PKCS11SPY", module_path, TRUE);
+      g_free (module_path);
+      module_path = g_strdup (spy_path);
+    }
+
   ret = gnutls_pkcs11_init (GNUTLS_PKCS11_FLAG_MANUAL, NULL);
   g_assert_cmpint (ret, ==, GNUTLS_E_SUCCESS);
   ret = gnutls_pkcs11_add_provider (module_path, NULL);


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