[gnome-keyring/gnome-3-0] Modernise the gck tests.



commit 2649d459708c6177ffd2f67444dd4f8e70ed812e
Author: Stef Walter <stefw collabora co uk>
Date:   Wed Mar 23 09:27:13 2011 +0100

    Modernise the gck tests.

 .gitignore                      |   11 ++
 egg/Makefile.am                 |   12 ++-
 gck/tests/Makefile.am           |   51 +++---
 gck/tests/test-gck-attributes.c |  148 ++++++++++++---
 gck/tests/test-gck-crypto.c     |  375 ++++++++++++++++++++++++---------------
 gck/tests/test-gck-enumerator.c |  151 ++++++++++++-----
 gck/tests/test-gck-module.c     |  169 ++++++++----------
 gck/tests/test-gck-modules.c    |  130 +++++++++++---
 gck/tests/test-gck-object.c     |  323 ++++++++++++++++++++--------------
 gck/tests/test-gck-session.c    |  230 ++++++++++++++++--------
 gck/tests/test-gck-slot.c       |  137 ++++++++++----
 gck/tests/test-gck-uri.c        |  148 ++++++++++++----
 gck/tests/test-gck.h            |   43 -----
 13 files changed, 1240 insertions(+), 688 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index d9b1480..f021b6f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -92,6 +92,17 @@ run-tests
 /egg/tests/test-spawn
 /egg/tests/test-symkey
 
+/gck/tests/test-gck-attributes
+/gck/tests/test-gck-crypto
+/gck/tests/test-gck-enumerator
+/gck/tests/test-gck-module
+/gck/tests/test-gck-modules
+/gck/tests/test-gck-object
+/gck/tests/test-gck-session
+/gck/tests/test-gck-slot
+/gck/tests/test-gck-uri
+
+
 /daemon/dbus/tests/test-secret-util
 
 /ui/gnome-keyring-prompt.desktop
diff --git a/egg/Makefile.am b/egg/Makefile.am
index 3d8e149..00799e3 100644
--- a/egg/Makefile.am
+++ b/egg/Makefile.am
@@ -8,7 +8,8 @@ noinst_LTLIBRARIES = \
 	libegg-secure.la \
 	libegg-prompt.la \
 	libegg-entry-buffer.la \
-	libegg-hex.la
+	libegg-hex.la \
+	libegg-test.la
 
 BUILT_SOURCES = \
 	asn1-def-pk.c asn1-def-pkix.c
@@ -122,6 +123,15 @@ libegg_hex_la_CFLAGS = \
 libegg_hex_la_LIBS = \
 	$(GLIB_LIBS)
 
+libegg_test_la_SOURCES = \
+	egg-testing.c egg-testing.h
+
+libegg_test_la_CFLAGS = \
+	$(GLIB_CFLAGS)
+
+libegg_test_la_LIBS = \
+	$(GLIB_LIBS)
+
 # -------------------------------------------------------------------
 
 if WITH_TESTS
diff --git a/gck/tests/Makefile.am b/gck/tests/Makefile.am
index af69779..50b22cf 100644
--- a/gck/tests/Makefile.am
+++ b/gck/tests/Makefile.am
@@ -1,32 +1,39 @@
 
-# Keep these in the order they should be tested
-TESTING_FILES = \
-	test-gck-attributes.c \
-	test-gck-module.c \
-	test-gck-slot.c \
-	test-gck-session.c \
-	test-gck-object.c \
-	test-gck-crypto.c \
-	test-gck-uri.c \
-	test-gck-enumerator.c \
-	test-gck-modules.c
-
-TESTING_FLAGS = \
-	-I$(top_srcdir)/gck/ \
-	-DEXTERNAL_TEST \
-	-DGCK_API_SUBJECT_TO_CHANGE
+INCLUDES = \
+	-I$(top_srcdir)/egg \
+	-DSRCDIR=$(srcdir) \
+	-DGCK_API_SUBJECT_TO_CHANGE \
+	$(GLIB_CFLAGS)
 
-TESTING_LIBS = \
-	$(GIO_LIBS) \
+LDADD =  \
 	$(top_builddir)/gck/libgck.la \
+	$(top_builddir)/egg/libegg-test.la \
+	$(GTHREAD_LIBS) \
+	$(GLIB_LIBS)
+	$(GIO_LIBS) \
 	libmock-test-module.la
 
-include $(top_srcdir)/testing/testing.make
+TEST_PROGS = \
+	test-gck-attributes \
+	test-gck-module \
+	test-gck-slot \
+	test-gck-session \
+	test-gck-object \
+	test-gck-crypto \
+	test-gck-uri \
+	test-gck-enumerator \
+	test-gck-modules
+
+check_PROGRAMS = $(TEST_PROGS)
+
+test: $(TEST_PROGS)
+	SRCDIR='$(srcdir)' gtester -k --verbose ${TEST_PROGS}
 
-EXTRA_DIST += \
-	test-gck.h
+check-local: test
 
-# ------------------------------------------------------------------------
+if WITH_TESTS
+all-local: $(check_PROGRAMS)
+endif
 
 lib_LTLIBRARIES = libmock-test-module.la
 
diff --git a/gck/tests/test-gck-attributes.c b/gck/tests/test-gck-attributes.c
index 020f224..62a866b 100644
--- a/gck/tests/test-gck-attributes.c
+++ b/gck/tests/test-gck-attributes.c
@@ -1,15 +1,39 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* test-gck-attributes.c - the GObject PKCS#11 wrapper library
+
+   Copyright (C) 2011 Collabora Ltd.
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Stef Walter <stefw collabora co uk>
+*/
+
+#include "config.h"
 
 #include <glib.h>
 #include <string.h>
 
-#include "test-suite.h"
-#include "gck-test.h"
+#include "gck/gck.h"
 
 #define ATTR_TYPE 55
 #define ATTR_DATA "TEST DATA"
 #define N_ATTR_DATA ((gsize)9)
 
-TESTING_TEST(init_memory)
+static void
+test_init_memory (void)
 {
 	GckAttribute attr;
 
@@ -23,7 +47,8 @@ TESTING_TEST(init_memory)
 	gck_attribute_clear (&attr);
 }
 
-TESTING_TEST(value_to_boolean)
+static void
+test_value_to_boolean (void)
 {
 	CK_BBOOL data = CK_TRUE;
 	gboolean result = FALSE;
@@ -45,7 +70,8 @@ TESTING_TEST(value_to_boolean)
 		g_assert_not_reached ();
 }
 
-TESTING_TEST(value_to_ulong)
+static void
+test_value_to_ulong (void)
 {
 	CK_ULONG data = 34343;
 	gulong result = 0;
@@ -67,7 +93,8 @@ TESTING_TEST(value_to_ulong)
 		g_assert_not_reached ();
 }
 
-TESTING_TEST(init_boolean)
+static void
+test_init_boolean (void)
 {
 	GckAttribute attr;
 
@@ -79,7 +106,8 @@ TESTING_TEST(init_boolean)
 	gck_attribute_clear (&attr);
 }
 
-TESTING_TEST(init_date)
+static void
+test_init_date (void)
 {
 	GckAttribute attr;
 	CK_DATE ck_date;
@@ -98,7 +126,8 @@ TESTING_TEST(init_date)
 	gck_attribute_clear (&attr);
 }
 
-TESTING_TEST(init_ulong)
+static void
+test_init_ulong (void)
 {
 	GckAttribute attr;
 
@@ -110,7 +139,8 @@ TESTING_TEST(init_ulong)
 	gck_attribute_clear (&attr);
 }
 
-TESTING_TEST(init_string)
+static void
+test_init_string (void)
 {
 	GckAttribute attr;
 
@@ -122,7 +152,8 @@ TESTING_TEST(init_string)
 	gck_attribute_clear (&attr);
 }
 
-TESTING_TEST(init_invalid)
+static void
+test_init_invalid (void)
 {
 	GckAttribute attr;
 
@@ -135,7 +166,8 @@ TESTING_TEST(init_invalid)
 	gck_attribute_clear (&attr);
 }
 
-TESTING_TEST(init_empty)
+static void
+test_init_empty (void)
 {
 	GckAttribute attr;
 
@@ -147,7 +179,8 @@ TESTING_TEST(init_empty)
 	gck_attribute_clear (&attr);
 }
 
-TESTING_TEST(new_memory)
+static void
+test_new_memory (void)
 {
 	GckAttribute *attr;
 
@@ -159,7 +192,8 @@ TESTING_TEST(new_memory)
 	gck_attribute_free (attr);
 }
 
-TESTING_TEST(new_boolean)
+static void
+test_new_boolean (void)
 {
 	GckAttribute *attr;
 
@@ -171,7 +205,8 @@ TESTING_TEST(new_boolean)
 	gck_attribute_free (attr);
 }
 
-TESTING_TEST(new_date)
+static void
+test_new_date (void)
 {
 	GckAttribute *attr;
 	CK_DATE ck_date;
@@ -190,7 +225,8 @@ TESTING_TEST(new_date)
 	gck_attribute_free (attr);
 }
 
-TESTING_TEST(new_ulong)
+static void
+test_new_ulong (void)
 {
 	GckAttribute *attr;
 
@@ -202,7 +238,8 @@ TESTING_TEST(new_ulong)
 	gck_attribute_free (attr);
 }
 
-TESTING_TEST(new_string)
+static void
+test_new_string (void)
 {
 	GckAttribute *attr;
 
@@ -214,7 +251,8 @@ TESTING_TEST(new_string)
 	gck_attribute_free (attr);
 }
 
-TESTING_TEST(new_invalid)
+static void
+test_new_invalid (void)
 {
 	GckAttribute *attr;
 
@@ -228,7 +266,8 @@ TESTING_TEST(new_invalid)
 	gck_attribute_free (attr);
 }
 
-TESTING_TEST(new_empty)
+static void
+test_new_empty (void)
 {
 	GckAttribute *attr;
 
@@ -240,7 +279,8 @@ TESTING_TEST(new_empty)
 	gck_attribute_free (attr);
 }
 
-TESTING_TEST(get_boolean)
+static void
+test_get_boolean (void)
 {
 	GckAttribute *attr;
 
@@ -249,7 +289,8 @@ TESTING_TEST(get_boolean)
 	gck_attribute_free (attr);
 }
 
-TESTING_TEST(get_date)
+static void
+test_get_date (void)
 {
 	GckAttribute *attr;
 	CK_DATE ck_date;
@@ -265,7 +306,8 @@ TESTING_TEST(get_date)
 	gck_attribute_free (attr);
 }
 
-TESTING_TEST(get_ulong)
+static void
+test_get_ulong (void)
 {
 	GckAttribute *attr;
 
@@ -274,7 +316,8 @@ TESTING_TEST(get_ulong)
 	gck_attribute_free (attr);
 }
 
-TESTING_TEST(get_string)
+static void
+test_get_string (void)
 {
 	GckAttribute *attr;
 	gchar *value;
@@ -292,7 +335,8 @@ TESTING_TEST(get_string)
 	gck_attribute_free (attr);
 }
 
-TESTING_TEST(dup_attribute)
+static void
+test_dup_attribute (void)
 {
 	GckAttribute attr, *dup;
 
@@ -308,7 +352,8 @@ TESTING_TEST(dup_attribute)
 	g_assert (dup == NULL);
 }
 
-TESTING_TEST(copy_attribute)
+static void
+test_copy_attribute (void)
 {
 	GckAttribute attr, copy;
 
@@ -320,7 +365,8 @@ TESTING_TEST(copy_attribute)
 	gck_attribute_clear (&copy);
 }
 
-TESTING_TEST(new_attributes)
+static void
+test_new_attributes (void)
 {
 	GckAttributes *attrs;
 
@@ -390,7 +436,8 @@ test_attributes_contents (GckAttributes *attrs, gboolean extras)
 	g_assert (attr->value == NULL);
 }
 
-TESTING_TEST(new_empty_attributes)
+static void
+test_new_empty_attributes (void)
 {
 	GckAttributes *attrs = gck_attributes_new_empty (101UL, 202UL, 303UL, 404UL, GCK_INVALID);
 	GckAttribute *attr;
@@ -405,7 +452,8 @@ TESTING_TEST(new_empty_attributes)
 	}
 }
 
-TESTING_TEST(add_data_attributes)
+static void
+test_add_data_attributes (void)
 {
 	GckAttributes *attrs;
 	GDate *date = g_date_new_dmy (11, 12, 2008);
@@ -422,7 +470,8 @@ TESTING_TEST(add_data_attributes)
 	gck_attributes_unref (attrs);
 }
 
-TESTING_TEST(add_attributes)
+static void
+test_add_attributes (void)
 {
 	GckAttributes *attrs;
 	GckAttribute attr;
@@ -462,7 +511,8 @@ TESTING_TEST(add_attributes)
 	gck_attributes_unref (attrs);
 }
 
-TESTING_TEST(add_all_attributes)
+static void
+test_add_all_attributes (void)
 {
 	GckAttributes *attrs;
 	GckAttributes *copy;
@@ -486,7 +536,8 @@ TESTING_TEST(add_all_attributes)
 }
 
 
-TESTING_TEST(find_attributes)
+static void
+test_find_attributes (void)
 {
 	GckAttribute *attr;
 	GDate check, *date = g_date_new_dmy (13, 12, 2008);
@@ -527,3 +578,40 @@ TESTING_TEST(find_attributes)
 	gck_attributes_unref (attrs);
 	g_date_free (date);
 }
+
+int
+main (int argc, char **argv)
+{
+	g_test_init (&argc, &argv, NULL);
+
+	g_test_add_func ("/gck/attributes/init_memory", test_init_memory);
+	g_test_add_func ("/gck/attributes/value_to_boolean", test_value_to_boolean);
+	g_test_add_func ("/gck/attributes/value_to_ulong", test_value_to_ulong);
+	g_test_add_func ("/gck/attributes/init_boolean", test_init_boolean);
+	g_test_add_func ("/gck/attributes/init_date", test_init_date);
+	g_test_add_func ("/gck/attributes/init_ulong", test_init_ulong);
+	g_test_add_func ("/gck/attributes/init_string", test_init_string);
+	g_test_add_func ("/gck/attributes/init_invalid", test_init_invalid);
+	g_test_add_func ("/gck/attributes/init_empty", test_init_empty);
+	g_test_add_func ("/gck/attributes/new_memory", test_new_memory);
+	g_test_add_func ("/gck/attributes/new_boolean", test_new_boolean);
+	g_test_add_func ("/gck/attributes/new_date", test_new_date);
+	g_test_add_func ("/gck/attributes/new_ulong", test_new_ulong);
+	g_test_add_func ("/gck/attributes/new_string", test_new_string);
+	g_test_add_func ("/gck/attributes/new_invalid", test_new_invalid);
+	g_test_add_func ("/gck/attributes/new_empty", test_new_empty);
+	g_test_add_func ("/gck/attributes/get_boolean", test_get_boolean);
+	g_test_add_func ("/gck/attributes/get_date", test_get_date);
+	g_test_add_func ("/gck/attributes/get_ulong", test_get_ulong);
+	g_test_add_func ("/gck/attributes/get_string", test_get_string);
+	g_test_add_func ("/gck/attributes/dup_attribute", test_dup_attribute);
+	g_test_add_func ("/gck/attributes/copy_attribute", test_copy_attribute);
+	g_test_add_func ("/gck/attributes/new_attributes", test_new_attributes);
+	g_test_add_func ("/gck/attributes/new_empty_attributes", test_new_empty_attributes);
+	g_test_add_func ("/gck/attributes/add_data_attributes", test_add_data_attributes);
+	g_test_add_func ("/gck/attributes/add_attributes", test_add_attributes);
+	g_test_add_func ("/gck/attributes/add_all_attributes", test_add_all_attributes);
+	g_test_add_func ("/gck/attributes/find_attributes", test_find_attributes);
+
+	return g_test_run ();
+}
diff --git a/gck/tests/test-gck-crypto.c b/gck/tests/test-gck-crypto.c
index abcf159..d6dfc9e 100644
--- a/gck/tests/test-gck-crypto.c
+++ b/gck/tests/test-gck-crypto.c
@@ -1,18 +1,46 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* test-gck-crypto.c - the GObject PKCS#11 wrapper library
+
+   Copyright (C) 2011 Collabora Ltd.
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Stef Walter <stefw collabora co uk>
+*/
+
+#include "config.h"
 
