summaryrefslogtreecommitdiff
path: root/gck
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2013-08-17 10:49:24 +0200
committerStef Walter <stefw@gnome.org>2013-08-17 10:49:24 +0200
commitdd6aba8b94f90265124b0b11e279677769906bb1 (patch)
tree537138352db86c2164a1f4461946c8817ce806be /gck
parent7924b75e10aa6f8d627f20a8368cb711e54f777e (diff)
downloadgcr-dd6aba8b94f90265124b0b11e279677769906bb1.tar.gz
More reliable means of checking if object was finalized
Don't try to use G_IS_OBJECT() to see if an object was finalized as this segfaults in corner cases, even with our crafty check for a pointer within our memory space. https://bugzilla.gnome.org/show_bug.cgi?id=705139
Diffstat (limited to 'gck')
-rw-r--r--gck/tests/test-gck-crypto.c15
-rw-r--r--gck/tests/test-gck-enumerator.c18
-rw-r--r--gck/tests/test-gck-module.c3
-rw-r--r--gck/tests/test-gck-session.c15
4 files changed, 34 insertions, 17 deletions
diff --git a/gck/tests/test-gck-crypto.c b/gck/tests/test-gck-crypto.c
index c70a765..492ad06 100644
--- a/gck/tests/test-gck-crypto.c
+++ b/gck/tests/test-gck-crypto.c
@@ -60,6 +60,7 @@ setup (Test *test, gconstpointer unused)
test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
g_assert_no_error (err);
g_assert (GCK_IS_MODULE (test->module));
+ g_object_add_weak_pointer (G_OBJECT (test->module), (gpointer *)&test->module);
slots = gck_module_get_slots (test->module, TRUE);
g_assert (slots != NULL);
@@ -67,6 +68,7 @@ setup (Test *test, gconstpointer unused)
test->session = gck_slot_open_session (slots->data, 0, NULL, &err);
g_assert_no_error (err);
g_assert (GCK_IS_SESSION (test->session));
+ g_object_add_weak_pointer (G_OBJECT (test->session), (gpointer *)&test->session);
slot = gck_session_get_slot (test->session);
g_assert (slot);
@@ -74,6 +76,7 @@ setup (Test *test, gconstpointer unused)
test->session_with_auth = gck_session_from_handle (slot, gck_session_get_handle (test->session), GCK_SESSION_AUTHENTICATE);
g_signal_connect (test->session_with_auth, "discard-handle", G_CALLBACK (on_discard_handle_ignore), NULL);
g_assert (test->session_with_auth);
+ g_object_add_weak_pointer (G_OBJECT (test->session_with_auth), (gpointer *)&test->session_with_auth);
g_object_unref (slot);
gck_list_unref_free (slots);
@@ -86,9 +89,9 @@ teardown (Test *test, gconstpointer unused)
g_object_unref (test->module);
g_object_unref (test->session_with_auth);
- egg_assert_not_object (test->session);
- egg_assert_not_object (test->session_with_auth);
- egg_assert_not_object (test->module);
+ g_assert (test->session == NULL);
+ g_assert (test->session_with_auth == NULL);
+ g_assert (test->module == NULL);
}
static void
@@ -280,6 +283,7 @@ test_login_context_specific (Test *test, gconstpointer unused)
/* Find the right key */
key = find_key (test->session, CKA_SIGN, CKM_MOCK_PREFIX);
g_assert (GCK_IS_OBJECT (key));
+ g_object_add_weak_pointer (G_OBJECT (key), (gpointer *)&key);
/* Simple one */
output = gck_session_sign (test->session, key, CKM_MOCK_PREFIX, (const guchar*)"TV Monster", 11, &n_output, NULL, &error);
@@ -288,7 +292,7 @@ test_login_context_specific (Test *test, gconstpointer unused)
g_error_free (error);
g_object_unref (key);
- egg_assert_not_object (key);
+ g_assert (key == NULL);
}
static void
@@ -349,6 +353,7 @@ test_verify (Test *test, gconstpointer unused)
/* Find the right key */
key = find_key (test->session, CKA_VERIFY, CKM_MOCK_PREFIX);
g_assert (GCK_IS_OBJECT (key));
+ g_object_add_weak_pointer (G_OBJECT (key), (gpointer *)&key);
/* Simple one */
ret = gck_session_verify (test->session, key, CKM_MOCK_PREFIX, (const guchar*)"Labarbara", 10,
@@ -386,7 +391,7 @@ test_verify (Test *test, gconstpointer unused)
g_object_unref (result);
g_object_unref (key);
- egg_assert_not_object (key);
+ g_assert (key == NULL);
}
static void
diff --git a/gck/tests/test-gck-enumerator.c b/gck/tests/test-gck-enumerator.c
index bbbea5f..25197f5 100644
--- a/gck/tests/test-gck-enumerator.c
+++ b/gck/tests/test-gck-enumerator.c
@@ -53,6 +53,7 @@ setup (Test *test, gconstpointer unused)
test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
g_assert_no_error (err);
g_assert (GCK_IS_MODULE (test->module));
+ g_object_add_weak_pointer (G_OBJECT (test->module), (gpointer *)&test->module);
test->modules = g_list_append (NULL, g_object_ref (test->module));
}
@@ -63,7 +64,7 @@ teardown (Test *test, gconstpointer unused)
gck_list_unref_free (test->modules);
g_object_unref (test->module);
- egg_assert_not_object (test->module);
+ g_assert (test->module == NULL);
g_thread_pool_stop_unused_threads ();
}
@@ -294,8 +295,10 @@ test_authenticate_interaction (Test *test,
uri_data = gck_uri_data_new ();
en = _gck_enumerator_new_for_modules (test->modules, GCK_SESSION_LOGIN_USER, uri_data);
g_assert (GCK_IS_ENUMERATOR (en));
+ g_object_add_weak_pointer (G_OBJECT (en), (gpointer *)&en);
interaction = mock_interaction_new ("booo");
+ g_object_add_weak_pointer (G_OBJECT (interaction), (gpointer *)&interaction);
g_object_set (en, "interaction", interaction, NULL);
check = NULL;
@@ -306,13 +309,14 @@ test_authenticate_interaction (Test *test,
obj = gck_enumerator_next (en, NULL, &error);
g_assert (GCK_IS_OBJECT (obj));
+ g_object_add_weak_pointer (G_OBJECT (obj), (gpointer *)&obj);
g_object_unref (obj);
g_object_unref (en);
- egg_assert_not_object (en);
- egg_assert_not_object (obj);
- egg_assert_not_object (interaction);
+ g_assert (en == NULL);
+ g_assert (obj == NULL);
+ g_assert (interaction == NULL);
}
static gboolean
@@ -348,17 +352,19 @@ test_authenticate_compat (Test *test,
uri_data = gck_uri_data_new ();
en = _gck_enumerator_new_for_modules (test->modules, GCK_SESSION_LOGIN_USER, uri_data);
g_assert (GCK_IS_ENUMERATOR (en));
+ g_object_add_weak_pointer (G_OBJECT (en), (gpointer *)&en);
obj = gck_enumerator_next (en, NULL, &error);
g_assert (GCK_IS_OBJECT (obj));
+ g_object_add_weak_pointer (G_OBJECT (obj), (gpointer *)&obj);
g_object_unref (obj);
g_object_unref (en);
g_signal_handler_disconnect (test->modules->data, sig);
- egg_assert_not_object (obj);
- egg_assert_not_object (en);
+ g_assert (obj == NULL);
+ g_assert (en == NULL);
}
static void
diff --git a/gck/tests/test-gck-module.c b/gck/tests/test-gck-module.c
index 99d2d61..10c7606 100644
--- a/gck/tests/test-gck-module.c
+++ b/gck/tests/test-gck-module.c
@@ -45,13 +45,14 @@ setup (Test *test, gconstpointer unused)
test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
g_assert_no_error (err);
g_assert (test->module);
+ g_object_add_weak_pointer (G_OBJECT (test->module), (gpointer *)&test->module);
}
static void
teardown (Test *test, gconstpointer unused)
{
g_object_unref (test->module);
- egg_assert_not_object (test->module);
+ g_assert (test->module == NULL);
}
static void
diff --git a/gck/tests/test-gck-session.c b/gck/tests/test-gck-session.c
index f23a832..1bd2569 100644
--- a/gck/tests/test-gck-session.c
+++ b/gck/tests/test-gck-session.c
@@ -53,6 +53,7 @@ setup (Test *test, gconstpointer unused)
test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
g_assert_no_error (err);
g_assert (GCK_IS_MODULE (test->module));
+ g_object_add_weak_pointer (G_OBJECT (test->module), (gpointer *)&test->module);
slots = gck_module_get_slots (test->module, TRUE);
g_assert (slots != NULL);
@@ -60,10 +61,12 @@ setup (Test *test, gconstpointer unused)
test->slot = GCK_SLOT (slots->data);
g_object_ref (test->slot);
gck_list_unref_free (slots);
+ g_object_add_weak_pointer (G_OBJECT (test->slot), (gpointer *)&test->slot);
test->session = gck_slot_open_session (test->slot, 0, NULL, &err);
g_assert_no_error (err);
g_assert (GCK_IS_SESSION (test->session));
+ g_object_add_weak_pointer (G_OBJECT (test->session), (gpointer *)&test->session);
}
static void
@@ -73,9 +76,9 @@ teardown (Test *test, gconstpointer unused)
g_object_unref (test->slot);
g_object_unref (test->module);
- egg_assert_not_object (test->session);
- egg_assert_not_object (test->slot);
- egg_assert_not_object (test->module);
+ g_assert (test->session == NULL);
+ g_assert (test->slot == NULL);
+ g_assert (test->module == NULL);
}
static void
@@ -137,15 +140,17 @@ test_open_close_session (Test *test, gconstpointer unused)
g_assert (result != NULL);
/* Get the result */
+ g_object_add_weak_pointer (G_OBJECT (result), (gpointer *)&result);
sess = gck_slot_open_session_finish (test->slot, result, &err);
g_assert_no_error (err);
g_assert (GCK_IS_SESSION (sess));
+ g_object_add_weak_pointer (G_OBJECT (sess), (gpointer *)&sess);
g_object_unref (result);
- egg_assert_not_object (result);
+ g_assert (result == NULL);
g_object_unref (sess);
- egg_assert_not_object (sess);
+ g_assert (sess == NULL);
}
static void