Commit 24983752 authored by Stef Walter's avatar Stef Walter

Modernize the remainder of the tests.

 * Bring up to date with gtester running and individual binaries.
 * Make the tests run in make distcheck
parent eedfc975
......@@ -95,6 +95,11 @@ run-tests
/egg/tests/test-spawn
/egg/tests/test-symkey
/daemon/control/tests/frob-control-change
/daemon/control/tests/frob-control-init
/daemon/control/tests/frob-control-quit
/daemon/control/tests/frob-control-unlock
/gck/tests/test-gck-attributes
/gck/tests/test-gck-crypto
/gck/tests/test-gck-enumerator
......@@ -129,6 +134,43 @@ run-tests
/pkcs11/gkm/tests/test-timer
/pkcs11/gkm/tests/test-transaction
/pkcs11/gnome2-store/tests/frob-gnome2-file
/pkcs11/gnome2-store/tests/test-gnome2-file
/pkcs11/gnome2-store/tests/check-gnome2-module
/pkcs11/gnome2-store/tests/check-module
/pkcs11/roots-store/tests/check-roots-module
/pkcs11/secret-store/tests/test-secret-binary
/pkcs11/secret-store/tests/test-secret-collection
/pkcs11/secret-store/tests/test-secret-compat
/pkcs11/secret-store/tests/test-secret-data
/pkcs11/secret-store/tests/test-secret-fields
/pkcs11/secret-store/tests/test-secret-item
/pkcs11/secret-store/tests/test-secret-object
/pkcs11/secret-store/tests/test-secret-search
/pkcs11/secret-store/tests/test-secret-textual
/pkcs11/ssh-store/tests/check-ssh-module
/pkcs11/ssh-store/tests/test-private-key
/pkcs11/ssh-store/tests/test-ssh-openssh
/pkcs11/wrap-layer/tests/test-create-credential
/pkcs11/wrap-layer/tests/test-init-pin
/pkcs11/wrap-layer/tests/test-login-auto
/pkcs11/wrap-layer/tests/test-login-hints
/pkcs11/wrap-layer/tests/test-login-keyring
/pkcs11/wrap-layer/tests/test-login-specific
/pkcs11/wrap-layer/tests/test-login-user
/pkcs11/wrap-layer/tests/test-set-pin
/pkcs11/xdg-store/tests/check-xdg-module
/pkcs11/xdg-store/tests/frob-trust-file
/pkcs11/xdg-store/tests/test-xdg-module
/pkcs11/xdg-store/tests/test-xdg-trust
/ui/tests/test-util
/daemon/dbus/tests/test-secret-util
/ui/gnome-keyring-prompt.desktop
......
......@@ -36,8 +36,8 @@ EXTRA_DIST = \
DISTCHECK_CONFIGURE_FLAGS = \
--enable-gtk-doc \
--enable-tests \
--disable-debug \
--enable-tests=full \
--enable-debug=yes \
--disable-gcov
DISTCLEANFILES = \
......
......@@ -12,45 +12,45 @@ LIBS = \
$(P11_TESTS_LIBS)
noinst_PROGRAMS= \
test-control-change \
test-control-init \
test-control-unlock \
test-control-quit
frob-control-change \
frob-control-init \
frob-control-unlock \
frob-control-quit
# ------------------------------------------------------------------------------
# Test unlocking the login keyring
test_control_change_SOURCES = \
test-control-change.c
frob_control_change_SOURCES = \
frob-control-change.c
test_control_change_LDADD = \
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
test_control_init_SOURCES = \
test-control-init.c
frob_control_init_SOURCES = \
frob-control-init.c
test_control_init_LDADD = \
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
test_control_quit_SOURCES = \
test-control-quit.c
frob_control_quit_SOURCES = \
frob-control-quit.c
test_control_quit_LDADD = \
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
test_control_unlock_SOURCES = \
test-control-unlock.c
frob_control_unlock_SOURCES = \
frob-control-unlock.c
test_control_unlock_LDADD = \
frob_control_unlock_LDADD = \
$(top_builddir)/daemon/control/libgkd-control-client.la \
$(top_builddir)/egg/libegg-buffer.la \
$(top_builddir)/egg/libegg-creds.la \
......
#include "control/gkd-control.h"
#include "testing/testing.h"
#include "egg/egg-secure-memory.h"
#include <pwd.h>
#include <unistd.h>
static int
run (void)
EGG_SECURE_GLIB_DEFINITIONS ();
int
main (int argc, char *argv[])
{
gchar *original;
const char *password;
......@@ -26,5 +29,3 @@ run (void)
g_free (original);
return 0;
}
#include "testing/testing.c"
#include "control/gkd-control.h"
#include "testing/testing.h"
#include "egg/egg-secure-memory.h"
#include <pwd.h>
#include <stdlib.h>
#include <unistd.h>
static int
run (void)
EGG_SECURE_GLIB_DEFINITIONS ();
int
main (int argc, char *argv[])
{
const char *directory;
const gchar *env[] = { NULL };
......@@ -26,5 +29,3 @@ run (void)
return 0;
}
#include "testing/testing.c"
#include "control/gkd-control.h"
#include "testing/testing.h"
#include "egg/egg-secure-memory.h"
#include <pwd.h>
#include <stdlib.h>
#include <unistd.h>
static int
run (void)
EGG_SECURE_GLIB_DEFINITIONS ();
int
main (int argc, char *argv[])
{
const char *directory;
......@@ -21,5 +24,3 @@ run (void)
return 0;
}
#include "testing/testing.c"
#include "control/gkd-control.h"
#include "testing/testing.h"
#include "egg/egg-secure-memory.h"
#include <pwd.h>
#include <unistd.h>
static int
run (void)
EGG_SECURE_GLIB_DEFINITIONS ();
int
main (int argc, char *argv[])
{
const char *password;
const char *directory;
......@@ -20,5 +23,3 @@ run (void)
gkd_control_unlock (directory, password);
return 0;
}
#include "testing/testing.c"
INCLUDES = \
-I$(top_srcdir)/daemon/dbus \
-DSRCDIR=$(srcdir) \
-DSRCDIR="\"$(srcdir)\"" \
$(DAEMON_CFLAGS) \
$(GLIB_CFLAGS)
......@@ -14,7 +14,7 @@ TEST_PROGS = \
check_PROGRAMS = $(TEST_PROGS)
test: $(TEST_PROGS)
SRCDIR='$(srcdir)' gtester -k --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
gtester -k --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
check-local: test
......
......@@ -3,8 +3,9 @@ asn1-def-test.c: test.asn
$(ASN1PARSER) -o asn1-def-test.c $(srcdir)/test.asn
INCLUDES = \
-I$(top_srcdir)/egg \
-DSRCDIR=$(srcdir) \
-I$(top_builddir) \
-I$(top_srcdir) \
-DSRCDIR="\"$(srcdir)\"" \
$(GLIB_CFLAGS)
LDADD = \
......@@ -34,7 +35,7 @@ test_asn1_SOURCES = \
check_PROGRAMS = $(TEST_PROGS)
test: $(TEST_PROGS)
SRCDIR='$(srcdir)' gtester -k --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
gtester -k --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
check-local: test
......@@ -44,6 +45,9 @@ EXTRA_DIST = \
test.asn \
files
DISTCLEANFILES = \
asn1-def-test.c
# ------------------------------------------------------------------------------
noinst_PROGRAMS = \
......
......@@ -23,9 +23,9 @@
#include "config.h"
#include "egg-asn1x.h"
#include "egg-asn1-defs.h"
#include "egg-testing.h"
#include "egg/egg-asn1x.h"
#include "egg/egg-asn1-defs.h"
#include "egg/egg-testing.h"
#include <glib.h>
#include <libtasn1.h>
......@@ -726,8 +726,8 @@ typedef struct {
static void
setup (Test *test, gconstpointer unused)
{
if (!g_file_get_contents ("files/test-certificate-1.der", (gchar**)&test->data,
&test->n_data, NULL))
if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der",
(gchar**)&test->data, &test->n_data, NULL))
g_assert_not_reached ();
test->asn1 = egg_asn1x_create (pkix_asn1_tab, "Certificate");
......
......@@ -21,15 +21,16 @@
Author: Stef Walter <stef@memberwebs.com>
*/
#include "egg-asn1x.h"
#include "config.h"
#include "egg/egg-asn1x.h"
#include "egg/egg-asn1-defs.h"
#include "egg/egg-testing.h"
#include <pwd.h>
#include <stdlib.h>
#include <unistd.h>
#include "egg-asn1-defs.h"
#include "egg-testing.h"
#if 0
static void
build_personal_name (void)
......@@ -101,13 +102,13 @@ main (int argc, char **argv)
egg_tests_chdir_base (argv[0]);
test_some_asn1_stuff (pkix_asn1_tab, "files/test-certificate-1.der", "Certificate");
test_some_asn1_stuff (pkix_asn1_tab, "files/test-pkcs8-1.der", "pkcs-8-PrivateKeyInfo");
test_some_asn1_stuff (pk_asn1_tab, "files/test-rsakey-1.der", "RSAPrivateKey");
test_some_asn1_stuff (pkix_asn1_tab, "files/test-personalname-1.der", "PersonalName");
test_some_asn1_stuff (pkix_asn1_tab, "files/test-pkcs7-1.der", "pkcs-7-ContentInfo");
test_some_asn1_stuff (pkix_asn1_tab, "files/test-pkcs7-2.der", "pkcs-7-ContentInfo");
test_some_asn1_stuff (pkix_asn1_tab, "files/test-pkcs12-1.der", "pkcs-12-PFX");
test_some_asn1_stuff (pkix_asn1_tab, SRCDIR "/files/test-certificate-1.der", "Certificate");
test_some_asn1_stuff (pkix_asn1_tab, SRCDIR "/files/test-pkcs8-1.der", "pkcs-8-PrivateKeyInfo");
test_some_asn1_stuff (pk_asn1_tab, SRCDIR "/files/test-rsakey-1.der", "RSAPrivateKey");
test_some_asn1_stuff (pkix_asn1_tab, SRCDIR "/files/test-personalname-1.der", "PersonalName");
test_some_asn1_stuff (pkix_asn1_tab, SRCDIR "/files/test-pkcs7-1.der", "pkcs-7-ContentInfo");
test_some_asn1_stuff (pkix_asn1_tab, SRCDIR "/files/test-pkcs7-2.der", "pkcs-7-ContentInfo");
test_some_asn1_stuff (pkix_asn1_tab, SRCDIR "/files/test-pkcs12-1.der", "pkcs-12-PFX");
return 0;
}
......@@ -25,7 +25,7 @@
#include <stdio.h>
#include <string.h>
#include "egg-cleanup.h"
#include "egg/egg-cleanup.h"
#define DATA "some string"
......
......@@ -23,9 +23,9 @@
#include "config.h"
#include "egg-dh.h"
#include "egg-secure-memory.h"
#include "egg-testing.h"
#include "egg/egg-dh.h"
#include "egg/egg-secure-memory.h"
#include "egg/egg-testing.h"
#include <stdlib.h>
#include <stdio.h>
......
......@@ -23,10 +23,10 @@
#include "config.h"
#include "egg-asn1-defs.h"
#include "egg-asn1x.h"
#include "egg-dn.h"
#include "egg-oid.h"
#include "egg/egg-asn1-defs.h"
#include "egg/egg-asn1x.h"
#include "egg/egg-dn.h"
#include "egg/egg-oid.h"
#include <glib.h>
#include <gcrypt.h>
......@@ -45,8 +45,8 @@ typedef struct {
static void
setup (Test *test, gconstpointer unused)
{
if (!g_file_get_contents ("files/test-certificate-1.der", (gchar**)&test->data,
&test->n_data, NULL))
if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der",
(gchar**)&test->data, &test->n_data, NULL))
g_assert_not_reached ();
test->asn1 = egg_asn1x_create (pkix_asn1_tab, "Certificate");
......
......@@ -23,7 +23,7 @@
#include "config.h"
#include "egg-hex.h"
#include "egg/egg-hex.h"
#include <stdlib.h>
#include <stdio.h>
......
......@@ -27,9 +27,9 @@
#include <stdio.h>
#include <string.h>
#include "egg-hkdf.h"
#include "egg-secure-memory.h"
#include "egg-testing.h"
#include "egg/egg-hkdf.h"
#include "egg/egg-secure-memory.h"
#include "egg/egg-testing.h"
#include <gcrypt.h>
......
......@@ -22,7 +22,7 @@
#include "config.h"
#include "egg-oid.h"
#include "egg/egg-oid.h"
#include <glib.h>
......
......@@ -23,10 +23,10 @@
#include "config.h"
#include "egg-symkey.h"
#include "egg-openssl.h"
#include "egg-secure-memory.h"
#include "egg-testing.h"
#include "egg/egg-symkey.h"
#include "egg/egg-openssl.h"
#include "egg/egg-secure-memory.h"
#include "egg/egg-testing.h"
#include <glib.h>
......@@ -51,7 +51,7 @@ typedef struct {
static void
setup (Test *test, gconstpointer unused)
{
if (!g_file_get_contents ("files/pem-rsa-enc.key", (gchar**)&test->input, &test->n_input, NULL))
if (!g_file_get_contents (SRCDIR "/files/pem-rsa-enc.key", (gchar**)&test->input, &test->n_input, NULL))
g_assert_not_reached ();
}
......
......@@ -23,8 +23,8 @@
#include "config.h"
#include "egg-padding.h"
#include "egg-testing.h"
#include "egg/egg-padding.h"
#include "egg/egg-testing.h"
#include <gcrypt.h>
......
......@@ -23,7 +23,7 @@
#include "config.h"
#include "egg-secure-memory.h"
#include "egg/egg-secure-memory.h"
#include <glib.h>
......
......@@ -23,8 +23,8 @@
#include "config.h"
#include "egg-spawn.h"
#include "egg-testing.h"
#include "egg/egg-spawn.h"
#include "egg/egg-testing.h"
#include <sys/wait.h>
......@@ -176,7 +176,7 @@ test_sync (void)
data.parent_pid = getpid();
data.index = 80;
ret = egg_spawn_sync_with_callbacks ("./files",
ret = egg_spawn_sync_with_callbacks (SRCDIR "/files",
echo_argv, NULL, 0, &pid,
&echo_callbacks, &data,
&exit_status, &error);
......@@ -197,7 +197,7 @@ test_sync_error (void)
GError *error = NULL;
gboolean ret;
ret = egg_spawn_sync_with_callbacks ("./files",
ret = egg_spawn_sync_with_callbacks (SRCDIR "/files",
error_argv, NULL, 0, NULL,
NULL, NULL,
NULL, &error);
......@@ -220,7 +220,7 @@ test_async (void)
data.index = 80;
data.is_async = TRUE;
ret = egg_spawn_async_with_callbacks ("./files",
ret = egg_spawn_async_with_callbacks (SRCDIR "/files",
echo_argv, NULL, 0, &pid,
&echo_callbacks, &data,
NULL, &error);
......@@ -247,7 +247,7 @@ test_async_none (void)
data.parent_pid = getpid();
data.is_async = TRUE;
ret = egg_spawn_async_with_callbacks ("./files",
ret = egg_spawn_async_with_callbacks (SRCDIR "/files",
echo_argv, NULL, 0, NULL,
&null_callbacks, &data,
NULL, &error);
......@@ -268,7 +268,7 @@ test_async_error (void)
GError *error = NULL;
guint ret;
ret = egg_spawn_async_with_callbacks ("./files",
ret = egg_spawn_async_with_callbacks (SRCDIR "/files",
error_argv, NULL, 0, NULL,
NULL, NULL,
NULL, &error);
......@@ -280,14 +280,8 @@ test_async_error (void)
int
main (int argc, char **argv)
{
const gchar *srcdir;
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_func ("/spawn/sync", test_sync);
g_test_add_func ("/spawn/sync_error", test_sync_error);
g_test_add_func ("/spawn/async", test_async);
......
......@@ -23,9 +23,9 @@
#include "config.h"
#include "egg-libgcrypt.h"
#include "egg-secure-memory.h"
#include "egg-symkey.h"
#include "egg/egg-libgcrypt.h"
#include "egg/egg-secure-memory.h"
#include "egg/egg-symkey.h"
#include <gcrypt.h>
......
INCLUDES = \
-I$(top_srcdir)/egg \
-DSRCDIR=$(srcdir) \
-I$(top_builddir) \
-I$(top_srcdir) \
-DSRCDIR="\"$(srcdir)\"" \
-DBUILDDIR="\"$(builddir)\"" \
-DGCK_API_SUBJECT_TO_CHANGE \
$(GLIB_CFLAGS)
......@@ -28,7 +30,7 @@ TEST_PROGS = \
check_PROGRAMS = $(TEST_PROGS)
test: $(TEST_PROGS)
SRCDIR='$(srcdir)' gtester -k --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
gtester -k --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
check-local: test
......
......@@ -57,7 +57,7 @@ setup (Test *test, gconstpointer unused)
GckSlot *slot;
/* Successful load */
test->module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, 0, &err);
g_assert_no_error (err);
g_assert (GCK_IS_MODULE (test->module));
......@@ -627,15 +627,9 @@ test_derive_key (Test *test, gconstpointer unused)
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);
......
......@@ -48,7 +48,7 @@ setup (Test *test, gconstpointer unused)
GError *err = NULL;
/* Successful load */
test->module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, 0, &err);
g_assert_no_error (err);
g_assert (GCK_IS_MODULE (test->module));
......@@ -266,15 +266,9 @@ test_token_match (Test *test, gconstpointer unused)
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);
......
......@@ -40,7 +40,7 @@ setup (Test *test, gconstpointer unused)
GError *err = NULL;
/* Successful load */
test->module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, 0, &err);
g_assert_no_error (err);
g_assert (test->module);
}
......@@ -101,7 +101,7 @@ test_module_props (Test *test, gconstpointer unused)
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_assert (strcmp (BUILDDIR "/.libs/libmock-test-module.so", path) == 0 && "module path wrong");
g_free (path);
}
......@@ -127,15 +127,9 @@ test_module_info (Test *test, gconstpointer unused)
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/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);
......
......@@ -48,7 +48,7 @@ setup (Test *test, gconstpointer unused)
GError *err = NULL;
/* Successful load */
module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, 0, &err);
g_assert_no_error (err);
g_assert (GCK_IS_MODULE (module));
......@@ -193,15 +193,9 @@ test_enumerate_uri (Test *test, gconstpointer unused)
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);
......
......@@ -50,7 +50,7 @@ setup (Test *test, gconstpointer unused)
GList *slots;
/* Successful load */
test->module = gck_module_initialize (".libs/libmock-test-module.so", NULL, 0, &err);
test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, 0, &err);
g_assert_no_error (err);
g_assert (GCK_IS_MODULE (test->module));
......@@ -403,15 +403,9 @@ test_find_objects (Test *test, gconstpointer unused)
int