-#include "test-suite.h"
+#include "gck/gck.h"
+#include "gck/gck-mock.h"
+#include "gck/gck-test.h"
+
+#include "egg/egg-testing.h"
 
 #include <glib.h>
 
-#include "gck-test.h"
-#include "gck-mock.h"
-#include "test-gck.h"
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
 
-static GckModule *module = NULL;
-static GckSession *session = NULL;
-static GckSession *session_with_auth = NULL;
+typedef struct {
+	GckModule *module;
+	GckSession *session;
+	GckSession *session_with_auth;
+} Test;
 
 static gboolean
 on_discard_handle_ignore (GckSession *self, CK_OBJECT_HANDLE handle, gpointer unused)
@@ -21,38 +49,42 @@ on_discard_handle_ignore (GckSession *self, CK_OBJECT_HANDLE handle, gpointer un
 	return TRUE;
 }
 
-TESTING_SETUP(crypto_session)
+static void
+setup (Test *test, gconstpointer unused)
 {
 	GError *err = NULL;
 	GList *slots;
 	GckSlot *slot;
 
 	/* Successful load */
-	module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
-	SUCCESS_RES (module, err);
+	test->module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_MODULE (test->module));
 
-	slots = gck_module_get_slots (module, TRUE);
+	slots = gck_module_get_slots (test->module, TRUE);
 	g_assert (slots != NULL);
 
-	session = gck_slot_open_session (slots->data, 0, NULL, &err);
-	SUCCESS_RES(session, err);
+	test->session = gck_slot_open_session (slots->data, 0, NULL, &err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_SESSION (test->session));
 
-	slot = gck_session_get_slot (session);
+	slot = gck_session_get_slot (test->session);
 	g_assert (slot);
 
-	session_with_auth = gck_session_from_handle (slot, gck_session_get_handle (session), GCK_SESSION_AUTHENTICATE);
-	g_signal_connect (session_with_auth, "discard-handle", G_CALLBACK (on_discard_handle_ignore), NULL);
-	g_assert (session_with_auth);
+	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_unref (slot);
 	gck_list_unref_free (slots);
 }
 
-TESTING_TEARDOWN(crypto_session)
+static void
+teardown (Test *test, gconstpointer unused)
 {
-	g_object_unref (session);
-	g_object_unref (module);
-	g_object_unref (session_with_auth);
+	g_object_unref (test->session);
+	g_object_unref (test->module);
+	g_object_unref (test->session_with_auth);
 }
 
 static void
@@ -60,7 +92,7 @@ fetch_async_result (GObject *source, GAsyncResult *result, gpointer user_data)
 {
 	*((GAsyncResult**)user_data) = result;
 	g_object_ref (result);
-	testing_wait_stop ();
+	egg_test_wait_stop ();
 }
 
 static GckObject*
