summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorStef Walter <stefw@collabora.co.uk>2011-04-24 00:19:42 +0200
committerStef Walter <stefw@collabora.co.uk>2011-04-24 10:23:19 +0200
commit24983752cb3e452b255306695fd7217256add905 (patch)
tree87dc294d879dd565a250ed1e3b7cf7181c8b4a50 /ui
parenteedfc9755323f68a26c39ff2374a11dbc18ada32 (diff)
downloadgnome-keyring-24983752cb3e452b255306695fd7217256add905.tar.gz
Modernize the remainder of the tests.
* Bring up to date with gtester running and individual binaries. * Make the tests run in make distcheck
Diffstat (limited to 'ui')
-rw-r--r--ui/tests/Makefile.am35
-rw-r--r--ui/tests/files/prompt-empty (renamed from ui/tests/test-data/prompt-empty)0
-rw-r--r--ui/tests/files/prompt-full (renamed from ui/tests/test-data/prompt-full)0
-rw-r--r--ui/tests/files/prompt-test (renamed from ui/tests/test-data/prompt-test)0
-rw-r--r--ui/tests/test-util.c (renamed from ui/tests/unit-test-util.c)72
5 files changed, 75 insertions, 32 deletions
diff --git a/ui/tests/Makefile.am b/ui/tests/Makefile.am
index cf2c5301..46f7b352 100644
--- a/ui/tests/Makefile.am
+++ b/ui/tests/Makefile.am
@@ -1,14 +1,29 @@
-# Test files should be listed in order they need to run
-TESTING_FILES = \
- unit-test-util.c
-UNIT_PROMPT =
+INCLUDES = \
+ -I$(top_builddir) \
+ -I$(top_srcdir) \
+ -DSRCDIR="\"$(srcdir)\"" \
+ $(GLIB_CFLAGS) \
+ $(LIBGCRYPT_CFLAGS)
-TESTING_LIBS = \
- $(top_builddir)/ui/libgku-prompt.la \
- $(top_builddir)/egg/libegg-prompt.la
+LDADD = \
+ $(top_builddir)/ui/libgku-prompt-testable.la \
+ $(top_builddir)/egg/libegg.la \
+ $(GLIB_LIBS) \
+ $(GOBJECT_LIBS) \
+ $(LIBGCRYPT_LIBS)
-include $(top_srcdir)/testing/testing.make
+TEST_PROGS = \
+ test-util
-EXTRA_DIST += \
- test-data \ No newline at end of file
+check_PROGRAMS = $(TEST_PROGS)
+
+test: $(TEST_PROGS) $(CHECK_PROGS)
+ gtester -k --verbose -m $(TEST_MODE) --g-fatal-warnings $(TEST_PROGS)
+
+check-local: test
+
+all-local: $(check_PROGRAMS)
+
+EXTRA_DIST = \
+ files
diff --git a/ui/tests/test-data/prompt-empty b/ui/tests/files/prompt-empty
index 825111e2..825111e2 100644
--- a/ui/tests/test-data/prompt-empty
+++ b/ui/tests/files/prompt-empty
diff --git a/ui/tests/test-data/prompt-full b/ui/tests/files/prompt-full
index ad504908..ad504908 100644
--- a/ui/tests/test-data/prompt-full
+++ b/ui/tests/files/prompt-full
diff --git a/ui/tests/test-data/prompt-test b/ui/tests/files/prompt-test
index c00e826f..c00e826f 100644
--- a/ui/tests/test-data/prompt-test
+++ b/ui/tests/files/prompt-test
diff --git a/ui/tests/unit-test-util.c b/ui/tests/test-util.c
index 6c9d1cdc..0cb92121 100644
--- a/ui/tests/unit-test-util.c
+++ b/ui/tests/test-util.c
@@ -21,39 +21,48 @@
Author: Stef Walter <stef@memberwebs.com>
*/
-#include "test-suite.h"
+#include "config.h"
-#include "gku-prompt-util.h"
+#include "ui/gku-prompt-util.h"
-#include <egg/egg-dh.h>
-#include <egg/egg-libgcrypt.h>
-#include <egg/egg-secure-memory.h>
+#include "egg/egg-dh.h"
+#include "egg/egg-libgcrypt.h"
+#include "egg/egg-secure-memory.h"
#include <gcrypt.h>
-static GKeyFile *key_file = NULL;
+#include <glib-object.h>
-TESTING_SETUP(prompt_util)
+EGG_SECURE_GLIB_DEFINITIONS ();
+
+typedef struct {
+ GKeyFile *key_file;
+} Test;
+
+static void
+setup (Test *test, gconstpointer unused)
{
egg_libgcrypt_initialize ();
- key_file = g_key_file_new ();
+ test->key_file = g_key_file_new ();
}
-TESTING_TEARDOWN(prompt_util)
+static void
+teardown (Test *test, gconstpointer unused)
{
- g_key_file_free (key_file);
- key_file = NULL;
+ g_key_file_free (test->key_file);
+ test->key_file = NULL;
}
-TESTING_TEST(encode_decode_mpi)
+static void
+test_encode_decode_mpi (Test *test, gconstpointer unused)
{
gcry_mpi_t mpi, check;
mpi = gcry_mpi_new (512);
gcry_mpi_randomize (mpi, 512, GCRY_WEAK_RANDOM);
- gku_prompt_util_encode_mpi (key_file, "section", "field", mpi);
- if (!gku_prompt_util_decode_mpi (key_file, "section", "field", &check))
+ gku_prompt_util_encode_mpi (test->key_file, "section", "field", mpi);
+ if (!gku_prompt_util_decode_mpi (test->key_file, "section", "field", &check))
g_assert_not_reached ();
g_assert (gcry_mpi_cmp (mpi, check) == 0);
@@ -61,23 +70,25 @@ TESTING_TEST(encode_decode_mpi)
gcry_mpi_release (check);
}
-TESTING_TEST(decode_nonexistant_mpi)
+static void
+test_decode_nonexistant_mpi (Test *test, gconstpointer unused)
{
gcry_mpi_t mpi;
- if (gku_prompt_util_decode_mpi (key_file, "nonexist", "nope", &mpi))
+ if (gku_prompt_util_decode_mpi (test->key_file, "nonexist", "nope", &mpi))
g_assert_not_reached ();
}
-TESTING_TEST(encode_decode_hex)
+static void
+test_encode_decode_hex (Test *test, gconstpointer unused)
{
gchar buffer[32];
gpointer check;
gsize n_check;
gcry_create_nonce (buffer, 32);
- gku_prompt_util_encode_hex (key_file, "section", "field", buffer, 32);
- check = gku_prompt_util_decode_hex (key_file, "section", "field", &n_check);
+ gku_prompt_util_encode_hex (test->key_file, "section", "field", buffer, 32);
+ check = gku_prompt_util_decode_hex (test->key_file, "section", "field", &n_check);
g_assert (check);
g_assert (n_check == 32);
g_assert (memcmp (buffer, check, 32) == 0);
@@ -85,11 +96,12 @@ TESTING_TEST(encode_decode_hex)
g_free (check);
}
-TESTING_TEST(decode_nonexistant_hex)
+static void
+test_decode_nonexistant_hex (Test *test, gconstpointer unused)
{
gsize n_data;
- if (gku_prompt_util_decode_hex (key_file, "nonexist", "nope", &n_data))
+ if (gku_prompt_util_decode_hex (test->key_file, "nonexist", "nope", &n_data))
g_assert_not_reached ();
}
@@ -126,7 +138,8 @@ do_encrypt_decrypt_text (const gchar *text)
g_assert_cmpstr (check, ==, text);
}
-TESTING_TEST(encrypt_decrypt_text)
+static void
+test_encrypt_decrypt_text (Test *test, gconstpointer unused)
{
do_encrypt_decrypt_text ("");
do_encrypt_decrypt_text ("blah");
@@ -134,3 +147,18 @@ TESTING_TEST(encrypt_decrypt_text)
do_encrypt_decrypt_text ("0123456789ABCDE");
do_encrypt_decrypt_text ("0123456789ABCDEF 12345");
}
+
+int
+main (int argc, char **argv)
+{
+ g_type_init ();
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add ("/ui/util/encode_decode_mpi", Test, NULL, setup, test_encode_decode_mpi, teardown);
+ g_test_add ("/ui/util/decode_nonexistant_mpi", Test, NULL, setup, test_decode_nonexistant_mpi, teardown);
+ g_test_add ("/ui/util/encode_decode_hex", Test, NULL, setup, test_encode_decode_hex, teardown);
+ g_test_add ("/ui/util/decode_nonexistant_hex", Test, NULL, setup, test_decode_nonexistant_hex, teardown);
+ g_test_add ("/ui/util/encrypt_decrypt_text", Test, NULL, setup, test_encrypt_decrypt_text, teardown);
+
+ return g_test_run ();
+}