[gnome-keyring/trust-store] [testing] Ignore g_message and g_debug messages in tests.



commit 85a7c816f8fca1457ed013d0ed5aadcebe10c516
Author: Stef Walter <stefw collabora co uk>
Date:   Wed Nov 24 20:30:02 2010 +0000

    [testing] Ignore g_message and g_debug messages in tests.

 pkcs11/xdg-store/gkm-xdg-module.c        |    5 +++--
 pkcs11/xdg-store/tests/test-xdg-module.c |   12 ++++++++++++
 testing/testing.c                        |   11 +++++++++++
 3 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/pkcs11/xdg-store/gkm-xdg-module.c b/pkcs11/xdg-store/gkm-xdg-module.c
index 79c8a58..5d7fe6c 100644
--- a/pkcs11/xdg-store/gkm-xdg-module.c
+++ b/pkcs11/xdg-store/gkm-xdg-module.c
@@ -103,8 +103,9 @@ type_from_path (const gchar *path)
 	const gchar *ext;
 
 	ext = strrchr (path, '.');
-	if (ext == NULL)
-		return 0;
+
+	/* The file tracker doesn't match files without exts */
+	g_return_val_if_fail (ext, 0);
 
 	if (g_str_equal (ext, ".trust"))
 		return GKM_XDG_TYPE_TRUST;
diff --git a/pkcs11/xdg-store/tests/test-xdg-module.c b/pkcs11/xdg-store/tests/test-xdg-module.c
index 1e8e0a7..4cc3335 100644
--- a/pkcs11/xdg-store/tests/test-xdg-module.c
+++ b/pkcs11/xdg-store/tests/test-xdg-module.c
@@ -56,6 +56,16 @@ copy_scratch_file (const gchar *basename)
 	g_free (data);
 }
 
+static void
+empty_scratch_file (const gchar *basename)
+{
+	gchar *filename;
+	filename = testing_scratch_filename (basename);
+	if (!g_file_set_contents (filename, "", 0, NULL))
+		g_return_if_reached ();
+	g_free (filename);
+}
+
 GkmModule*
 test_xdg_module_initialize_and_enter (void)
 {
@@ -73,6 +83,8 @@ test_xdg_module_initialize_and_enter (void)
 
 	/* Copy files from test-data to scratch */
 	copy_scratch_file ("test-refer-1.trust");
+	empty_scratch_file ("invalid-without-ext");
+	empty_scratch_file ("test-file.unknown");
 
 	funcs = gkm_xdg_store_get_functions ();
 	rv = (funcs->C_Initialize) (&args);
diff --git a/testing/testing.c b/testing/testing.c
index 119b8d2..d4a5463 100644
--- a/testing/testing.c
+++ b/testing/testing.c
@@ -271,6 +271,13 @@ testing_thread (gpointer loop)
 	return GINT_TO_POINTER (ret);
 }
 
+static void
+null_log_handler (const gchar *log_domain, GLogLevelFlags log_level,
+                  const gchar *message, gpointer user_data)
+{
+
+}
+
 int
 main (int argc, char* argv[])
 {
@@ -302,6 +309,10 @@ main (int argc, char* argv[])
 	fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
 	g_log_set_always_fatal (fatal_mask);
 
+	/* Suppress these messages in tests */
+	g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG,
+	                   null_log_handler, NULL);
+
 	thread = g_thread_create (testing_thread, loop, TRUE, NULL);
 	g_assert (thread);
 



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