@@ -131,7 +163,7 @@ check_key_with_value (GckSession *session, GckObject *key, CK_OBJECT_CLASS klass
 	attr = gck_attributes_find (attrs, CKA_VALUE);
 	g_assert (attr);
 	g_assert (!gck_attribute_is_invalid (attr));
-	g_assert_cmpsize (attr->length, ==, strlen (value));
+	egg_assert_cmpsize (attr->length, ==, strlen (value));
 	g_assert (memcmp (attr->value, value, attr->length) == 0);
 
 	gck_attributes_unref (attrs);
@@ -149,7 +181,8 @@ authenticate_object (GckSlot *module, GckObject *object, gchar *label, gchar **p
 	return TRUE;
 }
 
-TESTING_TEST(encrypt)
+static void
+test_encrypt (Test *test, gconstpointer unused)
 {
 	GckMechanism mech = { CKM_MOCK_CAPITALIZE, NULL, 0 };
 	GError *error = NULL;
@@ -159,25 +192,27 @@ TESTING_TEST(encrypt)
 	gsize n_output;
 
 	/* Find the right key */
-	key = find_key (session, CKA_ENCRYPT, CKM_MOCK_CAPITALIZE);
+	key = find_key (test->session, CKA_ENCRYPT, CKM_MOCK_CAPITALIZE);
 	g_assert (key);
 
 	/* Simple one */
-	output = gck_session_encrypt (session, key, CKM_MOCK_CAPITALIZE, (const guchar*)"blah blah", 10, &n_output, NULL, &error);
-	SUCCESS_RES (output, error);
+	output = gck_session_encrypt (test->session, key, CKM_MOCK_CAPITALIZE, (const guchar*)"blah blah", 10, &n_output, NULL, &error);
+	g_assert_no_error (error);
+	g_assert (output);
 	g_assert (n_output == 10);
 	g_assert_cmpstr ((gchar*)output, ==, "BLAH BLAH");
 	g_free (output);
 
 	/* Asynchronous one */
-	gck_session_encrypt_async (session, key, &mech, (const guchar*)"second chance", 14, NULL, fetch_async_result, &result);
+	gck_session_encrypt_async (test->session, key, &mech, (const guchar*)"second chance", 14, NULL, fetch_async_result, &result);
 
-	testing_wait_until (500);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
 
 	/* Get the result */
-	output = gck_session_encrypt_finish (session, result, &n_output, &error);
-	SUCCESS_RES (output, error);
+	output = gck_session_encrypt_finish (test->session, result, &n_output, &error);
+	g_assert_no_error (error);
+	g_assert (output);
 	g_assert (n_output == 14);
 	g_assert_cmpstr ((gchar*)output, ==, "SECOND CHANCE");
 	g_free (output);
@@ -186,7 +221,8 @@ TESTING_TEST(encrypt)
 	g_object_unref (key);
 }
 
-TESTING_TEST(decrypt)
+static void
+test_decrypt (Test *test, gconstpointer unused)
 {
 	GckMechanism mech = { CKM_MOCK_CAPITALIZE, NULL, 0 };
 	GError *error = NULL;
@@ -196,25 +232,27 @@ TESTING_TEST(decrypt)
 	gsize n_output;
 
 	/* Find the right key */
-	key = find_key (session, CKA_DECRYPT, CKM_MOCK_CAPITALIZE);
+	key = find_key (test->session, CKA_DECRYPT, CKM_MOCK_CAPITALIZE);
 	g_assert (key);
 
 	/* Simple one */
-	output = gck_session_decrypt (session, key, CKM_MOCK_CAPITALIZE, (const guchar*)"FRY???", 7, &n_output, NULL, &error);
-	SUCCESS_RES (output, error);
+	output = gck_session_decrypt (test->session, key, CKM_MOCK_CAPITALIZE, (const guchar*)"FRY???", 7, &n_output, NULL, &error);
+	g_assert_no_error (error);
+	g_assert (output);
 	g_assert (n_output == 7);
 	g_assert_cmpstr ((gchar*)output, ==, "fry???");
 	g_free (output);
 
 	/* Asynchronous one */
-	gck_session_decrypt_async (session, key, &mech, (const guchar*)"FAT CHANCE", 11, NULL, fetch_async_result, &result);
+	gck_session_decrypt_async (test->session, key, &mech, (const guchar*)"FAT CHANCE", 11, NULL, fetch_async_result, &result);
 
-	testing_wait_until (500);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
 
 	/* Get the result */
-	output = gck_session_decrypt_finish (session, result, &n_output, &error);
-	SUCCESS_RES (output, error);
+	output = gck_session_decrypt_finish (test->session, result, &n_output, &error);
+	g_assert_no_error (error);
+	g_assert (output);
 	g_assert (n_output == 11);
 	g_assert_cmpstr ((gchar*)output, ==, "fat chance");
 	g_free (output);
@@ -223,7 +261,8 @@ TESTING_TEST(decrypt)
 	g_object_unref (key);
 }
 
-TESTING_TEST(login_context_specific)
+static void
+test_login_context_specific (Test *test, gconstpointer unused)
 {
 	/* The test module won't let us sign without doing a login, check that */
 
@@ -233,19 +272,19 @@ TESTING_TEST(login_context_specific)
 	gsize n_output;
 
 	/* Find the right key */
-	key = find_key (session, CKA_SIGN, CKM_MOCK_PREFIX);
+	key = find_key (test->session, CKA_SIGN, CKM_MOCK_PREFIX);
 	g_assert (key);
 
 	/* Simple one */
-	output = gck_session_sign (session, key, CKM_MOCK_PREFIX, (const guchar*)"TV Monster", 11, &n_output, NULL, &error);
-	g_assert (error && error->code == CKR_USER_NOT_LOGGED_IN);
-	FAIL_RES (output, error);
+	output = gck_session_sign (test->session, key, CKM_MOCK_PREFIX, (const guchar*)"TV Monster", 11, &n_output, NULL, &error);
+	g_assert_error (error, GCK_ERROR, CKR_USER_NOT_LOGGED_IN);
 	g_assert (output == NULL);
 
 	g_object_unref (key);
 }
 
-TESTING_TEST(sign)
+static void
+test_sign (Test *test, gconstpointer unused)
 {
 	GckMechanism mech = { CKM_MOCK_PREFIX, "my-prefix:", 10 };
 	GError *error = NULL;
@@ -254,29 +293,31 @@ TESTING_TEST(sign)
 	guchar *output;
 	gsize n_output;
 
-	/* Enable auto-login on this session, see previous test */
-	g_signal_connect (module, "authenticate-object", G_CALLBACK (authenticate_object), NULL);
+	/* Enable auto-login on this test->session, see previous test */
+	g_signal_connect (test->module, "authenticate-object", G_CALLBACK (authenticate_object), NULL);
 
 	/* Find the right key */
-	key = find_key (session_with_auth, CKA_SIGN, CKM_MOCK_PREFIX);
+	key = find_key (test->session_with_auth, CKA_SIGN, CKM_MOCK_PREFIX);
 	g_assert (key);
 
 	/* Simple one */
-	output = gck_session_sign (session_with_auth, key, CKM_MOCK_PREFIX, (const guchar*)"Labarbara", 10, &n_output, NULL, &error);
-	SUCCESS_RES (output, error);
+	output = gck_session_sign (test->session_with_auth, key, CKM_MOCK_PREFIX, (const guchar*)"Labarbara", 10, &n_output, NULL, &error);
+	g_assert_no_error (error);
+	g_assert (output);
 	g_assert_cmpuint (n_output, ==, 24);
 	g_assert_cmpstr ((gchar*)output, ==, "signed-prefix:Labarbara");
 	g_free (output);
 
 	/* Asynchronous one */
-	gck_session_sign_async (session_with_auth, key, &mech, (const guchar*)"Conrad", 7, NULL, fetch_async_result, &result);
+	gck_session_sign_async (test->session_with_auth, key, &mech, (const guchar*)"Conrad", 7, NULL, fetch_async_result, &result);
 
-	testing_wait_until (500);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
 
 	/* Get the result */
-	output = gck_session_sign_finish (session_with_auth, result, &n_output, &error);
-	SUCCESS_RES (output, error);
+	output = gck_session_sign_finish (test->session_with_auth, result, &n_output, &error);
+	g_assert_no_error (error);
+	g_assert (output);
 	g_assert_cmpuint (n_output, ==, 17);
 	g_assert_cmpstr ((gchar*)output, ==, "my-prefix:Conrad");
 	g_free (output);
@@ -285,7 +326,8 @@ TESTING_TEST(sign)
 	g_object_unref (key);
 }
 
-TESTING_TEST(verify)
+static void
+test_verify (Test *test, gconstpointer unused)
 {
 	GckMechanism mech = { CKM_MOCK_PREFIX, "my-prefix:", 10 };
 	GError *error = NULL;
@@ -294,45 +336,52 @@ TESTING_TEST(verify)
 	gboolean ret;
 
 	/* Enable auto-login on this session, shouldn't be needed */
-	g_signal_connect (module, "authenticate-object", G_CALLBACK (authenticate_object), NULL);
+	g_signal_connect (test->module, "authenticate-object", G_CALLBACK (authenticate_object), NULL);
 
 	/* Find the right key */
-	key = find_key (session, CKA_VERIFY, CKM_MOCK_PREFIX);
+	key = find_key (test->session, CKA_VERIFY, CKM_MOCK_PREFIX);
 	g_assert (key);
 
 	/* Simple one */
-	ret = gck_session_verify (session, key, CKM_MOCK_PREFIX, (const guchar*)"Labarbara", 10,
+	ret = gck_session_verify (test->session, key, CKM_MOCK_PREFIX, (const guchar*)"Labarbara", 10,
 	                           (const guchar*)"signed-prefix:Labarbara", 24, NULL, &error);
-	SUCCESS_RES (ret, error);
+	g_assert_no_error (error);
+	g_assert (ret);
 
 	/* Failure one */
-	ret = gck_session_verify_full (session, key, &mech, (const guchar*)"Labarbara", 10,
+	ret = gck_session_verify_full (test->session, key, &mech, (const guchar*)"Labarbara", 10,
 	                                (const guchar*)"my-prefix:Loborboro", 20, NULL, &error);
-	FAIL_RES (ret, error);
+	g_assert (error != NULL);
+	g_assert (!ret);
+	g_clear_error (&error);
 
 	/* Asynchronous one */
-	gck_session_verify_async (session, key, &mech, (const guchar*)"Labarbara", 10,
+	gck_session_verify_async (test->session, key, &mech, (const guchar*)"Labarbara", 10,
 	                           (const guchar*)"my-prefix:Labarbara", 20, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
-	ret = gck_session_verify_finish (session, result, &error);
-	SUCCESS_RES (ret, error);
+	ret = gck_session_verify_finish (test->session, result, &error);
+	g_assert_no_error (error);
+	g_assert (ret);
 	g_object_unref (result);
 
 	/* Asynchronous failure */
 	result = NULL;
-	gck_session_verify_async (session, key, &mech, (const guchar*)"Labarbara", 10,
+	gck_session_verify_async (test->session, key, &mech, (const guchar*)"Labarbara", 10,
 	                           (const guchar*)"my-prefix:Labarxoro", 20, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
-	ret = gck_session_verify_finish (session, result, &error);
-	FAIL_RES (ret, error);
+	ret = gck_session_verify_finish (test->session, result, &error);
+	g_assert (error != NULL);
+	g_assert (!ret);
+	g_clear_error (&error);
 	g_object_unref (result);
 
 	g_object_unref (key);
 }
 
-TESTING_TEST(generate_key_pair)
+static void
+test_generate_key_pair (Test *test, gconstpointer unused)
 {
 	GckMechanism mech = { CKM_MOCK_GENERATE, "generate", 9 };
 	GckAttributes *pub_attrs, *prv_attrs;
@@ -347,28 +396,32 @@ TESTING_TEST(generate_key_pair)
 	gck_attributes_add_ulong (prv_attrs, CKA_CLASS, CKO_PRIVATE_KEY);
 
 	/* Full One*/
-	ret = gck_session_generate_key_pair_full (session, &mech, pub_attrs, prv_attrs,
+	ret = gck_session_generate_key_pair_full (test->session, &mech, pub_attrs, prv_attrs,
 	                                           &pub_key, &prv_key, NULL, &error);
-	SUCCESS_RES (ret, error);
+	g_assert_no_error (error);
+	g_assert (ret);
 	g_object_unref (pub_key);
 	g_object_unref (prv_key);
 
 	/* Failure one */
 	mech.type = 0;
 	pub_key = prv_key = NULL;
-	ret = gck_session_generate_key_pair_full (session, &mech, pub_attrs, prv_attrs,
+	ret = gck_session_generate_key_pair_full (test->session, &mech, pub_attrs, prv_attrs,
 	                                           &pub_key, &prv_key, NULL, &error);
-	FAIL_RES (ret, error);
+	g_assert (error != NULL);
+	g_assert (!ret);
+	g_clear_error (&error);
 	g_assert (pub_key == NULL);
 	g_assert (prv_key == NULL);
 
 	/* Asynchronous one */
 	mech.type = CKM_MOCK_GENERATE;
-	gck_session_generate_key_pair_async (session, &mech, pub_attrs, prv_attrs, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_generate_key_pair_async (test->session, &mech, pub_attrs, prv_attrs, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
-	ret = gck_session_generate_key_pair_finish (session, result, &pub_key, &prv_key, &error);
-	SUCCESS_RES (ret, error);
+	ret = gck_session_generate_key_pair_finish (test->session, result, &pub_key, &prv_key, &error);
+	g_assert_no_error (error);
+	g_assert (ret);
 	g_object_unref (result);
 	g_object_unref (pub_key);
 	g_object_unref (prv_key);
@@ -377,11 +430,13 @@ TESTING_TEST(generate_key_pair)
 	result = NULL;
 	mech.type = 0;
 	pub_key = prv_key = NULL;
-	gck_session_generate_key_pair_async (session, &mech, pub_attrs, prv_attrs, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_generate_key_pair_async (test->session, &mech, pub_attrs, prv_attrs, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
-	ret = gck_session_generate_key_pair_finish (session, result, &pub_key, &prv_key, &error);
-	FAIL_RES (ret, error);
+	ret = gck_session_generate_key_pair_finish (test->session, result, &pub_key, &prv_key, &error);
+	g_assert (error != NULL);
+	g_assert (!ret);
+	g_clear_error (&error);
 	g_object_unref (result);
 	g_assert (pub_key == NULL);
 	g_assert (prv_key == NULL);
@@ -390,7 +445,8 @@ TESTING_TEST(generate_key_pair)
 	gck_attributes_unref (prv_attrs);
 }
 
-TESTING_TEST(wrap_key)
+static void
+test_wrap_key (Test *test, gconstpointer unused)
 {
 	GckMechanism mech = { CKM_MOCK_WRAP, "wrap", 4 };
 	GError *error = NULL;
@@ -399,39 +455,43 @@ TESTING_TEST(wrap_key)
 	gpointer output;
 	gsize n_output;
 
-	wrapper = find_key (session, CKA_WRAP, 0);
-	wrapped = find_key_with_value (session, "value");
+	wrapper = find_key (test->session, CKA_WRAP, 0);
+	wrapped = find_key_with_value (test->session, "value");
 
 	/* Simple One */
-	output = gck_session_wrap_key (session, wrapper, CKM_MOCK_WRAP, wrapped, &n_output, NULL, &error);
-	SUCCESS_RES (output, error);
+	output = gck_session_wrap_key (test->session, wrapper, CKM_MOCK_WRAP, wrapped, &n_output, NULL, &error);
+	g_assert_no_error (error);
 	g_assert (output);
-	g_assert_cmpsize (n_output, ==, 5);
+	egg_assert_cmpsize (n_output, ==, 5);
 	g_assert (memcmp (output, "value", 5) == 0);
 	g_free (output);
 
 	/* Full One*/
-	output = gck_session_wrap_key_full (session, wrapper, &mech, wrapped, &n_output, NULL, &error);
-	SUCCESS_RES (output, error);
-	g_assert_cmpsize (n_output, ==, 5);
+	output = gck_session_wrap_key_full (test->session, wrapper, &mech, wrapped, &n_output, NULL, &error);
+	g_assert_no_error (error);
+	g_assert (output);
+	egg_assert_cmpsize (n_output, ==, 5);
 	g_assert (memcmp (output, "value", 5) == 0);
 	g_free (output);
 
 	/* Failure one */
 	mech.type = 0;
 	n_output = 0;
-	output = gck_session_wrap_key_full (session, wrapper, &mech, wrapped, &n_output, NULL, &error);
-	FAIL_RES (output, error);
-	g_assert_cmpsize (n_output, ==, 0);
+	output = gck_session_wrap_key_full (test->session, wrapper, &mech, wrapped, &n_output, NULL, &error);
+	g_assert (error != NULL);
+	g_assert (!output);
+	g_clear_error (&error);
+	egg_assert_cmpsize (n_output, ==, 0);
 
 	/* Asynchronous one */
 	mech.type = CKM_MOCK_WRAP;
-	gck_session_wrap_key_async (session, wrapper, &mech, wrapped, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_wrap_key_async (test->session, wrapper, &mech, wrapped, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
-	output = gck_session_wrap_key_finish (session, result, &n_output, &error);
-	SUCCESS_RES (output, error);
-	g_assert_cmpsize (n_output, ==, 5);
+	output = gck_session_wrap_key_finish (test->session, result, &n_output, &error);
+	g_assert_no_error (error);
+	g_assert (output);
+	egg_assert_cmpsize (n_output, ==, 5);
 	g_assert (memcmp (output, "value", 5) == 0);
 	g_object_unref (result);
 	g_free (output);
@@ -440,19 +500,22 @@ TESTING_TEST(wrap_key)
 	result = NULL;
 	mech.type = 0;
 	n_output = 0;
-	gck_session_wrap_key_async (session, wrapper, &mech, wrapped, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_wrap_key_async (test->session, wrapper, &mech, wrapped, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
-	output = gck_session_wrap_key_finish (session, result, &n_output, &error);
-	FAIL_RES (output, error);
-	g_assert_cmpsize (n_output, ==, 0);
+	output = gck_session_wrap_key_finish (test->session, result, &n_output, &error);
+	g_assert (error != NULL);
+	g_assert (!output);
+	g_clear_error (&error);
+	egg_assert_cmpsize (n_output, ==, 0);
 	g_object_unref (result);
 
 	g_object_unref (wrapper);
 	g_object_unref (wrapped);
 }
 
-TESTING_TEST(unwrap_key)
+static void
+test_unwrap_key (Test *test, gconstpointer unused)
 {
 	GckMechanism mech = { CKM_MOCK_WRAP, "wrap", 4 };
 	GError *error = NULL;
@@ -460,49 +523,54 @@ TESTING_TEST(unwrap_key)
 	GckObject *wrapper, *unwrapped;
 	GckAttributes *attrs;
 
-	wrapper = find_key (session, CKA_UNWRAP, 0);
+	wrapper = find_key (test->session, CKA_UNWRAP, 0);
 	attrs = gck_attributes_new ();
 	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_SECRET_KEY);
 
 	/* Full One*/
-	unwrapped = gck_session_unwrap_key_full (session, wrapper, &mech, "special", 7, attrs, NULL, &error);
-	SUCCESS_RES (unwrapped, error);
+	unwrapped = gck_session_unwrap_key_full (test->session, wrapper, &mech, "special", 7, attrs, NULL, &error);
+	g_assert_no_error (error);
 	g_assert (GCK_IS_OBJECT (unwrapped));
-	check_key_with_value (session, unwrapped, CKO_SECRET_KEY, "special");
+	check_key_with_value (test->session, unwrapped, CKO_SECRET_KEY, "special");
 	g_object_unref (unwrapped);
 
 	/* Failure one */
 	mech.type = 0;
-	unwrapped = gck_session_unwrap_key_full (session, wrapper, &mech, "special", 7, attrs, NULL, &error);
-	FAIL_RES (unwrapped, error);
+	unwrapped = gck_session_unwrap_key_full (test->session, wrapper, &mech, "special", 7, attrs, NULL, &error);
+	g_assert (error != NULL);
+	g_assert (!unwrapped);
+	g_clear_error (&error);
 
 	/* Asynchronous one */
 	mech.type = CKM_MOCK_WRAP;
-	gck_session_unwrap_key_async (session, wrapper, &mech, "special", 7, attrs, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_unwrap_key_async (test->session, wrapper, &mech, "special", 7, attrs, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
-	unwrapped = gck_session_unwrap_key_finish (session, result, &error);
-	SUCCESS_RES (unwrapped, error);
+	unwrapped = gck_session_unwrap_key_finish (test->session, result, &error);
+	g_assert_no_error (error);
 	g_assert (GCK_IS_OBJECT (unwrapped));
-	check_key_with_value (session, unwrapped, CKO_SECRET_KEY, "special");
+	check_key_with_value (test->session, unwrapped, CKO_SECRET_KEY, "special");
 	g_object_unref (unwrapped);
 	g_object_unref (result);
 
 	/* Asynchronous failure */
 	result = NULL;
 	mech.type = 0;
-	gck_session_unwrap_key_async (session, wrapper, &mech, "special", 6, attrs, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_unwrap_key_async (test->session, wrapper, &mech, "special", 6, attrs, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
-	unwrapped = gck_session_unwrap_key_finish (session, result, &error);
-	FAIL_RES (unwrapped, error);
+	unwrapped = gck_session_unwrap_key_finish (test->session, result, &error);
+	g_assert (error != NULL);
+	g_assert (!unwrapped);
+	g_clear_error (&error);
 	g_object_unref (result);
 
 	g_object_unref (wrapper);
 	gck_attributes_unref (attrs);
 }
 
-TESTING_TEST(derive_key)
+static void
+test_derive_key (Test *test, gconstpointer unused)
 {
 	GckMechanism mech = { CKM_MOCK_DERIVE, "derive", 6 };
 	GError *error = NULL;
@@ -510,44 +578,73 @@ TESTING_TEST(derive_key)
 	GckObject *wrapper, *derived;
 	GckAttributes *attrs;
 
-	wrapper = find_key (session, CKA_DERIVE, 0);
+	wrapper = find_key (test->session, CKA_DERIVE, 0);
 	attrs = gck_attributes_new ();
 	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_SECRET_KEY);
 
 	/* Full One*/
-	derived = gck_session_derive_key_full (session, wrapper, &mech, attrs, NULL, &error);
-	SUCCESS_RES (derived, error);
+	derived = gck_session_derive_key_full (test->session, wrapper, &mech, attrs, NULL, &error);
+	g_assert_no_error (error);
 	g_assert (GCK_IS_OBJECT (derived));
-	check_key_with_value (session, derived, CKO_SECRET_KEY, "derived");
+	check_key_with_value (test->session, derived, CKO_SECRET_KEY, "derived");
 	g_object_unref (derived);
 
 	/* Failure one */
 	mech.type = 0;
-	derived = gck_session_derive_key_full (session, wrapper, &mech, attrs, NULL, &error);
-	FAIL_RES (derived, error);
+	derived = gck_session_derive_key_full (test->session, wrapper, &mech, attrs, NULL, &error);
+	g_assert (error != NULL);
+	g_assert (!derived);
+	g_clear_error (&error);
 
 	/* Asynchronous one */
 	mech.type = CKM_MOCK_DERIVE;
-	gck_session_derive_key_async (session, wrapper, &mech, attrs, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_derive_key_async (test->session, wrapper, &mech, attrs, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
-	derived = gck_session_derive_key_finish (session, result, &error);
-	SUCCESS_RES (derived, error);
+	derived = gck_session_derive_key_finish (test->session, result, &error);
+	g_assert_no_error (error);
 	g_assert (GCK_IS_OBJECT (derived));
-	check_key_with_value (session, derived, CKO_SECRET_KEY, "derived");
+	check_key_with_value (test->session, derived, CKO_SECRET_KEY, "derived");
 	g_object_unref (derived);
 	g_object_unref (result);
 
 	/* Asynchronous failure */
 	result = NULL;
 	mech.type = 0;
-	gck_session_derive_key_async (session, wrapper, &mech, attrs, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_derive_key_async (test->session, wrapper, &mech, attrs, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
-	derived = gck_session_derive_key_finish (session, result, &error);
-	FAIL_RES (derived, error);
+	derived = gck_session_derive_key_finish (test->session, result, &error);
+	g_assert (error != NULL);
+	g_assert (!derived);
+	g_clear_error (&error);
 	g_object_unref (result);
 
 	g_object_unref (wrapper);
 	gck_attributes_unref (attrs);
 }
+
+int
+main (int argc, char **argv)
+{
+	const gchar *srcdir;
+
+	g_type_init ();
+	g_test_init (&argc, &argv, NULL);
+
+	srcdir = g_getenv ("SRCDIR");
+	if (srcdir && chdir (srcdir) < 0)
+		g_error ("couldn't change directory to: %s: %s", srcdir, g_strerror (errno));
+
+	g_test_add ("/gck/crypto/encrypt", Test, NULL, setup, test_encrypt, teardown);
+	g_test_add ("/gck/crypto/decrypt", Test, NULL, setup, test_decrypt, teardown);
+	g_test_add ("/gck/crypto/login_context_specific", Test, NULL, setup, test_login_context_specific, teardown);
+	g_test_add ("/gck/crypto/sign", Test, NULL, setup, test_sign, teardown);
+	g_test_add ("/gck/crypto/verify", Test, NULL, setup, test_verify, teardown);
+	g_test_add ("/gck/crypto/generate_key_pair", Test, NULL, setup, test_generate_key_pair, teardown);
+	g_test_add ("/gck/crypto/wrap_key", Test, NULL, setup, test_wrap_key, teardown);
+	g_test_add ("/gck/crypto/unwrap_key", Test, NULL, setup, test_unwrap_key, teardown);
+	g_test_add ("/gck/crypto/derive_key", Test, NULL, setup, test_derive_key, teardown);
+
+	return egg_tests_run_in_thread_with_loop ();
+}
diff --git a/gck/tests/test-gck-enumerator.c b/gck/tests/test-gck-enumerator.c
index 2b63b8e..a92128b 100644
--- a/gck/tests/test-gck-enumerator.c
+++ b/gck/tests/test-gck-enumerator.c
@@ -1,61 +1,99 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* test-gck-enumerator.c - the GObject PKCS#11 wrapper library
+
+   Copyright (C) 2011 Collabora Ltd.
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Stef Walter <stefw collabora co uk>
+*/
+
+#include "config.h"
+
+#include "gck/gck.h"
+#include "gck/gck-mock.h"
+#include "gck/gck-private.h"
+#include "gck/gck-test.h"
+
+#include "egg/egg-testing.h"
 
 #include <glib.h>
-#include <string.h>
 
-#include "test-suite.h"
-#include "test-gck.h"
-#include "gck-test.h"
-#include "gck-private.h"
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
 
-static GList *modules = NULL;
-static GckModule *module = NULL;
+typedef struct {
+	GList *modules;
+	GckModule *module;
+} Test;
 
-TESTING_SETUP(enumerator)
+static void
+setup (Test *test, gconstpointer unused)
 {
 	GError *err = NULL;
 
 	/* Successful load */
-	module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
-	SUCCESS_RES (module, err);
+	test->module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_MODULE (test->module));
 
-	modules = g_list_append (NULL, g_object_ref (module));
+	test->modules = g_list_append (NULL, g_object_ref (test->module));
 }
 
-TESTING_TEARDOWN(enumerator)
+static void
+teardown (Test *test, gconstpointer unused)
 {
-	gck_list_unref_free (modules);
-	modules = NULL;
+	gck_list_unref_free (test->modules);
+	test->modules = NULL;
 
-	g_object_unref (module);
-	module = NULL;
+	g_object_unref (test->module);
+	test->module = NULL;
 }
 
-TESTING_TEST(enumerator_create)
+static void
+test_create (Test *test, gconstpointer unused)
 {
 	GckUriInfo *uri_info;
 	GckEnumerator *en;
 
 	uri_info = _gck_uri_info_new ();
-	en = _gck_enumerator_new (modules, 0, uri_info);
+	en = _gck_enumerator_new (test->modules, 0, uri_info);
 	g_assert (GCK_IS_ENUMERATOR (en));
 	g_object_unref (en);
 }
 
-TESTING_TEST(enumerator_create_slots)
+static void
+test_create_slots (Test *test, gconstpointer unused)
 {
 	GckUriInfo *uri_info;
 	GckEnumerator *en;
 	GList *slots;
 
 	uri_info = _gck_uri_info_new ();
-	slots = gck_module_get_slots (module, FALSE);
+	slots = gck_module_get_slots (test->module, FALSE);
 	en = _gck_enumerator_new (slots, 0, uri_info);
 	g_assert (GCK_IS_ENUMERATOR (en));
 	g_object_unref (en);
 	gck_list_unref_free (slots);
 }
 
-TESTING_TEST(enumerator_next)
+static void
+test_next (Test *test, gconstpointer unused)
 {
 	GckUriInfo *uri_info;
 	GError *error = NULL;
@@ -63,7 +101,7 @@ TESTING_TEST(enumerator_next)
 	GckObject *obj;
 
 	uri_info = _gck_uri_info_new ();
-	en = _gck_enumerator_new (modules, 0, uri_info);
+	en = _gck_enumerator_new (test->modules, 0, uri_info);
 	g_assert (GCK_IS_ENUMERATOR (en));
 
 	obj = gck_enumerator_next (en, NULL, &error);
@@ -73,7 +111,8 @@ TESTING_TEST(enumerator_next)
 	g_object_unref (en);
 }
 
-TESTING_TEST(enumerator_next_slots)
+static void
+test_next_slots (Test *test, gconstpointer unused)
 {
 	GckUriInfo *uri_info;
 	GError *error = NULL;
@@ -82,7 +121,7 @@ TESTING_TEST(enumerator_next_slots)
 	GckObject *obj;
 
 	uri_info = _gck_uri_info_new ();
-	slots = gck_module_get_slots (module, FALSE);
+	slots = gck_module_get_slots (test->module, FALSE);
 	en = _gck_enumerator_new (slots, 0, uri_info);
 	g_assert (GCK_IS_ENUMERATOR (en));
 
@@ -94,7 +133,8 @@ TESTING_TEST(enumerator_next_slots)
 	gck_list_unref_free (slots);
 }
 
-TESTING_TEST(enumerator_next_and_resume)
+static void
+test_next_and_resume (Test *test, gconstpointer unused)
 {
 	GckUriInfo *uri_info;
 	GError *error = NULL;
@@ -102,15 +142,15 @@ TESTING_TEST(enumerator_next_and_resume)
 	GckObject *obj, *obj2;
 
 	uri_info = _gck_uri_info_new ();
-	en = _gck_enumerator_new (modules, 0, uri_info);
+	en = _gck_enumerator_new (test->modules, 0, uri_info);
 	g_assert (GCK_IS_ENUMERATOR (en));
 
 	obj = gck_enumerator_next (en, NULL, &error);
-	SUCCESS_RES (obj, error);
+	g_assert_no_error (error);
 	g_assert (GCK_IS_OBJECT (obj));
 
 	obj2 = gck_enumerator_next (en, NULL, &error);
-	SUCCESS_RES (obj2, error);
+	g_assert_no_error (error);
 	g_assert (GCK_IS_OBJECT (obj2));
 
 	g_assert (!gck_object_equal (obj, obj2));
@@ -120,7 +160,8 @@ TESTING_TEST(enumerator_next_and_resume)
 	g_object_unref (en);
 }
 
-TESTING_TEST(enumerator_next_n)
+static void
+test_next_n (Test *test, gconstpointer unused)
 {
 	GckUriInfo *uri_info;
 	GError *error = NULL;
@@ -128,11 +169,11 @@ TESTING_TEST(enumerator_next_n)
 	GList *objects, *l;
 
 	uri_info = _gck_uri_info_new ();
-	en = _gck_enumerator_new (modules, 0, uri_info);
+	en = _gck_enumerator_new (test->modules, 0, uri_info);
 	g_assert (GCK_IS_ENUMERATOR (en));
 
 	objects = gck_enumerator_next_n (en, -1, NULL, &error);
-	SUCCESS_RES (objects, error);
+	g_assert_no_error (error);
 	g_assert_cmpint (g_list_length (objects), ==, 5);
 	for (l = objects; l; l = g_list_next (l))
 		g_assert (GCK_IS_OBJECT (l->data));
@@ -146,10 +187,11 @@ fetch_async_result (GObject *source, GAsyncResult *result, gpointer user_data)
 {
 	*((GAsyncResult**)user_data) = result;
 	g_object_ref (result);
-	testing_wait_stop ();
+	egg_test_wait_stop ();
 }
 
-TESTING_TEST(enumerator_next_async)
+static void
+test_next_async (Test *test, gconstpointer unused)
 {
 	GckUriInfo *uri_info;
 	GAsyncResult *result = NULL;
@@ -158,15 +200,15 @@ TESTING_TEST(enumerator_next_async)
 	GList *objects, *l;
 
 	uri_info = _gck_uri_info_new ();
-	en = _gck_enumerator_new (modules, 0, uri_info);
+	en = _gck_enumerator_new (test->modules, 0, uri_info);
 	g_assert (GCK_IS_ENUMERATOR (en));
 
 	gck_enumerator_next_async (en, -1, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	egg_test_wait_until (500);
 	g_assert (result);
 
 	objects = gck_enumerator_next_finish (en, result, &error);
-	SUCCESS_RES (objects, error);
+	g_assert_no_error (error);
 	g_assert_cmpint (g_list_length (objects), ==, 5);
 	for (l = objects; l; l = g_list_next (l))
 		g_assert (GCK_IS_OBJECT (l->data));
@@ -176,7 +218,8 @@ TESTING_TEST(enumerator_next_async)
 	g_object_unref (en);
 }
 
-TESTING_TEST(enumerator_attributes)
+static void
+test_attributes (Test *test, gconstpointer unused)
 {
 	GckUriInfo *uri_info;
 	GError *error = NULL;
@@ -186,11 +229,11 @@ TESTING_TEST(enumerator_attributes)
 	uri_info = _gck_uri_info_new ();
 	uri_info->attributes = gck_attributes_new ();
 	gck_attributes_add_string (uri_info->attributes, CKA_LABEL, "Private Capitalize Key");
-	en = _gck_enumerator_new (modules, 0, uri_info);
+	en = _gck_enumerator_new (test->modules, 0, uri_info);
 	g_assert (GCK_IS_ENUMERATOR (en));
 
 	objects = gck_enumerator_next_n (en, -1, NULL, &error);
-	SUCCESS_RES (objects, error);
+	g_assert_no_error (error);
 	g_assert_cmpint (g_list_length (objects), ==, 1);
 	g_assert (GCK_IS_OBJECT (objects->data));
 
@@ -198,7 +241,8 @@ TESTING_TEST(enumerator_attributes)
 	g_object_unref (en);
 }
 
-TESTING_TEST(enumerator_token_match)
+static void
+test_token_match (Test *test, gconstpointer unused)
 {
 	GckUriInfo *uri_info;
 	GError *error = NULL;
@@ -208,7 +252,7 @@ TESTING_TEST(enumerator_token_match)
 	uri_info = _gck_uri_info_new ();
 	uri_info->token_info = g_new0 (GckTokenInfo, 1);
 	uri_info->token_info->label = g_strdup ("Invalid token name");
-	en = _gck_enumerator_new (modules, 0, uri_info);
+	en = _gck_enumerator_new (test->modules, 0, uri_info);
 	g_assert (GCK_IS_ENUMERATOR (en));
 
 	objects = gck_enumerator_next_n (en, -1, NULL, &error);
@@ -218,3 +262,28 @@ TESTING_TEST(enumerator_token_match)
 	gck_list_unref_free (objects);
 	g_object_unref (en);
 }
+
+int
+main (int argc, char **argv)
+{
+	const gchar *srcdir;
+
+	g_type_init ();
+	g_test_init (&argc, &argv, NULL);
+
+	srcdir = g_getenv ("SRCDIR");
+	if (srcdir && chdir (srcdir) < 0)
+		g_error ("couldn't change directory to: %s: %s", srcdir, g_strerror (errno));
+
+	g_test_add ("/gck/enumerator/create", Test, NULL, setup, test_create, teardown);
+	g_test_add ("/gck/enumerator/create_slots", Test, NULL, setup, test_create_slots, teardown);
+	g_test_add ("/gck/enumerator/next", Test, NULL, setup, test_next, teardown);
+	g_test_add ("/gck/enumerator/next_slots", Test, NULL, setup, test_next_slots, teardown);
+	g_test_add ("/gck/enumerator/next_and_resume", Test, NULL, setup, test_next_and_resume, teardown);
+	g_test_add ("/gck/enumerator/next_n", Test, NULL, setup, test_next_n, teardown);
+	g_test_add ("/gck/enumerator/next_async", Test, NULL, setup, test_next_async, teardown);
+	g_test_add ("/gck/enumerator/attributes", Test, NULL, setup, test_attributes, teardown);
+	g_test_add ("/gck/enumerator/token_match", Test, NULL, setup, test_token_match, teardown);
+
+	return egg_tests_run_in_thread_with_loop ();
+}
diff --git a/gck/tests/test-gck-module.c b/gck/tests/test-gck-module.c
index 1c78e8f..48050b2 100644
--- a/gck/tests/test-gck-module.c
+++ b/gck/tests/test-gck-module.c
@@ -1,79 +1,116 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* test-gck-module.c - the GObject PKCS#11 wrapper library
 
+   Copyright (C) 2011 Collabora Ltd.
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Stef Walter <stefw collabora co uk>
+*/
+
+#include "config.h"
+
+#include <errno.h>
 #include <glib.h>
 #include <string.h>
 
-#include "test-suite.h"
-#include "gck-test.h"
-#include "test-gck.h"
+#include "gck/gck.h"
+#include "gck/gck-test.h"
 
-static GckModule *module = NULL;
+typedef struct {
+	GckModule *module;
+} Test;
 
-TESTING_SETUP(load_module)
+static void
+setup (Test *test, gconstpointer unused)
 {
 	GError *err = NULL;
 
 	/* Successful load */
-	module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
-	SUCCESS_RES (module, err);
+	test->module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
+	g_assert_no_error (err);
+	g_assert (test->module);
 }
 
-TESTING_TEARDOWN(load_module)
+static void
+teardown (Test *test, gconstpointer unused)
 {
-	g_object_unref (module);
+	g_object_unref (test->module);
 }
 
-TESTING_TEST(invalid_modules)
+static void
+test_invalid_modules (Test *test, gconstpointer unused)
 {
 	GckModule *invalid;
 	GError *err = NULL;
 
 	/* Shouldn't be able to load modules */
 	invalid = gck_module_initialize ("blah-blah-non-existant", NULL, 0, &err);
-	FAIL_RES (invalid, err);
+	g_assert (invalid == NULL);
+	g_assert_error (err, GCK_ERROR, CKR_GCK_MODULE_PROBLEM);
+
+	g_clear_error (&err);
 
 	/* Shouldn't be able to load any file successfully */
 	invalid = gck_module_initialize ("/usr/lib/libm.so", NULL, 0, &err);
-	FAIL_RES (invalid, err);
+	g_assert (invalid == NULL);
+	g_assert_error (err, GCK_ERROR, CKR_GCK_MODULE_PROBLEM);
 }
 
-TESTING_TEST(module_equals_hash)
+static void
+test_module_equals_hash (Test *test, gconstpointer unused)
 {
 	GckModule *other;
 	GObject *obj;
 	guint hash;
 
-	hash = gck_module_hash (module);
+	hash = gck_module_hash (test->module);
 	g_assert (hash != 0);
 
-	g_assert (gck_module_equal (module, module));
+	g_assert (gck_module_equal (test->module, test->module));
 
-	other = gck_module_new (gck_module_get_functions (module), 0);
+	other = gck_module_new (gck_module_get_functions (test->module), 0);
 	obj = g_object_new (G_TYPE_OBJECT, NULL);
 
-	g_assert (gck_module_equal (module, other));
+	g_assert (gck_module_equal (test->module, other));
 
 	/* TODO: Could do with another test for inequality */
-	g_assert (!gck_module_equal (module, obj));
+	g_assert (!gck_module_equal (test->module, obj));
 
 	g_object_unref (other);
 	g_object_unref (obj);
 }
 
-TESTING_TEST(module_props)
+static void
+test_module_props (Test *test, gconstpointer unused)
 {
 	gchar *path;
 
-	g_object_get (module, "path", &path, NULL);
+	g_object_get (test->module, "path", &path, NULL);
 	g_assert (path != NULL && "no module-path");
 	g_assert (strcmp (".libs/libmock-test-module.so", path) == 0 && "module path wrong");
 	g_free (path);
 }
 
-TESTING_TEST(module_info)
+static void
+test_module_info (Test *test, gconstpointer unused)
 {
 	GckModuleInfo *info;
 
-	info = gck_module_get_info (module);
+	info = gck_module_get_info (test->module);
 	g_assert (info != NULL && "no module info");
 
 	g_assert (info->pkcs11_version_major == CRYPTOKI_VERSION_MAJOR && "wrong major version");
@@ -87,84 +124,22 @@ TESTING_TEST(module_info)
 	gck_module_info_free (info);
 }
 
-#if 0
-static int n_objects = 0;
-static GckObject *last_object = NULL;
-
-static gboolean
-for_each_object (GckObject *object, gpointer user_data)
-{
-	g_assert (GCK_IS_OBJECT (object));
-	g_assert_cmpstr ("blah", ==, user_data);
-	g_assert (user_data);
-
-	if (last_object)
-		g_object_unref (last_object);
-	last_object = g_object_ref (object);
-
-	++n_objects;
-
-	return TRUE;
-}
-
-static gboolean
-for_first_object (GckObject *object, gpointer user_data)
+int
+main (int argc, char **argv)
 {
-	g_assert (GCK_IS_OBJECT (object));
-	g_assert_cmpstr ("first", ==, user_data);
-	g_assert (user_data);
+	const gchar *srcdir;
 
-	if (last_object)
-		g_object_unref (last_object);
-	last_object = g_object_ref (object);
+	g_type_init ();
+	g_test_init (&argc, &argv, NULL);
 
-	++n_objects;
+	srcdir = g_getenv ("SRCDIR");
+	if (srcdir && chdir (srcdir) < 0)
+		g_error ("couldn't change directory to: %s: %s", srcdir, g_strerror (errno));
 
-	return FALSE;
-}
-#endif
+	g_test_add ("/gck/module/invalid_modules", Test, NULL, setup, test_invalid_modules, teardown);
+	g_test_add ("/gck/module/module_equals_hash", Test, NULL, setup, test_module_equals_hash, teardown);
+	g_test_add ("/gck/module/module_props", Test, NULL, setup, test_module_props, teardown);
+	g_test_add ("/gck/module/module_info", Test, NULL, setup, test_module_info, teardown);
 
-TESTING_TEST(module_enumerate)
-{
-#if 0
-	GckSession *session;
-	GckAttributes *attrs;
-	gboolean ret;
-	GList *modules;
-
-	modules = g_list_prepend (NULL, g_object_ref (module));
-
-	attrs = gck_attributes_new ();
-	ret = gck_modules_enumerate_objects (modules, attrs, 0, NULL, for_first_object, "first", NULL);
-	g_assert (ret);
-	g_assert_cmpint (n_objects, ==, 1);
-	g_assert (GCK_IS_OBJECT (last_object));
-	gck_attributes_unref (attrs);
-
-	session = gck_object_get_session (last_object);
-	g_assert (GCK_IS_SESSION (session));
-	g_object_unref (session);
-
-	g_object_unref (last_object);
-	last_object = NULL;
-	n_objects = 0;
-
-	attrs = gck_attributes_new ();
-	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_PRIVATE_KEY);
-	ret = gck_modules_enumerate_objects (modules, attrs, 0, NULL, for_each_object, "blah", NULL);
-	g_assert (ret);
-	g_assert_cmpint (n_objects, ==, 2);
-	g_assert (GCK_IS_OBJECT (last_object));
-	gck_attributes_unref (attrs);
-
-	session = gck_object_get_session (last_object);
-	g_assert (GCK_IS_SESSION (session));
-	g_object_unref (session);
-
-	g_object_unref (last_object);
-	last_object = NULL;
-	n_objects = 0;
-
-	gck_list_unref_free (modules);
-#endif
+	return g_test_run ();
 }
diff --git a/gck/tests/test-gck-modules.c b/gck/tests/test-gck-modules.c
index e4abb04..0fe287e 100644
--- a/gck/tests/test-gck-modules.c
+++ b/gck/tests/test-gck-modules.c
@@ -1,32 +1,69 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* test-gck-modules.c - the GObject PKCS#11 wrapper library
+
+   Copyright (C) 2011 Collabora Ltd.
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Stef Walter <stefw collabora co uk>
+*/
+
+#include "config.h"
+
+#include "gck/gck.h"
+#include "gck/gck-mock.h"
+#include "gck/gck-private.h"
+#include "gck/gck-test.h"
+
+#include "egg/egg-testing.h"
 
 #include <glib.h>
-#include <string.h>
 
-#include "test-suite.h"
-#include "gck-test.h"
-#include "test-gck.h"
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
 
-static GList *modules = NULL;
+typedef struct {
+	GList *modules;
+} Test;
 
-TESTING_SETUP(modules)
+static void
+setup (Test *test, gconstpointer unused)
 {
 	GckModule *module;
 	GError *err = NULL;
 
 	/* Successful load */
 	module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
-	SUCCESS_RES (module, err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_MODULE (module));
 
-	modules = g_list_append (NULL, module);
+	test->modules = g_list_append (NULL, module);
 }
 
-TESTING_TEARDOWN(modules)
+static void
+teardown (Test *test, gconstpointer unused)
 {
-	gck_list_unref_free (modules);
-	modules = NULL;
+	gck_list_unref_free (test->modules);
+	test->modules = NULL;
 }
 
-TESTING_TEST(modules_enumerate_objects)
+static void
+test_enumerate_objects (Test *test, gconstpointer unused)
 {
 	GckAttributes *attrs;
 	GError *error = NULL;
@@ -35,12 +72,12 @@ TESTING_TEST(modules_enumerate_objects)
 
 	attrs = gck_attributes_new ();
 	gck_attributes_add_string (attrs, CKA_LABEL, "Private Capitalize Key");
-	en = gck_modules_enumerate_objects (modules, attrs, 0);
+	en = gck_modules_enumerate_objects (test->modules, attrs, 0);
 	g_assert (GCK_IS_ENUMERATOR (en));
 	gck_attributes_unref (attrs);
 
 	objects = gck_enumerator_next_n (en, -1, NULL, &error);
-	SUCCESS_RES (objects, error);
+	g_assert_no_error (error);
 	g_assert_cmpint (g_list_length (objects), ==, 1);
 	g_assert (GCK_IS_OBJECT (objects->data));
 
@@ -49,77 +86,84 @@ TESTING_TEST(modules_enumerate_objects)
 }
 
 
-TESTING_TEST(modules_token_for_uri)
+static void
+test_token_for_uri (Test *test, gconstpointer unused)
 {
 	GckSlot *slot;
 	GError *error = NULL;
 
-	slot = gck_modules_token_for_uri (modules, "pkcs11:token=TEST%20LABEL", &error);
+	slot = gck_modules_token_for_uri (test->modules, "pkcs11:token=TEST%20LABEL", &error);
 	g_assert (GCK_IS_SLOT (slot));
 
 	g_object_unref (slot);
 }
 
-TESTING_TEST(modules_token_for_uri_not_found)
+static void
+test_token_for_uri_not_found (Test *test, gconstpointer unused)
 {
 	GckSlot *slot;
 	GError *error = NULL;
 
-	slot = gck_modules_token_for_uri (modules, "pkcs11:token=UNKNOWN", &error);
+	slot = gck_modules_token_for_uri (test->modules, "pkcs11:token=UNKNOWN", &error);
 	g_assert (slot == NULL);
 	g_assert (error == NULL);
 }
 
-TESTING_TEST(modules_token_for_uri_error)
+static void
+test_token_for_uri_error (Test *test, gconstpointer unused)
 {
 	GckSlot *slot;
 	GError *error = NULL;
 
-	slot = gck_modules_token_for_uri (modules, "http://invalid.uri";, &error);
+	slot = gck_modules_token_for_uri (test->modules, "http://invalid.uri";, &error);
 	g_assert (slot == NULL);
 	g_assert (error != NULL);
 	g_assert (g_error_matches (error, GCK_URI_ERROR, GCK_URI_BAD_PREFIX));
 	g_error_free (error);
 }
 
-TESTING_TEST(modules_object_for_uri)
+static void
+test_object_for_uri (Test *test, gconstpointer unused)
 {
 	GckObject *object;
 	GError *error = NULL;
 
-	object = gck_modules_object_for_uri (modules, "pkcs11:object=Public%20Capitalize%20Key;objecttype=public", 0, &error);
+	object = gck_modules_object_for_uri (test->modules, "pkcs11:object=Public%20Capitalize%20Key;objecttype=public", 0, &error);
 	g_assert (GCK_IS_OBJECT (object));
 	g_object_unref (object);
 }
 
-TESTING_TEST(modules_object_for_uri_not_found)
+static void
+test_object_for_uri_not_found (Test *test, gconstpointer unused)
 {
 	GckObject *object;
 	GError *error = NULL;
 
-	object = gck_modules_object_for_uri (modules, "pkcs11:object=Unknown%20Label", 0, &error);
+	object = gck_modules_object_for_uri (test->modules, "pkcs11:object=Unknown%20Label", 0, &error);
 	g_assert (object == NULL);
 	g_assert (error == NULL);
 }
 
-TESTING_TEST(modules_object_for_uri_error)
+static void
+test_object_for_uri_error (Test *test, gconstpointer unused)
 {
 	GckObject *object;
 	GError *error = NULL;
 
-	object = gck_modules_object_for_uri (modules, "http://invalid.uri";, 0, &error);
+	object = gck_modules_object_for_uri (test->modules, "http://invalid.uri";, 0, &error);
 	g_assert (object == NULL);
 	g_assert (error != NULL);
 	g_assert (g_error_matches (error, GCK_URI_ERROR, GCK_URI_BAD_PREFIX));
 	g_error_free (error);
 }
 
-TESTING_TEST(modules_objects_for_uri)
+static void
+test_objects_for_uri (Test *test, gconstpointer unused)
 {
 	GList *objects;
 	GError *error = NULL;
 
-	objects = gck_modules_objects_for_uri (modules, "pkcs11:token=TEST%20LABEL", 0, &error);
+	objects = gck_modules_objects_for_uri (test->modules, "pkcs11:token=TEST%20LABEL", 0, &error);
 	g_assert (objects);
 	g_assert (!error);
 	g_assert_cmpint (g_list_length (objects), ==, 5);
@@ -127,13 +171,14 @@ TESTING_TEST(modules_objects_for_uri)
 	gck_list_unref_free (objects);
 }
 
-TESTING_TEST(modules_enumerate_uri)
+static void
+test_enumerate_uri (Test *test, gconstpointer unused)
 {
 	GckEnumerator *en;
 	GList *objects;
 	GError *error = NULL;
 
-	en = gck_modules_enumerate_uri (modules, "pkcs11:token=TEST%20LABEL", 0, &error);
+	en = gck_modules_enumerate_uri (test->modules, "pkcs11:token=TEST%20LABEL", 0, &error);
 	g_assert (GCK_IS_ENUMERATOR (en));
 	g_assert (!error);
 
@@ -144,3 +189,28 @@ TESTING_TEST(modules_enumerate_uri)
 	g_object_unref (en);
 	gck_list_unref_free (objects);
 }
+
+int
+main (int argc, char **argv)
+{
+	const gchar *srcdir;
+
+	g_type_init ();
+	g_test_init (&argc, &argv, NULL);
+
+	srcdir = g_getenv ("SRCDIR");
+	if (srcdir && chdir (srcdir) < 0)
+		g_error ("couldn't change directory to: %s: %s", srcdir, g_strerror (errno));
+
+	g_test_add ("/gck/modules/enumerate_objects", Test, NULL, setup, test_enumerate_objects, teardown);
+	g_test_add ("/gck/modules/token_for_uri", Test, NULL, setup, test_token_for_uri, teardown);
+	g_test_add ("/gck/modules/token_for_uri_not_found", Test, NULL, setup, test_token_for_uri_not_found, teardown);
+	g_test_add ("/gck/modules/token_for_uri_error", Test, NULL, setup, test_token_for_uri_error, teardown);
+	g_test_add ("/gck/modules/object_for_uri", Test, NULL, setup, test_object_for_uri, teardown);
+	g_test_add ("/gck/modules/object_for_uri_not_found", Test, NULL, setup, test_object_for_uri_not_found, teardown);
+	g_test_add ("/gck/modules/object_for_uri_error", Test, NULL, setup, test_object_for_uri_error, teardown);
+	g_test_add ("/gck/modules/objects_for_uri", Test, NULL, setup, test_objects_for_uri, teardown);
+	g_test_add ("/gck/modules/enumerate_uri", Test, NULL, setup, test_enumerate_uri, teardown);
+
+	return egg_tests_run_in_thread_with_loop ();
+}
diff --git a/gck/tests/test-gck-object.c b/gck/tests/test-gck-object.c
index 77363fa..e41e4db 100644
--- a/gck/tests/test-gck-object.c
+++ b/gck/tests/test-gck-object.c
@@ -1,65 +1,100 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* test-gck-object.c - the GObject PKCS#11 wrapper library
+
+   Copyright (C) 2011 Collabora Ltd.
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
 
-#include "test-suite.h"
+   Author: Stef Walter <stefw collabora co uk>
+*/
+
+#include "config.h"
+
+#include "gck/gck.h"
+#include "gck/gck-mock.h"
+#include "gck/gck-test.h"
+
+#include "egg/egg-testing.h"
 
 #include <glib.h>
 
-#include "gck-test.h"
-#include "test-gck.h"
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
 
-static GckModule *module = NULL;
-static GckSlot *slot = NULL;
-static GckSession *session = NULL;
-static GckObject *object = NULL;
+typedef struct {
+	GckModule *module;
+	GckSlot *slot;
+	GckSession *session;
+	GckObject *object;
+} Test;
 
-TESTING_SETUP(prep_object)
+static void
+setup (Test *test, gconstpointer unused)
 {
 	GError *err = NULL;
 	GList *slots;
 
 	/* Successful load */
-	module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
-	SUCCESS_RES (module, err);
+	test->module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_MODULE (test->module));
 
-	slots = gck_module_get_slots (module, TRUE);
+	slots = gck_module_get_slots (test->module, TRUE);
 	g_assert (slots != NULL);
 
-	slot = GCK_SLOT (slots->data);
-	g_object_ref (slot);
+	test->slot = GCK_SLOT (slots->data);
+	g_object_ref (test->slot);
 	gck_list_unref_free (slots);
 
-	session = gck_slot_open_session (slot, 0, NULL, &err);
-	SUCCESS_RES(session, err);
+	test->session = gck_slot_open_session (test->slot, 0, NULL, &err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_SESSION (test->session));
 
 	/* Our module always exports a token object with this */
-	object = gck_object_from_handle (session, 2);
-	g_assert (object != NULL);
+	test->object = gck_object_from_handle (test->session, 2);
+	g_assert (test->object != NULL);
 }
 
-TESTING_TEARDOWN(prep_object)
+static void
+teardown (Test *test, gconstpointer unused)
 {
-	g_object_unref (object);
-	g_object_unref (session);
-	g_object_unref (slot);
-	g_object_unref (module);
+	g_object_unref (test->object);
+	g_object_unref (test->session);
+	g_object_unref (test->slot);
+	g_object_unref (test->module);
 }
 
-TESTING_TEST(object_props)
+static void
+test_object_props (Test *test, gconstpointer unused)
 {
 	GckSession *sess;
 	GckModule *mod;
 	CK_OBJECT_HANDLE handle;
-	g_object_get (object, "session", &sess, "module", &mod, "handle", &handle, NULL);
-	g_assert (session == sess);
+	g_object_get (test->object, "session", &sess, "module", &mod, "handle", &handle, NULL);
+	g_assert (test->session == sess);
 	g_object_unref (sess);
-	g_assert (module == mod);
+	g_assert (test->module == mod);
 	g_object_unref (mod);
 	g_assert (handle == 2);
 }
 
-TESTING_TEST(object_equals_hash)
+static void
+test_object_equals_hash (Test *test, gconstpointer unused)
 {
 	GckSlot *other_slot;
 	GckSession *other_session;
@@ -68,30 +103,31 @@ TESTING_TEST(object_equals_hash)
 	GError *err = NULL;
 	guint hash;
 
-	hash = gck_object_hash (object);
+	hash = gck_object_hash (test->object);
 	g_assert (hash != 0);
 
-	g_assert (gck_object_equal (object, object));
+	g_assert (gck_object_equal (test->object, test->object));
 
-	other_slot = g_object_new (GCK_TYPE_SLOT, "module", module, "handle", GCK_MOCK_SLOT_TWO_ID, NULL);
+	other_slot = g_object_new (GCK_TYPE_SLOT, "module", test->module, "handle", GCK_MOCK_SLOT_TWO_ID, NULL);
 	other_session = gck_slot_open_session (other_slot, 0, NULL, &err);
-	SUCCESS_RES (other_session, err);
-	other_object = gck_object_from_handle (other_session, gck_object_get_handle (object));
-	g_assert (!gck_object_equal (object, other_object));
+	g_assert_no_error (err);
+	g_assert (GCK_IS_SESSION (other_session));
+	other_object = gck_object_from_handle (other_session, gck_object_get_handle (test->object));
+	g_assert (!gck_object_equal (test->object, other_object));
 	g_object_unref (other_slot);
 	g_object_unref (other_session);
 	g_object_unref (other_object);
 
 	obj = g_object_new (G_TYPE_OBJECT, NULL);
-	g_assert (!gck_object_equal (object, obj));
+	g_assert (!gck_object_equal (test->object, obj));
 	g_object_unref (obj);
 
-	other_object = gck_object_from_handle (session, 383838);
-	g_assert (!gck_object_equal (object, other_object));
+	other_object = gck_object_from_handle (test->session, 383838);
+	g_assert (!gck_object_equal (test->object, other_object));
 	g_object_unref (other_object);
 
-	other_object = gck_object_from_handle (session, gck_object_get_handle (object));
-	g_assert (gck_object_equal (object, other_object));
+	other_object = gck_object_from_handle (test->session, gck_object_get_handle (test->object));
+	g_assert (gck_object_equal (test->object, other_object));
 	g_object_unref (other_object);
 }
 
@@ -100,10 +136,11 @@ fetch_async_result (GObject *source, GAsyncResult *result, gpointer user_data)
 {
 	*((GAsyncResult**)user_data) = result;
 	g_object_ref (result);
-	testing_wait_stop ();
+	egg_test_wait_stop ();
 }
 
-TESTING_TEST(create_object)
+static void
+test_create_object (Test *test, gconstpointer unused)
 {
 	GAsyncResult *result = NULL;
 	GckAttributes *attrs;
@@ -117,21 +154,21 @@ TESTING_TEST(create_object)
 	gck_attributes_add_boolean (attrs, CKA_TOKEN, CK_FALSE);
 	gck_attributes_add_data (attrs, CKA_VALUE, "BLAH", 4);
 
-	object = gck_session_create_object (session, attrs, NULL, &err);
+	object = gck_session_create_object (test->session, attrs, NULL, &err);
 	g_assert (GCK_IS_OBJECT (object));
-	SUCCESS_RES (object, err);
+	g_assert_no_error (err);
 
 	last_handle = gck_object_get_handle (object);
 	g_object_unref (object);
 
 	/* Using async */
-	gck_session_create_object_async (session, attrs, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_create_object_async (test->session, attrs, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
 
-	object = gck_session_create_object_finish (session, result, &err);
+	object = gck_session_create_object_finish (test->session, result, &err);
 	g_object_unref (result);
-	SUCCESS_RES (object, err);
+	g_assert_no_error (err);
 	g_assert (GCK_IS_OBJECT (object));
 
 	g_assert (last_handle != gck_object_get_handle (object));
@@ -140,7 +177,8 @@ TESTING_TEST(create_object)
 	gck_attributes_unref (attrs);
 }
 
-TESTING_TEST(destroy_object)
+static void
+test_destroy_object (Test *test, gconstpointer unused)
 {
 	GAsyncResult *result = NULL;
 	GckAttributes *attrs;
@@ -154,31 +192,34 @@ TESTING_TEST(destroy_object)
 	gck_attributes_add_boolean (attrs, CKA_TOKEN, CK_TRUE);
 
 	/* Using simple */
-	object = gck_session_create_object (session, attrs, NULL, &err);
-	SUCCESS_RES (object, err);
+	object = gck_session_create_object (test->session, attrs, NULL, &err);
+	g_assert_no_error (err);
 	g_assert (GCK_IS_OBJECT (object));
 
 	ret = gck_object_destroy (object, NULL, &err);
-	SUCCESS_RES (ret, err);
+	g_assert_no_error (err);
+	g_assert (ret);
 	g_object_unref (object);
 
 	/* Using async */
-	object = gck_session_create_object (session, attrs, NULL, &err);
-	SUCCESS_RES (object, err);
+	object = gck_session_create_object (test->session, attrs, NULL, &err);
+	g_assert_no_error (err);
 	g_assert (GCK_IS_OBJECT (object));
 
 	/* Using async */
 	gck_object_destroy_async (object, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
 
 	ret = gck_object_destroy_finish (object, result, &err);
 	g_object_unref (result);
-	SUCCESS_RES (object, err);
+	g_assert_no_error (err);
+	g_assert (ret);
 	g_object_unref (object);
 }
 
-TESTING_TEST(get_attributes)
+static void
+test_get_attributes (Test *test, gconstpointer unused)
 {
 	GAsyncResult *result = NULL;
 	GckAttributes *attrs;
@@ -191,8 +232,8 @@ TESTING_TEST(get_attributes)
 	attr_types[1] = CKA_LABEL;
 
 	/* Simple */
-	attrs = gck_object_get (object, NULL, &err, CKA_CLASS, CKA_LABEL, GCK_INVALID);
-	SUCCESS_RES (attrs, err);
+	attrs = gck_object_get (test->object, NULL, &err, CKA_CLASS, CKA_LABEL, GCK_INVALID);
+	g_assert_no_error (err);
 	if (attrs != NULL) {
 		g_assert (gck_attributes_find_ulong (attrs, CKA_CLASS, &klass) && klass == CKO_DATA);
 		g_assert (gck_attributes_find_string (attrs, CKA_LABEL, &value) && strcmp (value, "TEST LABEL") == 0);
@@ -201,32 +242,31 @@ TESTING_TEST(get_attributes)
 	gck_attributes_unref (attrs);
 
 	/* Full */
-	attrs = gck_object_get_full (object, attr_types, G_N_ELEMENTS (attr_types), NULL, &err);
-	SUCCESS_RES (attrs, err);
-	if (attrs != NULL) {
-		g_assert (gck_attributes_find_ulong (attrs, CKA_CLASS, &klass) && klass == CKO_DATA);
-		g_assert (gck_attributes_find_string (attrs, CKA_LABEL, &value) && strcmp (value, "TEST LABEL") == 0);
-		g_free (value); value = NULL;
-	}
+	attrs = gck_object_get_full (test->object, attr_types, G_N_ELEMENTS (attr_types), NULL, &err);
+	g_assert_no_error (err);
+	g_assert (attrs);
+	g_assert (gck_attributes_find_ulong (attrs, CKA_CLASS, &klass) && klass == CKO_DATA);
+	g_assert (gck_attributes_find_string (attrs, CKA_LABEL, &value) && strcmp (value, "TEST LABEL") == 0);
+	g_free (value); value = NULL;
 	gck_attributes_unref (attrs);
 
 	/* Async */
-	gck_object_get_async (object, attr_types, G_N_ELEMENTS (attr_types), NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_object_get_async (test->object, attr_types, G_N_ELEMENTS (attr_types), NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
 
-	attrs = gck_object_get_finish (object, result, &err);
+	attrs = gck_object_get_finish (test->object, result, &err);
 	g_object_unref (result);
-	SUCCESS_RES (attrs, err);
-	if (attrs != NULL) {
-		g_assert (gck_attributes_find_ulong (attrs, CKA_CLASS, &klass) && klass == CKO_DATA);
-		g_assert (gck_attributes_find_string (attrs, CKA_LABEL, &value) && strcmp (value, "TEST LABEL") == 0);
-		g_free (value); value = NULL;
-	}
+	g_assert_no_error (err);
+	g_assert (attrs);
+	g_assert (gck_attributes_find_ulong (attrs, CKA_CLASS, &klass) && klass == CKO_DATA);
+	g_assert (gck_attributes_find_string (attrs, CKA_LABEL, &value) && strcmp (value, "TEST LABEL") == 0);
+	g_free (value); value = NULL;
 	gck_attributes_unref (attrs);
 }
 
-TESTING_TEST(get_data_attribute)
+static void
+test_get_data_attribute (Test *test, gconstpointer unused)
 {
 	GAsyncResult *result = NULL;
 	CK_OBJECT_CLASS_PTR klass;
@@ -234,40 +274,38 @@ TESTING_TEST(get_data_attribute)
 	GError *err = NULL;
 
 	/* Simple */
-	klass = gck_object_get_data (object, CKA_CLASS, NULL, &n_data, &err);
-	SUCCESS_RES (klass, err);
-	if (klass != NULL) {
-		g_assert (n_data == sizeof (CK_OBJECT_CLASS));
-		g_assert (*klass == CKO_DATA);
-		g_free (klass);
-	}
+	klass = gck_object_get_data (test->object, CKA_CLASS, NULL, &n_data, &err);
+	g_assert_no_error (err);
+	g_assert (klass);
+	g_assert (n_data == sizeof (CK_OBJECT_CLASS));
+	g_assert (*klass == CKO_DATA);
+	g_free (klass);
 
 	/* Full */
-	klass = gck_object_get_data_full (object, CKA_CLASS, NULL, NULL, &n_data, &err);
-	SUCCESS_RES (klass, err);
-	if (klass != NULL) {
-		g_assert (n_data == sizeof (CK_OBJECT_CLASS));
-		g_assert (*klass == CKO_DATA);
-		g_free (klass);
-	}
+	klass = gck_object_get_data_full (test->object, CKA_CLASS, NULL, NULL, &n_data, &err);
+	g_assert_no_error (err);
+	g_assert (klass);
+	g_assert (n_data == sizeof (CK_OBJECT_CLASS));
+	g_assert (*klass == CKO_DATA);
+	g_free (klass);
 
 	/* Async */
-	gck_object_get_data_async (object, CKA_CLASS, NULL, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_object_get_data_async (test->object, CKA_CLASS, NULL, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
 
-	klass = gck_object_get_data_finish (object, result, &n_data, &err);
+	klass = gck_object_get_data_finish (test->object, result, &n_data, &err);
 	g_object_unref (result);
-	SUCCESS_RES (klass, err);
-	if (klass != NULL) {
-		g_assert (n_data == sizeof (CK_OBJECT_CLASS));
-		g_assert (*klass == CKO_DATA);
-		g_free (klass);
-	}
+	g_assert_no_error (err);
+	g_assert (klass);
+	g_assert (n_data == sizeof (CK_OBJECT_CLASS));
+	g_assert (*klass == CKO_DATA);
+	g_free (klass);
 
 }
 
-TESTING_TEST(set_attributes)
+static void
+test_set_attributes (Test *test, gconstpointer unused)
 {
 	GAsyncResult *result = NULL;
 	GckAttributes *attrs, *templ;
@@ -281,39 +319,38 @@ TESTING_TEST(set_attributes)
 	gck_attributes_add_string (templ, CKA_LABEL, "CHANGE TWO");
 
 	/* Full */
-	ret = gck_object_set (object, templ, NULL, &err);
+	ret = gck_object_set (test->object, templ, NULL, &err);
 	gck_attributes_unref (templ);
-	SUCCESS_RES (ret, err);
-	if (ret) {
-		attrs = gck_object_get (object, NULL, &err, CKA_CLASS, CKA_LABEL, GCK_INVALID);
-		g_assert (gck_attributes_find_ulong (attrs, CKA_CLASS, &klass) && klass == 6);
-		g_assert (gck_attributes_find_string (attrs, CKA_LABEL, &value) && strcmp (value, "CHANGE TWO") == 0);
-		g_free (value); value = NULL;
-		gck_attributes_unref (attrs);
-	}
+	g_assert_no_error (err);
+	g_assert (ret);
+	attrs = gck_object_get (test->object, NULL, &err, CKA_CLASS, CKA_LABEL, GCK_INVALID);
+	g_assert (gck_attributes_find_ulong (attrs, CKA_CLASS, &klass) && klass == 6);
+	g_assert (gck_attributes_find_string (attrs, CKA_LABEL, &value) && strcmp (value, "CHANGE TWO") == 0);
+	g_free (value); value = NULL;
+	gck_attributes_unref (attrs);
 
 	templ = gck_attributes_new ();
 	gck_attributes_add_ulong (templ, CKA_CLASS, 7);
 	gck_attributes_add_string (templ, CKA_LABEL, "CHANGE THREE");
 
 	/* Async */
-	gck_object_set_async (object, templ, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_object_set_async (test->object, templ, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
 
-	ret = gck_object_set_finish (object, result, &err);
+	ret = gck_object_set_finish (test->object, result, &err);
 	g_object_unref (result);
-	SUCCESS_RES (ret, err);
-	if (ret) {
-		attrs = gck_object_get (object, NULL, &err, CKA_CLASS, CKA_LABEL, GCK_INVALID);
-		g_assert (gck_attributes_find_ulong (attrs, CKA_CLASS, &klass) && klass == 7);
-		g_assert (gck_attributes_find_string (attrs, CKA_LABEL, &value) && strcmp (value, "CHANGE THREE") == 0);
-		g_free (value); value = NULL;
-		gck_attributes_unref (attrs);
-	}
+	g_assert_no_error (err);
+	g_assert (ret);
+	attrs = gck_object_get (test->object, NULL, &err, CKA_CLASS, CKA_LABEL, GCK_INVALID);
+	g_assert (gck_attributes_find_ulong (attrs, CKA_CLASS, &klass) && klass == 7);
+	g_assert (gck_attributes_find_string (attrs, CKA_LABEL, &value) && strcmp (value, "CHANGE THREE") == 0);
+	g_free (value); value = NULL;
+	gck_attributes_unref (attrs);
 }
 
-TESTING_TEST(find_objects)
+static void
+test_find_objects (Test *test, gconstpointer unused)
 {
 	GAsyncResult *result = NULL;
 	GckAttributes *templ, *attrs;
@@ -324,41 +361,65 @@ TESTING_TEST(find_objects)
 	attrs = gck_attributes_new ();
 	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_DATA);
 	gck_attributes_add_string (attrs, CKA_LABEL, "UNIQUE LABEL");
-	testobj = gck_session_create_object (session, attrs, NULL, &err);
+	testobj = gck_session_create_object (test->session, attrs, NULL, &err);
 	gck_attributes_unref (attrs);
 	g_object_unref (testobj);
 
 	attrs = gck_attributes_new ();
 	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_DATA);
 	gck_attributes_add_string (attrs, CKA_LABEL, "OTHER LABEL");
-	testobj = gck_session_create_object (session, attrs, NULL, &err);
+	testobj = gck_session_create_object (test->session, attrs, NULL, &err);
 	gck_attributes_unref (attrs);
 	g_object_unref (testobj);
 
 	/* Simple, "TEST LABEL" */
 	attrs = gck_attributes_new ();
 	gck_attributes_add_string (attrs, CKA_LABEL, "UNIQUE LABEL");
-	objects = gck_session_find_objects (session, attrs, NULL, &err);
-	SUCCESS_RES (objects, err);
+	objects = gck_session_find_objects (test->session, attrs, NULL, &err);
+	g_assert_no_error (err);
 	g_assert (g_list_length (objects) == 1);
 	gck_list_unref_free (objects);
 	gck_attributes_unref (attrs);
 
 	/* Full, All */
 	templ = gck_attributes_new ();
-	objects = gck_session_find_objects (session, templ, NULL, &err);
-	SUCCESS_RES (objects, err);
+	objects = gck_session_find_objects (test->session, templ, NULL, &err);
+	g_assert_no_error (err);
 	g_assert (g_list_length (objects) > 1);
 	gck_list_unref_free (objects);
 
 	/* Async, None */
 	gck_attributes_add_string (templ, CKA_LABEL, "blah blah");
-	gck_session_find_objects_async (session, templ, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_find_objects_async (test->session, templ, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
 
-	objects = gck_session_find_objects_finish (session, result, &err);
+	objects = gck_session_find_objects_finish (test->session, result, &err);
 	g_object_unref (result);
 	g_assert (objects == NULL);
 	gck_list_unref_free (objects);
 }
+
+int
+main (int argc, char **argv)
+{
+	const gchar *srcdir;
+
+	g_type_init ();
+	g_test_init (&argc, &argv, NULL);
+
+	srcdir = g_getenv ("SRCDIR");
+	if (srcdir && chdir (srcdir) < 0)
+		g_error ("couldn't change directory to: %s: %s", srcdir, g_strerror (errno));
+
+	g_test_add ("/gck/object/object_props", Test, NULL, setup, test_object_props, teardown);
+	g_test_add ("/gck/object/object_equals_hash", Test, NULL, setup, test_object_equals_hash, teardown);
+	g_test_add ("/gck/object/create_object", Test, NULL, setup, test_create_object, teardown);
+	g_test_add ("/gck/object/destroy_object", Test, NULL, setup, test_destroy_object, teardown);
+	g_test_add ("/gck/object/get_attributes", Test, NULL, setup, test_get_attributes, teardown);
+	g_test_add ("/gck/object/get_data_attribute", Test, NULL, setup, test_get_data_attribute, teardown);
+	g_test_add ("/gck/object/set_attributes", Test, NULL, setup, test_set_attributes, teardown);
+	g_test_add ("/gck/object/find_objects", Test, NULL, setup, test_find_objects, teardown);
+
+	return egg_tests_run_in_thread_with_loop ();
+}
diff --git a/gck/tests/test-gck-session.c b/gck/tests/test-gck-session.c
index 1635fa6..5cc1564 100644
--- a/gck/tests/test-gck-session.c
+++ b/gck/tests/test-gck-session.c
@@ -1,69 +1,103 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* test-gck-session.c - the GObject PKCS#11 wrapper library
+
+   Copyright (C) 2011 Collabora Ltd.
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
 
-#include "test-suite.h"
+   Author: Stef Walter <stefw collabora co uk>
+*/
+
+#include "config.h"
+
+#include "gck/gck.h"
+#include "gck/gck-test.h"
+
+#include "egg/egg-testing.h"
 
 #include <glib.h>
 
-#include "gck-test.h"
-#include "test-gck.h"
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
 
-static GckModule *module = NULL;
-static GckSlot *slot = NULL;
-static GckSession *session = NULL;
+typedef struct {
+	GckModule *module;
+	GckSlot *slot;
+	GckSession *session;
+} Test;
 
-TESTING_SETUP(load_session)
+static void
+setup (Test *test, gconstpointer unused)
 {
 	GError *err = NULL;
 	GList *slots;
 
 	/* Successful load */
-	module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
-	SUCCESS_RES (module, err);
+	test->module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_MODULE (test->module));
 
-	slots = gck_module_get_slots (module, TRUE);
+	slots = gck_module_get_slots (test->module, TRUE);
 	g_assert (slots != NULL);
 
-	slot = GCK_SLOT (slots->data);
-	g_object_ref (slot);
+	test->slot = GCK_SLOT (slots->data);
+	g_object_ref (test->slot);
 	gck_list_unref_free (slots);
 
-	session = gck_slot_open_session (slot, 0, NULL, &err);
-	SUCCESS_RES(session, err);
+	test->session = gck_slot_open_session (test->slot, 0, NULL, &err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_SESSION (test->session));
 }
 
-TESTING_TEARDOWN(load_session)
+static void
+teardown (Test *test, gconstpointer unused)
 {
-	g_object_unref (session);
-	g_object_unref (slot);
-	g_object_unref (module);
+	g_object_unref (test->session);
+	g_object_unref (test->slot);
+	g_object_unref (test->module);
 }
 
-TESTING_TEST(session_props)
+static void
+test_session_props (Test *test, gconstpointer unused)
 {
 	GckModule *mod;
 	GckSlot *sl;
 	gulong handle;
 
-	g_object_get (session, "module", &mod, "handle", &handle, "slot", &sl, NULL);
-	g_assert (mod == module);
-	g_assert (sl == slot);
+	g_object_get (test->session, "module", &mod, "handle", &handle, "slot", &sl, NULL);
+	g_assert (mod == test->module);
+	g_assert (sl == test->slot);
 	g_object_unref (mod);
 	g_object_unref (sl);
 
 	g_assert (handle != 0);
-	g_assert (gck_session_get_handle (session) == handle);
+	g_assert (gck_session_get_handle (test->session) == handle);
 }
 
-TESTING_TEST(session_info)
+static void
+test_session_info (Test *test, gconstpointer unused)
 {
 	GckSessionInfo *info;
 
-	info = gck_session_get_info (session);
+	info = gck_session_get_info (test->session);
 	g_assert (info != NULL && "no session info");
 
-	g_assert (info->slot_id == gck_slot_get_handle (slot));
+	g_assert (info->slot_id == gck_slot_get_handle (test->slot));
 	g_assert ((info->flags & CKF_SERIAL_SESSION) == CKF_SERIAL_SESSION);
 	g_assert (info->device_error == 1414);
 	gck_session_info_free (info);
@@ -74,99 +108,112 @@ fetch_async_result (GObject *source, GAsyncResult *result, gpointer user_data)
 {
 	*((GAsyncResult**)user_data) = result;
 	g_object_ref (result);
-	testing_wait_stop ();
+	egg_test_wait_stop ();
 }
 
-TESTING_TEST(open_close_session)
+static void
+test_open_close_session (Test *test, gconstpointer unused)
 {
 	GckSession *sess;
 	GAsyncResult *result = NULL;
 	GError *err = NULL;
 
-	sess = gck_slot_open_session (slot, 0, NULL, &err);
-	SUCCESS_RES (sess, err);
+	sess = gck_slot_open_session (test->slot, 0, NULL, &err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_SESSION (sess));
 
 	g_object_unref (sess);
 
 	/* Test opening async */
-	gck_slot_open_session_async (slot, 0, NULL, fetch_async_result, &result);
+	gck_slot_open_session_async (test->slot, 0, NULL, fetch_async_result, &result);
 
-	testing_wait_until (500);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
 
 	/* Get the result */
-	sess = gck_slot_open_session_finish (slot, result, &err);
-	SUCCESS_RES (sess, err);
+	sess = gck_slot_open_session_finish (test->slot, result, &err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_SESSION (sess));
 
 	g_object_unref (result);
 	g_object_unref (sess);
 }
 
-TESTING_TEST(init_set_pin)
+static void
+test_init_set_pin (Test *test, gconstpointer unused)
 {
 	GAsyncResult *result = NULL;
 	GError *err = NULL;
 	gboolean ret;
 
 	/* init pin */
-	ret = gck_session_init_pin (session, (guchar*)"booo", 4, NULL, &err);
-	SUCCESS_RES (ret, err);
+	ret = gck_session_init_pin (test->session, (guchar*)"booo", 4, NULL, &err);
+	g_assert_no_error (err);
+	g_assert (ret);
 
 	/* set pin */
-	ret = gck_session_set_pin (session, (guchar*)"booo", 4, (guchar*)"tooo", 4, NULL, &err);
-	SUCCESS_RES (ret, err);
+	ret = gck_session_set_pin (test->session, (guchar*)"booo", 4, (guchar*)"tooo", 4, NULL, &err);
+	g_assert_no_error (err);
+	g_assert (ret);
 
 	/* init pin async */
-	gck_session_init_pin_async (session, (guchar*)"booo", 4, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_init_pin_async (test->session, (guchar*)"booo", 4, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
-	ret = gck_session_init_pin_finish (session, result, &err);
-	SUCCESS_RES (ret, err);
+	ret = gck_session_init_pin_finish (test->session, result, &err);
+	g_assert_no_error (err);
+	g_assert (ret);
 	g_object_unref (result);
 	result = NULL;
 
 	/* set pin async */
-	gck_session_set_pin_async (session, (guchar*)"booo", 4, (guchar*)"tooo", 4, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_set_pin_async (test->session, (guchar*)"booo", 4, (guchar*)"tooo", 4, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
-	ret = gck_session_set_pin_finish (session, result, &err);
-	SUCCESS_RES (ret, err);
+	ret = gck_session_set_pin_finish (test->session, result, &err);
+	g_assert_no_error (err);
+	g_assert (ret);
 	g_object_unref (result);
 	result = NULL;
 }
 
 
-TESTING_TEST(login_logout)
+static void
+test_login_logout (Test *test, gconstpointer unused)
 {
 	GAsyncResult *result = NULL;
 	GError *err = NULL;
 	gboolean ret;
 
 	/* login/logout */
-	ret = gck_session_login (session, CKU_USER, (guchar*)"booo", 4, NULL, &err);
-	SUCCESS_RES (ret, err);
+	ret = gck_session_login (test->session, CKU_USER, (guchar*)"booo", 4, NULL, &err);
+	g_assert_no_error (err);
+	g_assert (ret);
 
-	ret = gck_session_logout (session, NULL, &err);
-	SUCCESS_RES (ret, err);
+	ret = gck_session_logout (test->session, NULL, &err);
+	g_assert_no_error (err);
+	g_assert (ret);
 
 	/* login async */
-	gck_session_login_async (session, CKU_USER, (guchar*)"booo", 4, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_login_async (test->session, CKU_USER, (guchar*)"booo", 4, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
 
-	ret = gck_session_login_finish (session, result, &err);
-	SUCCESS_RES (ret, err);
+	ret = gck_session_login_finish (test->session, result, &err);
+	g_assert_no_error (err);
+	g_assert (ret);
 
 	g_object_unref (result);
 	result = NULL;
 
 	/* logout async */
-	gck_session_logout_async (session, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_session_logout_async (test->session, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
 
-	ret = gck_session_logout_finish (session, result, &err);
-	SUCCESS_RES (ret, err);
+	ret = gck_session_logout_finish (test->session, result, &err);
+	g_assert_no_error (err);
+	g_assert (ret);
 
 	g_object_unref (result);
 	result = NULL;
@@ -186,7 +233,8 @@ authenticate_token (GckModule *module, GckSlot *slot, gchar *label, gchar **pass
 	return TRUE;
 }
 
-TESTING_TEST(auto_login)
+static void
+test_auto_login (Test *test, gconstpointer unused)
 {
 	GckObject *object;
 	GckSession *new_session;
@@ -201,47 +249,75 @@ TESTING_TEST(auto_login)
 	gck_attributes_add_boolean (attrs, CKA_PRIVATE, CK_TRUE);
 
 	/* Try to do something that requires a login */
-	object = gck_session_create_object (session, attrs, NULL, &err);
+	object = gck_session_create_object (test->session, attrs, NULL, &err);
 	g_assert (!object);
 	g_assert (err && err->code == CKR_USER_NOT_LOGGED_IN);
 	g_clear_error (&err);
 
 	/* Setup for auto login */
-	g_signal_connect (module, "authenticate-slot", G_CALLBACK (authenticate_token), GUINT_TO_POINTER (35));
-	new_session = gck_slot_open_session (slot, GCK_SESSION_READ_WRITE | GCK_SESSION_LOGIN_USER, NULL, &err);
-	SUCCESS_RES (new_session, err);
+	g_signal_connect (test->module, "authenticate-slot", G_CALLBACK (authenticate_token), GUINT_TO_POINTER (35));
+	new_session = gck_slot_open_session (test->slot, GCK_SESSION_READ_WRITE | GCK_SESSION_LOGIN_USER, NULL, &err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_SESSION (new_session));
 
 	/* Try again to do something that requires a login */
 	object = gck_session_create_object (new_session, attrs, NULL, &err);
-	SUCCESS_RES (object, err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_OBJECT (object));
 	g_object_unref (object);
 
 	/* We should now be logged in, try to log out */
 	ret = gck_session_logout (new_session, NULL, &err);
-	SUCCESS_RES (ret, err);
+	g_assert_no_error (err);
+	g_assert (ret);
 
 	g_object_unref (new_session);
 
 	/* Now try the same thing, but asyncronously */
-	gck_slot_open_session_async (slot, GCK_SESSION_READ_WRITE | GCK_SESSION_LOGIN_USER, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	gck_slot_open_session_async (test->slot, GCK_SESSION_READ_WRITE | GCK_SESSION_LOGIN_USER, NULL, fetch_async_result, &result);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
-	new_session = gck_slot_open_session_finish (slot, result, &err);
-	SUCCESS_RES (new_session, err);
+	new_session = gck_slot_open_session_finish (test->slot, result, &err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_SESSION (new_session));
 	g_object_unref (result);
 
 	result = NULL;
 	gck_session_create_object_async (new_session, attrs, NULL, fetch_async_result, &result);
-	testing_wait_until (500);
+	egg_test_wait_until (500);
 	g_assert (result != NULL);
 	object = gck_session_create_object_finish (new_session, result, &err);
-	SUCCESS_RES (object, err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_OBJECT (object));
 	g_object_unref (result);
 	g_object_unref (object);
 
 	/* We should now be logged in, try to log out */
 	ret = gck_session_logout (new_session, NULL, &err);
-	SUCCESS_RES (ret, err);
+	g_assert_no_error (err);
+	g_assert (ret);
 
 	g_object_unref (new_session);
 }
+
+int
+main (int argc, char **argv)
+{
+	const gchar *srcdir;
+
+	g_type_init ();
+	g_test_init (&argc, &argv, NULL);
+
+	srcdir = g_getenv ("SRCDIR");
+	if (srcdir && chdir (srcdir) < 0)
+		g_error ("couldn't change directory to: %s: %s", srcdir, g_strerror (errno));
+
+	g_test_add ("/gck/session/session_props", Test, NULL, setup, test_session_props, teardown);
+	g_test_add ("/gck/session/session_info", Test, NULL, setup, test_session_info, teardown);
+	g_test_add ("/gck/session/open_close_session", Test, NULL, setup, test_open_close_session, teardown);
+	g_test_add ("/gck/session/init_set_pin", Test, NULL, setup, test_init_set_pin, teardown);
+	g_test_add ("/gck/session/login_logout", Test, NULL, setup, test_login_logout, teardown);
+	g_test_add ("/gck/session/auto_login", Test, NULL, setup, test_auto_login, teardown);
+
+	return egg_tests_run_in_thread_with_loop ();
+}
diff --git a/gck/tests/test-gck-slot.c b/gck/tests/test-gck-slot.c
index 5d97197..e36dc6d 100644
--- a/gck/tests/test-gck-slot.c
+++ b/gck/tests/test-gck-slot.c
@@ -1,46 +1,76 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* test-gck-slot.c - the GObject PKCS#11 wrapper library
 
+   Copyright (C) 2011 Collabora Ltd.
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Stef Walter <stefw collabora co uk>
+*/
+
+#include "config.h"
+
+#include <errno.h>
 #include <glib.h>
 #include <string.h>
 
-#include "test-suite.h"
-#include "gck-test.h"
-#include "gck-private.h"
-#include "test-gck.h"
+#include "gck/gck.h"
+#include "gck/gck-private.h"
+#include "gck/gck-test.h"
 
-static GckModule *module = NULL;
-static GckSlot *slot = NULL;
+typedef struct {
+	GckModule *module;
+	GckSlot *slot;
+} Test;
 
-TESTING_SETUP(load_slots)
+static void
+setup (Test *test, gconstpointer unused)
 {
 	GError *err = NULL;
 	GList *slots;
 
 	/* Successful load */
-	module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
-	SUCCESS_RES (module, err);
+	test->module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
+	g_assert_no_error (err);
+	g_assert (GCK_IS_MODULE (test->module));
 
-	slots = gck_module_get_slots (module, TRUE);
+	slots = gck_module_get_slots (test->module, TRUE);
 	g_assert (slots != NULL);
 
-	slot = GCK_SLOT (slots->data);
-	g_object_ref (slot);
+	test->slot = GCK_SLOT (slots->data);
+	g_object_ref (test->slot);
 	gck_list_unref_free (slots);
 
 }
 
-TESTING_TEARDOWN(load_slots)
+static void
+teardown (Test *test, gconstpointer unused)
 {
-	g_object_unref (slot);
-	g_object_unref (module);
+	g_object_unref (test->slot);
+	g_object_unref (test->module);
 }
 
-TESTING_TEST(slot_info)
+static void
+test_slot_info (Test *test, gconstpointer unused)
 {
 	GckSlotInfo *info;
 	GckTokenInfo *token;
 	GList *slots, *l;
 
-	slots = gck_module_get_slots (module, FALSE);
+	slots = gck_module_get_slots (test->module, FALSE);
 	g_assert (2 == g_list_length (slots) && "wrong number of slots returned");
 	g_assert (GCK_IS_SLOT (slots->data) && "missing slot one");
 	g_assert (GCK_IS_SLOT (slots->next->data) && "missing slot two");
@@ -57,7 +87,7 @@ TESTING_TEST(slot_info)
 		g_assert (165 == info->firmware_version_minor);
 
 		if (info->flags & CKF_TOKEN_PRESENT) {
-			token = gck_slot_get_token_info (slot);
+			token = gck_slot_get_token_info (test->slot);
 			g_assert (token != NULL && "no token info");
 
 			g_assert (strcmp ("TEST MANUFACTURER", token->manufacturer_id) == 0);
@@ -89,57 +119,60 @@ TESTING_TEST(slot_info)
 	gck_list_unref_free (slots);
 }
 
-TESTING_TEST(slot_props)
+static void
+test_slot_props (Test *test, gconstpointer unused)
 {
 	GckModule *mod;
 	CK_SLOT_ID slot_id;
 
-	g_object_get (slot, "module", &mod, "handle", &slot_id, NULL);
-	g_assert (mod == module);
+	g_object_get (test->slot, "module", &mod, "handle", &slot_id, NULL);
+	g_assert (mod == test->module);
 	g_assert (slot_id == 52);
 
 	g_object_unref (mod);
 }
 
-TESTING_TEST(slot_equals_hash)
+static void
+test_slot_equals_hash (Test *test, gconstpointer unused)
 {
 	GckModule *other_mod;
 	GckSlot *other_slot;
 	GObject *obj;
 	guint hash;
 
-	hash = gck_slot_hash (slot);
+	hash = gck_slot_hash (test->slot);
 	g_assert (hash != 0);
 
-	g_assert (gck_slot_equal (slot, slot));
+	g_assert (gck_slot_equal (test->slot, test->slot));
 
-	other_mod = gck_module_new (gck_module_get_functions (module), 0);
-	other_slot = g_object_new (GCK_TYPE_SLOT, "module", other_mod, "handle", gck_slot_get_handle (slot), NULL);
-	g_assert (gck_slot_equal (slot, other_slot));
+	other_mod = gck_module_new (gck_module_get_functions (test->module), 0);
+	other_slot = g_object_new (GCK_TYPE_SLOT, "module", other_mod, "handle", gck_slot_get_handle (test->slot), NULL);
+	g_assert (gck_slot_equal (test->slot, other_slot));
 	g_object_unref (other_mod);
 	g_object_unref (other_slot);
 
 	obj = g_object_new (G_TYPE_OBJECT, NULL);
-	g_assert (!gck_slot_equal (slot, obj));
+	g_assert (!gck_slot_equal (test->slot, obj));
 	g_object_unref (obj);
 
-	other_slot = g_object_new (GCK_TYPE_SLOT, "module", module, "handle", 8909, NULL);
-	g_assert (!gck_slot_equal (slot, obj));
+	other_slot = g_object_new (GCK_TYPE_SLOT, "module", test->module, "handle", 8909, NULL);
+	g_assert (!gck_slot_equal (test->slot, obj));
 	g_object_unref (other_slot);
 }
 
-TESTING_TEST(slot_mechanisms)
+static void
+test_slot_mechanisms (Test *test, gconstpointer unused)
 {
 	GckMechanisms *mechs;
 	GckMechanismInfo *info;
 	guint i;
 
-	mechs = gck_slot_get_mechanisms (slot);
+	mechs = gck_slot_get_mechanisms (test->slot);
 	g_assert (2 == gck_mechanisms_length (mechs) && "wrong number of mech types returned");
 
 	for (i = 0; i < gck_mechanisms_length (mechs); ++i) {
 
-		info = gck_slot_get_mechanism_info (slot, gck_mechanisms_at (mechs, i));
+		info = gck_slot_get_mechanism_info (test->slot, gck_mechanisms_at (mechs, i));
 		g_assert (info != NULL && "no mech info returned");
 
 		gck_mechanism_info_free (info);
@@ -148,13 +181,14 @@ TESTING_TEST(slot_mechanisms)
 	gck_mechanisms_free (mechs);
 }
 
-TESTING_TEST(token_info_match_null)
+static void
+test_token_info_match_null (Test *test, gconstpointer unused)
 {
 	GckTokenInfo *match;
 	GckTokenInfo *token;
 	gboolean ret;
 
-	token = gck_slot_get_token_info (slot);
+	token = gck_slot_get_token_info (test->slot);
 	match = g_new0 (GckTokenInfo, 1);
 
 	/* Should match, since no fields are set */
@@ -165,13 +199,14 @@ TESTING_TEST(token_info_match_null)
 	gck_token_info_free (token);
 }
 
-TESTING_TEST(token_info_match_label)
+static void
+test_token_info_match_label (Test *test, gconstpointer unused)
 {
 	GckTokenInfo *match;
 	GckTokenInfo *token;
 	gboolean ret;
 
-	token = gck_slot_get_token_info (slot);
+	token = gck_slot_get_token_info (test->slot);
 	match = g_new0 (GckTokenInfo, 1);
 
 	/* Should match since the label and serial are matching */
@@ -184,13 +219,14 @@ TESTING_TEST(token_info_match_label)
 	gck_token_info_free (token);
 }
 
-TESTING_TEST(token_info_match_different)
+static void
+test_token_info_match_different (Test *test, gconstpointer unused)
 {
 	GckTokenInfo *match;
 	GckTokenInfo *token;
 	gboolean ret;
 
-	token = gck_slot_get_token_info (slot);
+	token = gck_slot_get_token_info (test->slot);
 	match = g_new0 (GckTokenInfo, 1);
 
 	/* Should not match since serial is different */
@@ -202,3 +238,26 @@ TESTING_TEST(token_info_match_different)
 	gck_token_info_free (match);
 	gck_token_info_free (token);
 }
+
+int
+main (int argc, char **argv)
+{
+	const gchar *srcdir;
+
+	g_type_init ();
+	g_test_init (&argc, &argv, NULL);
+
+	srcdir = g_getenv ("SRCDIR");
+	if (srcdir && chdir (srcdir) < 0)
+		g_error ("couldn't change directory to: %s: %s", srcdir, g_strerror (errno));
+
+	g_test_add ("/gck/slot/slot_info", Test, NULL, setup, test_slot_info, teardown);
+	g_test_add ("/gck/slot/slot_props", Test, NULL, setup, test_slot_props, teardown);
+	g_test_add ("/gck/slot/slot_equals_hash", Test, NULL, setup, test_slot_equals_hash, teardown);
+	g_test_add ("/gck/slot/slot_mechanisms", Test, NULL, setup, test_slot_mechanisms, teardown);
+	g_test_add ("/gck/slot/token_info_match_null", Test, NULL, setup, test_token_info_match_null, teardown);
+	g_test_add ("/gck/slot/token_info_match_label", Test, NULL, setup, test_token_info_match_label, teardown);
+	g_test_add ("/gck/slot/token_info_match_different", Test, NULL, setup, test_token_info_match_different, teardown);
+
+	return g_test_run ();
+}
diff --git a/gck/tests/test-gck-uri.c b/gck/tests/test-gck-uri.c
index 0df702f..865aa0f 100644
--- a/gck/tests/test-gck-uri.c
+++ b/gck/tests/test-gck-uri.c
@@ -21,24 +21,19 @@
    Author: Stef Walter <stefw collabora co uk>
 */
 
-#include <glib.h>
-#include <string.h>
+#include "config.h"
 
-#include "test-suite.h"
-#include "gck-test.h"
-#include "gck-private.h"
+#include "gck/gck.h"
+#include "gck/gck-private.h"
+#include "gck/gck-test.h"
 
-TESTING_SETUP(uri)
-{
-
-}
-
-TESTING_TEARDOWN(uri)
-{
+#include <glib.h>
 
-}
+#include <errno.h>
+#include <string.h>
 
-TESTING_TEST(uri_parse)
+static void
+test_parse (void)
 {
 	GError *error = NULL;
 	GckUriInfo *uri_info;
@@ -57,7 +52,8 @@ TESTING_TEST(uri_parse)
 	gck_uri_info_free (uri_info);
 }
 
-TESTING_TEST(uri_parse_bad_scheme)
+static void
+test_parse_bad_scheme (void)
 {
 	GError *error = NULL;
 	GckUriInfo *uri_info;
@@ -68,7 +64,8 @@ TESTING_TEST(uri_parse_bad_scheme)
 	g_error_free (error);
 }
 
-TESTING_TEST(uri_parse_with_label)
+static void
+test_parse_with_label (void)
 {
 	GError *error = NULL;
 	GckUriInfo *uri_info;
@@ -87,7 +84,8 @@ TESTING_TEST(uri_parse_with_label)
 	gck_uri_info_free (uri_info);
 }
 
-TESTING_TEST(uri_parse_with_label_and_klass)
+static void
+test_parse_with_label_and_klass (void)
 {
 	GError *error = NULL;
 	GckUriInfo *uri_info;
@@ -111,7 +109,8 @@ TESTING_TEST(uri_parse_with_label_and_klass)
 	gck_uri_info_free (uri_info);
 }
 
-TESTING_TEST(uri_parse_with_id)
+static void
+test_parse_with_id (void)
 {
 	GError *error = NULL;
 	GckAttribute *attr;
@@ -130,7 +129,8 @@ TESTING_TEST(uri_parse_with_id)
 	gck_uri_info_free (uri_info);
 }
 
-TESTING_TEST(uri_parse_with_bad_string_encoding)
+static void
+test_parse_with_bad_string_encoding (void)
 {
 	GError *error = NULL;
 	GckUriInfo *uri_info;
@@ -141,7 +141,8 @@ TESTING_TEST(uri_parse_with_bad_string_encoding)
 	g_error_free (error);
 }
 
-TESTING_TEST(uri_parse_with_bad_binary_encoding)
+static void
+test_parse_with_bad_binary_encoding (void)
 {
 	GError *error = NULL;
 	GckUriInfo *uri_info;
@@ -151,7 +152,8 @@ TESTING_TEST(uri_parse_with_bad_binary_encoding)
 	g_error_free (error);
 }
 
-TESTING_TEST(uri_parse_with_token)
+static void
+test_parse_with_token (void)
 {
 	GError *error = NULL;
 	GckUriInfo *uri_info = NULL;
@@ -168,7 +170,8 @@ TESTING_TEST(uri_parse_with_token)
 	gck_uri_info_free (uri_info);
 }
 
-TESTING_TEST(uri_parse_with_token_bad_encoding)
+static void
+test_parse_with_token_bad_encoding (void)
 {
 	GError *error = NULL;
 	GckUriInfo *uri_info;
@@ -179,7 +182,8 @@ TESTING_TEST(uri_parse_with_token_bad_encoding)
 	g_error_free (error);
 }
 
-TESTING_TEST(uri_parse_with_bad_syntax)
+static void
+test_parse_with_bad_syntax (void)
 {
 	GError *error = NULL;
 	GckUriInfo *uri_info;
@@ -190,7 +194,8 @@ TESTING_TEST(uri_parse_with_bad_syntax)
 	g_error_free (error);
 }
 
-TESTING_TEST(uri_parse_with_library)
+static void
+test_parse_with_library (void)
 {
 	GError *error = NULL;
 	GckUriInfo *uri_info = NULL;
@@ -205,7 +210,8 @@ TESTING_TEST(uri_parse_with_library)
 	gck_uri_info_free (uri_info);
 }
 
-TESTING_TEST(uri_parse_with_library_bad_encoding)
+static void
+test_parse_with_library_bad_encoding (void)
 {
 	GError *error = NULL;
 	GckUriInfo *uri_info;
@@ -216,7 +222,8 @@ TESTING_TEST(uri_parse_with_library_bad_encoding)
 	g_error_free (error);
 }
 
-TESTING_TEST(uri_build_empty)
+static void
+test_build_empty (void)
 {
 	GckUriInfo uri_info;
 	gchar *uri;
@@ -227,7 +234,8 @@ TESTING_TEST(uri_build_empty)
 	g_free (uri);
 }
 
-TESTING_TEST(uri_build_with_token_info)
+static void
+test_build_with_token_info (void)
 {
 	gchar *uri = NULL;
 	GckUriInfo uri_info;
@@ -261,7 +269,8 @@ TESTING_TEST(uri_build_with_token_info)
 	g_free (uri);
 }
 
-TESTING_TEST(uri_build_with_token_null_info)
+static void
+test_build_with_token_null_info (void)
 {
 	gchar *uri = NULL;
 	GckUriInfo uri_info;
@@ -281,7 +290,8 @@ TESTING_TEST(uri_build_with_token_null_info)
 	g_free (uri);
 }
 
-TESTING_TEST(uri_build_with_token_empty_info)
+static void
+test_build_with_token_empty_info (void)
 {
 	gchar *uri = NULL;
 	GckUriInfo uri_info;
@@ -302,7 +312,8 @@ TESTING_TEST(uri_build_with_token_empty_info)
 	g_free (uri);
 }
 
-TESTING_TEST(uri_build_with_attributes)
+static void
+test_build_with_attributes (void)
 {
 	gchar *uri = NULL;
 	GckUriInfo uri_info;
@@ -349,7 +360,8 @@ TESTING_TEST(uri_build_with_attributes)
 	g_free (uri);
 }
 
-TESTING_TEST (uri_parse_private_key)
+static void
+test_parse_private_key (void)
 {
 	GckUriInfo *uri_info;
 	GError *error = NULL;
@@ -367,7 +379,8 @@ TESTING_TEST (uri_parse_private_key)
 	gck_uri_info_free (uri_info);
 }
 
-TESTING_TEST (uri_parse_parse_secret_key)
+static void
+test_parse_secret_key (void)
 {
 	GckUriInfo *uri_info;
 	GError *error = NULL;
@@ -386,7 +399,8 @@ TESTING_TEST (uri_parse_parse_secret_key)
 }
 
 
-TESTING_TEST (uri_parse_parse_unknown_objecttype)
+static void
+test_parse_unknown_objecttype (void)
 {
 	GckUriInfo *uri_info;
 	GError *error = NULL;
@@ -404,7 +418,8 @@ TESTING_TEST (uri_parse_parse_unknown_objecttype)
 	gck_uri_info_free (uri_info);
 }
 
-TESTING_TEST (uri_build_objecttype_cert)
+static void
+test_build_objecttype_cert (void)
 {
 	GckUriInfo *uri_info;
 	gchar *uri;
@@ -421,7 +436,8 @@ TESTING_TEST (uri_build_objecttype_cert)
 	g_free (uri);
 }
 
-TESTING_TEST (uri_build_objecttype_private)
+static void
+test_build_objecttype_private (void)
 {
 	GckUriInfo *uri_info;
 	gchar *uri;
@@ -438,7 +454,8 @@ TESTING_TEST (uri_build_objecttype_private)
 	g_free (uri);
 }
 
-TESTING_TEST (uri_build_objecttype_public)
+static void
+test_build_objecttype_public (void)
 {
 	GckUriInfo *uri_info;
 	gchar *uri;
@@ -455,7 +472,8 @@ TESTING_TEST (uri_build_objecttype_public)
 	g_free (uri);
 }
 
-TESTING_TEST (uri_build_objecttype_secret)
+static void
+test_build_objecttype_secret (void)
 {
 	GckUriInfo *uri_info;
 	gchar *uri;
@@ -472,7 +490,8 @@ TESTING_TEST (uri_build_objecttype_secret)
 	g_free (uri);
 }
 
-TESTING_TEST (uri_build_with_library)
+static void
+test_build_with_library (void)
 {
 	GckUriInfo *uri_info;
 	gchar *uri;
@@ -488,3 +507,56 @@ TESTING_TEST (uri_build_with_library)
 	gck_uri_info_free (uri_info);
 	g_free (uri);
 }
+
+
+static void
+null_log_handler (const gchar *log_domain, GLogLevelFlags log_level,
+                  const gchar *message, gpointer user_data)
+{
+
+}
+
+int
+main (int argc, char **argv)
+{
+	const gchar *srcdir;
+
+	g_type_init ();
+	g_test_init (&argc, &argv, NULL);
+
+	srcdir = g_getenv ("SRCDIR");
+	if (srcdir && chdir (srcdir) < 0)
+		g_error ("couldn't change directory to: %s: %s", srcdir, g_strerror (errno));
+
+	/* 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);
+
+	g_test_add_func ("/gck/uri/parse", test_parse);
+	g_test_add_func ("/gck/uri/parse_bad_scheme", test_parse_bad_scheme);
+	g_test_add_func ("/gck/uri/parse_with_label", test_parse_with_label);
+	g_test_add_func ("/gck/uri/parse_with_label_and_klass", test_parse_with_label_and_klass);
+	g_test_add_func ("/gck/uri/parse_with_id", test_parse_with_id);
+	g_test_add_func ("/gck/uri/parse_with_bad_string_encoding", test_parse_with_bad_string_encoding);
+	g_test_add_func ("/gck/uri/parse_with_bad_binary_encoding", test_parse_with_bad_binary_encoding);
+	g_test_add_func ("/gck/uri/parse_with_token", test_parse_with_token);
+	g_test_add_func ("/gck/uri/parse_with_token_bad_encoding", test_parse_with_token_bad_encoding);
+	g_test_add_func ("/gck/uri/parse_with_bad_syntax", test_parse_with_bad_syntax);
+	g_test_add_func ("/gck/uri/parse_with_library", test_parse_with_library);
+	g_test_add_func ("/gck/uri/parse_with_library_bad_encoding", test_parse_with_library_bad_encoding);
+	g_test_add_func ("/gck/uri/build_empty", test_build_empty);
+	g_test_add_func ("/gck/uri/build_with_token_info", test_build_with_token_info);
+	g_test_add_func ("/gck/uri/build_with_token_null_info", test_build_with_token_null_info);
+	g_test_add_func ("/gck/uri/build_with_token_empty_info", test_build_with_token_empty_info);
+	g_test_add_func ("/gck/uri/build_with_attributes", test_build_with_attributes);
+	g_test_add_func ("/gck/uri/parse_private_key", test_parse_private_key);
+	g_test_add_func ("/gck/uri/parse_secret_key", test_parse_secret_key);
+	g_test_add_func ("/gck/uri/parse_unknown_objecttype", test_parse_unknown_objecttype);
+	g_test_add_func ("/gck/uri/build_objecttype_cert", test_build_objecttype_cert);
+	g_test_add_func ("/gck/uri/build_objecttype_private", test_build_objecttype_private);
+	g_test_add_func ("/gck/uri/build_objecttype_public", test_build_objecttype_public);
+	g_test_add_func ("/gck/uri/build_objecttype_secret", test_build_objecttype_secret);
+	g_test_add_func ("/gck/uri/build_with_library", test_build_with_library);
+
+	return g_test_run ();
+}



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