[gnome-keyring] Makefile.am: Move tests into same directories as tested code



commit 50e0feec5d80263ba2c65d005290a3e9837905f4
Author: Stef Walter <stefw gnome org>
Date:   Tue Mar 4 16:12:16 2014 +0100

    Makefile.am: Move tests into same directories as tested code
    
    This allows for a cleaner build tree, and will provide benefits
    when moving to a single Makefile.

 configure.ac                                       |    9 --
 daemon/control/Makefile.am                         |   52 ++++++++++++-
 daemon/control/{tests => }/frob-control-change.c   |    0
 daemon/control/{tests => }/frob-control-init.c     |    0
 daemon/control/{tests => }/frob-control-quit.c     |    0
 daemon/control/{tests => }/frob-control-unlock.c   |    0
 daemon/control/tests/.gitignore                    |    4 -
 daemon/control/tests/Makefile.am                   |   55 --------------
 daemon/dbus/Makefile.am                            |   40 ++++++++++-
 daemon/dbus/{tests/files => fixtures}/test.keyring |  Bin 180 -> 180 bytes
 daemon/dbus/{tests => }/test-secret-items.c        |    0
 daemon/dbus/{tests => }/test-secret-lock.c         |    0
 daemon/dbus/{tests => }/test-secret-search.c       |    0
 daemon/dbus/{tests => }/test-secret-signals.c      |    0
 daemon/dbus/{tests => }/test-secret-util.c         |    0
 daemon/dbus/{tests => }/test-service.c             |    2 +-
 daemon/dbus/{tests => }/test-service.h             |    0
 daemon/dbus/tests/Makefile.am                      |   44 -----------
 egg/Makefile.am                                    |   58 +++++++++++++--
 egg/{tests/files => fixtures}/dh-params.pem        |    0
 egg/{tests/files => fixtures}/echo-script.sh       |    0
 egg/{tests/files => fixtures}/pem-rsa-enc.key      |    0
 .../files => fixtures}/test-certificate-1.der      |  Bin 813 -> 813 bytes
 .../test-personalname-invalid.der                  |    0
 egg/{tests/files => fixtures}/test-pkcs12-1.der    |  Bin 2824 -> 2824 bytes
 egg/{tests/files => fixtures}/test-pkcs7-1.der     |  Bin 1002 -> 1002 bytes
 egg/{tests/files => fixtures}/test-pkcs7-2.der     |  Bin 1002 -> 1002 bytes
 egg/{tests/files => fixtures}/test-pkcs8-1.der     |  Bin 335 -> 335 bytes
 egg/{tests/files => fixtures}/test-rsakey-1.der    |  Bin 609 -> 609 bytes
 egg/{tests => }/test-armor.c                       |    0
 egg/{tests => }/test-asn1.c                        |    2 +-
 egg/{tests => }/test-asn1x.c                       |   14 ++--
 egg/{tests => }/test-cleanup.c                     |    0
 egg/{tests => }/test-dh.c                          |    0
 egg/{tests => }/test-dn.c                          |    2 +-
 egg/{tests => }/test-hex.c                         |    0
 egg/{tests => }/test-hkdf.c                        |    0
 egg/{tests => }/test-oid.c                         |    0
 egg/{tests => }/test-openssl.c                     |    2 +-
 egg/{tests => }/test-padding.c                     |    0
 egg/{tests => }/test-secmem.c                      |    0
 egg/{tests => }/test-spawn.c                       |   10 +-
 egg/{tests => }/test-symkey.c                      |    0
 egg/{tests => }/test.asn                           |    0
 egg/{tests => }/test.asn.h                         |    0
 egg/tests/.gitignore                               |    1 -
 egg/tests/Makefile.am                              |   54 -------------
 pkcs11/gkm/Makefile.am                             |   73 ++++++++++++++++++-
 pkcs11/gkm/{tests/test.asn.h => asn1-def-test.h}   |    2 +-
 .../{tests/files => fixtures}/ca-certificates.crt  |    0
 .../files => fixtures}/der-key-PBE-MD5-DES.p8      |  Bin 677 -> 677 bytes
 .../files => fixtures}/der-key-PBE-SHA1-3DES.p8    |  Bin 678 -> 678 bytes
 .../files => fixtures}/der-key-PBE-SHA1-DES.p8     |  Bin 677 -> 677 bytes
 .../files => fixtures}/der-key-PBE-SHA1-RC2-40.p8  |  Bin 678 -> 678 bytes
 .../files => fixtures}/der-key-PBE-SHA1-RC4-128.p8 |  Bin 673 -> 673 bytes
 .../gkm/{tests/files => fixtures}/der-key-dsa.p8   |  Bin 335 -> 335 bytes
 .../files => fixtures}/der-key-encrypted-pkcs5.p8  |  Bin 677 -> 677 bytes
 .../{tests/files => fixtures}/der-key-v2-des.p8    |  Bin 711 -> 711 bytes
 .../{tests/files => fixtures}/der-key-v2-des3.p8   |  Bin 714 -> 714 bytes
 pkcs11/gkm/{tests/files => fixtures}/der-key.p8    |  Bin 635 -> 635 bytes
 .../gkm/{tests/files => fixtures}/pem-rsa-enc.key  |    0
 .../files => fixtures}/test-certificate-1.der      |  Bin 813 -> 813 bytes
 .../files => fixtures}/test-certificate-2.der      |  Bin 1346 -> 1346 bytes
 pkcs11/gkm/{tests => }/mock-locked-object.c        |    0
 pkcs11/gkm/{tests => }/mock-locked-object.h        |    0
 pkcs11/gkm/{tests => }/mock-module.c               |    2 +-
 pkcs11/gkm/{tests => }/mock-module.h               |    0
 pkcs11/gkm/{tests => }/test-attributes.c           |    0
 pkcs11/gkm/{tests => }/test-certificate.c          |    2 +-
 pkcs11/gkm/{tests => }/test-credential.c           |    0
 pkcs11/gkm/{tests => }/test-data-asn1.c            |    2 +-
 pkcs11/gkm/{tests => }/test-data-der.c             |   12 ++--
 pkcs11/gkm/{tests => }/test-file-tracker.c         |    0
 pkcs11/gkm/{tests => }/test-memory-store.c         |    0
 pkcs11/gkm/{tests => }/test-object.c               |    2 +-
 pkcs11/gkm/{tests => }/test-secret.c               |    0
 pkcs11/gkm/{tests => }/test-sexp.c                 |    0
 pkcs11/gkm/{tests => }/test-store.c                |    0
 pkcs11/gkm/{tests => }/test-timer.c                |    0
 pkcs11/gkm/{tests => }/test-transaction.c          |    0
 pkcs11/gkm/{tests => }/test.asn                    |    0
 pkcs11/gkm/{tests => }/test.asn.h                  |    0
 pkcs11/gkm/tests/.gitignore                        |    2 -
 pkcs11/gkm/tests/Makefile.am                       |   79 --------------------
 pkcs11/gnome2-store/Makefile.am                    |   59 ++++++++++++++-
 .../gnome2-store/{tests => }/check-gnome2-module.c |    0
 .../{tests/files => fixtures}/.gitempty            |    0
 .../Thawte_Personal_Premium_CA.cer                 |  Bin 813 -> 813 bytes
 .../files => fixtures}/data-file-private.store     |  Bin 494 -> 494 bytes
 .../files => fixtures}/data-file-public.store      |  Bin 216 -> 216 bytes
 .../{tests/files => fixtures}/der-key-v2-des3.p8   |  Bin 714 -> 714 bytes
 .../{tests/files => fixtures}/personal.p12         |  Bin 3396 -> 3396 bytes
 .../{tests/files => fixtures}/test-certificate.cer |  Bin 1857 -> 1857 bytes
 .../{tests/files => fixtures}/user.keystore        |  Bin 226 -> 226 bytes
 pkcs11/gnome2-store/{tests => }/frob-gnome2-file.c |    0
 .../gnome2-store/{tests => }/mock-gnome2-module.c  |    0
 .../gnome2-store/{tests => }/mock-gnome2-module.h  |    0
 pkcs11/gnome2-store/{tests => }/p11-tests.conf.in  |    0
 pkcs11/gnome2-store/{tests => }/test-gnome2-file.c |    4 +-
 .../{tests => }/test-gnome2-private-key.c          |    2 +-
 .../gnome2-store/{tests => }/test-gnome2-storage.c |    6 +-
 pkcs11/gnome2-store/{tests => }/test-import.c      |    2 +-
 pkcs11/gnome2-store/tests/.gitignore               |    1 -
 pkcs11/gnome2-store/tests/Makefile.am              |   66 ----------------
 pkcs11/secret-store/Makefile.am                    |   42 ++++++++++-
 .../{tests => }/dump-keyring0-format.c             |    0
 .../files => fixtures}/created-on-rhel.keyring     |  Bin 105 -> 105 bytes
 .../created-on-solaris-opencsw.keyring             |  Bin 105 -> 105 bytes
 .../encrypted-with-schema.keyring                  |  Bin 404 -> 404 bytes
 .../{tests/files => fixtures}/encrypted.keyring    |  Bin 733 -> 733 bytes
 .../files => fixtures}/plain-bad-number.keyring    |    0
 .../files => fixtures}/plain-with-schema.keyring   |    0
 .../{tests/files => fixtures}/plain.keyring        |    0
 .../{tests/files => fixtures}/schema1.keyring      |  Bin 769 -> 769 bytes
 .../{tests/files => fixtures}/schema2.keyring      |  Bin 1005 -> 1005 bytes
 .../secret-store/{tests => }/mock-secret-module.c  |    4 +-
 .../secret-store/{tests => }/mock-secret-module.h  |    0
 .../secret-store/{tests => }/test-secret-binary.c  |   16 ++--
 .../{tests => }/test-secret-collection.c           |   12 ++--
 .../secret-store/{tests => }/test-secret-compat.c  |    0
 pkcs11/secret-store/{tests => }/test-secret-data.c |    0
 .../secret-store/{tests => }/test-secret-fields.c  |    0
 pkcs11/secret-store/{tests => }/test-secret-item.c |    0
 .../secret-store/{tests => }/test-secret-object.c  |    0
 .../secret-store/{tests => }/test-secret-schema.c  |    2 +-
 .../secret-store/{tests => }/test-secret-search.c  |    0
 .../secret-store/{tests => }/test-secret-textual.c |   10 +-
 pkcs11/secret-store/tests/Makefile.am              |   48 ------------
 pkcs11/ssh-store/Makefile.am                       |   52 +++++++++++++-
 pkcs11/ssh-store/{tests => }/check-ssh-module.c    |    0
 .../{tests/files => fixtures}/id_dsa_encrypted     |    0
 .../{tests/files => fixtures}/id_dsa_encrypted.pub |    0
 .../{tests/files => fixtures}/id_dsa_plain         |    0
 .../{tests/files => fixtures}/id_dsa_plain.pub     |    0
 .../{tests/files => fixtures}/id_dsa_test.pub      |    0
 .../{tests/files => fixtures}/id_rsa_encrypted     |    0
 .../{tests/files => fixtures}/id_rsa_encrypted.pub |    0
 .../{tests/files => fixtures}/id_rsa_plain         |    0
 .../{tests/files => fixtures}/id_rsa_plain.pub     |    0
 .../{tests/files => fixtures}/id_rsa_test.pub      |    0
 pkcs11/ssh-store/{tests => }/mock-ssh-module.c     |    0
 pkcs11/ssh-store/{tests => }/mock-ssh-module.h     |    0
 pkcs11/ssh-store/{tests => }/p11-tests.conf.in     |    0
 pkcs11/ssh-store/{tests => }/test-private-key.c    |    8 +-
 pkcs11/ssh-store/{tests => }/test-ssh-openssh.c    |   12 ++--
 pkcs11/ssh-store/tests/Makefile.am                 |   58 --------------
 pkcs11/wrap-layer/Makefile.am                      |   34 ++++++++-
 pkcs11/wrap-layer/{tests => }/mock-secret-store.c  |    0
 .../{tests => }/test-create-credential.c           |    0
 pkcs11/wrap-layer/{tests => }/test-init-pin.c      |    0
 pkcs11/wrap-layer/{tests => }/test-login-auto.c    |    0
 pkcs11/wrap-layer/{tests => }/test-login-hints.c   |    0
 pkcs11/wrap-layer/{tests => }/test-login-keyring.c |    0
 .../wrap-layer/{tests => }/test-login-specific.c   |    0
 pkcs11/wrap-layer/{tests => }/test-login-user.c    |    0
 pkcs11/wrap-layer/{tests => }/test-set-pin.c       |    0
 pkcs11/wrap-layer/tests/Makefile.am                |   42 ----------
 pkcs11/xdg-store/Makefile.am                       |   53 ++++++++++++-
 pkcs11/xdg-store/{tests => }/check-xdg-module.c    |    0
 pkcs11/xdg-store/{tests => }/dump-trust-file.c     |    0
 .../files => fixtures}/test-certificate-1.cer      |  Bin 813 -> 813 bytes
 .../files => fixtures}/test-certificate-2.cer      |  Bin 813 -> 813 bytes
 .../{tests/files => fixtures}/test-refer-1.trust   |  Bin 241 -> 241 bytes
 pkcs11/xdg-store/{tests => }/frob-trust-file.c     |    0
 pkcs11/xdg-store/{tests => }/mock-xdg-module.c     |    6 +-
 pkcs11/xdg-store/{tests => }/mock-xdg-module.h     |    0
 pkcs11/xdg-store/{tests => }/p11-tests.conf        |    0
 pkcs11/xdg-store/{tests => }/test-xdg-module.c     |    2 +-
 pkcs11/xdg-store/{tests => }/test-xdg-trust.c      |    2 +-
 pkcs11/xdg-store/tests/Makefile.am                 |   54 -------------
 170 files changed, 515 insertions(+), 607 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2b7bf26..1022cd4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -663,31 +663,22 @@ AC_OUTPUT([
 Makefile
 daemon/Makefile
 daemon/control/Makefile
-daemon/control/tests/Makefile
 daemon/dbus/Makefile
-daemon/dbus/tests/Makefile
 daemon/gpg-agent/Makefile
 daemon/login/Makefile
 daemon/ssh-agent/Makefile
 docs/Makefile
 egg/Makefile
-egg/tests/Makefile
 pam/Makefile
 pkcs11/Makefile
 pkcs11/gkm/Makefile
-pkcs11/gkm/tests/Makefile
 pkcs11/gnome2-store/Makefile
-pkcs11/gnome2-store/tests/Makefile
 pkcs11/rpc-layer/Makefile
 pkcs11/rpc-layer/gnome-keyring.module
 pkcs11/secret-store/Makefile
-pkcs11/secret-store/tests/Makefile
 pkcs11/ssh-store/Makefile
-pkcs11/ssh-store/tests/Makefile
 pkcs11/wrap-layer/Makefile
-pkcs11/wrap-layer/tests/Makefile
 pkcs11/xdg-store/Makefile
-pkcs11/xdg-store/tests/Makefile
 po/Makefile.in
 schema/Makefile
 testing/Makefile
diff --git a/daemon/control/Makefile.am b/daemon/control/Makefile.am
index 2b53d7b..4df8cfd 100644
--- a/daemon/control/Makefile.am
+++ b/daemon/control/Makefile.am
@@ -1,6 +1,4 @@
 
-SUBDIRS = . tests
-
 INCLUDES= \
        -DPREFIX=\""$(prefix)"\" \
        -DBINDIR=\""$(bindir)"\" \
@@ -11,6 +9,11 @@ INCLUDES= \
        -I$(top_builddir) \
        $(GLIB_CFLAGS)
 
+LIBS = \
+       $(GLIB_LIBS) \
+       $(GTHREAD_LIBS) \
+       $(P11_TESTS_LIBS)
+
 # ------------------------------------------------------------------
 # DAEMON CODE
 
@@ -24,3 +27,48 @@ libgkd_control_la_SOURCES = \
 
 libgkd_control_client_la_SOURCES = \
        gkd-control-client.c gkd-control.h
+
+# -------------------------------------------------------------------
+# TESTS
+
+noinst_PROGRAMS= \
+       frob-control-change \
+       frob-control-init \
+       frob-control-unlock \
+       frob-control-quit
+
+frob_control_change_SOURCES = \
+       frob-control-change.c
+
+frob_control_change_LDADD = \
+       $(top_builddir)/daemon/control/libgkd-control-client.la \
+       $(top_builddir)/egg/libegg-buffer.la \
+       $(top_builddir)/egg/libegg-creds.la \
+       $(top_builddir)/egg/libegg-secure.la
+
+frob_control_init_SOURCES = \
+       frob-control-init.c
+
+frob_control_init_LDADD = \
+       $(top_builddir)/daemon/control/libgkd-control-client.la \
+       $(top_builddir)/egg/libegg-buffer.la \
+       $(top_builddir)/egg/libegg-creds.la \
+       $(top_builddir)/egg/libegg-secure.la
+
+frob_control_quit_SOURCES = \
+       frob-control-quit.c
+
+frob_control_quit_LDADD = \
+       $(top_builddir)/daemon/control/libgkd-control-client.la \
+       $(top_builddir)/egg/libegg-buffer.la \
+       $(top_builddir)/egg/libegg-creds.la \
+       $(top_builddir)/egg/libegg-secure.la
+
+frob_control_unlock_SOURCES = \
+       frob-control-unlock.c
+
+frob_control_unlock_LDADD = \
+       $(top_builddir)/daemon/control/libgkd-control-client.la \
+       $(top_builddir)/egg/libegg-buffer.la \
+       $(top_builddir)/egg/libegg-creds.la \
+       $(top_builddir)/egg/libegg-secure.la
\ No newline at end of file
diff --git a/daemon/control/tests/frob-control-change.c b/daemon/control/frob-control-change.c
similarity index 100%
rename from daemon/control/tests/frob-control-change.c
rename to daemon/control/frob-control-change.c
diff --git a/daemon/control/tests/frob-control-init.c b/daemon/control/frob-control-init.c
similarity index 100%
rename from daemon/control/tests/frob-control-init.c
rename to daemon/control/frob-control-init.c
diff --git a/daemon/control/tests/frob-control-quit.c b/daemon/control/frob-control-quit.c
similarity index 100%
rename from daemon/control/tests/frob-control-quit.c
rename to daemon/control/frob-control-quit.c
diff --git a/daemon/control/tests/frob-control-unlock.c b/daemon/control/frob-control-unlock.c
similarity index 100%
rename from daemon/control/tests/frob-control-unlock.c
rename to daemon/control/frob-control-unlock.c
diff --git a/daemon/dbus/Makefile.am b/daemon/dbus/Makefile.am
index 20180d3..9cf6175 100644
--- a/daemon/dbus/Makefile.am
+++ b/daemon/dbus/Makefile.am
@@ -2,12 +2,17 @@
 INCLUDES = \
        -I$(top_srcdir) \
        -I$(top_srcdir)/daemon \
+       -I$(top_srcdir)/daemon/dbus \
        -I$(top_builddir) \
        $(DAEMON_CFLAGS) \
+       $(GCR_BASE_CFLAGS) \
        $(GOBJECT_CFLAGS) \
        $(GLIB_CFLAGS) \
        -DGCK_API_SUBJECT_TO_CHANGE \
-       -DGCR_API_SUBJECT_TO_CHANGE
+       -DGCR_API_SUBJECT_TO_CHANGE \
+       -DSRCDIR="\"@abs_srcdir \"" \
+       -DTOP_SRCDIR="\"@abs_top_srcdir \"" \
+       -DTOP_BUILDDIR="\"@abs_top_builddir \""
 
 noinst_LTLIBRARIES = libgkd-dbus.la
 
@@ -40,5 +45,36 @@ libgkd_dbus_la_LIBADD = \
        $(GOBJECT_LIBS)
 
 # -------------------------------------------------------------------
+# TESTS
 
-SUBDIRS = . tests
+noinst_LTLIBRARIES += \
+       libtestservice.la
+
+libtestservice_la_SOURCES = \
+       test-service.c test-service.h
+
+LDADD =  \
+       $(builddir)/libtestservice.la \
+       $(top_builddir)/daemon/dbus/libgkd-dbus.la \
+       $(top_builddir)/egg/libegg-test.la \
+       $(GCR_BASE_LIBS) \
+       $(GIO_LIBS) \
+       $(GLIB_LIBS)
+
+TEST_PROGS = \
+       test-secret-util \
+       test-secret-search \
+       test-secret-items \
+       test-secret-signals \
+       test-secret-lock
+
+check_PROGRAMS = $(TEST_PROGS)
+
+EXTRA_DIST = fixtures
+
+test: $(TEST_PROGS)
+       gtester --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
+
+check-local: test
+
+all-local: $(check_PROGRAMS)
diff --git a/daemon/dbus/tests/test-secret-items.c b/daemon/dbus/test-secret-items.c
similarity index 100%
rename from daemon/dbus/tests/test-secret-items.c
rename to daemon/dbus/test-secret-items.c
diff --git a/daemon/dbus/tests/test-secret-lock.c b/daemon/dbus/test-secret-lock.c
similarity index 100%
rename from daemon/dbus/tests/test-secret-lock.c
rename to daemon/dbus/test-secret-lock.c
diff --git a/daemon/dbus/tests/test-secret-search.c b/daemon/dbus/test-secret-search.c
similarity index 100%
rename from daemon/dbus/tests/test-secret-search.c
rename to daemon/dbus/test-secret-search.c
diff --git a/daemon/dbus/tests/test-secret-signals.c b/daemon/dbus/test-secret-signals.c
similarity index 100%
rename from daemon/dbus/tests/test-secret-signals.c
rename to daemon/dbus/test-secret-signals.c
diff --git a/daemon/dbus/tests/test-secret-util.c b/daemon/dbus/test-secret-util.c
similarity index 100%
rename from daemon/dbus/tests/test-secret-util.c
rename to daemon/dbus/test-secret-util.c
diff --git a/daemon/dbus/tests/test-service.c b/daemon/dbus/test-service.c
similarity index 99%
rename from daemon/dbus/tests/test-service.c
rename to daemon/dbus/test-service.c
index 16adb3e..8882d5c 100644
--- a/daemon/dbus/tests/test-service.c
+++ b/daemon/dbus/test-service.c
@@ -96,7 +96,7 @@ test_service_setup (TestService *test)
                                           test, NULL);
 
        test->directory = egg_tests_create_scratch_directory (
-               SRCDIR "/files/test.keyring",
+               SRCDIR "/fixtures/test.keyring",
                NULL);
 
        /* The schema directory */
diff --git a/daemon/dbus/tests/test-service.h b/daemon/dbus/test-service.h
similarity index 100%
rename from daemon/dbus/tests/test-service.h
rename to daemon/dbus/test-service.h
diff --git a/egg/Makefile.am b/egg/Makefile.am
index 0e59577..6b50242 100644
--- a/egg/Makefile.am
+++ b/egg/Makefile.am
@@ -12,8 +12,10 @@ noinst_LTLIBRARIES = \
        libegg-test.la
 
 INCLUDES = \
+       -I$(top_builddir) \
        -I$(top_srcdir) \
-       -I$(top_builddir) 
+       -DSRCDIR="\"@abs_srcdir \"" \
+       $(GLIB_CFLAGS)
 
 libegg_la_CFLAGS = \
        $(LIBTASN1_CFLAGS) \
@@ -120,11 +122,55 @@ libegg_test_la_CFLAGS = \
 libegg_test_la_LIBS = \
        $(GLIB_LIBS)
 
-# -------------------------------------------------------------------
-
-SUBDIRS = . tests
-
 asn:
        asn1Parser -o pk.asn.h pk.asn
        asn1Parser -o pkix.asn.h pkix.asn
-       sed -i 's|#include.*|/* \0 */|' pk.asn.h pkix.asn.h
\ No newline at end of file
+       sed -i 's|#include.*|/* \0 */|' pk.asn.h pkix.asn.h
+       asn1Parser -o test.asn.h test.asn
+       sed -i 's|#include.*|/* \0 */|' test.asn.h
+
+# -------------------------------------------------------------------
+# TESTS
+
+LDADD =  \
+       $(top_builddir)/egg/libegg.la \
+       $(LIBGCRYPT_LIBS) \
+       $(GTHREAD_LIBS) \
+       $(GLIB_LIBS)
+
+TEST_PROGS = \
+       test-asn1 \
+       test-asn1x \
+       test-dn \
+       test-cleanup \
+       test-hex \
+       test-hkdf \
+       test-oid \
+       test-secmem \
+       test-padding \
+       test-symkey \
+       test-armor \
+       test-openssl \
+       test-dh \
+       test-spawn
+
+test_asn1_SOURCES = \
+       test-asn1.c \
+       test.asn.h
+
+test_asn1x_LDADD = \
+       $(top_builddir)/egg/libegg-asn1x.la \
+       $(LDADD)
+
+check_PROGRAMS = $(TEST_PROGS)
+
+test: $(TEST_PROGS)
+       gtester --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
+
+check-local: test
+
+all-local: $(check_PROGRAMS)
+
+EXTRA_DIST += \
+       test.asn \
+       fixtures
diff --git a/egg/tests/files/dh-params.pem b/egg/fixtures/dh-params.pem
similarity index 100%
rename from egg/tests/files/dh-params.pem
rename to egg/fixtures/dh-params.pem
diff --git a/egg/tests/files/echo-script.sh b/egg/fixtures/echo-script.sh
similarity index 100%
rename from egg/tests/files/echo-script.sh
rename to egg/fixtures/echo-script.sh
diff --git a/egg/tests/files/pem-rsa-enc.key b/egg/fixtures/pem-rsa-enc.key
similarity index 100%
rename from egg/tests/files/pem-rsa-enc.key
rename to egg/fixtures/pem-rsa-enc.key
diff --git a/egg/tests/files/test-personalname-invalid.der b/egg/fixtures/test-personalname-invalid.der
similarity index 100%
rename from egg/tests/files/test-personalname-invalid.der
rename to egg/fixtures/test-personalname-invalid.der
diff --git a/egg/tests/test-armor.c b/egg/test-armor.c
similarity index 100%
rename from egg/tests/test-armor.c
rename to egg/test-armor.c
diff --git a/egg/tests/test-asn1.c b/egg/test-asn1.c
similarity index 99%
rename from egg/tests/test-asn1.c
rename to egg/test-asn1.c
index a437355..598d26a 100644
--- a/egg/tests/test-asn1.c
+++ b/egg/test-asn1.c
@@ -1747,7 +1747,7 @@ setup (Test *test, gconstpointer unused)
 {
        GBytes *bytes;
 
-       if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der",
+       if (!g_file_get_contents (SRCDIR "/fixtures/test-certificate-1.der",
                                  (gchar**)&test->data, &test->n_data, NULL))
                g_assert_not_reached ();
 
diff --git a/egg/tests/test-asn1x.c b/egg/test-asn1x.c
similarity index 89%
rename from egg/tests/test-asn1x.c
rename to egg/test-asn1x.c
index cce6fe8..879def2 100644
--- a/egg/tests/test-asn1x.c
+++ b/egg/test-asn1x.c
@@ -74,11 +74,11 @@ typedef struct {
 } Fixture;
 
 static const Fixture parse_test_fixtures[] = {
-       { pkix_asn1_tab, SRCDIR "/files/test-certificate-1.der", "Certificate" },
-       { pkix_asn1_tab, SRCDIR "/files/test-pkcs8-1.der", "pkcs-8-PrivateKeyInfo" },
-       { pk_asn1_tab, SRCDIR "/files/test-rsakey-1.der", "RSAPrivateKey" },
-       { pkix_asn1_tab, SRCDIR "/files/test-pkcs7-1.der", "pkcs-7-ContentInfo" },
-       { pkix_asn1_tab, SRCDIR "/files/test-pkcs7-2.der", "pkcs-7-ContentInfo" },
+       { pkix_asn1_tab, SRCDIR "/fixtures/test-certificate-1.der", "Certificate" },
+       { pkix_asn1_tab, SRCDIR "/fixtures/test-pkcs8-1.der", "pkcs-8-PrivateKeyInfo" },
+       { pk_asn1_tab, SRCDIR "/fixtures/test-rsakey-1.der", "RSAPrivateKey" },
+       { pkix_asn1_tab, SRCDIR "/fixtures/test-pkcs7-1.der", "pkcs-7-ContentInfo" },
+       { pkix_asn1_tab, SRCDIR "/fixtures/test-pkcs7-2.der", "pkcs-7-ContentInfo" },
 };
 
 static void
@@ -191,9 +191,9 @@ main (int argc, char **argv)
                g_free (name);
        }
 
-       g_test_add ("/asn1x/pkcs12-decode/1", Test, SRCDIR "/files/test-pkcs12-1.der",
+       g_test_add ("/asn1x/pkcs12-decode/1", Test, SRCDIR "/fixtures/test-pkcs12-1.der",
                    setup, test_pkcs12_decode, teardown);
-       g_test_add ("/asn1x/pkcs5-personal-name/invalid", Test, SRCDIR "/files/test-personalname-invalid.der",
+       g_test_add ("/asn1x/pkcs5-personal-name/invalid", Test, SRCDIR 
"/fixtures/test-personalname-invalid.der",
                    setup, test_personal_name_invalid, teardown);
 
        return g_test_run ();
diff --git a/egg/tests/test-cleanup.c b/egg/test-cleanup.c
similarity index 100%
rename from egg/tests/test-cleanup.c
rename to egg/test-cleanup.c
diff --git a/egg/tests/test-dh.c b/egg/test-dh.c
similarity index 100%
rename from egg/tests/test-dh.c
rename to egg/test-dh.c
diff --git a/egg/tests/test-dn.c b/egg/test-dn.c
similarity index 98%
rename from egg/tests/test-dn.c
rename to egg/test-dn.c
index d1b6f72..347a5cd 100644
--- a/egg/tests/test-dn.c
+++ b/egg/test-dn.c
@@ -46,7 +46,7 @@ setup (Test *test, gconstpointer unused)
 {
        GBytes *bytes;
 
-       if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der",
+       if (!g_file_get_contents (SRCDIR "/fixtures/test-certificate-1.der",
                                  (gchar**)&test->data, &test->n_data, NULL))
                g_assert_not_reached ();
 
diff --git a/egg/tests/test-hex.c b/egg/test-hex.c
similarity index 100%
rename from egg/tests/test-hex.c
rename to egg/test-hex.c
diff --git a/egg/tests/test-hkdf.c b/egg/test-hkdf.c
similarity index 100%
rename from egg/tests/test-hkdf.c
rename to egg/test-hkdf.c
diff --git a/egg/tests/test-oid.c b/egg/test-oid.c
similarity index 100%
rename from egg/tests/test-oid.c
rename to egg/test-oid.c
diff --git a/egg/tests/test-openssl.c b/egg/test-openssl.c
similarity index 98%
rename from egg/tests/test-openssl.c
rename to egg/test-openssl.c
index 91622b9..4f51126 100644
--- a/egg/tests/test-openssl.c
+++ b/egg/test-openssl.c
@@ -53,7 +53,7 @@ setup (Test *test, gconstpointer unused)
        gchar *contents;
        gsize length;
 
-       if (!g_file_get_contents (SRCDIR "/files/pem-rsa-enc.key", &contents, &length, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/pem-rsa-enc.key", &contents, &length, NULL))
                g_assert_not_reached ();
 
        test->input = g_bytes_new_take (contents, length);
diff --git a/egg/tests/test-padding.c b/egg/test-padding.c
similarity index 100%
rename from egg/tests/test-padding.c
rename to egg/test-padding.c
diff --git a/egg/tests/test-secmem.c b/egg/test-secmem.c
similarity index 100%
rename from egg/tests/test-secmem.c
rename to egg/test-secmem.c
diff --git a/egg/tests/test-spawn.c b/egg/test-spawn.c
similarity index 95%
rename from egg/tests/test-spawn.c
rename to egg/test-spawn.c
index 7c0d1e1..347f9ba 100644
--- a/egg/tests/test-spawn.c
+++ b/egg/test-spawn.c
@@ -175,7 +175,7 @@ test_sync (void)
        data.parent_pid = getpid();
        data.index = 80;
 
-       ret = egg_spawn_sync_with_callbacks (SRCDIR "/files",
+       ret = egg_spawn_sync_with_callbacks (SRCDIR "/fixtures",
                                             echo_argv, NULL, 0, &pid,
                                             &echo_callbacks, &data,
                                             &exit_status, &error);
@@ -196,7 +196,7 @@ test_sync_error (void)
        GError *error = NULL;
        gboolean ret;
 
-       ret = egg_spawn_sync_with_callbacks (SRCDIR "/files",
+       ret = egg_spawn_sync_with_callbacks (SRCDIR "/fixtures",
                                             error_argv, NULL, 0, NULL,
                                             NULL, NULL,
                                             NULL, &error);
@@ -219,7 +219,7 @@ test_async (void)
        data.index = 80;
        data.is_async = TRUE;
 
-       ret = egg_spawn_async_with_callbacks (SRCDIR "/files",
+       ret = egg_spawn_async_with_callbacks (SRCDIR "/fixtures",
                                             echo_argv, NULL, 0, &pid,
                                             &echo_callbacks, &data,
                                             NULL, &error);
@@ -246,7 +246,7 @@ test_async_none (void)
        data.parent_pid = getpid();
        data.is_async = TRUE;
 
-       ret = egg_spawn_async_with_callbacks (SRCDIR "/files",
+       ret = egg_spawn_async_with_callbacks (SRCDIR "/fixtures",
                                             echo_argv, NULL, 0, NULL,
                                             &null_callbacks, &data,
                                             NULL, &error);
@@ -267,7 +267,7 @@ test_async_error (void)
        GError *error = NULL;
        guint ret;
 
-       ret = egg_spawn_async_with_callbacks (SRCDIR "/files",
+       ret = egg_spawn_async_with_callbacks (SRCDIR "/fixtures",
                                             error_argv, NULL, 0, NULL,
                                             NULL, NULL,
                                             NULL, &error);
diff --git a/egg/tests/test-symkey.c b/egg/test-symkey.c
similarity index 100%
rename from egg/tests/test-symkey.c
rename to egg/test-symkey.c
diff --git a/egg/tests/test.asn b/egg/test.asn
similarity index 100%
rename from egg/tests/test.asn
rename to egg/test.asn
diff --git a/egg/tests/test.asn.h b/egg/test.asn.h
similarity index 100%
rename from egg/tests/test.asn.h
rename to egg/test.asn.h
diff --git a/pkcs11/gkm/Makefile.am b/pkcs11/gkm/Makefile.am
index fe1900e..45f61b0 100644
--- a/pkcs11/gkm/Makefile.am
+++ b/pkcs11/gkm/Makefile.am
@@ -1,6 +1,8 @@
 INCLUDES = \
        -I$(top_builddir) \
        -I$(top_srcdir) \
+       -I$(top_srcdir)/pkcs11 \
+       -DSRCDIR="\"@abs_srcdir \"" \
        $(GOBJECT_CFLAGS) \
        $(LIBGCRYPT_CFLAGS) \
        $(GLIB_CFLAGS)
@@ -87,5 +89,74 @@ EXTRA_DIST = \
        gkm-marshal.list
 
 # -------------------------------------------------------------------------------
+# TESTS
 
-SUBDIRS = . tests
+LDADD = \
+       $(top_builddir)/pkcs11/gkm/libgkm.la \
+       $(top_builddir)/egg/libegg.la \
+       $(GLIB_LIBS) \
+       $(GTHREAD_LIBS) \
+       $(LIBGCRYPT_LIBS)
+
+noinst_LIBRARIES = libgkm-mock.a
+
+libgkm_mock_a_SOURCES = \
+       mock-module.c mock-module.h \
+       mock-locked-object.c mock-locked-object.h \
+       test.asn.h
+
+TEST_PROGS = \
+       test-attributes \
+       test-credential \
+       test-data-asn1 \
+       test-data-der \
+       test-file-tracker \
+       test-memory-store \
+       test-object \
+       test-certificate \
+       test-secret \
+       test-sexp \
+       test-store \
+       test-timer \
+       test-transaction
+
+test_credential_LDADD = \
+       libgkm-mock.a \
+       $(LDADD)
+
+test_memory_store_LDADD = \
+       libgkm-mock.a \
+       $(LDADD)
+
+test_object_LDADD = \
+       libgkm-mock.a \
+       $(LDADD)
+
+test_certificate_LDADD = \
+       libgkm-mock.a \
+       $(LDADD)
+
+test_store_LDADD = \
+       libgkm-mock.a \
+       $(LDADD)
+
+test_timer_LDADD = \
+       libgkm-mock.a \
+       $(LDADD)
+
+check_PROGRAMS = $(TEST_PROGS)
+
+test: $(TEST_PROGS)
+       gtester --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
+
+check-local: test
+
+all-local: $(check_PROGRAMS)
+
+EXTRA_DIST += \
+       test.asn \
+       fixtures
+
+asn:
+       asn1Parser -o test.asn.h test.asn
+       sed -i 's|#include.*|/* \0 */|' test.asn.h
diff --git a/pkcs11/gkm/tests/test.asn.h b/pkcs11/gkm/asn1-def-test.h
similarity index 92%
copy from pkcs11/gkm/tests/test.asn.h
copy to pkcs11/gkm/asn1-def-test.h
index 9a6381e..9991ec7 100644
--- a/pkcs11/gkm/tests/test.asn.h
+++ b/pkcs11/gkm/asn1-def-test.h
@@ -2,7 +2,7 @@
 # include "config.h"
 #endif
 
-/* #include <libtasn1.h> */
+#include <libtasn1.h>
 
 const ASN1_ARRAY_TYPE test_asn1_tab[] = {
   { "TEST", 536872976, NULL },
diff --git a/pkcs11/gkm/tests/files/ca-certificates.crt b/pkcs11/gkm/fixtures/ca-certificates.crt
similarity index 100%
rename from pkcs11/gkm/tests/files/ca-certificates.crt
rename to pkcs11/gkm/fixtures/ca-certificates.crt
diff --git a/pkcs11/gkm/tests/files/pem-rsa-enc.key b/pkcs11/gkm/fixtures/pem-rsa-enc.key
similarity index 100%
rename from pkcs11/gkm/tests/files/pem-rsa-enc.key
rename to pkcs11/gkm/fixtures/pem-rsa-enc.key
diff --git a/pkcs11/gkm/tests/mock-locked-object.c b/pkcs11/gkm/mock-locked-object.c
similarity index 100%
rename from pkcs11/gkm/tests/mock-locked-object.c
rename to pkcs11/gkm/mock-locked-object.c
diff --git a/pkcs11/gkm/tests/mock-locked-object.h b/pkcs11/gkm/mock-locked-object.h
similarity index 100%
rename from pkcs11/gkm/tests/mock-locked-object.h
rename to pkcs11/gkm/mock-locked-object.h
diff --git a/pkcs11/gkm/tests/mock-module.c b/pkcs11/gkm/mock-module.c
similarity index 96%
rename from pkcs11/gkm/tests/mock-module.c
rename to pkcs11/gkm/mock-module.c
index 6b98630..5676026 100644
--- a/pkcs11/gkm/tests/mock-module.c
+++ b/pkcs11/gkm/mock-module.c
@@ -109,7 +109,7 @@ mock_module_object_new (GkmSession *session)
                { CKA_CERTIFICATE_TYPE, &type, sizeof (type) },
        };
 
-       if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der", &data, &n_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/test-certificate-1.der", &data, &n_data, NULL))
                g_assert_not_reached ();
 
        attrs[0].pValue = data;
diff --git a/pkcs11/gkm/tests/mock-module.h b/pkcs11/gkm/mock-module.h
similarity index 100%
rename from pkcs11/gkm/tests/mock-module.h
rename to pkcs11/gkm/mock-module.h
diff --git a/pkcs11/gkm/tests/test-attributes.c b/pkcs11/gkm/test-attributes.c
similarity index 100%
rename from pkcs11/gkm/tests/test-attributes.c
rename to pkcs11/gkm/test-attributes.c
diff --git a/pkcs11/gkm/tests/test-certificate.c b/pkcs11/gkm/test-certificate.c
similarity index 98%
rename from pkcs11/gkm/tests/test-certificate.c
rename to pkcs11/gkm/test-certificate.c
index 42f1442..9356ad2 100644
--- a/pkcs11/gkm/tests/test-certificate.c
+++ b/pkcs11/gkm/test-certificate.c
@@ -53,7 +53,7 @@ setup_basic (Test* test,
        test->module = mock_module_initialize_and_enter ();
        test->session = mock_module_open_session (TRUE);
 
-       if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der", &data, &length, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/test-certificate-1.der", &data, &length, NULL))
                g_assert_not_reached ();
 
        test->certificate_data = g_bytes_new_take (data, length);
diff --git a/pkcs11/gkm/tests/test-credential.c b/pkcs11/gkm/test-credential.c
similarity index 100%
rename from pkcs11/gkm/tests/test-credential.c
rename to pkcs11/gkm/test-credential.c
diff --git a/pkcs11/gkm/tests/test-data-asn1.c b/pkcs11/gkm/test-data-asn1.c
similarity index 96%
rename from pkcs11/gkm/tests/test-data-asn1.c
rename to pkcs11/gkm/test-data-asn1.c
index 5d613c1..7978652 100644
--- a/pkcs11/gkm/tests/test-data-asn1.c
+++ b/pkcs11/gkm/test-data-asn1.c
@@ -50,7 +50,7 @@ setup (Test *test, gconstpointer unused)
        gchar *contents;
        gsize length;
 
-       if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der", &contents, &length, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/test-certificate-1.der", &contents, &length, NULL))
                g_assert_not_reached ();
 
        data = g_bytes_new_take (contents, length);
diff --git a/pkcs11/gkm/tests/test-data-der.c b/pkcs11/gkm/test-data-der.c
similarity index 97%
rename from pkcs11/gkm/tests/test-data-der.c
rename to pkcs11/gkm/test-data-der.c
index 54c3ce1..592ed9b 100644
--- a/pkcs11/gkm/tests/test-data-der.c
+++ b/pkcs11/gkm/test-data-der.c
@@ -119,7 +119,7 @@ setup (Test *test, gconstpointer unused)
 {
        GBytes *data;
 
-       if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der", &test->certificate_data, 
&test->n_certificate_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/test-certificate-1.der", &test->certificate_data, 
&test->n_certificate_data, NULL))
                g_assert_not_reached ();
 
        data = g_bytes_new (test->certificate_data, test->n_certificate_data);
@@ -127,7 +127,7 @@ setup (Test *test, gconstpointer unused)
        g_assert (test->certificate != NULL);
        g_bytes_unref (data);
 
-       if (!g_file_get_contents (SRCDIR "/files/test-certificate-2.der", &test->certificate2_data, 
&test->n_certificate2_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/test-certificate-2.der", &test->certificate2_data, 
&test->n_certificate2_data, NULL))
                g_assert_not_reached ();
        data = g_bytes_new (test->certificate2_data, test->n_certificate2_data);
        test->certificate2 = egg_asn1x_create_and_decode (pkix_asn1_tab, "Certificate", data);
@@ -342,7 +342,7 @@ test_read_ca_certificates_public_key_info (Test *test, gconstpointer unused)
        gchar *data;
        gsize n_data;
 
-       if (!g_file_get_contents (SRCDIR "/files/ca-certificates.crt", &data, &n_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/ca-certificates.crt", &data, &n_data, NULL))
                g_assert_not_reached ();
 
        bytes = g_bytes_new_take (data, n_data);
@@ -448,7 +448,7 @@ test_read_all_pkcs8 (Test *test, gconstpointer unused)
        gsize n_data;
        gchar *path;
 
-       dir = g_dir_open (SRCDIR "/files", 0, NULL);
+       dir = g_dir_open (SRCDIR "/fixtures", 0, NULL);
        g_assert (dir);
 
        for(;;) {
@@ -459,7 +459,7 @@ test_read_all_pkcs8 (Test *test, gconstpointer unused)
                if (!g_pattern_match_simple ("der-key-*", name))
                        continue;
 
-               path = g_build_filename (SRCDIR "/files", name, NULL);
+               path = g_build_filename (SRCDIR "/fixtures", name, NULL);
                if (!g_file_get_contents (path, &data, &n_data, NULL))
                        g_assert_not_reached ();
                g_free (path);
@@ -485,7 +485,7 @@ test_read_pkcs8_bad_password (Test *test, gconstpointer unused)
        gchar *data;
        gsize n_data;
 
-       if (!g_file_get_contents (SRCDIR "/files/der-key-encrypted-pkcs5.p8", &data, &n_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/der-key-encrypted-pkcs5.p8", &data, &n_data, NULL))
                g_assert_not_reached ();
 
        bytes = g_bytes_new_take (data, n_data);
diff --git a/pkcs11/gkm/tests/test-file-tracker.c b/pkcs11/gkm/test-file-tracker.c
similarity index 100%
rename from pkcs11/gkm/tests/test-file-tracker.c
rename to pkcs11/gkm/test-file-tracker.c
diff --git a/pkcs11/gkm/tests/test-memory-store.c b/pkcs11/gkm/test-memory-store.c
similarity index 100%
rename from pkcs11/gkm/tests/test-memory-store.c
rename to pkcs11/gkm/test-memory-store.c
diff --git a/pkcs11/gkm/tests/test-object.c b/pkcs11/gkm/test-object.c
similarity index 98%
rename from pkcs11/gkm/tests/test-object.c
rename to pkcs11/gkm/test-object.c
index 7ecca5b..53c2e9b 100644
--- a/pkcs11/gkm/tests/test-object.c
+++ b/pkcs11/gkm/test-object.c
@@ -47,7 +47,7 @@ setup (Test* test, gconstpointer unused)
        test->module = mock_module_initialize_and_enter ();
        test->session = mock_module_open_session (TRUE);
 
-       if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der", &test->certificate_data, 
&test->n_certificate_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/test-certificate-1.der", &test->certificate_data, 
&test->n_certificate_data, NULL))
                g_assert_not_reached ();
 }
 
diff --git a/pkcs11/gkm/tests/test-secret.c b/pkcs11/gkm/test-secret.c
similarity index 100%
rename from pkcs11/gkm/tests/test-secret.c
rename to pkcs11/gkm/test-secret.c
diff --git a/pkcs11/gkm/tests/test-sexp.c b/pkcs11/gkm/test-sexp.c
similarity index 100%
rename from pkcs11/gkm/tests/test-sexp.c
rename to pkcs11/gkm/test-sexp.c
diff --git a/pkcs11/gkm/tests/test-store.c b/pkcs11/gkm/test-store.c
similarity index 100%
rename from pkcs11/gkm/tests/test-store.c
rename to pkcs11/gkm/test-store.c
diff --git a/pkcs11/gkm/tests/test-timer.c b/pkcs11/gkm/test-timer.c
similarity index 100%
rename from pkcs11/gkm/tests/test-timer.c
rename to pkcs11/gkm/test-timer.c
diff --git a/pkcs11/gkm/tests/test-transaction.c b/pkcs11/gkm/test-transaction.c
similarity index 100%
rename from pkcs11/gkm/tests/test-transaction.c
rename to pkcs11/gkm/test-transaction.c
diff --git a/pkcs11/gkm/tests/test.asn b/pkcs11/gkm/test.asn
similarity index 100%
rename from pkcs11/gkm/tests/test.asn
rename to pkcs11/gkm/test.asn
diff --git a/pkcs11/gkm/tests/test.asn.h b/pkcs11/gkm/test.asn.h
similarity index 100%
rename from pkcs11/gkm/tests/test.asn.h
rename to pkcs11/gkm/test.asn.h
diff --git a/pkcs11/gnome2-store/Makefile.am b/pkcs11/gnome2-store/Makefile.am
index e1f0c2b..cca0a7f 100644
--- a/pkcs11/gnome2-store/Makefile.am
+++ b/pkcs11/gnome2-store/Makefile.am
@@ -1,9 +1,11 @@
+include $(top_srcdir)/Makefile.decl
 
 INCLUDES = \
        -I$(top_builddir) \
        -I$(top_builddir)/pkcs11 \
        -I$(top_srcdir) \
        -I$(top_srcdir)/pkcs11 \
+       -DSRCDIR="\"@abs_srcdir \"" \
        $(GOBJECT_CFLAGS) \
        $(LIBGCRYPT_CFLAGS) \
        $(GLIB_CFLAGS)
@@ -49,4 +51,59 @@ gkm_gnome2_store_standalone_la_LIBADD = \
 
 # -------------------------------------------------------------------------------
 
-SUBDIRS = . tests
+LDADD = \
+       $(top_builddir)/pkcs11/gnome2-store/libgkm-gnome2-store.la \
+       $(top_builddir)/pkcs11/gkm/libgkm.la \
+       $(top_builddir)/egg/libegg.la \
+       $(GLIB_LIBS) \
+       $(LIBGCRYPT_LIBS)
+
+if WITH_P11_TESTS
+CHECK_PROGS = check-gnome2-module
+else
+CHECK_PROGS =
+endif
+
+CHECK_FILES = \
+       p11-tests.conf
+
+TEST_PROGS = \
+       test-gnome2-file \
+       test-gnome2-storage \
+       test-gnome2-private-key \
+       test-import
+
+test_gnome2_storage_SOURCES = \
+       test-gnome2-storage.c \
+       mock-gnome2-module.c mock-gnome2-module.h
+
+test_gnome2_private_key_SOURCES = \
+       test-gnome2-private-key.c \
+       mock-gnome2-module.c mock-gnome2-module.h
+
+test_import_CFLAGS = $(GCR_BASE_CFLAGS) $(GCK_CFLAGS)
+test_import_LDADD = $(GCR_BASE_LIBS) $(GCK_LIBS) $(LDADD)
+
+check_PROGRAMS = $(TEST_PROGS)
+
+test: $(TEST_PROGS) $(CHECK_PROGS) $(CHECK_FILES)
+       gtester --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
+       @for prog in $(CHECK_PROGS); do SRCDIR='.' ./$$prog || exit 1; done
+
+check-local: test
+
+all-local: $(check_PROGRAMS)
+
+noinst_PROGRAMS = \
+       frob-gnome2-file \
+       $(CHECK_PROGS)
+
+check_gnome2_module_CFLAGS = $(P11_TESTS_CFLAGS)
+check_gnome2_module_LDADD = $(P11_TESTS_LIBS) $(LDADD)
+
+EXTRA_DIST = \
+       p11-tests.conf.in \
+       fixtures
+
+CLEANFILES = \
+       $(CHECK_FILES)
diff --git a/pkcs11/gnome2-store/tests/check-gnome2-module.c b/pkcs11/gnome2-store/check-gnome2-module.c
similarity index 100%
rename from pkcs11/gnome2-store/tests/check-gnome2-module.c
rename to pkcs11/gnome2-store/check-gnome2-module.c
diff --git a/pkcs11/gnome2-store/tests/files/.gitempty b/pkcs11/gnome2-store/fixtures/.gitempty
similarity index 100%
rename from pkcs11/gnome2-store/tests/files/.gitempty
rename to pkcs11/gnome2-store/fixtures/.gitempty
diff --git a/pkcs11/gnome2-store/tests/frob-gnome2-file.c b/pkcs11/gnome2-store/frob-gnome2-file.c
similarity index 100%
rename from pkcs11/gnome2-store/tests/frob-gnome2-file.c
rename to pkcs11/gnome2-store/frob-gnome2-file.c
diff --git a/pkcs11/gnome2-store/tests/mock-gnome2-module.c b/pkcs11/gnome2-store/mock-gnome2-module.c
similarity index 100%
rename from pkcs11/gnome2-store/tests/mock-gnome2-module.c
rename to pkcs11/gnome2-store/mock-gnome2-module.c
diff --git a/pkcs11/gnome2-store/tests/mock-gnome2-module.h b/pkcs11/gnome2-store/mock-gnome2-module.h
similarity index 100%
rename from pkcs11/gnome2-store/tests/mock-gnome2-module.h
rename to pkcs11/gnome2-store/mock-gnome2-module.h
diff --git a/pkcs11/gnome2-store/tests/p11-tests.conf.in b/pkcs11/gnome2-store/p11-tests.conf.in
similarity index 100%
rename from pkcs11/gnome2-store/tests/p11-tests.conf.in
rename to pkcs11/gnome2-store/p11-tests.conf.in
diff --git a/pkcs11/gnome2-store/tests/test-gnome2-file.c b/pkcs11/gnome2-store/test-gnome2-file.c
similarity index 99%
rename from pkcs11/gnome2-store/tests/test-gnome2-file.c
rename to pkcs11/gnome2-store/test-gnome2-file.c
index 614a083..28e9d53 100644
--- a/pkcs11/gnome2-store/tests/test-gnome2-file.c
+++ b/pkcs11/gnome2-store/test-gnome2-file.c
@@ -52,8 +52,8 @@ EGG_SECURE_DEFINE_GLIB_GLOBALS ();
 static void
 setup (Test *test, gconstpointer unused)
 {
-       test->public_filename = g_build_filename (SRCDIR "/files", "data-file-public.store", NULL);
-       test->private_filename = g_build_filename (SRCDIR "/files", "data-file-private.store", NULL);
+       test->public_filename = g_build_filename (SRCDIR "/fixtures", "data-file-public.store", NULL);
+       test->private_filename = g_build_filename (SRCDIR "/fixtures", "data-file-private.store", NULL);
        test->write_filename = g_build_filename ("/tmp", "unit-test-file.store", NULL);
 
        test->data_file = gkm_gnome2_file_new ();
diff --git a/pkcs11/gnome2-store/tests/test-gnome2-private-key.c 
b/pkcs11/gnome2-store/test-gnome2-private-key.c
similarity index 98%
rename from pkcs11/gnome2-store/tests/test-gnome2-private-key.c
rename to pkcs11/gnome2-store/test-gnome2-private-key.c
index 7e43ac6..de6d18d 100644
--- a/pkcs11/gnome2-store/tests/test-gnome2-private-key.c
+++ b/pkcs11/gnome2-store/test-gnome2-private-key.c
@@ -58,7 +58,7 @@ setup_basic (Test* test,
        test->module = mock_gnome2_module_initialize_and_enter ();
        test->session = mock_gnome2_module_open_session (TRUE);
 
-       if (!g_file_get_contents (SRCDIR "/files/der-key-v2-des3.p8", &data, &length, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/der-key-v2-des3.p8", &data, &length, NULL))
                g_assert_not_reached ();
 
        test->key_data = g_bytes_new_take (data, length);
diff --git a/pkcs11/gnome2-store/tests/test-gnome2-storage.c b/pkcs11/gnome2-store/test-gnome2-storage.c
similarity index 98%
rename from pkcs11/gnome2-store/tests/test-gnome2-storage.c
rename to pkcs11/gnome2-store/test-gnome2-storage.c
index a89376a..d0fd4d8 100644
--- a/pkcs11/gnome2-store/tests/test-gnome2-storage.c
+++ b/pkcs11/gnome2-store/test-gnome2-storage.c
@@ -59,8 +59,8 @@ setup_directory (Test *test,
                  gconstpointer unused)
 {
        test->directory = egg_tests_create_scratch_directory (
-               SRCDIR "/files/Thawte_Personal_Premium_CA.cer",
-               SRCDIR "/files/user.keystore",
+               SRCDIR "/fixtures/Thawte_Personal_Premium_CA.cer",
+               SRCDIR "/fixtures/user.keystore",
                NULL);
 }
 
@@ -102,7 +102,7 @@ setup_module (Test *test,
                                         "module", test->module,
                                         "manager", manager,
                                         NULL);
-       g_file_get_contents (SRCDIR "/files/test-certificate.cer", &contents, &length, &error);
+       g_file_get_contents (SRCDIR "/fixtures/test-certificate.cer", &contents, &length, &error);
        g_assert_no_error (error);
 
        bytes = g_bytes_new_take (contents, length);
diff --git a/pkcs11/gnome2-store/tests/test-import.c b/pkcs11/gnome2-store/test-import.c
similarity index 98%
rename from pkcs11/gnome2-store/tests/test-import.c
rename to pkcs11/gnome2-store/test-import.c
index d1c30a4..4547df7 100644
--- a/pkcs11/gnome2-store/tests/test-import.c
+++ b/pkcs11/gnome2-store/test-import.c
@@ -133,7 +133,7 @@ test_pkcs12_import (Test *test,
        gsize length;
        GList *l;
 
-       g_file_get_contents (SRCDIR "/files/personal.p12", &contents, &length, &error);
+       g_file_get_contents (SRCDIR "/fixtures/personal.p12", &contents, &length, &error);
        g_assert_no_error (error);
 
        /* Parse the pkcs12 file */
diff --git a/pkcs11/secret-store/Makefile.am b/pkcs11/secret-store/Makefile.am
index c0dbbbb..d7cc8bf 100644
--- a/pkcs11/secret-store/Makefile.am
+++ b/pkcs11/secret-store/Makefile.am
@@ -3,6 +3,7 @@ INCLUDES = \
        -I$(top_builddir) \
        -I$(top_srcdir) \
        -I$(top_srcdir)/pkcs11 \
+       -DSRCDIR="\"@abs_srcdir \"" \
        $(GOBJECT_CFLAGS) \
        $(GLIB_CFLAGS) \
        $(GMODULE_CFLAGS)
@@ -52,5 +53,44 @@ gkm_secret_store_standalone_la_LIBADD = \
        $(LIBGCRYPT_LIBS)
 
 # -------------------------------------------------------------------------------
+# TESTS
 
-SUBDIRS = . tests
+LDADD = \
+       libgkm-mock-secret-module.a \
+       $(top_builddir)/pkcs11/secret-store/libgkm-secret-store.la \
+       $(top_builddir)/pkcs11/gkm/libgkm.la \
+       $(top_builddir)/egg/libegg.la \
+       $(GLIB_LIBS) \
+       $(LIBGCRYPT_LIBS)
+
+noinst_LIBRARIES = libgkm-mock-secret-module.a
+
+libgkm_mock_secret_module_a_SOURCES = \
+       mock-secret-module.c mock-secret-module.h
+
+noinst_PROGRAMS = dump-keyring0-format
+
+TEST_PROGS = \
+       test-secret-compat \
+       test-secret-fields \
+       test-secret-data \
+       test-secret-object \
+       test-secret-collection \
+       test-secret-item \
+       test-secret-schema \
+       test-secret-search \
+       test-secret-textual \
+       test-secret-binary \
+       test-secret-schema
+
+check_PROGRAMS = $(TEST_PROGS)
+
+test: $(TEST_PROGS)
+       gtester --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
+
+check-local: test
+
+all-local: $(check_PROGRAMS)
+
+EXTRA_DIST = \
+       fixtures
diff --git a/pkcs11/secret-store/tests/dump-keyring0-format.c b/pkcs11/secret-store/dump-keyring0-format.c
similarity index 100%
rename from pkcs11/secret-store/tests/dump-keyring0-format.c
rename to pkcs11/secret-store/dump-keyring0-format.c
diff --git a/pkcs11/secret-store/tests/files/plain-bad-number.keyring 
b/pkcs11/secret-store/fixtures/plain-bad-number.keyring
similarity index 100%
rename from pkcs11/secret-store/tests/files/plain-bad-number.keyring
rename to pkcs11/secret-store/fixtures/plain-bad-number.keyring
diff --git a/pkcs11/secret-store/tests/files/plain-with-schema.keyring 
b/pkcs11/secret-store/fixtures/plain-with-schema.keyring
similarity index 100%
rename from pkcs11/secret-store/tests/files/plain-with-schema.keyring
rename to pkcs11/secret-store/fixtures/plain-with-schema.keyring
diff --git a/pkcs11/secret-store/tests/files/plain.keyring b/pkcs11/secret-store/fixtures/plain.keyring
similarity index 100%
rename from pkcs11/secret-store/tests/files/plain.keyring
rename to pkcs11/secret-store/fixtures/plain.keyring
diff --git a/pkcs11/secret-store/tests/mock-secret-module.c b/pkcs11/secret-store/mock-secret-module.c
similarity index 99%
rename from pkcs11/secret-store/tests/mock-secret-module.c
rename to pkcs11/secret-store/mock-secret-module.c
index afcda04..bf6bc96 100644
--- a/pkcs11/secret-store/tests/mock-secret-module.c
+++ b/pkcs11/secret-store/mock-secret-module.c
@@ -59,8 +59,8 @@ test_secret_module_initialize_and_enter (void)
        CK_RV rv;
 
        directory = egg_tests_create_scratch_directory (
-               SRCDIR "/files/encrypted.keyring",
-               SRCDIR "/files/plain.keyring",
+               SRCDIR "/fixtures/encrypted.keyring",
+               SRCDIR "/fixtures/plain.keyring",
                NULL);
 
        /* Setup test directory to work in */
diff --git a/pkcs11/secret-store/tests/mock-secret-module.h b/pkcs11/secret-store/mock-secret-module.h
similarity index 100%
rename from pkcs11/secret-store/tests/mock-secret-module.h
rename to pkcs11/secret-store/mock-secret-module.h
diff --git a/pkcs11/secret-store/tests/test-secret-binary.c b/pkcs11/secret-store/test-secret-binary.c
similarity index 91%
rename from pkcs11/secret-store/tests/test-secret-binary.c
rename to pkcs11/secret-store/test-secret-binary.c
index 0302469..2900cb4 100644
--- a/pkcs11/secret-store/tests/test-secret-binary.c
+++ b/pkcs11/secret-store/test-secret-binary.c
@@ -99,7 +99,7 @@ test_read_encrypted (Test *test, gconstpointer unused)
 {
        GkmDataResult res;
 
-       res = check_read_keyring_file (test, SRCDIR "/files/encrypted.keyring");
+       res = check_read_keyring_file (test, SRCDIR "/fixtures/encrypted.keyring");
        g_assert (res == GKM_DATA_SUCCESS);
 
        test_secret_collection_validate (test->collection, test->sdata);
@@ -110,7 +110,7 @@ test_read_wrong_format (Test *test, gconstpointer unused)
 {
        GkmDataResult res;
 
-       res = check_read_keyring_file (test, SRCDIR "/files/plain.keyring");
+       res = check_read_keyring_file (test, SRCDIR "/fixtures/plain.keyring");
        g_assert (res == GKM_DATA_UNRECOGNIZED);
 }
 
@@ -124,7 +124,7 @@ test_read_wrong_master (Test *test, gconstpointer unused)
        gkm_secret_data_set_master (test->sdata, master);
        g_object_unref (master);
 
-       res = check_read_keyring_file (test, SRCDIR "/files/encrypted.keyring");
+       res = check_read_keyring_file (test, SRCDIR "/fixtures/encrypted.keyring");
        g_assert (res == GKM_DATA_LOCKED);
 }
 
@@ -135,7 +135,7 @@ test_read_sdata_but_no_master (Test *test, gconstpointer unused)
 
        gkm_secret_data_set_master (test->sdata, NULL);
 
-       res = check_read_keyring_file (test, SRCDIR "/files/encrypted.keyring");
+       res = check_read_keyring_file (test, SRCDIR "/fixtures/encrypted.keyring");
        g_assert (res == GKM_DATA_LOCKED);
 }
 
@@ -166,7 +166,7 @@ test_remove_unavailable (Test *test, gconstpointer unused)
        gchar *data;
        gsize n_data;
 
-       if (!g_file_get_contents (SRCDIR "/files/encrypted.keyring", &data, &n_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/encrypted.keyring", &data, &n_data, NULL))
                g_assert_not_reached ();
        res = gkm_secret_binary_read (test->collection, test->sdata, data, n_data);
        g_assert (res == GKM_DATA_SUCCESS);
@@ -206,7 +206,7 @@ test_read_created_on_solaris_opencsw (Test *test, gconstpointer unused)
        gkm_secret_data_set_master (test->sdata, master);
        g_object_unref (master);
 
-       res = check_read_keyring_file (test, SRCDIR "/files/created-on-solaris-opencsw.keyring");
+       res = check_read_keyring_file (test, SRCDIR "/fixtures/created-on-solaris-opencsw.keyring");
        g_assert_cmpint (res, ==, GKM_DATA_SUCCESS);
 }
 
@@ -220,7 +220,7 @@ test_read_created_on_rhel (Test *test, gconstpointer unused)
        gkm_secret_data_set_master (test->sdata, master);
        g_object_unref (master);
 
-       res = check_read_keyring_file (test, SRCDIR "/files/created-on-rhel.keyring");
+       res = check_read_keyring_file (test, SRCDIR "/fixtures/created-on-rhel.keyring");
        g_assert_cmpint (res, ==, GKM_DATA_SUCCESS);
 }
 
@@ -235,7 +235,7 @@ test_read_with_schema (Test *test,
        master = gkm_secret_new_from_password ("test");
        gkm_secret_data_set_master (test->sdata, master);
        g_object_unref (master);
-       res = check_read_keyring_file (test, SRCDIR "/files/encrypted-with-schema.keyring");
+       res = check_read_keyring_file (test, SRCDIR "/fixtures/encrypted-with-schema.keyring");
        g_assert_cmpint (res, ==, GKM_DATA_SUCCESS);
 
        item = gkm_secret_collection_get_item (test->collection, "1");
diff --git a/pkcs11/secret-store/tests/test-secret-collection.c b/pkcs11/secret-store/test-secret-collection.c
similarity index 99%
rename from pkcs11/secret-store/tests/test-secret-collection.c
rename to pkcs11/secret-store/test-secret-collection.c
index 7d6d670..f9e0394 100644
--- a/pkcs11/secret-store/tests/test-secret-collection.c
+++ b/pkcs11/secret-store/test-secret-collection.c
@@ -171,7 +171,7 @@ test_load_unlock_plain (Test *test, gconstpointer unused)
        GkmDataResult res;
        CK_RV rv;
 
-       gkm_secret_collection_set_filename (test->collection, SRCDIR "/files/plain.keyring");
+       gkm_secret_collection_set_filename (test->collection, SRCDIR "/fixtures/plain.keyring");
 
        /* Load the data in the file */
        res = gkm_secret_collection_load (test->collection);
@@ -197,7 +197,7 @@ test_load_unlock_encrypted (Test *test, gconstpointer unused)
        GkmDataResult res;
        CK_RV rv;
 
-       gkm_secret_collection_set_filename (test->collection, SRCDIR "/files/encrypted.keyring");
+       gkm_secret_collection_set_filename (test->collection, SRCDIR "/fixtures/encrypted.keyring");
 
        /* Load the data in the file */
        res = gkm_secret_collection_load (test->collection);
@@ -223,7 +223,7 @@ test_load_unlock_bad_password (Test *test, gconstpointer unused)
        GkmDataResult res;
        CK_RV rv;
 
-       gkm_secret_collection_set_filename (test->collection, SRCDIR "/files/encrypted.keyring");
+       gkm_secret_collection_set_filename (test->collection, SRCDIR "/fixtures/encrypted.keyring");
 
        /* Load the data in the file */
        res = gkm_secret_collection_load (test->collection);
@@ -242,7 +242,7 @@ test_unlock_without_load (Test *test, gconstpointer unused)
        GkmSecretData *sdata;
        CK_RV rv;
 
-       gkm_secret_collection_set_filename (test->collection, SRCDIR "/files/encrypted.keyring");
+       gkm_secret_collection_set_filename (test->collection, SRCDIR "/fixtures/encrypted.keyring");
 
        /* Unlock the keyring, which should load it */
        rv = gkm_credential_create (test->module, gkm_session_get_manager (test->session), GKM_OBJECT 
(test->collection),
@@ -264,7 +264,7 @@ test_twice_unlock (Test *test, gconstpointer unused)
        GkmSecretData *sdata;
        CK_RV rv;
 
-       gkm_secret_collection_set_filename (test->collection, SRCDIR "/files/encrypted.keyring");
+       gkm_secret_collection_set_filename (test->collection, SRCDIR "/fixtures/encrypted.keyring");
 
        /* Unlock the keyring, which should load */
        rv = gkm_credential_create (test->module, gkm_session_get_manager (test->session), GKM_OBJECT 
(test->collection),
@@ -293,7 +293,7 @@ test_twice_unlock_bad_password (Test *test, gconstpointer unused)
        GkmSecretData *sdata;
        CK_RV rv;
 
-       gkm_secret_collection_set_filename (test->collection, SRCDIR "/files/encrypted.keyring");
+       gkm_secret_collection_set_filename (test->collection, SRCDIR "/fixtures/encrypted.keyring");
 
        /* Unlock the keyring, which should load */
        rv = gkm_credential_create (test->module, gkm_session_get_manager (test->session), GKM_OBJECT 
(test->collection),
diff --git a/pkcs11/secret-store/tests/test-secret-compat.c b/pkcs11/secret-store/test-secret-compat.c
similarity index 100%
rename from pkcs11/secret-store/tests/test-secret-compat.c
rename to pkcs11/secret-store/test-secret-compat.c
diff --git a/pkcs11/secret-store/tests/test-secret-data.c b/pkcs11/secret-store/test-secret-data.c
similarity index 100%
rename from pkcs11/secret-store/tests/test-secret-data.c
rename to pkcs11/secret-store/test-secret-data.c
diff --git a/pkcs11/secret-store/tests/test-secret-fields.c b/pkcs11/secret-store/test-secret-fields.c
similarity index 100%
rename from pkcs11/secret-store/tests/test-secret-fields.c
rename to pkcs11/secret-store/test-secret-fields.c
diff --git a/pkcs11/secret-store/tests/test-secret-item.c b/pkcs11/secret-store/test-secret-item.c
similarity index 100%
rename from pkcs11/secret-store/tests/test-secret-item.c
rename to pkcs11/secret-store/test-secret-item.c
diff --git a/pkcs11/secret-store/tests/test-secret-object.c b/pkcs11/secret-store/test-secret-object.c
similarity index 100%
rename from pkcs11/secret-store/tests/test-secret-object.c
rename to pkcs11/secret-store/test-secret-object.c
diff --git a/pkcs11/secret-store/tests/test-secret-schema.c b/pkcs11/secret-store/test-secret-schema.c
similarity index 99%
rename from pkcs11/secret-store/tests/test-secret-schema.c
rename to pkcs11/secret-store/test-secret-schema.c
index 123c903..82fafdd 100644
--- a/pkcs11/secret-store/tests/test-secret-schema.c
+++ b/pkcs11/secret-store/test-secret-schema.c
@@ -72,7 +72,7 @@ setup (Test *test,
         */
 
        gkm_secret_collection_set_filename (test->collection,
-                                           SRCDIR "/files/schema1.keyring");
+                                           SRCDIR "/fixtures/schema1.keyring");
 
        /* Load the collection */
        res = gkm_secret_collection_load (test->collection);
diff --git a/pkcs11/secret-store/tests/test-secret-search.c b/pkcs11/secret-store/test-secret-search.c
similarity index 100%
rename from pkcs11/secret-store/tests/test-secret-search.c
rename to pkcs11/secret-store/test-secret-search.c
diff --git a/pkcs11/secret-store/tests/test-secret-textual.c b/pkcs11/secret-store/test-secret-textual.c
similarity index 93%
rename from pkcs11/secret-store/tests/test-secret-textual.c
rename to pkcs11/secret-store/test-secret-textual.c
index bfd722a..0752712 100644
--- a/pkcs11/secret-store/tests/test-secret-textual.c
+++ b/pkcs11/secret-store/test-secret-textual.c
@@ -81,7 +81,7 @@ test_read (Test *test, gconstpointer unused)
        gchar *data;
        gsize n_data;
 
-       if (!g_file_get_contents (SRCDIR "/files/plain.keyring", &data, &n_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/plain.keyring", &data, &n_data, NULL))
                g_assert_not_reached ();
        res = gkm_secret_textual_read (test->collection, test->sdata, data, n_data);
        g_free (data);
@@ -98,7 +98,7 @@ test_read_wrong_format (Test *test, gconstpointer unused)
        gchar *data;
        gsize n_data;
 
-       if (!g_file_get_contents (SRCDIR "/files/encrypted.keyring", &data, &n_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/encrypted.keyring", &data, &n_data, NULL))
                g_assert_not_reached ();
 
        res = gkm_secret_textual_read (test->collection, test->sdata, data, n_data);
@@ -116,7 +116,7 @@ test_read_bad_number (Test *test, gconstpointer unused)
        gchar *data;
        gsize n_data;
 
-       if (!g_file_get_contents (SRCDIR "/files/plain-bad-number.keyring", &data, &n_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/plain-bad-number.keyring", &data, &n_data, NULL))
                g_assert_not_reached ();
        res = gkm_secret_textual_read (test->collection, test->sdata, data, n_data);
        g_free (data);
@@ -158,7 +158,7 @@ test_remove_unavailable (Test *test, gconstpointer unused)
        gchar *data;
        gsize n_data;
 
-       if (!g_file_get_contents (SRCDIR "/files/plain.keyring", &data, &n_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/plain.keyring", &data, &n_data, NULL))
                g_assert_not_reached ();
        res = gkm_secret_textual_read (test->collection, test->sdata, data, n_data);
        g_assert (res == GKM_DATA_SUCCESS);
@@ -197,7 +197,7 @@ test_read_with_schema (Test *test,
        gchar *data;
        gsize n_data;
 
-       if (!g_file_get_contents (SRCDIR "/files/plain-with-schema.keyring", &data, &n_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/plain-with-schema.keyring", &data, &n_data, NULL))
                g_assert_not_reached ();
        res = gkm_secret_textual_read (test->collection, test->sdata, data, n_data);
        g_assert (res == GKM_DATA_SUCCESS);
diff --git a/pkcs11/ssh-store/Makefile.am b/pkcs11/ssh-store/Makefile.am
index d221d49..d9e6aab 100644
--- a/pkcs11/ssh-store/Makefile.am
+++ b/pkcs11/ssh-store/Makefile.am
@@ -1,8 +1,10 @@
+include $(top_srcdir)/Makefile.decl
 
 INCLUDES = \
        -I$(top_builddir) \
        -I$(top_srcdir) \
        -I$(top_srcdir)/pkcs11 \
+       -DSRCDIR="\"@abs_srcdir \"" \
        $(GOBJECT_CFLAGS) \
        $(LIBGCRYPT_CFLAGS) \
        $(GLIB_CFLAGS) \
@@ -48,5 +50,53 @@ gkm_ssh_store_standalone_la_LIBADD = \
 
 
 # -------------------------------------------------------------------------------
+# TESTS
 
-SUBDIRS = . tests
+LDADD = \
+       libgkm-mock-ssh-module.a \
+       $(top_builddir)/pkcs11/ssh-store/libgkm-ssh-store.la \
+       $(top_builddir)/pkcs11/gkm/libgkm.la \
+       $(top_builddir)/egg/libegg.la \
+       $(GLIB_LIBS) \
+       $(LIBGCRYPT_LIBS)
+
+if WITH_P11_TESTS
+CHECK_PROGS = check-ssh-module
+else
+CHECK_PROGS =
+endif
+
+CHECK_FILES = \
+       p11-tests.conf
+
+TEST_PROGS = \
+       test-ssh-openssh \
+       test-private-key
+
+check_PROGRAMS = $(TEST_PROGS)
+
+test: $(TEST_PROGS) $(CHECK_PROGS) $(CHECK_FILES)
+       gtester --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
+       @for prog in $(CHECK_PROGS); do SRCDIR='.' ./$$prog || exit 1; done
+
+check-local: test
+
+all-local: $(check_PROGRAMS)
+
+noinst_PROGRAMS = \
+       $(CHECK_PROGS)
+
+check_ssh_module_CFLAGS = $(P11_TESTS_CFLAGS)
+check_ssh_module_LDADD = $(P11_TESTS_LIBS) $(LDADD)
+
+noinst_LIBRARIES = libgkm-mock-ssh-module.a
+
+libgkm_mock_ssh_module_a_SOURCES = \
+       mock-ssh-module.c mock-ssh-module.h
+
+EXTRA_DIST = \
+       p11-tests.conf.in \
+       fixtures
+
+CLEANFILES = \
+       $(CHECK_FILES)
diff --git a/pkcs11/ssh-store/tests/check-ssh-module.c b/pkcs11/ssh-store/check-ssh-module.c
similarity index 100%
rename from pkcs11/ssh-store/tests/check-ssh-module.c
rename to pkcs11/ssh-store/check-ssh-module.c
diff --git a/pkcs11/ssh-store/tests/files/id_dsa_encrypted b/pkcs11/ssh-store/fixtures/id_dsa_encrypted
similarity index 100%
rename from pkcs11/ssh-store/tests/files/id_dsa_encrypted
rename to pkcs11/ssh-store/fixtures/id_dsa_encrypted
diff --git a/pkcs11/ssh-store/tests/files/id_dsa_encrypted.pub 
b/pkcs11/ssh-store/fixtures/id_dsa_encrypted.pub
similarity index 100%
rename from pkcs11/ssh-store/tests/files/id_dsa_encrypted.pub
rename to pkcs11/ssh-store/fixtures/id_dsa_encrypted.pub
diff --git a/pkcs11/ssh-store/tests/files/id_dsa_plain b/pkcs11/ssh-store/fixtures/id_dsa_plain
similarity index 100%
rename from pkcs11/ssh-store/tests/files/id_dsa_plain
rename to pkcs11/ssh-store/fixtures/id_dsa_plain
diff --git a/pkcs11/ssh-store/tests/files/id_dsa_plain.pub b/pkcs11/ssh-store/fixtures/id_dsa_plain.pub
similarity index 100%
rename from pkcs11/ssh-store/tests/files/id_dsa_plain.pub
rename to pkcs11/ssh-store/fixtures/id_dsa_plain.pub
diff --git a/pkcs11/ssh-store/tests/files/id_dsa_test.pub b/pkcs11/ssh-store/fixtures/id_dsa_test.pub
similarity index 100%
rename from pkcs11/ssh-store/tests/files/id_dsa_test.pub
rename to pkcs11/ssh-store/fixtures/id_dsa_test.pub
diff --git a/pkcs11/ssh-store/tests/files/id_rsa_encrypted b/pkcs11/ssh-store/fixtures/id_rsa_encrypted
similarity index 100%
rename from pkcs11/ssh-store/tests/files/id_rsa_encrypted
rename to pkcs11/ssh-store/fixtures/id_rsa_encrypted
diff --git a/pkcs11/ssh-store/tests/files/id_rsa_encrypted.pub 
b/pkcs11/ssh-store/fixtures/id_rsa_encrypted.pub
similarity index 100%
rename from pkcs11/ssh-store/tests/files/id_rsa_encrypted.pub
rename to pkcs11/ssh-store/fixtures/id_rsa_encrypted.pub
diff --git a/pkcs11/ssh-store/tests/files/id_rsa_plain b/pkcs11/ssh-store/fixtures/id_rsa_plain
similarity index 100%
rename from pkcs11/ssh-store/tests/files/id_rsa_plain
rename to pkcs11/ssh-store/fixtures/id_rsa_plain
diff --git a/pkcs11/ssh-store/tests/files/id_rsa_plain.pub b/pkcs11/ssh-store/fixtures/id_rsa_plain.pub
similarity index 100%
rename from pkcs11/ssh-store/tests/files/id_rsa_plain.pub
rename to pkcs11/ssh-store/fixtures/id_rsa_plain.pub
diff --git a/pkcs11/ssh-store/tests/files/id_rsa_test.pub b/pkcs11/ssh-store/fixtures/id_rsa_test.pub
similarity index 100%
rename from pkcs11/ssh-store/tests/files/id_rsa_test.pub
rename to pkcs11/ssh-store/fixtures/id_rsa_test.pub
diff --git a/pkcs11/ssh-store/tests/mock-ssh-module.c b/pkcs11/ssh-store/mock-ssh-module.c
similarity index 100%
rename from pkcs11/ssh-store/tests/mock-ssh-module.c
rename to pkcs11/ssh-store/mock-ssh-module.c
diff --git a/pkcs11/ssh-store/tests/mock-ssh-module.h b/pkcs11/ssh-store/mock-ssh-module.h
similarity index 100%
rename from pkcs11/ssh-store/tests/mock-ssh-module.h
rename to pkcs11/ssh-store/mock-ssh-module.h
diff --git a/pkcs11/ssh-store/tests/p11-tests.conf.in b/pkcs11/ssh-store/p11-tests.conf.in
similarity index 100%
rename from pkcs11/ssh-store/tests/p11-tests.conf.in
rename to pkcs11/ssh-store/p11-tests.conf.in
diff --git a/pkcs11/ssh-store/tests/test-private-key.c b/pkcs11/ssh-store/test-private-key.c
similarity index 91%
rename from pkcs11/ssh-store/tests/test-private-key.c
rename to pkcs11/ssh-store/test-private-key.c
index 04d2bb6..50aa58c 100644
--- a/pkcs11/ssh-store/tests/test-private-key.c
+++ b/pkcs11/ssh-store/test-private-key.c
@@ -66,8 +66,8 @@ setup (Test *test,
        test->key = gkm_ssh_private_key_new (test->module, "my-unique");
        g_assert (GKM_IS_SSH_PRIVATE_KEY (test->key));
 
-       ret = gkm_ssh_private_key_parse (test->key, SRCDIR "/files/id_dsa_encrypted.pub",
-                                        SRCDIR "/files/id_dsa_encrypted", NULL);
+       ret = gkm_ssh_private_key_parse (test->key, SRCDIR "/fixtures/id_dsa_encrypted.pub",
+                                        SRCDIR "/fixtures/id_dsa_encrypted", NULL);
        g_assert (ret == TRUE);
 }
 
@@ -88,8 +88,8 @@ test_parse_plain (Test *test, gconstpointer unused)
        key = gkm_ssh_private_key_new (test->module, "my-unique");
        g_assert (GKM_IS_SSH_PRIVATE_KEY (key));
 
-       ret = gkm_ssh_private_key_parse (key, SRCDIR "/files/id_dsa_plain.pub",
-                                        SRCDIR "/files/id_dsa_plain", NULL);
+       ret = gkm_ssh_private_key_parse (key, SRCDIR "/fixtures/id_dsa_plain.pub",
+                                        SRCDIR "/fixtures/id_dsa_plain", NULL);
        g_assert (ret == TRUE);
 
        g_object_unref (key);
diff --git a/pkcs11/ssh-store/tests/test-ssh-openssh.c b/pkcs11/ssh-store/test-ssh-openssh.c
similarity index 93%
rename from pkcs11/ssh-store/tests/test-ssh-openssh.c
rename to pkcs11/ssh-store/test-ssh-openssh.c
index ba4b8d9..3be9f73 100644
--- a/pkcs11/ssh-store/tests/test-ssh-openssh.c
+++ b/pkcs11/ssh-store/test-ssh-openssh.c
@@ -36,15 +36,15 @@
 EGG_SECURE_DEFINE_GLIB_GLOBALS ();
 
 static const gchar *PRIVATE_FILES[] = {
-       SRCDIR "/files/id_rsa_encrypted",
-       SRCDIR "/files/id_rsa_plain",
-       SRCDIR "/files/id_dsa_encrypted",
-       SRCDIR "/files/id_dsa_plain"
+       SRCDIR "/fixtures/id_rsa_encrypted",
+       SRCDIR "/fixtures/id_rsa_plain",
+       SRCDIR "/fixtures/id_dsa_encrypted",
+       SRCDIR "/fixtures/id_dsa_plain"
 };
 
 static const gchar *PUBLIC_FILES[] = {
-       SRCDIR "/files/id_rsa_test.pub",
-       SRCDIR "/files/id_dsa_test.pub"
+       SRCDIR "/fixtures/id_rsa_test.pub",
+       SRCDIR "/fixtures/id_dsa_test.pub"
 };
 
 #define COMMENT "A public key comment"
diff --git a/pkcs11/wrap-layer/Makefile.am b/pkcs11/wrap-layer/Makefile.am
index e49a955..97a6707 100644
--- a/pkcs11/wrap-layer/Makefile.am
+++ b/pkcs11/wrap-layer/Makefile.am
@@ -6,6 +6,7 @@ INCLUDES = -I. \
        -I$(top_srcdir) \
        -I$(top_builddir) \
        -I$(top_srcdir)/pkcs11 \
+       -DSRCDIR="\"@abs_srcdir \"" \
        $(GCR_BASE_CFLAGS) \
        -DGCR_API_SUBJECT_TO_CHANGE
 
@@ -29,5 +30,36 @@ libgkm_wrap_layer_la_CFLAGS = \
        $(GIO_CFLAGS)
 
 # ------------------------------------------------------------------------------
+# TESTS
 
-SUBDIRS = . tests
+LDADD = \
+       $(top_builddir)/pkcs11/wrap-layer/libgkm-wrap-layer.la \
+       libgkm-mock-secret-store.a \
+       $(top_builddir)/pkcs11/gkm/libgkm.la \
+       $(top_builddir)/egg/libegg.la \
+       $(GCR_BASE_LIBS) \
+       $(GLIB_LIBS)
+
+TEST_PROGS = \
+       test-create-credential \
+       test-init-pin \
+       test-login-auto \
+       test-login-hints \
+       test-login-keyring \
+       test-login-specific \
+       test-login-user \
+       test-set-pin
+
+check_PROGRAMS = $(TEST_PROGS)
+
+test: $(TEST_PROGS) $(CHECK_PROGS)
+       gtester --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
+
+check-local: test
+
+all-local: $(check_PROGRAMS)
+
+noinst_LIBRARIES = libgkm-mock-secret-store.a
+
+libgkm_mock_secret_store_a_SOURCES = \
+       mock-secret-store.c
\ No newline at end of file
diff --git a/pkcs11/wrap-layer/tests/mock-secret-store.c b/pkcs11/wrap-layer/mock-secret-store.c
similarity index 100%
rename from pkcs11/wrap-layer/tests/mock-secret-store.c
rename to pkcs11/wrap-layer/mock-secret-store.c
diff --git a/pkcs11/wrap-layer/tests/test-create-credential.c b/pkcs11/wrap-layer/test-create-credential.c
similarity index 100%
rename from pkcs11/wrap-layer/tests/test-create-credential.c
rename to pkcs11/wrap-layer/test-create-credential.c
diff --git a/pkcs11/wrap-layer/tests/test-init-pin.c b/pkcs11/wrap-layer/test-init-pin.c
similarity index 100%
rename from pkcs11/wrap-layer/tests/test-init-pin.c
rename to pkcs11/wrap-layer/test-init-pin.c
diff --git a/pkcs11/wrap-layer/tests/test-login-auto.c b/pkcs11/wrap-layer/test-login-auto.c
similarity index 100%
rename from pkcs11/wrap-layer/tests/test-login-auto.c
rename to pkcs11/wrap-layer/test-login-auto.c
diff --git a/pkcs11/wrap-layer/tests/test-login-hints.c b/pkcs11/wrap-layer/test-login-hints.c
similarity index 100%
rename from pkcs11/wrap-layer/tests/test-login-hints.c
rename to pkcs11/wrap-layer/test-login-hints.c
diff --git a/pkcs11/wrap-layer/tests/test-login-keyring.c b/pkcs11/wrap-layer/test-login-keyring.c
similarity index 100%
rename from pkcs11/wrap-layer/tests/test-login-keyring.c
rename to pkcs11/wrap-layer/test-login-keyring.c
diff --git a/pkcs11/wrap-layer/tests/test-login-specific.c b/pkcs11/wrap-layer/test-login-specific.c
similarity index 100%
rename from pkcs11/wrap-layer/tests/test-login-specific.c
rename to pkcs11/wrap-layer/test-login-specific.c
diff --git a/pkcs11/wrap-layer/tests/test-login-user.c b/pkcs11/wrap-layer/test-login-user.c
similarity index 100%
rename from pkcs11/wrap-layer/tests/test-login-user.c
rename to pkcs11/wrap-layer/test-login-user.c
diff --git a/pkcs11/wrap-layer/tests/test-set-pin.c b/pkcs11/wrap-layer/test-set-pin.c
similarity index 100%
rename from pkcs11/wrap-layer/tests/test-set-pin.c
rename to pkcs11/wrap-layer/test-set-pin.c
diff --git a/pkcs11/xdg-store/Makefile.am b/pkcs11/xdg-store/Makefile.am
index e34b863..680f662 100644
--- a/pkcs11/xdg-store/Makefile.am
+++ b/pkcs11/xdg-store/Makefile.am
@@ -4,6 +4,7 @@ INCLUDES = \
        -I$(top_builddir) \
        -I$(top_srcdir) \
        -I$(top_srcdir)/pkcs11 \
+       -DSRCDIR="\"@abs_srcdir \"" \
        $(GOBJECT_CFLAGS) \
        $(LIBGCRYPT_CFLAGS) \
        $(GLIB_CFLAGS) \
@@ -52,11 +53,55 @@ gkm_xdg_store_standalone_la_LIBADD = \
        $(GMODULE_LIBS) \
        $(LIBGCRYPT_LIBS)
 
+asn:
+       asn1Parser -o xdg.asn.h xdg.asn
+       sed -i 's|#include.*|/* \0 */|' xdg.asn.h
 
 # -------------------------------------------------------------------------------
+# TESTS
 
-SUBDIRS = . tests
+LDADD = \
+       libgkm-mock-xdg-module.a \
+       $(top_builddir)/pkcs11/xdg-store/libgkm-xdg-store.la \
+       $(top_builddir)/pkcs11/gkm/libgkm.la \
+       $(top_builddir)/egg/libegg.la \
+       $(GLIB_LIBS) \
+       $(GTHREAD_LIBS) \
+       $(LIBGCRYPT_LIBS)
 
-asn:
-       asn1Parser -o xdg.asn.h xdg.asn
-       sed -i 's|#include.*|/* \0 */|' xdg.asn.h
+if WITH_P11_TESTS
+CHECK_PROGS = check-xdg-module
+else
+CHECK_PROGS =
+endif
+
+TEST_PROGS = \
+       test-xdg-module \
+       test-xdg-trust
+
+check_PROGRAMS = $(TEST_PROGS)
+
+test: $(TEST_PROGS) $(CHECK_PROGS)
+       gtester --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
+       @for prog in $(CHECK_PROGS); do SRCDIR='.' ./$$prog || exit 1; done
+
+check-local: test
+
+all-local: $(check_PROGRAMS)
+
+EXTRA_DIST += \
+       p11-tests.conf \
+       fixtures
+
+noinst_PROGRAMS = \
+       frob-trust-file \
+       dump-trust-file \
+       $(CHECK_PROGS)
+
+check_xdg_module_CFLAGS = $(P11_TESTS_CFLAGS)
+check_xdg_module_LDADD = $(P11_TESTS_LIBS) $(LDADD)
+
+noinst_LIBRARIES = libgkm-mock-xdg-module.a
+
+libgkm_mock_xdg_module_a_SOURCES = \
+       mock-xdg-module.c mock-xdg-module.h
diff --git a/pkcs11/xdg-store/tests/check-xdg-module.c b/pkcs11/xdg-store/check-xdg-module.c
similarity index 100%
rename from pkcs11/xdg-store/tests/check-xdg-module.c
rename to pkcs11/xdg-store/check-xdg-module.c
diff --git a/pkcs11/xdg-store/tests/dump-trust-file.c b/pkcs11/xdg-store/dump-trust-file.c
similarity index 100%
rename from pkcs11/xdg-store/tests/dump-trust-file.c
rename to pkcs11/xdg-store/dump-trust-file.c
diff --git a/pkcs11/xdg-store/tests/frob-trust-file.c b/pkcs11/xdg-store/frob-trust-file.c
similarity index 100%
rename from pkcs11/xdg-store/tests/frob-trust-file.c
rename to pkcs11/xdg-store/frob-trust-file.c
diff --git a/pkcs11/xdg-store/tests/mock-xdg-module.c b/pkcs11/xdg-store/mock-xdg-module.c
similarity index 97%
rename from pkcs11/xdg-store/tests/mock-xdg-module.c
rename to pkcs11/xdg-store/mock-xdg-module.c
index 4d17d97..cdc886b 100644
--- a/pkcs11/xdg-store/tests/mock-xdg-module.c
+++ b/pkcs11/xdg-store/mock-xdg-module.c
@@ -109,8 +109,8 @@ mock_xdg_module_initialize_and_enter (void)
        CK_RV rv;
 
        directory = egg_tests_create_scratch_directory (
-               SRCDIR "/files/test-refer-1.trust",
-               SRCDIR "/files/test-certificate-1.cer",
+               SRCDIR "/fixtures/test-refer-1.trust",
+               SRCDIR "/fixtures/test-certificate-1.cer",
                NULL);
 
        /* Setup test directory to work in */
@@ -119,7 +119,7 @@ mock_xdg_module_initialize_and_enter (void)
        args.pReserved = string;
        args.flags = CKF_OS_LOCKING_OK;
 
-       /* Copy files from test-data to scratch */
+       /* Copy fixtures from test-data to scratch */
        mock_xdg_module_empty_file ("invalid-without-ext");
        mock_xdg_module_empty_file ("test-file.unknown");
        mock_xdg_module_empty_file ("test-invalid.trust");
diff --git a/pkcs11/xdg-store/tests/mock-xdg-module.h b/pkcs11/xdg-store/mock-xdg-module.h
similarity index 100%
rename from pkcs11/xdg-store/tests/mock-xdg-module.h
rename to pkcs11/xdg-store/mock-xdg-module.h
diff --git a/pkcs11/xdg-store/tests/p11-tests.conf b/pkcs11/xdg-store/p11-tests.conf
similarity index 100%
rename from pkcs11/xdg-store/tests/p11-tests.conf
rename to pkcs11/xdg-store/p11-tests.conf
diff --git a/pkcs11/xdg-store/tests/test-xdg-module.c b/pkcs11/xdg-store/test-xdg-module.c
similarity index 98%
rename from pkcs11/xdg-store/tests/test-xdg-module.c
rename to pkcs11/xdg-store/test-xdg-module.c
index 482d50c..fb0d72d 100644
--- a/pkcs11/xdg-store/tests/test-xdg-module.c
+++ b/pkcs11/xdg-store/test-xdg-module.c
@@ -181,7 +181,7 @@ test_create_and_add_object (Test *test, gconstpointer unused)
                { CKA_CERTIFICATE_TYPE, &ctype, sizeof (ctype) }
        };
 
-       if (!g_file_get_contents (SRCDIR "/files/test-certificate-2.cer", &data, &n_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/test-certificate-2.cer", &data, &n_data, NULL))
                g_assert_not_reached ();
 
        attrs[0].pValue = data;
diff --git a/pkcs11/xdg-store/tests/test-xdg-trust.c b/pkcs11/xdg-store/test-xdg-trust.c
similarity index 99%
rename from pkcs11/xdg-store/tests/test-xdg-trust.c
rename to pkcs11/xdg-store/test-xdg-trust.c
index f6ee580..cdddd99 100644
--- a/pkcs11/xdg-store/tests/test-xdg-trust.c
+++ b/pkcs11/xdg-store/test-xdg-trust.c
@@ -128,7 +128,7 @@ setup (Test *test, gconstpointer unused)
        rv = gkm_module_C_Login (test->module, gkm_session_get_handle (test->session), CKU_USER, NULL, 0);
        g_assert (rv == CKR_OK);
 
-       if (!g_file_get_contents (SRCDIR "/files/test-certificate-2.cer", &test->cert_data, 
&test->n_cert_data, NULL))
+       if (!g_file_get_contents (SRCDIR "/fixtures/test-certificate-2.cer", &test->cert_data, 
&test->n_cert_data, NULL))
                g_assert_not_reached ();
 }
 


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