summaryrefslogtreecommitdiff
path: root/p11-kit
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2013-04-05 23:52:39 +0200
committerStef Walter <stefw@gnome.org>2013-05-21 11:31:09 +0200
commitdcabaf1d56d410ba7ddb3dfbab9011bbbea5e6bc (patch)
treec49effa4a0696dc00fb591d95dc59e8579a8d030 /p11-kit
parent7fd6d89d92b6f1b543bf2aa4b2e578201dad7147 (diff)
Our own unit testing framework
* Support the TAP protocol * Much cleaner without having to carry around state * First class support for setup/teardown * Port the common tests * Wait on porting other tests until we've merged outstanding code
Diffstat (limited to 'p11-kit')
-rw-r--r--p11-kit/tests/Makefile.am14
-rw-r--r--p11-kit/tests/test-conf.c (renamed from p11-kit/tests/conf-test.c)252
-rw-r--r--p11-kit/tests/test-deprecated.c187
-rw-r--r--p11-kit/tests/test-init.c144
-rw-r--r--p11-kit/tests/test-iter.c481
-rw-r--r--p11-kit/tests/test-log.c41
-rw-r--r--p11-kit/tests/test-managed.c97
-rw-r--r--p11-kit/tests/test-mock.c1012
-rw-r--r--p11-kit/tests/test-modules.c157
-rw-r--r--p11-kit/tests/test-pin.c (renamed from p11-kit/tests/pin-test.c)104
-rw-r--r--p11-kit/tests/test-progname.c (renamed from p11-kit/tests/progname-test.c)34
-rw-r--r--p11-kit/tests/test-proxy.c75
-rw-r--r--p11-kit/tests/test-uri.c (renamed from p11-kit/tests/uri-test.c)633
-rw-r--r--p11-kit/tests/test-virtual.c70
14 files changed, 1572 insertions, 1729 deletions
diff --git a/p11-kit/tests/Makefile.am b/p11-kit/tests/Makefile.am
index f385d2a..4a3eaee 100644
--- a/p11-kit/tests/Makefile.am
+++ b/p11-kit/tests/Makefile.am
@@ -7,20 +7,20 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(srcdir)/.. \
-I$(COMMON) \
- $(CUTEST_CFLAGS)
+ $(TEST_CFLAGS)
LDADD = \
$(top_builddir)/p11-kit/libp11-kit-testable.la \
- $(top_builddir)/common/libp11-mock.la \
+ $(top_builddir)/common/libp11-test.la \
$(top_builddir)/common/libp11-common.la \
$(CUTEST_LIBS) \
$(LTLIBINTL)
CHECK_PROGS = \
- progname-test \
- conf-test \
- uri-test \
- pin-test \
+ test-progname \
+ test-conf \
+ test-uri \
+ test-pin \
test-init \
test-modules \
test-deprecated \
@@ -57,7 +57,7 @@ mock_one_la_CFLAGS = \
$(AM_CFLAGS)
mock_one_la_LIBADD = \
- $(top_builddir)/common/libp11-mock.la \
+ $(top_builddir)/common/libp11-test.la \
$(top_builddir)/common/libp11-common.la \
$(NULL)
diff --git a/p11-kit/tests/conf-test.c b/p11-kit/tests/test-conf.c
index d259cf8..c214bac 100644
--- a/p11-kit/tests/conf-test.c
+++ b/p11-kit/tests/test-conf.c
@@ -33,7 +33,7 @@
*/
#include "config.h"
-#include "CuTest.h"
+#include "test.h"
#include <errno.h>
#include <stdlib.h>
@@ -47,54 +47,54 @@
#include "private.h"
static void
-test_parse_conf_1 (CuTest *tc)
+test_parse_conf_1 (void)
{
p11_dict *map;
const char *value;
map = _p11_conf_parse_file (SRCDIR "/files/test-1.conf", 0);
- CuAssertPtrNotNull (tc, map);
+ assert_ptr_not_null (map);
value = p11_dict_get (map, "key1");
- CuAssertStrEquals (tc, "value1", value);
+ assert_str_eq ("value1", value);
value = p11_dict_get (map, "with-colon");
- CuAssertStrEquals (tc, "value-of-colon", value);
+ assert_str_eq ("value-of-colon", value);
value = p11_dict_get (map, "with-whitespace");
- CuAssertStrEquals (tc, "value-with-whitespace", value);
+ assert_str_eq ("value-with-whitespace", value);
value = p11_dict_get (map, "embedded-comment");
- CuAssertStrEquals (tc, "this is # not a comment", value);
+ assert_str_eq ("this is # not a comment", value);
p11_dict_free (map);
}
static void
-test_parse_ignore_missing (CuTest *tc)
+test_parse_ignore_missing (void)
{
p11_dict *map;
map = _p11_conf_parse_file (SRCDIR "/files/non-existant.conf", CONF_IGNORE_MISSING);
- CuAssertPtrNotNull (tc, map);
+ assert_ptr_not_null (map);
- CuAssertIntEquals (tc, 0, p11_dict_size (map));
- CuAssertPtrEquals (tc, NULL, (void*)p11_message_last ());
+ assert_num_eq (0, p11_dict_size (map));
+ assert (p11_message_last () == NULL);
p11_dict_free (map);
}
static void
-test_parse_fail_missing (CuTest *tc)
+test_parse_fail_missing (void)
{
p11_dict *map;
map = _p11_conf_parse_file (SRCDIR "/files/non-existant.conf", 0);
- CuAssertPtrEquals (tc, map, NULL);
- CuAssertPtrNotNull (tc, p11_message_last ());
+ assert (map == NULL);
+ assert_ptr_not_null (p11_message_last ());
}
static void
-test_merge_defaults (CuTest *tc)
+test_merge_defaults (void)
{
p11_dict *values;
p11_dict *defaults;
@@ -109,19 +109,19 @@ test_merge_defaults (CuTest *tc)
p11_dict_set (defaults, strdup ("three"), strdup ("default3"));
if (!_p11_conf_merge_defaults (values, defaults))
- CuFail (tc, "should not be reached");
+ assert_not_reached ();
p11_dict_free (defaults);
- CuAssertStrEquals (tc, p11_dict_get (values, "one"), "real1");
- CuAssertStrEquals (tc, p11_dict_get (values, "two"), "real2");
- CuAssertStrEquals (tc, p11_dict_get (values, "three"), "default3");
+ assert_str_eq (p11_dict_get (values, "one"), "real1");
+ assert_str_eq (p11_dict_get (values, "two"), "real2");
+ assert_str_eq (p11_dict_get (values, "three"), "default3");
p11_dict_free (values);
}
static void
-test_load_globals_merge (CuTest *tc)
+test_load_globals_merge (void)
{
int user_mode = -1;
p11_dict *config;
@@ -131,19 +131,19 @@ test_load_globals_merge (CuTest *tc)
config = _p11_conf_load_globals (SRCDIR "/files/test-system-merge.conf",
SRCDIR "/files/test-user.conf",
&user_mode);
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, NULL, p11_message_last ());
- CuAssertIntEquals (tc, CONF_USER_MERGE, user_mode);
+ assert_ptr_not_null (config);
+ assert (NULL == p11_message_last ());
+ assert_num_eq (CONF_USER_MERGE, user_mode);
- CuAssertStrEquals (tc, p11_dict_get (config, "key1"), "system1");
- CuAssertStrEquals (tc, p11_dict_get (config, "key2"), "user2");
- CuAssertStrEquals (tc, p11_dict_get (config, "key3"), "user3");
+ assert_str_eq (p11_dict_get (config, "key1"), "system1");
+ assert_str_eq (p11_dict_get (config, "key2"), "user2");
+ assert_str_eq (p11_dict_get (config, "key3"), "user3");
p11_dict_free (config);
}
static void
-test_load_globals_no_user (CuTest *tc)
+test_load_globals_no_user (void)
{
int user_mode = -1;
p11_dict *config;
@@ -153,19 +153,19 @@ test_load_globals_no_user (CuTest *tc)
config = _p11_conf_load_globals (SRCDIR "/files/test-system-none.conf",
SRCDIR "/files/test-user.conf",
&user_mode);
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, NULL, p11_message_last ());
- CuAssertIntEquals (tc, CONF_USER_NONE, user_mode);
+ assert_ptr_not_null (config);
+ assert (NULL == p11_message_last ());
+ assert_num_eq (CONF_USER_NONE, user_mode);
- CuAssertStrEquals (tc, p11_dict_get (config, "key1"), "system1");
- CuAssertStrEquals (tc, p11_dict_get (config, "key2"), "system2");
- CuAssertStrEquals (tc, p11_dict_get (config, "key3"), "system3");
+ assert_str_eq (p11_dict_get (config, "key1"), "system1");
+ assert_str_eq (p11_dict_get (config, "key2"), "system2");
+ assert_str_eq (p11_dict_get (config, "key3"), "system3");
p11_dict_free (config);
}
static void
-test_load_globals_user_sets_only (CuTest *tc)
+test_load_globals_user_sets_only (void)
{
int user_mode = -1;
p11_dict *config;
@@ -175,19 +175,19 @@ test_load_globals_user_sets_only (CuTest *tc)
config = _p11_conf_load_globals (SRCDIR "/files/test-system-merge.conf",
SRCDIR "/files/test-user-only.conf",
&user_mode);
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, NULL, p11_message_last ());
- CuAssertIntEquals (tc, CONF_USER_ONLY, user_mode);
+ assert_ptr_not_null (config);
+ assert (NULL == p11_message_last ());
+ assert_num_eq (CONF_USER_ONLY, user_mode);
- CuAssertStrEquals (tc, p11_dict_get (config, "key1"), NULL);
- CuAssertStrEquals (tc, p11_dict_get (config, "key2"), "user2");
- CuAssertStrEquals (tc, p11_dict_get (config, "key3"), "user3");
+ assert (p11_dict_get (config, "key1") == NULL);
+ assert_str_eq (p11_dict_get (config, "key2"), "user2");
+ assert_str_eq (p11_dict_get (config, "key3"), "user3");
p11_dict_free (config);
}
static void
-test_load_globals_system_sets_only (CuTest *tc)
+test_load_globals_system_sets_only (void)
{
int user_mode = -1;
p11_dict *config;
@@ -197,19 +197,19 @@ test_load_globals_system_sets_only (CuTest *tc)
config = _p11_conf_load_globals (SRCDIR "/files/test-system-only.conf",
SRCDIR "/files/test-user.conf",
&user_mode);
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, NULL, p11_message_last ());
- CuAssertIntEquals (tc, CONF_USER_ONLY, user_mode);
+ assert_ptr_not_null (config);
+ assert (NULL == p11_message_last ());
+ assert_num_eq (CONF_USER_ONLY, user_mode);
- CuAssertStrEquals (tc, p11_dict_get (config, "key1"), NULL);
- CuAssertStrEquals (tc, p11_dict_get (config, "key2"), "user2");
- CuAssertStrEquals (tc, p11_dict_get (config, "key3"), "user3");
+ assert (p11_dict_get (config, "key1") == NULL);
+ assert_str_eq (p11_dict_get (config, "key2"), "user2");
+ assert_str_eq (p11_dict_get (config, "key3"), "user3");
p11_dict_free (config);
}
static void
-test_load_globals_system_sets_invalid (CuTest *tc)
+test_load_globals_system_sets_invalid (void)
{
int user_mode = -1;
p11_dict *config;
@@ -221,15 +221,15 @@ test_load_globals_system_sets_invalid (CuTest *tc)
SRCDIR "/files/non-existant.conf",
&user_mode);
error = errno;
- CuAssertPtrEquals (tc, NULL, config);
- CuAssertIntEquals (tc, EINVAL, error);
- CuAssertPtrNotNull (tc, p11_message_last ());
+ assert_ptr_eq (NULL, config);
+ assert_num_eq (EINVAL, error);
+ assert_ptr_not_null (p11_message_last ());
p11_dict_free (config);
}
static void
-test_load_globals_user_sets_invalid (CuTest *tc)
+test_load_globals_user_sets_invalid (void)
{
int user_mode = -1;
p11_dict *config;
@@ -241,9 +241,9 @@ test_load_globals_user_sets_invalid (CuTest *tc)
SRCDIR "/files/test-user-invalid.conf",
&user_mode);
error = errno;
- CuAssertPtrEquals (tc, NULL, config);
- CuAssertIntEquals (tc, EINVAL, error);
- CuAssertPtrNotNull (tc, p11_message_last ());
+ assert_ptr_eq (NULL, config);
+ assert_num_eq (EINVAL, error);
+ assert_ptr_not_null (p11_message_last ());
p11_dict_free (config);
}
@@ -256,7 +256,7 @@ assert_msg_contains (const char *msg,
}
static void
-test_load_modules_merge (CuTest *tc)
+test_load_modules_merge (void)
{
p11_dict *configs;
p11_dict *config;
@@ -267,29 +267,29 @@ test_load_modules_merge (CuTest *tc)
SRCDIR "/files/package-modules",
SRCDIR "/files/system-modules",
SRCDIR "/files/user-modules");
- CuAssertPtrNotNull (tc, configs);
- CuAssertTrue (tc, assert_msg_contains (p11_message_last (), "invalid config filename"));
+ assert_ptr_not_null (configs);
+ assert (assert_msg_contains (p11_message_last (), "invalid config filename"));
config = p11_dict_get (configs, "one");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-one.so", p11_dict_get (config, "module"));
- CuAssertStrEquals (tc, p11_dict_get (config, "setting"), "user1");
+ assert_ptr_not_null (config);
+ assert_str_eq ("mock-one.so", p11_dict_get (config, "module"));
+ assert_str_eq (p11_dict_get (config, "setting"), "user1");
config = p11_dict_get (configs, "two.badname");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-two.so", p11_dict_get (config, "module"));
- CuAssertStrEquals (tc, p11_dict_get (config, "setting"), "system2");
+ assert_ptr_not_null (config);
+ assert_str_eq ("mock-two.so", p11_dict_get (config, "module"));
+ assert_str_eq (p11_dict_get (config, "setting"), "system2");
config = p11_dict_get (configs, "three");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-three.so", p11_dict_get (config, "module"));
- CuAssertStrEquals (tc, p11_dict_get (config, "setting"), "user3");
+ assert_ptr_not_null (config);
+ assert_str_eq ("mock-three.so", p11_dict_get (config, "module"));
+ assert_str_eq (p11_dict_get (config, "setting"), "user3");
p11_dict_free (configs);
}
static void
-test_load_modules_user_none (CuTest *tc)
+test_load_modules_user_none (void)
{
p11_dict *configs;
p11_dict *config;
@@ -300,27 +300,27 @@ test_load_modules_user_none (CuTest *tc)
SRCDIR "/files/package-modules",
SRCDIR "/files/system-modules",
SRCDIR "/files/user-modules");
- CuAssertPtrNotNull (tc, configs);
- CuAssertTrue (tc, assert_msg_contains (p11_message_last (), "invalid config filename"));
+ assert_ptr_not_null (configs);
+ assert (assert_msg_contains (p11_message_last (), "invalid config filename"));
config = p11_dict_get (configs, "one");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-one.so", p11_dict_get (config, "module"));
- CuAssertStrEquals (tc, p11_dict_get (config, "setting"), "system1");
+ assert_ptr_not_null (config);
+ assert_str_eq ("mock-one.so", p11_dict_get (config, "module"));
+ assert_str_eq (p11_dict_get (config, "setting"), "system1");
config = p11_dict_get (configs, "two.badname");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-two.so", p11_dict_get (config, "module"));
- CuAssertStrEquals (tc, p11_dict_get (config, "setting"), "system2");
+ assert_ptr_not_null (config);
+ assert_str_eq ("mock-two.so", p11_dict_get (config, "module"));
+ assert_str_eq (p11_dict_get (config, "setting"), "system2");
config = p11_dict_get (configs, "three");
- CuAssertPtrEquals (tc, NULL, config);
+ assert_ptr_eq (NULL, config);
p11_dict_free (configs);
}
static void
-test_load_modules_user_only (CuTest *tc)
+test_load_modules_user_only (void)
{
p11_dict *configs;
p11_dict *config;
@@ -331,27 +331,27 @@ test_load_modules_user_only (CuTest *tc)
SRCDIR "/files/package-modules",
SRCDIR "/files/system-modules",
SRCDIR "/files/user-modules");
- CuAssertPtrNotNull (tc, configs);
- CuAssertPtrEquals (tc, NULL, (void *)p11_message_last ());
+ assert_ptr_not_null (configs);
+ assert_ptr_eq (NULL, (void *)p11_message_last ());
config = p11_dict_get (configs, "one");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, p11_dict_get (config, "module"), NULL);
- CuAssertStrEquals (tc, p11_dict_get (config, "setting"), "user1");
+ assert_ptr_not_null (config);
+ assert (p11_dict_get (config, "module") == NULL);
+ assert_str_eq (p11_dict_get (config, "setting"), "user1");
config = p11_dict_get (configs, "two.badname");
- CuAssertPtrEquals (tc, NULL, config);
+ assert_ptr_eq (NULL, config);
config = p11_dict_get (configs, "three");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-three.so", p11_dict_get (config, "module"));
- CuAssertStrEquals (tc, p11_dict_get (config, "setting"), "user3");
+ assert_ptr_not_null (config);
+ assert_str_eq ("mock-three.so", p11_dict_get (config, "module"));
+ assert_str_eq (p11_dict_get (config, "setting"), "user3");
p11_dict_free (configs);
}
static void
-test_load_modules_no_user (CuTest *tc)
+test_load_modules_no_user (void)
{
p11_dict *configs;
p11_dict *config;
@@ -362,67 +362,53 @@ test_load_modules_no_user (CuTest *tc)
SRCDIR "/files/package-modules",
SRCDIR "/files/system-modules",
SRCDIR "/files/non-existant");
- CuAssertPtrNotNull (tc, configs);
- CuAssertTrue (tc, assert_msg_contains (p11_message_last (), "invalid config filename"));
+ assert_ptr_not_null (configs);
+ assert (assert_msg_contains (p11_message_last (), "invalid config filename"));
config = p11_dict_get (configs, "one");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-one.so", p11_dict_get (config, "module"));
- CuAssertStrEquals (tc, p11_dict_get (config, "setting"), "system1");
+ assert_ptr_not_null (config);
+ assert_str_eq ("mock-one.so", p11_dict_get (config, "module"));
+ assert_str_eq (p11_dict_get (config, "setting"), "system1");
config = p11_dict_get (configs, "two.badname");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-two.so", p11_dict_get (config, "module"));
- CuAssertStrEquals (tc, p11_dict_get (config, "setting"), "system2");
+ assert_ptr_not_null (config);
+ assert_str_eq ("mock-two.so", p11_dict_get (config, "module"));
+ assert_str_eq (p11_dict_get (config, "setting"), "system2");
config = p11_dict_get (configs, "three");
- CuAssertPtrEquals (tc, NULL, config);
+ assert_ptr_eq (NULL, config);
p11_dict_free (configs);
}
static void
-test_parse_boolean (CuTest *tc)
+test_parse_boolean (void)
{
p11_message_quiet ();
- CuAssertIntEquals (tc, true, _p11_conf_parse_boolean ("yes", false));
- CuAssertIntEquals (tc, false, _p11_conf_parse_boolean ("no", true));
- CuAssertIntEquals (tc, true, _p11_conf_parse_boolean ("!!!", true));
+ assert_num_eq (true, _p11_conf_parse_boolean ("yes", false));
+ assert_num_eq (false, _p11_conf_parse_boolean ("no", true));
+ assert_num_eq (true, _p11_conf_parse_boolean ("!!!", true));
}
int
-main (void)
+main (int argc,
+ char *argv[])
{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- putenv ("P11_KIT_STRICT=1");
- p11_debug_init ();
-
- SUITE_ADD_TEST (suite, test_parse_conf_1);
- SUITE_ADD_TEST (suite, test_parse_ignore_missing);
- SUITE_ADD_TEST (suite, test_parse_fail_missing);
- SUITE_ADD_TEST (suite, test_merge_defaults);
- SUITE_ADD_TEST (suite, test_load_globals_merge);
- SUITE_ADD_TEST (suite, test_load_globals_no_user);
- SUITE_ADD_TEST (suite, test_load_globals_system_sets_only);
- SUITE_ADD_TEST (suite, test_load_globals_user_sets_only);
- SUITE_ADD_TEST (suite, test_load_globals_system_sets_invalid);
- SUITE_ADD_TEST (suite, test_load_globals_user_sets_invalid);
- SUITE_ADD_TEST (suite, test_load_modules_merge);
- SUITE_ADD_TEST (suite, test_load_modules_no_user);
- SUITE_ADD_TEST (suite, test_load_modules_user_only);
- SUITE_ADD_TEST (suite, test_load_modules_user_none);
- SUITE_ADD_TEST (suite, test_parse_boolean);
-
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
- return ret;
+ p11_test (test_parse_conf_1, "/conf/test_parse_conf_1");
+ p11_test (test_parse_ignore_missing, "/conf/test_parse_ignore_missing");
+ p11_test (test_parse_fail_missing, "/conf/test_parse_fail_missing");
+ p11_test (test_merge_defaults, "/conf/test_merge_defaults");
+ p11_test (test_load_globals_merge, "/conf/test_load_globals_merge");
+ p11_test (test_load_globals_no_user, "/conf/test_load_globals_no_user");
+ p11_test (test_load_globals_system_sets_only, "/conf/test_load_globals_system_sets_only");
+ p11_test (test_load_globals_user_sets_only, "/conf/test_load_globals_user_sets_only");
+ p11_test (test_load_globals_system_sets_invalid, "/conf/test_load_globals_system_sets_invalid");
+ p11_test (test_load_globals_user_sets_invalid, "/conf/test_load_globals_user_sets_invalid");
+ p11_test (test_load_modules_merge, "/conf/test_load_modules_merge");
+ p11_test (test_load_modules_no_user, "/conf/test_load_modules_no_user");
+ p11_test (test_load_modules_user_only, "/conf/test_load_modules_user_only");
+ p11_test (test_load_modules_user_none, "/conf/test_load_modules_user_none");
+ p11_test (test_parse_boolean, "/conf/test_parse_boolean");
+ return p11_test_run (argc, argv);
}
diff --git a/p11-kit/tests/test-deprecated.c b/p11-kit/tests/test-deprecated.c
index 4509241..7ea8260 100644
--- a/p11-kit/tests/test-deprecated.c
+++ b/p11-kit/tests/test-deprecated.c
@@ -36,7 +36,7 @@
#define P11_KIT_NO_DEPRECATIONS
#include "config.h"
-#include "CuTest.h"
+#include "test.h"
#include "dict.h"
#include "library.h"
@@ -55,33 +55,32 @@
#include <unistd.h>
static CK_FUNCTION_LIST_PTR_PTR
-initialize_and_get_modules (CuTest *tc)
+initialize_and_get_modules (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
CK_RV rv;
rv = p11_kit_initialize_registered ();
- CuAssertIntEquals (tc, CKR_OK, rv);
+ assert_num_eq (CKR_OK, rv);
modules = p11_kit_registered_modules ();
- CuAssertTrue (tc, modules != NULL && modules[0] != NULL);
+ assert (modules != NULL && modules[0] != NULL);
return modules;
}
static void
-finalize_and_free_modules (CuTest *tc,
- CK_FUNCTION_LIST_PTR_PTR modules)
+finalize_and_free_modules (CK_FUNCTION_LIST_PTR_PTR modules)
{
CK_RV rv;
free (modules);
rv = p11_kit_finalize_registered ();
- CuAssertIntEquals (tc, CKR_OK, rv);
+ assert_num_eq (CKR_OK, rv);
}
static void
-test_no_duplicates (CuTest *tc)
+test_no_duplicates (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
p11_dict *paths;
@@ -89,7 +88,7 @@ test_no_duplicates (CuTest *tc)
char *path;
int i;
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
paths = p11_dict_new (p11_dict_str_hash, p11_dict_str_equal, NULL, NULL);
funcs = p11_dict_new (p11_dict_direct_hash, p11_dict_direct_equal, NULL, NULL);
@@ -98,26 +97,25 @@ test_no_duplicates (CuTest *tc)
path = p11_kit_registered_option (modules[i], "module");
if (p11_dict_get (funcs, modules[i]))
- CuAssert (tc, "found duplicate function list pointer", 0);
+ assert_fail ("found duplicate function list pointer", NULL);
if (p11_dict_get (paths, path))
- CuAssert (tc, "found duplicate path name", 0);
+ assert_fail ("found duplicate path name", NULL);
if (!p11_dict_set (funcs, modules[i], ""))
- CuAssert (tc, "shouldn't be reached", 0);
+ assert_not_reached ();
if (!p11_dict_set (paths, path, ""))
- CuAssert (tc, "shouldn't be reached", 0);
+ assert_not_reached ();
free (path);
}
p11_dict_free (paths);
p11_dict_free (funcs);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static CK_FUNCTION_LIST_PTR
-lookup_module_with_name (CuTest *tc,
- CK_FUNCTION_LIST_PTR_PTR modules,
+lookup_module_with_name (CK_FUNCTION_LIST_PTR_PTR modules,
const char *name)
{
CK_FUNCTION_LIST_PTR match = NULL;
@@ -127,7 +125,7 @@ lookup_module_with_name (CuTest *tc,
for (i = 0; match == NULL && modules[i] != NULL; i++) {
module_name = p11_kit_registered_module_to_name (modules[i]);
- CuAssertPtrNotNull (tc, module_name);
+ assert_ptr_not_null (module_name);
if (strcmp (module_name, name) == 0)
match = modules[i];
free (module_name);
@@ -138,14 +136,14 @@ lookup_module_with_name (CuTest *tc,
* matches the above search.
*/
module = p11_kit_registered_name_to_module (name);
- CuAssert(tc, "different result from p11_kit_registered_name_to_module()",
- module == match);
+ if (module != match)
+ assert_fail ("different result from p11_kit_registered_name_to_module()", NULL);
return match;
}
static void
-test_disable (CuTest *tc)
+test_disable (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
@@ -154,9 +152,9 @@ test_disable (CuTest *tc)
* that it has disabled.
*/
- modules = initialize_and_get_modules (tc);
- CuAssertTrue (tc, lookup_module_with_name (tc, modules, "four") != NULL);
- finalize_and_free_modules (tc, modules);
+ modules = initialize_and_get_modules ();
+ assert (lookup_module_with_name (modules, "four") != NULL);
+ finalize_and_free_modules (modules);
/*
* The module two shouldn't have been loaded, because in its config
@@ -167,15 +165,15 @@ test_disable (CuTest *tc)
p11_kit_set_progname ("test-disable");
- modules = initialize_and_get_modules (tc);
- CuAssertTrue (tc, lookup_module_with_name (tc, modules, "four") == NULL);
- finalize_and_free_modules (tc, modules);
+ modules = initialize_and_get_modules ();
+ assert (lookup_module_with_name (modules, "four") == NULL);
+ finalize_and_free_modules (modules);
p11_kit_set_progname (NULL);
}
static void
-test_disable_later (CuTest *tc)
+test_disable_later (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
CK_RV rv;
@@ -188,21 +186,21 @@ test_disable_later (CuTest *tc)
*/
rv = p11_kit_initialize_registered ();
- CuAssertIntEquals (tc, CKR_OK, rv);
+ assert_num_eq (CKR_OK, rv);
p11_kit_set_progname ("test-disable");
modules = p11_kit_registered_modules ();
- CuAssertTrue (tc, modules != NULL && modules[0] != NULL);
+ assert (modules != NULL && modules[0] != NULL);
- CuAssertTrue (tc, lookup_module_with_name (tc, modules, "two") == NULL);
- finalize_and_free_modules (tc, modules);
+ assert (lookup_module_with_name (modules, "two") == NULL);
+ finalize_and_free_modules (modules);
p11_kit_set_progname (NULL);
}
static void
-test_enable (CuTest *tc)
+test_enable (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
@@ -211,9 +209,9 @@ test_enable (CuTest *tc)
* program.
*/
- modules = initialize_and_get_modules (tc);
- CuAssertTrue (tc, lookup_module_with_name (tc, modules, "three") == NULL);
- finalize_and_free_modules (tc, modules);
+ modules = initialize_and_get_modules ();
+ assert (lookup_module_with_name (modules, "three") == NULL);
+ finalize_and_free_modules (modules);
/*
* The module three should be loaded here , because in its config
@@ -224,9 +222,9 @@ test_enable (CuTest *tc)
p11_kit_set_progname ("test-enable");
- modules = initialize_and_get_modules (tc);
- CuAssertTrue (tc, lookup_module_with_name (tc, modules, "three") != NULL);
- finalize_and_free_modules (tc, modules);
+ modules = initialize_and_get_modules ();
+ assert (lookup_module_with_name (modules, "three") != NULL);
+ finalize_and_free_modules (modules);
p11_kit_set_progname (NULL);
}
@@ -265,23 +263,23 @@ mock_C_Initialize__with_fork (CK_VOID_PTR init_args)
}
static void
-test_fork_initialization (CuTest *tc)
+test_fork_initialization (void)
{
CK_RV rv;
- CuAssertTrue (tc, !mock_module_initialized ());
+ assert (!mock_module_initialized ());
/* Build up our own function list */
memcpy (&module, &mock_module_no_slots, sizeof (CK_FUNCTION_LIST));
module.C_Initialize = mock_C_Initialize__with_fork;
rv = p11_kit_initialize_module (&module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = p11_kit_finalize_module (&module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertTrue (tc, !mock_module_initialized ());
+ assert (!mock_module_initialized ());
}
#endif /* OS_UNIX */
@@ -294,20 +292,20 @@ mock_C_Initialize__with_recursive (CK_VOID_PTR init_args)
}
static void
-test_recursive_initialization (CuTest *tc)
+test_recursive_initialization (void)
{
CK_RV rv;
- CuAssertTrue (tc, !mock_module_initialized ());
+ assert (!mock_module_initialized ());
/* Build up our own function list */
memcpy (&module, &mock_module_no_slots, sizeof (CK_FUNCTION_LIST));
module.C_Initialize = mock_C_Initialize__with_recursive;
rv = p11_kit_initialize_module (&module);
- CuAssertTrue (tc, rv == CKR_FUNCTION_FAILED);
+ assert (rv == CKR_FUNCTION_FAILED);
- CuAssertTrue (tc, !mock_module_initialized ());
+ assert (!mock_module_initialized ());
}
static p11_mutex_t race_mutex;
@@ -341,36 +339,36 @@ mock_C_Finalize__threaded_race (CK_VOID_PTR reserved)
static void *
initialization_thread (void *data)
{
- CuTest *tc = data;
CK_RV rv;
+ assert_str_eq (data, "thread-data");
rv = p11_kit_initialize_module (&module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- return tc;
+ return "thread-data";
}
static void *
finalization_thread (void *data)
{
- CuTest *tc = data;
CK_RV rv;
+ assert_str_eq (data, "thread-data");
rv = p11_kit_finalize_module (&module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- return tc;
+ return "thread-data";
}
static void
-test_threaded_initialization (CuTest *tc)
+test_threaded_initialization (void)
{
static const int num_threads = 2;
p11_thread_t threads[num_threads];
int ret;
int i;
- CuAssertTrue (tc, !mock_module_initialized ());
+ assert (!mock_module_initialized ());
/* Build up our own function list */
memcpy (&module, &mock_module_no_slots, sizeof (CK_FUNCTION_LIST));
@@ -381,34 +379,34 @@ test_threaded_initialization (CuTest *tc)
finalization_count = 0;
for (i = 0; i < num_threads; i++) {
- ret = p11_thread_create (&threads[i], initialization_thread, tc);
- CuAssertIntEquals (tc, 0, ret);
- CuAssertTrue (tc, threads[i] != 0);
+ ret = p11_thread_create (&threads[i], initialization_thread, "thread-data");
+ assert_num_eq (0, ret);
+ assert (threads[i] != 0);
}
for (i = 0; i < num_threads; i++) {
ret = p11_thread_join (threads[i]);
- CuAssertIntEquals (tc, 0, ret);
+ assert_num_eq (0, ret);
threads[i] = 0;
}
for (i = 0; i < num_threads; i++) {
- ret = p11_thread_create (&threads[i], finalization_thread, tc);
- CuAssertIntEquals (tc, 0, ret);
- CuAssertTrue (tc, threads[i] != 0);
+ ret = p11_thread_create (&threads[i], finalization_thread, "thread-data");
+ assert_num_eq (0, ret);
+ assert (threads[i] != 0);
}
for (i = 0; i < num_threads; i++) {
ret = p11_thread_join (threads[i]);
- CuAssertIntEquals (tc, 0, ret);
+ assert_num_eq (0, ret);
threads[i] = 0;
}
/* C_Initialize should have been called exactly once */
- CuAssertIntEquals (tc, 1, initialization_count);
- CuAssertIntEquals (tc, 1, finalization_count);
+ assert_num_eq (1, initialization_count);
+ assert_num_eq (1, finalization_count);
- CuAssertTrue (tc, !mock_module_initialized ());
+ assert (!mock_module_initialized ());
}
static CK_RV
@@ -441,27 +439,27 @@ mock_C_Initialize__test_mutexes (CK_VOID_PTR args)
}
static void
-test_mutexes (CuTest *tc)
+test_mutexes (void)
{
CK_RV rv;
- CuAssertTrue (tc, !mock_module_initialized ());
+ assert (!mock_module_initialized ());
/* Build up our own function list */
memcpy (&module, &mock_module_no_slots, sizeof (CK_FUNCTION_LIST));
module.C_Initialize = mock_C_Initialize__test_mutexes;
rv = p11_kit_initialize_module (&module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = p11_kit_finalize_module (&module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertTrue (tc, !mock_module_initialized ());
+ assert (!mock_module_initialized ());
}
static void
-test_load_and_initialize (CuTest *tc)
+test_load_and_initialize (void)
{
CK_FUNCTION_LIST_PTR module;
CK_INFO info;
@@ -469,53 +467,42 @@ test_load_and_initialize (CuTest *tc)
int ret;
rv = p11_kit_load_initialize_module (BUILDDIR "/.libs/mock-one" SHLEXT, &module);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertTrue (tc, module != NULL);
+ assert (rv == CKR_OK);
+ assert (module != NULL);
rv = (module->C_GetInfo) (&info);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
ret = memcmp (info.manufacturerID, "MOCK MANUFACTURER ", 32);
- CuAssertTrue (tc, ret == 0);
+ assert (ret == 0);
rv = p11_kit_finalize_module (module);
- CuAssertTrue (tc, ret == CKR_OK);
+ assert (ret == CKR_OK);
}
int
-main (void)
+main (int argc,
+ char *argv[])
{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- putenv ("P11_KIT_STRICT=1");
p11_mutex_init (&race_mutex);
mock_module_init ();
p11_library_init ();
- SUITE_ADD_TEST (suite, test_no_duplicates);
- SUITE_ADD_TEST (suite, test_disable);
- SUITE_ADD_TEST (suite, test_disable_later);
- SUITE_ADD_TEST (suite, test_enable);
+ p11_test (test_no_duplicates, "/deprecated/test_no_duplicates");
+ p11_test (test_disable, "/deprecated/test_disable");
+ p11_test (test_disable_later, "/deprecated/test_disable_later");
+ p11_test (test_enable, "/deprecated/test_enable");
#ifdef OS_UNIX
- SUITE_ADD_TEST (suite, test_fork_initialization);
+ p11_test (test_fork_initialization, "/deprecated/test_fork_initialization");
#endif
- SUITE_ADD_TEST (suite, test_recursive_initialization);
- SUITE_ADD_TEST (suite, test_threaded_initialization);
- SUITE_ADD_TEST (suite, test_mutexes);
- SUITE_ADD_TEST (suite, test_load_and_initialize);
+ p11_test (test_recursive_initialization, "/deprecated/test_recursive_initialization");
+ p11_test (test_threaded_initialization, "/deprecated/test_threaded_initialization");
+ p11_test (test_mutexes, "/deprecated/test_mutexes");
+ p11_test (test_load_and_initialize, "/deprecated/test_load_and_initialize");
p11_kit_be_quiet ();
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
- return ret;
+ return p11_test_run (argc, argv);
}
diff --git a/p11-kit/tests/test-init.c b/p11-kit/tests/test-init.c
index dbeab46..76805ee 100644
--- a/p11-kit/tests/test-init.c
+++ b/p11-kit/tests/test-init.c
@@ -33,7 +33,7 @@
*/
#include "config.h"
-#include "CuTest.h"
+#include "test.h"
#include <sys/types.h>
@@ -86,7 +86,7 @@ mock_C_Initialize__with_fork (CK_VOID_PTR init_args)
}
static void
-test_fork_initialization (CuTest *tc)
+test_fork_initialization (void)
{
CK_FUNCTION_LIST_PTR result;
CK_RV rv;
@@ -100,20 +100,20 @@ test_fork_initialization (CuTest *tc)
p11_lock ();
rv = p11_module_load_inlock_reentrant (&module, 0, &result);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_unlock ();
rv = p11_kit_module_initialize (result);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = p11_kit_module_finalize (result);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_lock ();
rv = p11_module_release_inlock_reentrant (result);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_unlock ();
}
@@ -134,7 +134,7 @@ mock_C_Initialize__with_recursive (CK_VOID_PTR init_args)
}
static void
-test_recursive_initialization (CuTest *tc)
+test_recursive_initialization (void)
{
CK_RV rv;
@@ -147,17 +147,17 @@ test_recursive_initialization (CuTest *tc)
p11_lock ();
rv = p11_module_load_inlock_reentrant (&module, 0, &recursive_managed);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_unlock ();
rv = p11_kit_module_initialize (recursive_managed);
- CuAssertIntEquals (tc, CKR_FUNCTION_FAILED, rv);
+ assert_num_eq (CKR_FUNCTION_FAILED, rv);
p11_lock ();
rv = p11_module_release_inlock_reentrant (recursive_managed);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_unlock ();
@@ -191,42 +191,37 @@ mock_C_Finalize__threaded_race (CK_VOID_PTR reserved)
return CKR_OK;
}
-typedef struct {
- CuTest *cu;
- CK_FUNCTION_LIST_PTR module;
-} ThreadData;
-
static void *
initialization_thread (void *data)
{
- ThreadData *td = data;
+ CK_FUNCTION_LIST *module = data;
CK_RV rv;
- assert (td->module != NULL);
- rv = p11_kit_module_initialize (td->module);
- CuAssertTrue (td->cu, rv == CKR_OK);
+ assert (module != NULL);
+ rv = p11_kit_module_initialize (module);
+ assert_num_eq (rv, CKR_OK);
- return td->cu;
+ return module;
}
static void *
finalization_thread (void *data)
{
- ThreadData *td = data;
+ CK_FUNCTION_LIST *module = data;
CK_RV rv;
- assert (td->module != NULL);
- rv = p11_kit_module_finalize (td->module);
- CuAssertTrue (td->cu, rv == CKR_OK);
+ assert (module != NULL);
+ rv = p11_kit_module_finalize (module);
+ assert_num_eq (rv, CKR_OK);
- return td->cu;
+ return module;
}
static void
-test_threaded_initialization (CuTest *tc)
+test_threaded_initialization (void)
{
static const int num_threads = 1;
- ThreadData data[num_threads];
+ CK_FUNCTION_LIST *data[num_threads];
p11_thread_t threads[num_threads];
CK_RV rv;
int ret;
@@ -244,51 +239,50 @@ test_threaded_initialization (CuTest *tc)
p11_lock ();
for (i = 0; i < num_threads; i++) {
- assert (data[i].module == NULL);
- rv = p11_module_load_inlock_reentrant (&module, 0, &data[i].module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (data[i] == NULL);
+ rv = p11_module_load_inlock_reentrant (&module, 0, &data[i]);
+ assert (rv == CKR_OK);
}
p11_unlock ();
for (i = 0; i < num_threads; i++) {
- data[i].cu = tc;
- ret = p11_thread_create (&threads[i], initialization_thread, data + i);
- CuAssertIntEquals (tc, 0, ret);
- CuAssertTrue (tc, threads[i] != 0);
+ ret = p11_thread_create (&threads[i], initialization_thread, data[i]);
+ assert_num_eq (0, ret);
+ assert (threads[i] != 0);
}
for (i = 0; i < num_threads; i++) {
ret = p11_thread_join (threads[i]);
- CuAssertIntEquals (tc, 0, ret);
+ assert_num_eq (0, ret);
threads[i] = 0;
}
for (i = 0; i < num_threads; i++) {
- ret = p11_thread_create (&threads[i], finalization_thread, data + i);
- CuAssertIntEquals (tc, 0, ret);
- CuAssertTrue (tc, threads[i] != 0);
+ ret = p11_thread_create (&threads[i], finalization_thread, data[i]);
+ assert_num_eq (0, ret);
+ assert (threads[i] != 0);
}
for (i = 0; i < num_threads; i++) {
ret = p11_thread_join (threads[i]);
- CuAssertIntEquals (tc, 0, ret);
+ assert_num_eq (0, ret);
threads[i] = 0;
}
p11_lock ();
for (i = 0; i < num_threads; i++) {
- assert (data[i].module != NULL);
- rv = p11_module_release_inlock_reentrant (data[i].module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (data[i] != NULL);
+ rv = p11_module_release_inlock_reentrant (data[i]);
+ assert (rv == CKR_OK);
}
p11_unlock ();
/* C_Initialize should have been called exactly once */
- CuAssertIntEquals (tc, 1, initialization_count);
- CuAssertIntEquals (tc, 1, finalization_count);
+ assert_num_eq (1, initialization_count);
+ assert_num_eq (1, finalization_count);
}
static CK_RV
@@ -317,7 +311,7 @@ mock_C_Initialize__test_mutexes (CK_VOID_PTR args)
}
static void
-test_mutexes (CuTest *tc)
+test_mutexes (void)
{
CK_FUNCTION_LIST_PTR result;
CK_RV rv;
@@ -329,16 +323,16 @@ test_mutexes (CuTest *tc)
p11_lock ();
rv = p11_module_load_inlock_reentrant (&module, 0, &result);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = p11_module_release_inlock_reentrant (result);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_unlock ();
}
static void
-test_load_and_initialize (CuTest *tc)
+test_load_and_initialize (void)
{
CK_FUNCTION_LIST_PTR module;
CK_INFO info;
@@ -346,25 +340,25 @@ test_load_and_initialize (CuTest *tc)
int ret;
module = p11_kit_module_load (BUILDDIR "/.libs/mock-one" SHLEXT, 0);
- CuAssertTrue (tc, module != NULL);
+ assert (module != NULL);
rv = p11_kit_module_initialize (module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_GetInfo) (&info);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
ret = memcmp (info.manufacturerID, "MOCK MANUFACTURER ", 32);
- CuAssertTrue (tc, ret == 0);
+ assert (ret == 0);
rv = p11_kit_module_finalize (module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_kit_module_release (module);
}
static void
-test_initalize_fail (CuTest *tc)
+test_initalize_fail (void)
{
CK_FUNCTION_LIST failer;
CK_FUNCTION_LIST *modules[3] = { &mock_module_no_slots, &failer, NULL };
@@ -377,58 +371,46 @@ test_initalize_fail (CuTest *tc)
p11_kit_be_quiet ();
rv = p11_kit_modules_initialize (modules, NULL);
- CuAssertIntEquals (tc, CKR_FUNCTION_FAILED, rv);
+ assert_num_eq (CKR_FUNCTION_FAILED, rv);
p11_kit_be_loud ();
/* Failed modules get removed from the list */
- CuAssertPtrEquals (tc, &mock_module_no_slots, modules[0]);
- CuAssertPtrEquals (tc, NULL, modules[1]);
- CuAssertPtrEquals (tc, NULL, modules[2]);
+ assert_ptr_eq (&mock_module_no_slots, modules[0]);
+ assert_ptr_eq (NULL, modules[1]);
+ assert_ptr_eq (NULL, modules[2]);
p11_kit_modules_finalize (modules);
}
static void
-test_finalize_fail (CuTest *tc)
+test_finalize_fail (void)
{
}
int
-main (void)
+main (int argc,
+ char *argv[])
{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- putenv ("P11_KIT_STRICT=1");
p11_mutex_init (&race_mutex);
mock_module_init ();
p11_library_init ();
/* These only work when managed */
if (p11_virtual_can_wrap ()) {
- SUITE_ADD_TEST (suite, test_recursive_initialization);
- SUITE_ADD_TEST (suite, test_threaded_initialization);
- SUITE_ADD_TEST (suite, test_mutexes);
- SUITE_ADD_TEST (suite, test_load_and_initialize);
+ p11_test (test_recursive_initialization, "/init/test_recursive_initialization");
+ p11_test (test_threaded_initialization, "/init/test_threaded_initialization");
+ p11_test (test_mutexes, "/init/test_mutexes");
+ p11_test (test_load_and_initialize, "/init/test_load_and_initialize");
#ifdef OS_UNIX
- SUITE_ADD_TEST (suite, test_fork_initialization);
+ p11_test (test_fork_initialization, "/init/test_fork_initialization");
#endif
}
- SUITE_ADD_TEST (suite, test_initalize_fail);
- SUITE_ADD_TEST (suite, test_finalize_fail);
-
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
+ p11_test (test_initalize_fail, "/init/test_initalize_fail");
+ p11_test (test_finalize_fail, "/init/test_finalize_fail");
- return ret;
+ return p11_test_run (argc, argv);
}
diff --git a/p11-kit/tests/test-iter.c b/p11-kit/tests/test-iter.c
index 451f4be..18b5ed6 100644
--- a/p11-kit/tests/test-iter.c
+++ b/p11-kit/tests/test-iter.c
@@ -33,7 +33,7 @@
*/
#include "config.h"
-#include "CuTest.h"
+#include "test.h"
#define P11_KIT_FUTURE_UNSTABLE_API 1
@@ -49,14 +49,14 @@
#include <stdlib.h>
static CK_FUNCTION_LIST_PTR_PTR
-initialize_and_get_modules (CuTest *tc)
+initialize_and_get_modules (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
p11_message_quiet ();
modules = p11_kit_modules_load_and_initialize (0);
- CuAssertTrue (tc, modules != NULL && modules[0] != NULL);
+ assert (modules != NULL && modules[0] != NULL);
p11_message_loud ();
@@ -64,8 +64,7 @@ initialize_and_get_modules (CuTest *tc)
}
static void
-finalize_and_free_modules (CuTest *tc,
- CK_FUNCTION_LIST_PTR_PTR modules)
+finalize_and_free_modules (CK_FUNCTION_LIST_PTR_PTR modules)
{
p11_kit_modules_finalize (modules);
p11_kit_modules_release (modules);
@@ -87,7 +86,7 @@ has_handle (CK_ULONG *objects,
static void
-test_all (CuTest *tc)
+test_all (void)
{
CK_OBJECT_HANDLE objects[128];
CK_FUNCTION_LIST_PTR *modules;
@@ -98,59 +97,60 @@ test_all (CuTest *tc)
CK_RV rv;
int at;
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
iter = p11_kit_iter_new (NULL);
p11_kit_iter_begin (iter, modules);
at = 0;
while ((rv = p11_kit_iter_next (iter)) == CKR_OK) {
- CuAssertTrue (tc, at < 128);
+ assert (at < 128);
objects[at] = p11_kit_iter_get_object (iter);
module = p11_kit_iter_get_module (iter);
- CuAssertPtrNotNull (tc, module);
+ assert_ptr_not_null (module);
session = p11_kit_iter_get_session (iter);
- CuAssertTrue (tc, session != 0);
+ assert (session != 0);
/* Do something with the object */
size = 0;
rv = (module->C_GetObjectSize) (session, objects[at], &size);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertTrue (tc, size > 0);
+ assert (rv == CKR_OK);
+ assert (size > 0);
at++;
}
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
/* Three modules, each with 1 slot, and 3 public objects */
- CuAssertIntEquals (tc, 9, at);
+ assert_num_eq (9, at);
- CuAssertTrue (tc, has_handle (objects, at, MOCK_DATA_OBJECT));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
+ assert (has_handle (objects, at, MOCK_DATA_OBJECT));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
p11_kit_iter_free (iter);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static CK_RV
on_iter_callback (P11KitIter *iter,
- CK_BBOOL *matches,
- void *data)
+ CK_BBOOL *matches,
+ void *data)
{
- CuTest *tc = data;
CK_OBJECT_HANDLE object;
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session;
CK_ULONG size;
CK_RV rv;
+ assert_str_eq (data, "callback");
+
object = p11_kit_iter_get_object (iter);
if (object != MOCK_PUBLIC_KEY_CAPITALIZE && object != MOCK_PUBLIC_KEY_PREFIX) {
*matches = CK_FALSE;
@@ -158,22 +158,22 @@ on_iter_callback (P11KitIter *iter,
}
module = p11_kit_iter_get_module (iter);
- CuAssertPtrNotNull (tc, module);
+ assert_ptr_not_null (module);
session = p11_kit_iter_get_session (iter);
- CuAssertTrue (tc, session != 0);
+ assert (session != 0);
/* Do something with the object */
size = 0;
rv = (module->C_GetObjectSize) (session, object, &size);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertTrue (tc, size > 0);
+ assert (rv == CKR_OK);
+ assert (size > 0);
return CKR_OK;
}
static void
-test_callback (CuTest *tc)
+test_callback (void)
{
CK_OBJECT_HANDLE objects[128];
CK_FUNCTION_LIST_PTR *modules;
@@ -181,33 +181,33 @@ test_callback (CuTest *tc)
CK_RV rv;
int at;
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
iter = p11_kit_iter_new (NULL);
- p11_kit_iter_add_callback (iter, on_iter_callback, tc, NULL);
+ p11_kit_iter_add_callback (iter, on_iter_callback, "callback", NULL);
p11_kit_iter_begin (iter, modules);
at= 0;
while ((rv = p11_kit_iter_next (iter)) == CKR_OK) {
- CuAssertTrue (tc, at < 128);
+ assert (at < 128);
objects[at] = p11_kit_iter_get_object (iter);
at++;
}
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
/* Three modules, each with 1 slot, and 2 public keys */
- CuAssertIntEquals (tc, 6, at);
+ assert_num_eq (6, at);
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_DATA_OBJECT));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
+ assert (!has_handle (objects, at, MOCK_DATA_OBJECT));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
p11_kit_iter_free (iter);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static CK_RV
@@ -219,30 +219,30 @@ on_callback_fail (P11KitIter *iter,
}
static void
-test_callback_fails (CuTest *tc)
+test_callback_fails (void)
{
CK_FUNCTION_LIST_PTR *modules;
P11KitIter *iter;
CK_RV rv;
int at;
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
iter = p11_kit_iter_new (NULL);
- p11_kit_iter_add_callback (iter, on_callback_fail, tc, NULL);
+ p11_kit_iter_add_callback (iter, on_callback_fail, "callback", NULL);
p11_kit_iter_begin (iter, modules);
at= 0;
while ((rv = p11_kit_iter_next (iter)) == CKR_OK)
at++;
- CuAssertTrue (tc, rv == CKR_DATA_INVALID);
+ assert (rv == CKR_DATA_INVALID);
/* Shouldn't have succeeded at all */
- CuAssertIntEquals (tc, 0, at);
+ assert_num_eq (0, at);
p11_kit_iter_free (iter);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static void
@@ -253,7 +253,7 @@ on_destroy_increment (void *data)
}
static void
-test_callback_destroyer (CuTest *tc)
+test_callback_destroyer (void)
{
P11KitIter *iter;
int value = 1;
@@ -262,11 +262,11 @@ test_callback_destroyer (CuTest *tc)
p11_kit_iter_add_callback (iter, on_callback_fail, &value, on_destroy_increment);
p11_kit_iter_free (iter);
- CuAssertIntEquals (tc, 2, value);
+ assert_num_eq (2, value);
}
static void
-test_with_session (CuTest *tc)
+test_with_session (void)
{
CK_OBJECT_HANDLE objects[128];
CK_SESSION_HANDLE session;
@@ -278,52 +278,52 @@ test_with_session (CuTest *tc)
mock_module_reset ();
rv = mock_module.C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = mock_C_OpenSession (MOCK_SLOT_ONE_ID, CKF_SERIAL_SESSION, NULL, NULL, &session);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
iter = p11_kit_iter_new (NULL);
p11_kit_iter_begin_with (iter, &mock_module, 0, session);
at= 0;
while ((rv = p11_kit_iter_next (iter)) == CKR_OK) {
- CuAssertTrue (tc, at < 128);
+ assert (at < 128);
objects[at] = p11_kit_iter_get_object (iter);
slot = p11_kit_iter_get_slot (iter);
- CuAssertTrue (tc, slot == MOCK_SLOT_ONE_ID);
+ assert (slot == MOCK_SLOT_ONE_ID);
module = p11_kit_iter_get_module (iter);
- CuAssertPtrEquals (tc, module, &mock_module);
+ assert_ptr_eq (module, &mock_module);
- CuAssertTrue (tc, session == p11_kit_iter_get_session (iter));
+ assert (session == p11_kit_iter_get_session (iter));
at++;
}
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
/* 1 modules, each with 1 slot, and 3 public objects */
- CuAssertIntEquals (tc, 3, at);
+ assert_num_eq (3, at);
- CuAssertTrue (tc, has_handle (objects, at, MOCK_DATA_OBJECT));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
+ assert (has_handle (objects, at, MOCK_DATA_OBJECT));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
p11_kit_iter_free (iter);
/* The session is still valid ... */
rv = mock_module.C_CloseSession (session);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = mock_module.C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
static void
-test_with_slot (CuTest *tc)
+test_with_slot (void)
{
CK_OBJECT_HANDLE objects[128];
CK_FUNCTION_LIST_PTR module;
@@ -334,43 +334,43 @@ test_with_slot (CuTest *tc)
mock_module_reset ();
rv = mock_module.C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
iter = p11_kit_iter_new (NULL);
p11_kit_iter_begin_with (iter, &mock_module, MOCK_SLOT_ONE_ID, 0);
at= 0;
while ((rv = p11_kit_iter_next (iter)) == CKR_OK) {
- CuAssertTrue (tc, at < 128);
+ assert (at < 128);
objects[at] = p11_kit_iter_get_object (iter);
slot = p11_kit_iter_get_slot (iter);
- CuAssertTrue (tc, slot == MOCK_SLOT_ONE_ID);
+ assert (slot == MOCK_SLOT_ONE_ID);
module = p11_kit_iter_get_module (iter);
- CuAssertPtrEquals (tc, module, &mock_module);
+ assert_ptr_eq (module, &mock_module);
at++;
}
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
/* 1 modules, each with 1 slot, and 3 public objects */
- CuAssertIntEquals (tc, 3, at);
+ assert_num_eq (3, at);
- CuAssertTrue (tc, has_handle (objects, at, MOCK_DATA_OBJECT));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
+ assert (has_handle (objects, at, MOCK_DATA_OBJECT));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
p11_kit_iter_free (iter);
rv = (mock_module.C_Finalize) (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
static void
-test_with_module (CuTest *tc)
+test_with_module (void)
{
CK_OBJECT_HANDLE objects[128];
CK_FUNCTION_LIST_PTR module;
@@ -380,40 +380,40 @@ test_with_module (CuTest *tc)
mock_module_reset ();
rv = mock_module.C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
iter = p11_kit_iter_new (NULL);
p11_kit_iter_begin_with (iter, &mock_module, 0, 0);
at= 0;
while ((rv = p11_kit_iter_next (iter)) == CKR_OK) {
- CuAssertTrue (tc, at < 128);
+ assert (at < 128);
objects[at] = p11_kit_iter_get_object (iter);
module = p11_kit_iter_get_module (iter);
- CuAssertPtrEquals (tc, module, &mock_module);
+ assert_ptr_eq (module, &mock_module);
at++;
}
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
/* 1 modules, each with 1 slot, and 3 public objects */
- CuAssertIntEquals (tc, 3, at);
+ assert_num_eq (3, at);
- CuAssertTrue (tc, has_handle (objects, at, MOCK_DATA_OBJECT));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
+ assert (has_handle (objects, at, MOCK_DATA_OBJECT));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
p11_kit_iter_free (iter);
rv = mock_module.C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
static void
-test_keep_session (CuTest *tc)
+test_keep_session (void)
{
CK_SESSION_HANDLE session;
P11KitIter *iter;
@@ -421,27 +421,27 @@ test_keep_session (CuTest *tc)
mock_module_reset ();
rv = mock_module.C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
iter = p11_kit_iter_new (NULL);
p11_kit_iter_begin_with (iter, &mock_module, 0, 0);
rv = p11_kit_iter_next (iter);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
session = p11_kit_iter_keep_session (iter);
p11_kit_iter_free (iter);
/* The session is still valid ... */
rv = mock_module.C_CloseSession (session);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = mock_module.C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
static void
-test_unrecognized (CuTest *tc)
+test_unrecognized (void)
{
CK_FUNCTION_LIST_PTR *modules;
P11KitIter *iter;
@@ -449,7 +449,7 @@ test_unrecognized (CuTest *tc)
CK_RV rv;
int count;
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
uri = p11_kit_uri_new ();
p11_kit_uri_set_unrecognized (uri, 1);
@@ -462,18 +462,18 @@ test_unrecognized (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK)
count++;
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
/* Nothing should have matched */
- CuAssertIntEquals (tc, 0, count);
+ assert_num_eq (0, count);
p11_kit_iter_free (iter);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static void
-test_uri_with_type (CuTest *tc)
+test_uri_with_type (void)
{
CK_OBJECT_HANDLE objects[128];
CK_FUNCTION_LIST_PTR *modules;
@@ -483,11 +483,11 @@ test_uri_with_type (CuTest *tc)
int at;
int ret;
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
uri = p11_kit_uri_new ();
ret = p11_kit_uri_parse ("pkcs11:object-type=public", P11_KIT_URI_FOR_OBJECT, uri);
- CuAssertIntEquals (tc, ret, P11_KIT_URI_OK);
+ assert_num_eq (ret, P11_KIT_URI_OK);
iter = p11_kit_iter_new (uri);
p11_kit_uri_free (uri);
@@ -496,29 +496,29 @@ test_uri_with_type (CuTest *tc)
at = 0;
while ((rv = p11_kit_iter_next (iter)) == CKR_OK) {
- CuAssertTrue (tc, at < 128);
+ assert (at < 128);
objects[at] = p11_kit_iter_get_object (iter);
at++;
}
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
/* Three modules, each with 1 slot, and 2 public keys */
- CuAssertIntEquals (tc, 6, at);
+ assert_num_eq (6, at);
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_DATA_OBJECT));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
+ assert (!has_handle (objects, at, MOCK_DATA_OBJECT));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
p11_kit_iter_free (iter);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static void
-test_filter (CuTest *tc)
+test_filter (void)
{
CK_OBJECT_HANDLE objects[128];
CK_FUNCTION_LIST_PTR *modules;
@@ -533,7 +533,7 @@ test_filter (CuTest *tc)
{ CKA_CLASS, &public_key, sizeof (public_key) },
};
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
iter = p11_kit_iter_new (NULL);
p11_kit_iter_add_filter (iter, attrs, 2);
@@ -542,29 +542,29 @@ test_filter (CuTest *tc)
at = 0;
while ((rv = p11_kit_iter_next (iter)) == CKR_OK) {
- CuAssertTrue (tc, at < 128);
+ assert (at < 128);
objects[at] = p11_kit_iter_get_object (iter);
at++;
}
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
/* Three modules, each with 1 slot, and 2 public keys */
- CuAssertIntEquals (tc, 6, at);
+ assert_num_eq (6, at);
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_DATA_OBJECT));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
- CuAssertTrue (tc, !has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
- CuAssertTrue (tc, has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
+ assert (!has_handle (objects, at, MOCK_DATA_OBJECT));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_CAPITALIZE));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_CAPITALIZE));
+ assert (!has_handle (objects, at, MOCK_PRIVATE_KEY_PREFIX));
+ assert (has_handle (objects, at, MOCK_PUBLIC_KEY_PREFIX));
p11_kit_iter_free (iter);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static void
-test_session_flags (CuTest *tc)
+test_session_flags (void)
{
CK_FUNCTION_LIST_PTR *modules;
CK_FUNCTION_LIST_PTR module;
@@ -573,7 +573,7 @@ test_session_flags (CuTest *tc)
P11KitIter *iter;
CK_RV rv;
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
iter = p11_kit_iter_new (NULL);
p11_kit_iter_set_session_flags (iter, CKF_RW_SESSION);
@@ -582,26 +582,26 @@ test_session_flags (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK) {
module = p11_kit_iter_get_module (iter);
- CuAssertPtrNotNull (tc, module);
+ assert_ptr_not_null (module);
session = p11_kit_iter_get_session (iter);
- CuAssertTrue (tc, session != 0);
+ assert (session != 0);
rv = (module->C_GetSessionInfo) (session, &info);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, CKS_RW_PUBLIC_SESSION, info.state);
+ assert_num_eq (CKS_RW_PUBLIC_SESSION, info.state);
}
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
p11_kit_iter_free (iter);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static void
-test_module_match (CuTest *tc)
+test_module_match (void)
{
CK_FUNCTION_LIST_PTR *modules;
P11KitIter *iter;
@@ -610,11 +610,11 @@ test_module_match (CuTest *tc)
int count;
int ret;
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
uri = p11_kit_uri_new ();
ret = p11_kit_uri_parse ("pkcs11:library-description=MOCK%20LIBRARY", P11_KIT_URI_FOR_MODULE, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
iter = p11_kit_iter_new (uri);
p11_kit_uri_free (uri);
@@ -625,18 +625,18 @@ test_module_match (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK)
count++;
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
/* Three modules, each with 1 slot, and 3 public objects */
- CuAssertIntEquals (tc, 9, count);
+ assert_num_eq (9, count);
p11_kit_iter_free (iter);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static void
-test_module_mismatch (CuTest *tc)
+test_module_mismatch (void)
{
CK_FUNCTION_LIST_PTR *modules;
P11KitIter *iter;
@@ -645,11 +645,11 @@ test_module_mismatch (CuTest *tc)
int count;
int ret;
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
uri = p11_kit_uri_new ();
ret = p11_kit_uri_parse ("pkcs11:library-description=blah", P11_KIT_URI_FOR_MODULE, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
iter = p11_kit_iter_new (uri);
p11_kit_uri_free (uri);
@@ -660,18 +660,18 @@ test_module_mismatch (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK)
count++;
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
/* Nothing should have matched */
- CuAssertIntEquals (tc, 0, count);
+ assert_num_eq (0, count);
p11_kit_iter_free (iter);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static void
-test_token_match (CuTest *tc)
+test_token_match (void)
{
CK_FUNCTION_LIST_PTR *modules;
P11KitIter *iter;
@@ -680,11 +680,11 @@ test_token_match (CuTest *tc)
int count;
int ret;
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
uri = p11_kit_uri_new ();
ret = p11_kit_uri_parse ("pkcs11:manufacturer=TEST%20MANUFACTURER", P11_KIT_URI_FOR_TOKEN, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
iter = p11_kit_iter_new (uri);
p11_kit_uri_free (uri);
@@ -695,18 +695,18 @@ test_token_match (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK)
count++;
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
/* Three modules, each with 1 slot, and 3 public objects */
- CuAssertIntEquals (tc, 9, count);
+ assert_num_eq (9, count);
p11_kit_iter_free (iter);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static void
-test_token_mismatch (CuTest *tc)
+test_token_mismatch (void)
{
CK_FUNCTION_LIST_PTR *modules;
P11KitIter *iter;
@@ -715,11 +715,11 @@ test_token_mismatch (CuTest *tc)
int count;
int ret;
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
uri = p11_kit_uri_new ();
ret = p11_kit_uri_parse ("pkcs11:manufacturer=blah", P11_KIT_URI_FOR_TOKEN, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
iter = p11_kit_iter_new (uri);
p11_kit_uri_free (uri);
@@ -730,18 +730,18 @@ test_token_mismatch (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK)
count++;
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
/* Nothing should have matched */
- CuAssertIntEquals (tc, 0, count);
+ assert_num_eq (0, count);
p11_kit_iter_free (iter);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static void
-test_getslotlist_fail_first (CuTest *tc)
+test_getslotlist_fail_first (void)
{
CK_FUNCTION_LIST module;
P11KitIter *iter;
@@ -750,7 +750,7 @@ test_getslotlist_fail_first (CuTest *tc)
mock_module_reset ();
rv = mock_module.C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
memcpy (&module, &mock_module, sizeof (CK_FUNCTION_LIST));
module.C_GetSlotList = mock_C_GetSlotList__fail_first;
@@ -762,19 +762,19 @@ test_getslotlist_fail_first (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK)
at++;
- CuAssertTrue (tc, rv == CKR_VENDOR_DEFINED);
+ assert (rv == CKR_VENDOR_DEFINED);
/* Should fail on the first iteration */
- CuAssertIntEquals (tc, 0, at);
+ assert_num_eq (0, at);
p11_kit_iter_free (iter);
rv = mock_module.C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
static void
-test_getslotlist_fail_late (CuTest *tc)
+test_getslotlist_fail_late (void)
{
CK_FUNCTION_LIST module;
P11KitIter *iter;
@@ -783,7 +783,7 @@ test_getslotlist_fail_late (CuTest *tc)
mock_module_reset ();
rv = mock_module.C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
memcpy (&module, &mock_module, sizeof (CK_FUNCTION_LIST));
module.C_GetSlotList = mock_C_GetSlotList__fail_late;
@@ -795,19 +795,19 @@ test_getslotlist_fail_late (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK)
at++;
- CuAssertTrue (tc, rv == CKR_VENDOR_DEFINED);
+ assert (rv == CKR_VENDOR_DEFINED);
/* Should fail on the first iteration */
- CuAssertIntEquals (tc, 0, at);
+ assert_num_eq (0, at);
p11_kit_iter_free (iter);
rv = mock_module.C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
static void
-test_open_session_fail (CuTest *tc)
+test_open_session_fail (void)
{
CK_FUNCTION_LIST module;
P11KitIter *iter;
@@ -816,7 +816,7 @@ test_open_session_fail (CuTest *tc)
mock_module_reset ();
rv = mock_module.C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
memcpy (&module, &mock_module, sizeof (CK_FUNCTION_LIST));
module.C_OpenSession = mock_C_OpenSession__fails;
@@ -828,19 +828,19 @@ test_open_session_fail (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK)
at++;
- CuAssertTrue (tc, rv == CKR_DEVICE_ERROR);
+ assert (rv == CKR_DEVICE_ERROR);
/* Should fail on the first iteration */
- CuAssertIntEquals (tc, 0, at);
+ assert_num_eq (0, at);
p11_kit_iter_free (iter);
rv = mock_module.C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
static void
-test_find_init_fail (CuTest *tc)
+test_find_init_fail (void)
{
CK_FUNCTION_LIST module;
P11KitIter *iter;
@@ -849,7 +849,7 @@ test_find_init_fail (CuTest *tc)
mock_module_reset ();
rv = mock_module.C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
memcpy (&module, &mock_module, sizeof (CK_FUNCTION_LIST));
module.C_FindObjectsInit = mock_C_FindObjectsInit__fails;
@@ -861,19 +861,19 @@ test_find_init_fail (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK)
at++;
- CuAssertTrue (tc, rv == CKR_DEVICE_MEMORY);
+ assert (rv == CKR_DEVICE_MEMORY);
/* Should fail on the first iteration */
- CuAssertIntEquals (tc, 0, at);
+ assert_num_eq (0, at);
p11_kit_iter_free (iter);
rv = mock_module.C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
static void
-test_find_objects_fail (CuTest *tc)
+test_find_objects_fail (void)
{
CK_FUNCTION_LIST module;
P11KitIter *iter;
@@ -882,7 +882,7 @@ test_find_objects_fail (CuTest *tc)
mock_module_reset ();
rv = mock_module.C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
memcpy (&module, &mock_module, sizeof (CK_FUNCTION_LIST));
module.C_FindObjects = mock_C_FindObjects__fails;
@@ -894,19 +894,19 @@ test_find_objects_fail (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK)
at++;
- CuAssertTrue (tc, rv == CKR_DEVICE_REMOVED);
+ assert (rv == CKR_DEVICE_REMOVED);
/* Should fail on the first iteration */
- CuAssertIntEquals (tc, 0, at);
+ assert_num_eq (0, at);
p11_kit_iter_free (iter);
rv = mock_module.C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
static void
-test_load_attributes (CuTest *tc)
+test_load_attributes (void)
{
CK_FUNCTION_LIST_PTR *modules;
P11KitIter *iter;
@@ -921,7 +921,7 @@ test_load_attributes (CuTest *tc)
{ CKA_LABEL },
};
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
iter = p11_kit_iter_new (NULL);
p11_kit_iter_begin (iter, modules);
@@ -931,24 +931,24 @@ test_load_attributes (CuTest *tc)
at = 0;
while ((rv = p11_kit_iter_next (iter)) == CKR_OK) {
rv = p11_kit_iter_load_attributes (iter, attrs, 2);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
object = p11_kit_iter_get_object (iter);
switch (object) {
case MOCK_DATA_OBJECT:
- CuAssertTrue (tc, p11_attrs_find_ulong (attrs, CKA_CLASS, &ulong) && ulong == CKO_DATA);
- CuAssertTrue (tc, p11_attr_match_value (p11_attrs_find (attrs, CKA_LABEL), "TEST LABEL", -1));
+ assert (p11_attrs_find_ulong (attrs, CKA_CLASS, &ulong) && ulong == CKO_DATA);
+ assert (p11_attr_match_value (p11_attrs_find (attrs, CKA_LABEL), "TEST LABEL", -1));
break;
case MOCK_PUBLIC_KEY_CAPITALIZE:
- CuAssertTrue (tc, p11_attrs_find_ulong (attrs, CKA_CLASS, &ulong) && ulong == CKO_PUBLIC_KEY);
- CuAssertTrue (tc, p11_attr_match_value (p11_attrs_find (attrs, CKA_LABEL), "Public Capitalize Key", -1));
+ assert (p11_attrs_find_ulong (attrs, CKA_CLASS, &ulong) && ulong == CKO_PUBLIC_KEY);
+ assert (p11_attr_match_value (p11_attrs_find (attrs, CKA_LABEL), "Public Capitalize Key", -1));
break;
case MOCK_PUBLIC_KEY_PREFIX:
- CuAssertTrue (tc, p11_attrs_find_ulong (attrs, CKA_CLASS, &ulong) && ulong == CKO_PUBLIC_KEY);
- CuAssertTrue (tc, p11_attr_match_value (p11_attrs_find (attrs, CKA_LABEL), "Public prefix key", -1));
+ assert (p11_attrs_find_ulong (attrs, CKA_CLASS, &ulong) && ulong == CKO_PUBLIC_KEY);
+ assert (p11_attr_match_value (p11_attrs_find (attrs, CKA_LABEL), "Public prefix key", -1));
break;
default:
- CuFail (tc, "Unknown object matched");
+ assert_fail ("Unknown object matched", NULL);
break;
}
@@ -957,18 +957,18 @@ test_load_attributes (CuTest *tc)
p11_attrs_free (attrs);
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
/* Three modules, each with 1 slot, and 3 public objects */
- CuAssertIntEquals (tc, 9, at);
+ assert_num_eq (9, at);
p11_kit_iter_free (iter);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static void
-test_load_attributes_none (CuTest *tc)
+test_load_attributes_none (void)
{
CK_FUNCTION_LIST module;
P11KitIter *iter;
@@ -977,7 +977,7 @@ test_load_attributes_none (CuTest *tc)
mock_module_reset ();
rv = mock_module.C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
memcpy (&module, &mock_module, sizeof (CK_FUNCTION_LIST));
@@ -987,20 +987,20 @@ test_load_attributes_none (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK) {
attrs = p11_attrs_buildn (NULL, NULL, 0);
rv = p11_kit_iter_load_attributes (iter, attrs, 0);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_attrs_free (attrs);
}
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
p11_kit_iter_free (iter);
rv = mock_module.C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
static void
-test_load_attributes_fail_first (CuTest *tc)
+test_load_attributes_fail_first (void)
{
CK_ATTRIBUTE label = { CKA_LABEL, };
CK_FUNCTION_LIST module;
@@ -1010,7 +1010,7 @@ test_load_attributes_fail_first (CuTest *tc)
mock_module_reset ();
rv = mock_module.C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
memcpy (&module, &mock_module, sizeof (CK_FUNCTION_LIST));
module.C_GetAttributeValue = mock_C_GetAttributeValue__fail_first;
@@ -1021,20 +1021,20 @@ test_load_attributes_fail_first (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK) {
attrs = p11_attrs_build (NULL, &label, NULL);
rv = p11_kit_iter_load_attributes (iter, attrs, 1);
- CuAssertTrue (tc, rv == CKR_FUNCTION_REJECTED);
+ assert (rv == CKR_FUNCTION_REJECTED);
p11_attrs_free (attrs);
}
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
p11_kit_iter_free (iter);
rv = mock_module.C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
static void
-test_load_attributes_fail_late (CuTest *tc)
+test_load_attributes_fail_late (void)
{
CK_ATTRIBUTE label = { CKA_LABEL, };
CK_FUNCTION_LIST module;
@@ -1044,7 +1044,7 @@ test_load_attributes_fail_late (CuTest *tc)
mock_module_reset ();
rv = mock_module.C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
memcpy (&module, &mock_module, sizeof (CK_FUNCTION_LIST));
module.C_GetAttributeValue = mock_C_GetAttributeValue__fail_late;
@@ -1055,61 +1055,50 @@ test_load_attributes_fail_late (CuTest *tc)
while ((rv = p11_kit_iter_next (iter)) == CKR_OK) {
attrs = p11_attrs_build (NULL, &label, NULL);
rv = p11_kit_iter_load_attributes (iter, attrs, 1);
- CuAssertTrue (tc, rv == CKR_FUNCTION_FAILED);
+ assert (rv == CKR_FUNCTION_FAILED);
p11_attrs_free (attrs);
}
- CuAssertTrue (tc, rv == CKR_CANCEL);
+ assert (rv == CKR_CANCEL);
p11_kit_iter_free (iter);
rv = mock_module.C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
int
-main (void)
+main (int argc,
+ char *argv[])
{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- putenv ("P11_KIT_STRICT=1");
p11_library_init ();
mock_module_init ();
- SUITE_ADD_TEST (suite, test_all);
- SUITE_ADD_TEST (suite, test_unrecognized);
- SUITE_ADD_TEST (suite, test_uri_with_type);
- SUITE_ADD_TEST (suite, test_session_flags);
- SUITE_ADD_TEST (suite, test_callback);
- SUITE_ADD_TEST (suite, test_callback_fails);
- SUITE_ADD_TEST (suite, test_callback_destroyer);
- SUITE_ADD_TEST (suite, test_filter);
- SUITE_ADD_TEST (suite, test_with_session);
- SUITE_ADD_TEST (suite, test_with_slot);
- SUITE_ADD_TEST (suite, test_with_module);
- SUITE_ADD_TEST (suite, test_keep_session);
- SUITE_ADD_TEST (suite, test_token_match);
- SUITE_ADD_TEST (suite, test_token_mismatch);
- SUITE_ADD_TEST (suite, test_module_match);
- SUITE_ADD_TEST (suite, test_module_mismatch);
- SUITE_ADD_TEST (suite, test_getslotlist_fail_first);
- SUITE_ADD_TEST (suite, test_getslotlist_fail_late);
- SUITE_ADD_TEST (suite, test_open_session_fail);
- SUITE_ADD_TEST (suite, test_find_init_fail);
- SUITE_ADD_TEST (suite, test_find_objects_fail);
- SUITE_ADD_TEST (suite, test_load_attributes);
- SUITE_ADD_TEST (suite, test_load_attributes_none);
- SUITE_ADD_TEST (suite, test_load_attributes_fail_first);
- SUITE_ADD_TEST (suite, test_load_attributes_fail_late);
-
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
- return ret;
+ p11_test (test_all, "/iter/test_all");
+ p11_test (test_unrecognized, "/iter/test_unrecognized");
+ p11_test (test_uri_with_type, "/iter/test_uri_with_type");
+ p11_test (test_session_flags, "/iter/test_session_flags");
+ p11_test (test_callback, "/iter/test_callback");
+ p11_test (test_callback_fails, "/iter/test_callback_fails");
+ p11_test (test_callback_destroyer, "/iter/test_callback_destroyer");
+ p11_test (test_filter, "/iter/test_filter");
+ p11_test (test_with_session, "/iter/test_with_session");
+ p11_test (test_with_slot, "/iter/test_with_slot");
+ p11_test (test_with_module, "/iter/test_with_module");
+ p11_test (test_keep_session, "/iter/test_keep_session");
+ p11_test (test_token_match, "/iter/test_token_match");
+ p11_test (test_token_mismatch, "/iter/test_token_mismatch");
+ p11_test (test_module_match, "/iter/test_module_match");
+ p11_test (test_module_mismatch, "/iter/test_module_mismatch");
+ p11_test (test_getslotlist_fail_first, "/iter/test_getslotlist_fail_first");
+ p11_test (test_getslotlist_fail_late, "/iter/test_getslotlist_fail_late");
+ p11_test (test_open_session_fail, "/iter/test_open_session_fail");
+ p11_test (test_find_init_fail, "/iter/test_find_init_fail");
+ p11_test (test_find_objects_fail, "/iter/test_find_objects_fail");
+ p11_test (test_load_attributes, "/iter/test_load_attributes");
+ p11_test (test_load_attributes_none, "/iter/test_load_attributes_none");
+ p11_test (test_load_attributes_fail_first, "/iter/test_load_attributes_fail_first");
+ p11_test (test_load_attributes_fail_late, "/iter/test_load_attributes_fail_late");
+
+ return p11_test_run (argc, argv);
}
diff --git a/p11-kit/tests/test-log.c b/p11-kit/tests/test-log.c
index fc8c45c..e7dab70 100644
--- a/p11-kit/tests/test-log.c
+++ b/p11-kit/tests/test-log.c
@@ -33,7 +33,7 @@
*/
#include "config.h"
-#include "CuTest.h"
+#include "test.h"
#include "dict.h"
#include "library.h"
@@ -49,8 +49,7 @@
#include <string.h>
static CK_FUNCTION_LIST_PTR
-setup_mock_module (CuTest *tc,
- CK_SESSION_HANDLE *session)
+setup_mock_module (CK_SESSION_HANDLE *session)
{
CK_FUNCTION_LIST_PTR module;
CK_RV rv;
@@ -59,38 +58,37 @@ setup_mock_module (CuTest *tc,
p11_log_force = true;
rv = p11_module_load_inlock_reentrant (&mock_module, 0, &module);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertPtrNotNull (tc, module);
- CuAssertTrue (tc, p11_virtual_is_wrapper (module));
+ assert (rv == CKR_OK);
+ assert_ptr_not_null (module);
+ assert (p11_virtual_is_wrapper (module));
p11_unlock ();
rv = p11_kit_module_initialize (module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
if (session) {
rv = (module->C_OpenSession) (MOCK_SLOT_ONE_ID,
CKF_RW_SESSION | CKF_SERIAL_SESSION,
NULL, NULL, session);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
return module;
}
static void
-teardown_mock_module (CuTest *tc,
- CK_FUNCTION_LIST_PTR module)
+teardown_mock_module (CK_FUNCTION_LIST_PTR module)
{
CK_RV rv;
rv = p11_kit_module_finalize (module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_lock ();
rv = p11_module_release_inlock_reentrant (module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_unlock ();
}
@@ -99,27 +97,16 @@ teardown_mock_module (CuTest *tc,
#include "test-mock.c"
int
-main (void)
+main (int argc,
+ char *argv[])
{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- putenv ("P11_KIT_STRICT=1");
p11_library_init ();
mock_module_init ();
- test_mock_add_tests (suite);
+ test_mock_add_tests ("/log");
p11_kit_be_quiet ();
p11_log_output = false;
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
- return ret;
+ return p11_test_run (argc, argv);
}
diff --git a/p11-kit/tests/test-managed.c b/p11-kit/tests/test-managed.c
index 6184c44..9fc9ffb 100644
--- a/p11-kit/tests/test-managed.c
+++ b/p11-kit/tests/test-managed.c
@@ -33,7 +33,7 @@
*/
#include "config.h"
-#include "CuTest.h"
+#include "test.h"
#include "dict.h"
#include "library.h"
@@ -48,8 +48,7 @@
#include <string.h>
static CK_FUNCTION_LIST_PTR
-setup_mock_module (CuTest *tc,
- CK_SESSION_HANDLE *session)
+setup_mock_module (CK_SESSION_HANDLE *session)
{
CK_FUNCTION_LIST_PTR module;
CK_RV rv;
@@ -57,38 +56,37 @@ setup_mock_module (CuTest *tc,
p11_lock ();
rv = p11_module_load_inlock_reentrant (&mock_module, 0, &module);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertPtrNotNull (tc, module);
- CuAssertTrue (tc, p11_virtual_is_wrapper (module));
+ assert (rv == CKR_OK);
+ assert_ptr_not_null (module);
+ assert (p11_virtual_is_wrapper (module));
p11_unlock ();
rv = p11_kit_module_initialize (module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
if (session) {
rv = (module->C_OpenSession) (MOCK_SLOT_ONE_ID,
CKF_RW_SESSION | CKF_SERIAL_SESSION,
NULL, NULL, session);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
return module;
}
static void
-teardown_mock_module (CuTest *tc,
- CK_FUNCTION_LIST_PTR module)
+teardown_mock_module (CK_FUNCTION_LIST_PTR module)
{
CK_RV rv;
rv = p11_kit_module_finalize (module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_lock ();
rv = p11_module_release_inlock_reentrant (module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_unlock ();
}
@@ -100,7 +98,7 @@ fail_C_Initialize (void *init_reserved)
}
static void
-test_initialize_finalize (CuTest *tc)
+test_initialize_finalize (void)
{
CK_FUNCTION_LIST_PTR module;
CK_RV rv;
@@ -108,34 +106,34 @@ test_initialize_finalize (CuTest *tc)
p11_lock ();
rv = p11_module_load_inlock_reentrant (&mock_module, 0, &module);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertPtrNotNull (tc, module);
- CuAssertTrue (tc, p11_virtual_is_wrapper (module));
+ assert (rv == CKR_OK);
+ assert_ptr_not_null (module);
+ assert (p11_virtual_is_wrapper (module));
p11_unlock ();
rv = module->C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = module->C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_CRYPTOKI_ALREADY_INITIALIZED);
+ assert (rv == CKR_CRYPTOKI_ALREADY_INITIALIZED);
rv = module->C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = module->C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_CRYPTOKI_NOT_INITIALIZED);
+ assert (rv == CKR_CRYPTOKI_NOT_INITIALIZED);
p11_lock ();
rv = p11_module_release_inlock_reentrant (module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_unlock ();
}
static void
-test_initialize_fail (CuTest *tc)
+test_initialize_fail (void)
{
CK_FUNCTION_LIST_PTR module;
CK_FUNCTION_LIST base;
@@ -147,16 +145,16 @@ test_initialize_fail (CuTest *tc)
p11_lock ();
rv = p11_module_load_inlock_reentrant (&base, 0, &module);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_unlock ();
rv = p11_kit_module_initialize (module);
- CuAssertTrue (tc, rv == CKR_FUNCTION_FAILED);
+ assert (rv == CKR_FUNCTION_FAILED);
}
static void
-test_separate_close_all_sessions (CuTest *tc)
+test_separate_close_all_sessions (void)
{
CK_FUNCTION_LIST *first;
CK_FUNCTION_LIST *second;
@@ -165,64 +163,53 @@ test_separate_close_all_sessions (CuTest *tc)
CK_SESSION_INFO info;
CK_RV rv;
- first = setup_mock_module (tc, &s1);
- second = setup_mock_module (tc, &s2);
+ first = setup_mock_module (&s1);
+ second = setup_mock_module (&s2);
rv = first->C_GetSessionInfo (s1, &info);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = second->C_GetSessionInfo (s2, &info);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
first->C_CloseAllSessions (MOCK_SLOT_ONE_ID);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = first->C_GetSessionInfo (s1, &info);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = second->C_GetSessionInfo (s2, &info);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
second->C_CloseAllSessions (MOCK_SLOT_ONE_ID);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = first->C_GetSessionInfo (s1, &info);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = second->C_GetSessionInfo (s2, &info);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
- teardown_mock_module (tc, first);
- teardown_mock_module (tc, second);
+ teardown_mock_module (first);
+ teardown_mock_module (second);
}
/* Bring in all the mock module tests */
#include "test-mock.c"
int
-main (void)
+main (int argc,
+ char *argv[])
{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- putenv ("P11_KIT_STRICT=1");
mock_module_init ();
p11_library_init ();
- SUITE_ADD_TEST (suite, test_initialize_finalize);
- SUITE_ADD_TEST (suite, test_initialize_fail);
- SUITE_ADD_TEST (suite, test_separate_close_all_sessions);
- test_mock_add_tests (suite);
+ p11_test (test_initialize_finalize, "/managed/test_initialize_finalize");
+ p11_test (test_initialize_fail, "/managed/test_initialize_fail");
+ p11_test (test_separate_close_all_sessions, "/managed/test_separate_close_all_sessions");
+ test_mock_add_tests ("/managed");
p11_kit_be_quiet ();
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
- return ret;
+ return p11_test_run (argc, argv);
}
diff --git a/p11-kit/tests/test-mock.c b/p11-kit/tests/test-mock.c
index 3bc5406..5fba7ec 100644
--- a/p11-kit/tests/test-mock.c
+++ b/p11-kit/tests/test-mock.c
@@ -33,7 +33,7 @@
* Author: Stef Walter <stef@thewalter.net>
*/
-#include "CuTest.h"
+#include "test.h"
#include "library.h"
#include "mock.h"
@@ -46,222 +46,222 @@
#include <stdlib.h>
static void
-test_get_info (CuTest *tc)
+test_get_info (void)
{
CK_FUNCTION_LIST_PTR module;
CK_INFO info;
CK_RV rv;
- module = setup_mock_module (tc, NULL);
+ module = setup_mock_module (NULL);
rv = (module->C_GetInfo) (&info);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertTrue (tc, memcmp (&info, &MOCK_INFO, sizeof (CK_INFO)) == 0);
+ assert (rv == CKR_OK);
+ assert (memcmp (&info, &MOCK_INFO, sizeof (CK_INFO)) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_get_slot_list (CuTest *tc)
+test_get_slot_list (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SLOT_ID slot_list[8];
CK_ULONG count = 0;
CK_RV rv;
- module = setup_mock_module (tc, NULL);
+ module = setup_mock_module (NULL);
/* Normal module has 2 slots, one with token present */
rv = (module->C_GetSlotList) (CK_TRUE, NULL, &count);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertIntEquals (tc, MOCK_SLOTS_PRESENT, count);
+ assert (rv == CKR_OK);
+ assert_num_eq (MOCK_SLOTS_PRESENT, count);
rv = (module->C_GetSlotList) (CK_FALSE, NULL, &count);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertIntEquals (tc, MOCK_SLOTS_ALL, count);
+ assert (rv == CKR_OK);
+ assert_num_eq (MOCK_SLOTS_ALL, count);
count = 8;
rv = (module->C_GetSlotList) (CK_TRUE, slot_list, &count);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertIntEquals (tc, MOCK_SLOTS_PRESENT, count);
- CuAssertIntEquals (tc, MOCK_SLOT_ONE_ID, slot_list[0]);
+ assert (rv == CKR_OK);
+ assert_num_eq (MOCK_SLOTS_PRESENT, count);
+ assert_num_eq (MOCK_SLOT_ONE_ID, slot_list[0]);
count = 8;
rv = (module->C_GetSlotList) (CK_FALSE, slot_list, &count);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertIntEquals (tc, MOCK_SLOTS_ALL, count);
- CuAssertIntEquals (tc, MOCK_SLOT_ONE_ID, slot_list[0]);
- CuAssertIntEquals (tc, MOCK_SLOT_TWO_ID, slot_list[1]);
+ assert (rv == CKR_OK);
+ assert_num_eq (MOCK_SLOTS_ALL, count);
+ assert_num_eq (MOCK_SLOT_ONE_ID, slot_list[0]);
+ assert_num_eq (MOCK_SLOT_TWO_ID, slot_list[1]);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_get_slot_info (CuTest *tc)
+test_get_slot_info (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SLOT_INFO info;
char *string;
CK_RV rv;
- module = setup_mock_module (tc, NULL);
+ module = setup_mock_module (NULL);
rv = (module->C_GetSlotInfo) (MOCK_SLOT_ONE_ID, &info);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
string = p11_kit_space_strdup (info.slotDescription, sizeof (info.slotDescription));
- CuAssertStrEquals (tc, "TEST SLOT", string);
+ assert_str_eq ("TEST SLOT", string);
free (string);
string = p11_kit_space_strdup (info.manufacturerID, sizeof (info.manufacturerID));
- CuAssertStrEquals (tc, "TEST MANUFACTURER", string);
+ assert_str_eq ("TEST MANUFACTURER", string);
free (string);
- CuAssertIntEquals (tc, CKF_TOKEN_PRESENT | CKF_REMOVABLE_DEVICE, info.flags);
- CuAssertIntEquals (tc, 55, info.hardwareVersion.major);
- CuAssertIntEquals (tc, 155, info.hardwareVersion.minor);
- CuAssertIntEquals (tc, 65, info.firmwareVersion.major);
- CuAssertIntEquals (tc, 165, info.firmwareVersion.minor);
+ assert_num_eq (CKF_TOKEN_PRESENT | CKF_REMOVABLE_DEVICE, info.flags);
+ assert_num_eq (55, info.hardwareVersion.major);
+ assert_num_eq (155, info.hardwareVersion.minor);
+ assert_num_eq (65, info.firmwareVersion.major);
+ assert_num_eq (165, info.firmwareVersion.minor);
rv = (module->C_GetSlotInfo) (MOCK_SLOT_TWO_ID, &info);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertIntEquals (tc, CKF_REMOVABLE_DEVICE, info.flags);
+ assert (rv == CKR_OK);
+ assert_num_eq (CKF_REMOVABLE_DEVICE, info.flags);
rv = (module->C_GetSlotInfo) (0, &info);
- CuAssertTrue (tc, rv == CKR_SLOT_ID_INVALID);
+ assert (rv == CKR_SLOT_ID_INVALID);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_get_token_info (CuTest *tc)
+test_get_token_info (void)
{
CK_FUNCTION_LIST_PTR module;
CK_TOKEN_INFO info;
char *string;
CK_RV rv;
- module = setup_mock_module (tc, NULL);
+ module = setup_mock_module (NULL);
rv = (module->C_GetTokenInfo) (MOCK_SLOT_ONE_ID, &info);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
string = p11_kit_space_strdup (info.label, sizeof (info.label));
- CuAssertStrEquals (tc, "TEST LABEL", string);
+ assert_str_eq ("TEST LABEL", string);
free (string);
string = p11_kit_space_strdup (info.manufacturerID, sizeof (info.manufacturerID));
- CuAssertStrEquals (tc, "TEST MANUFACTURER", string);
+ assert_str_eq ("TEST MANUFACTURER", string);
free (string);
string = p11_kit_space_strdup (info.model, sizeof (info.model));
- CuAssertStrEquals (tc, "TEST MODEL", string);
+ assert_str_eq ("TEST MODEL", string);
free (string);
string = p11_kit_space_strdup (info.serialNumber, sizeof (info.serialNumber));
- CuAssertStrEquals (tc, "TEST SERIAL", string);
+ assert_str_eq ("TEST SERIAL", string);
free (string);
- CuAssertIntEquals (tc, CKF_LOGIN_REQUIRED | CKF_USER_PIN_INITIALIZED | CKF_CLOCK_ON_TOKEN | CKF_TOKEN_INITIALIZED, info.flags);
- CuAssertIntEquals (tc, 1, info.ulMaxSessionCount);
- CuAssertIntEquals (tc, 2, info.ulSessionCount);
- CuAssertIntEquals (tc, 3, info.ulMaxRwSessionCount);
- CuAssertIntEquals (tc, 4, info.ulRwSessionCount);
- CuAssertIntEquals (tc, 5, info.ulMaxPinLen);
- CuAssertIntEquals (tc, 6, info.ulMinPinLen);
- CuAssertIntEquals (tc, 7, info.ulTotalPublicMemory);
- CuAssertIntEquals (tc, 8, info.ulFreePublicMemory);
- CuAssertIntEquals (tc, 9, info.ulTotalPrivateMemory);
- CuAssertIntEquals (tc, 10, info.ulFreePrivateMemory);
- CuAssertIntEquals (tc, 75, info.hardwareVersion.major);
- CuAssertIntEquals (tc, 175, info.hardwareVersion.minor);
- CuAssertIntEquals (tc, 85, info.firmwareVersion.major);
- CuAssertIntEquals (tc, 185, info.firmwareVersion.minor);
- CuAssertTrue (tc, memcmp (info.utcTime, "1999052509195900", sizeof (info.utcTime)) == 0);
+ assert_num_eq (CKF_LOGIN_REQUIRED | CKF_USER_PIN_INITIALIZED | CKF_CLOCK_ON_TOKEN | CKF_TOKEN_INITIALIZED, info.flags);
+ assert_num_eq (1, info.ulMaxSessionCount);
+ assert_num_eq (2, info.ulSessionCount);
+ assert_num_eq (3, info.ulMaxRwSessionCount);
+ assert_num_eq (4, info.ulRwSessionCount);
+ assert_num_eq (5, info.ulMaxPinLen);
+ assert_num_eq (6, info.ulMinPinLen);
+ assert_num_eq (7, info.ulTotalPublicMemory);
+ assert_num_eq (8, info.ulFreePublicMemory);
+ assert_num_eq (9, info.ulTotalPrivateMemory);
+ assert_num_eq (10, info.ulFreePrivateMemory);
+ assert_num_eq (75, info.hardwareVersion.major);
+ assert_num_eq (175, info.hardwareVersion.minor);
+ assert_num_eq (85, info.firmwareVersion.major);
+ assert_num_eq (185, info.firmwareVersion.minor);
+ assert (memcmp (info.utcTime, "1999052509195900", sizeof (info.utcTime)) == 0);
rv = (module->C_GetTokenInfo) (MOCK_SLOT_TWO_ID, &info);
- CuAssertTrue (tc, rv == CKR_TOKEN_NOT_PRESENT);
+ assert (rv == CKR_TOKEN_NOT_PRESENT);
rv = (module->C_GetTokenInfo) (0, &info);
- CuAssertTrue (tc, rv == CKR_SLOT_ID_INVALID);
+ assert (rv == CKR_SLOT_ID_INVALID);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_get_mechanism_list (CuTest *tc)
+test_get_mechanism_list (void)
{
CK_FUNCTION_LIST_PTR module;
CK_MECHANISM_TYPE mechs[8];
CK_ULONG count = 0;
CK_RV rv;
- module = setup_mock_module (tc, NULL);
+ module = setup_mock_module (NULL);
rv = (module->C_GetMechanismList) (MOCK_SLOT_ONE_ID, NULL, &count);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertIntEquals (tc, 2, count);
+ assert (rv == CKR_OK);
+ assert_num_eq (2, count);
rv = (module->C_GetMechanismList) (MOCK_SLOT_TWO_ID, NULL, &count);
- CuAssertTrue (tc, rv == CKR_TOKEN_NOT_PRESENT);
+ assert (rv == CKR_TOKEN_NOT_PRESENT);
rv = (module->C_GetMechanismList) (0, NULL, &count);
- CuAssertTrue (tc, rv == CKR_SLOT_ID_INVALID);
+ assert (rv == CKR_SLOT_ID_INVALID);
count = 8;
rv = (module->C_GetMechanismList) (MOCK_SLOT_ONE_ID, mechs, &count);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertIntEquals (tc, 2, count);
- CuAssertIntEquals (tc, mechs[0], CKM_MOCK_CAPITALIZE);
- CuAssertIntEquals (tc, mechs[1], CKM_MOCK_PREFIX);
+ assert (rv == CKR_OK);
+ assert_num_eq (2, count);
+ assert_num_eq (mechs[0], CKM_MOCK_CAPITALIZE);
+ assert_num_eq (mechs[1], CKM_MOCK_PREFIX);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_get_mechanism_info (CuTest *tc)
+test_get_mechanism_info (void)
{
CK_FUNCTION_LIST_PTR module;
CK_MECHANISM_INFO info;
CK_RV rv;
- module = setup_mock_module (tc, NULL);
+ module = setup_mock_module (NULL);
rv = (module->C_GetMechanismInfo) (MOCK_SLOT_ONE_ID, CKM_MOCK_CAPITALIZE, &info);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertIntEquals (tc, 512, info.ulMinKeySize);
- CuAssertIntEquals (tc, 4096, info.ulMaxKeySize);
- CuAssertIntEquals (tc, CKF_ENCRYPT | CKF_DECRYPT, info.flags);
+ assert (rv == CKR_OK);
+ assert_num_eq (512, info.ulMinKeySize);
+ assert_num_eq (4096, info.ulMaxKeySize);
+ assert_num_eq (CKF_ENCRYPT | CKF_DECRYPT, info.flags);
rv = (module->C_GetMechanismInfo) (MOCK_SLOT_ONE_ID, CKM_MOCK_PREFIX, &info);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertIntEquals (tc, 2048, info.ulMinKeySize);
- CuAssertIntEquals (tc, 2048, info.ulMaxKeySize);
- CuAssertIntEquals (tc, CKF_SIGN | CKF_VERIFY, info.flags);
+ assert (rv == CKR_OK);
+ assert_num_eq (2048, info.ulMinKeySize);
+ assert_num_eq (2048, info.ulMaxKeySize);
+ assert_num_eq (CKF_SIGN | CKF_VERIFY, info.flags);
rv = (module->C_GetMechanismInfo) (MOCK_SLOT_TWO_ID, CKM_MOCK_PREFIX, &info);
- CuAssertTrue (tc, rv == CKR_TOKEN_NOT_PRESENT);
+ assert (rv == CKR_TOKEN_NOT_PRESENT);
rv = (module->C_GetMechanismInfo) (MOCK_SLOT_ONE_ID, 0, &info);
- CuAssertTrue (tc, rv == CKR_MECHANISM_INVALID);
+ assert (rv == CKR_MECHANISM_INVALID);
rv = (module->C_GetMechanismInfo) (0, CKM_MOCK_PREFIX, &info);
- CuAssertTrue (tc, rv == CKR_SLOT_ID_INVALID);
+ assert (rv == CKR_SLOT_ID_INVALID);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_init_token (CuTest *tc)
+test_init_token (void)
{
CK_FUNCTION_LIST_PTR module;
CK_RV rv;
- module = setup_mock_module (tc, NULL);
+ module = setup_mock_module (NULL);
rv = (module->C_InitToken) (MOCK_SLOT_ONE_ID, (CK_UTF8CHAR_PTR)"TEST PIN", 8, (CK_UTF8CHAR_PTR)"TEST LABEL");
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_InitToken) (MOCK_SLOT_ONE_ID, (CK_UTF8CHAR_PTR)"OTHER", 5, (CK_UTF8CHAR_PTR)"TEST LABEL");
- CuAssertTrue (tc, rv == CKR_PIN_INVALID);
+ assert (rv == CKR_PIN_INVALID);
rv = (module->C_InitToken) (MOCK_SLOT_TWO_ID, (CK_UTF8CHAR_PTR)"TEST PIN", 8, (CK_UTF8CHAR_PTR)"TEST LABEL");
- CuAssertTrue (tc, rv == CKR_TOKEN_NOT_PRESENT);
+ assert (rv == CKR_TOKEN_NOT_PRESENT);
rv = (module->C_InitToken) (0, (CK_UTF8CHAR_PTR)"TEST PIN", 8, (CK_UTF8CHAR_PTR)"TEST LABEL");
- CuAssertTrue (tc, rv == CKR_SLOT_ID_INVALID);
+ assert (rv == CKR_SLOT_ID_INVALID);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_wait_for_slot_event (CuTest *tc)
+test_wait_for_slot_event (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SLOT_ID slot;
@@ -271,179 +271,179 @@ test_wait_for_slot_event (CuTest *tc)
return;
#endif
- module = setup_mock_module (tc, NULL);
+ module = setup_mock_module (NULL);
rv = (module->C_WaitForSlotEvent) (0, &slot, NULL);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertIntEquals (tc, slot, MOCK_SLOT_TWO_ID);
+ assert (rv == CKR_OK);
+ assert_num_eq (slot, MOCK_SLOT_TWO_ID);
rv = (module->C_WaitForSlotEvent) (CKF_DONT_BLOCK, &slot, NULL);
- CuAssertTrue (tc, rv == CKR_NO_EVENT);
+ assert (rv == CKR_NO_EVENT);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_open_close_session (CuTest *tc)
+test_open_close_session (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
CK_RV rv;
- module = setup_mock_module (tc, NULL);
+ module = setup_mock_module (NULL);
rv = (module->C_OpenSession) (MOCK_SLOT_TWO_ID, CKF_SERIAL_SESSION, NULL, NULL, &session);
- CuAssertTrue (tc, rv == CKR_TOKEN_NOT_PRESENT);
+ assert (rv == CKR_TOKEN_NOT_PRESENT);
rv = (module->C_OpenSession) (0, CKF_SERIAL_SESSION, NULL, NULL, &session);
- CuAssertTrue (tc, rv == CKR_SLOT_ID_INVALID);
+ assert (rv == CKR_SLOT_ID_INVALID);
rv = (module->C_OpenSession) (MOCK_SLOT_ONE_ID, CKF_SERIAL_SESSION, NULL, NULL, &session);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertTrue (tc, session != 0);
+ assert (rv == CKR_OK);
+ assert (session != 0);
rv = (module->C_CloseSession) (session);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_CloseSession) (session);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_close_all_sessions (CuTest *tc)
+test_close_all_sessions (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
CK_RV rv;
- module = setup_mock_module (tc, NULL);
+ module = setup_mock_module (NULL);
rv = (module->C_OpenSession) (MOCK_SLOT_ONE_ID, CKF_SERIAL_SESSION, NULL, NULL, &session);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertTrue (tc, session != 0);
+ assert (rv == CKR_OK);
+ assert (session != 0);
rv = (module->C_CloseAllSessions) (MOCK_SLOT_ONE_ID);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_CloseSession) (session);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_get_function_status (CuTest *tc)
+test_get_function_status (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_GetFunctionStatus) (session);
- CuAssertTrue (tc, rv == CKR_FUNCTION_NOT_PARALLEL);
+ assert (rv == CKR_FUNCTION_NOT_PARALLEL);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_cancel_function (CuTest *tc)
+test_cancel_function (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_CancelFunction) (session);
- CuAssertTrue (tc, rv == CKR_FUNCTION_NOT_PARALLEL);
+ assert (rv == CKR_FUNCTION_NOT_PARALLEL);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_get_session_info (CuTest *tc)
+test_get_session_info (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
CK_SESSION_INFO info;
CK_RV rv;
- module = setup_mock_module (tc, NULL);
+ module = setup_mock_module (NULL);
rv = (module->C_GetSessionInfo) (0, &info);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_OpenSession) (MOCK_SLOT_ONE_ID, CKF_SERIAL_SESSION, NULL, NULL, &session);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertTrue (tc, session != 0);
+ assert (rv == CKR_OK);
+ assert (session != 0);
rv = (module->C_GetSessionInfo) (session, &info);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertIntEquals (tc, MOCK_SLOT_ONE_ID, info.slotID);
- CuAssertIntEquals (tc, CKS_RO_PUBLIC_SESSION, info.state);
- CuAssertIntEquals (tc, CKF_SERIAL_SESSION, info.flags);
- CuAssertIntEquals (tc, 1414, info.ulDeviceError);
+ assert (rv == CKR_OK);
+ assert_num_eq (MOCK_SLOT_ONE_ID, info.slotID);
+ assert_num_eq (CKS_RO_PUBLIC_SESSION, info.state);
+ assert_num_eq (CKF_SERIAL_SESSION, info.flags);
+ assert_num_eq (1414, info.ulDeviceError);
rv = (module->C_OpenSession) (MOCK_SLOT_ONE_ID, CKF_RW_SESSION | CKF_SERIAL_SESSION, NULL, NULL, &session);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertTrue (tc, session != 0);
+ assert (rv == CKR_OK);
+ assert (session != 0);
rv = (module->C_GetSessionInfo) (session, &info);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertIntEquals (tc, MOCK_SLOT_ONE_ID, info.slotID);
- CuAssertIntEquals (tc, CKS_RW_PUBLIC_SESSION, info.state);
- CuAssertIntEquals (tc, CKF_SERIAL_SESSION | CKF_RW_SESSION, info.flags);
- CuAssertIntEquals (tc, 1414, info.ulDeviceError);
+ assert (rv == CKR_OK);
+ assert_num_eq (MOCK_SLOT_ONE_ID, info.slotID);
+ assert_num_eq (CKS_RW_PUBLIC_SESSION, info.state);
+ assert_num_eq (CKF_SERIAL_SESSION | CKF_RW_SESSION, info.flags);
+ assert_num_eq (1414, info.ulDeviceError);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_init_pin (CuTest *tc)
+test_init_pin (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_InitPIN) (0, (CK_UTF8CHAR_PTR)"TEST PIN", 8);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_InitPIN) (session, (CK_UTF8CHAR_PTR)"TEST PIN", 8);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_InitPIN) (session, (CK_UTF8CHAR_PTR)"OTHER", 5);
- CuAssertTrue (tc, rv == CKR_PIN_INVALID);
+ assert (rv == CKR_PIN_INVALID);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_set_pin (CuTest *tc)
+test_set_pin (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_SetPIN) (0, (CK_UTF8CHAR_PTR)"booo", 4, (CK_UTF8CHAR_PTR)"TEST PIN", 8);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_SetPIN) (session, (CK_UTF8CHAR_PTR)"booo", 4, (CK_UTF8CHAR_PTR)"TEST PIN", 8);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_SetPIN) (session, (CK_UTF8CHAR_PTR)"other", 5, (CK_UTF8CHAR_PTR)"OTHER", 5);
- CuAssertTrue (tc, rv == CKR_PIN_INCORRECT);
+ assert (rv == CKR_PIN_INCORRECT);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_operation_state (CuTest *tc)
+test_operation_state (void)
{
CK_FUNCTION_LIST_PTR module;
CK_BYTE state[128];
@@ -451,54 +451,54 @@ test_operation_state (CuTest *tc)
CK_SESSION_HANDLE session = 0;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
state_len = sizeof (state);
rv = (module->C_GetOperationState) (0, state, &state_len);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
state_len = sizeof (state);
rv = (module->C_GetOperationState) (session, state, &state_len);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_SetOperationState) (session, state, state_len, 355, 455);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_SetOperationState) (0, state, state_len, 355, 455);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_login_logout (CuTest *tc)
+test_login_logout (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_Login) (0, CKU_USER, (CK_UTF8CHAR_PTR)"booo", 4);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_Login) (session, CKU_USER, (CK_UTF8CHAR_PTR)"bo", 2);
- CuAssertTrue (tc, rv == CKR_PIN_INCORRECT);
+ assert (rv == CKR_PIN_INCORRECT);
rv = (module->C_Login) (session, CKU_USER, (CK_UTF8CHAR_PTR)"booo", 4);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_Logout) (session);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_Logout) (session);
- CuAssertTrue (tc, rv == CKR_USER_NOT_LOGGED_IN);
+ assert (rv == CKR_USER_NOT_LOGGED_IN);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_get_attribute_value (CuTest *tc)
+test_get_attribute_value (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -507,7 +507,7 @@ test_get_attribute_value (CuTest *tc)
CK_OBJECT_CLASS klass;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
attrs[0].type = CKA_CLASS;
attrs[0].pValue = &klass;
@@ -520,44 +520,44 @@ test_get_attribute_value (CuTest *tc)
attrs[2].ulValueLen = 0;
rv = (module->C_GetAttributeValue) (session, MOCK_PRIVATE_KEY_CAPITALIZE, attrs, 3);
- CuAssertTrue (tc, rv == CKR_USER_NOT_LOGGED_IN);
+ assert (rv == CKR_USER_NOT_LOGGED_IN);
rv = (module->C_GetAttributeValue) (session, MOCK_PUBLIC_KEY_CAPITALIZE, attrs, 2);
- CuAssertTrue (tc, rv == CKR_BUFFER_TOO_SMALL);
+ assert (rv == CKR_BUFFER_TOO_SMALL);
/* Get right size */
attrs[1].pValue = NULL;
attrs[1].ulValueLen = 0;
rv = (module->C_GetAttributeValue) (session, MOCK_PUBLIC_KEY_CAPITALIZE, attrs, 2);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_GetAttributeValue) (session, MOCK_PUBLIC_KEY_CAPITALIZE, attrs, 3);
- CuAssertTrue (tc, rv == CKR_ATTRIBUTE_TYPE_INVALID);
+ assert (rv == CKR_ATTRIBUTE_TYPE_INVALID);
- CuAssertIntEquals (tc, CKO_PUBLIC_KEY, klass);
- CuAssertIntEquals (tc, 21, attrs[1].ulValueLen);
- CuAssertPtrEquals (tc, NULL, attrs[1].pValue);
+ assert_num_eq (CKO_PUBLIC_KEY, klass);
+ assert_num_eq (21, attrs[1].ulValueLen);
+ assert_ptr_eq (NULL, attrs[1].pValue);
attrs[1].pValue = label;
attrs[1].ulValueLen = sizeof (label);
- CuAssertTrue (tc, (CK_ULONG)-1 == attrs[2].ulValueLen);
- CuAssertPtrEquals (tc, NULL, attrs[2].pValue);
+ assert ((CK_ULONG)-1 == attrs[2].ulValueLen);
+ assert_ptr_eq (NULL, attrs[2].pValue);
rv = (module->C_GetAttributeValue) (session, MOCK_PUBLIC_KEY_CAPITALIZE, attrs, 3);
- CuAssertTrue (tc, rv == CKR_ATTRIBUTE_TYPE_INVALID);
+ assert (rv == CKR_ATTRIBUTE_TYPE_INVALID);
- CuAssertIntEquals (tc, CKO_PUBLIC_KEY, klass);
- CuAssertIntEquals (tc, 21, attrs[1].ulValueLen);
- CuAssertPtrEquals (tc, label, attrs[1].pValue);
- CuAssertTrue (tc, memcmp (label, "Public Capitalize Key", attrs[1].ulValueLen) == 0);
- CuAssertTrue (tc, (CK_ULONG)-1 == attrs[2].ulValueLen);
- CuAssertPtrEquals (tc, NULL, attrs[2].pValue);
+ assert_num_eq (CKO_PUBLIC_KEY, klass);
+ assert_num_eq (21, attrs[1].ulValueLen);
+ assert_ptr_eq (label, attrs[1].pValue);
+ assert (memcmp (label, "Public Capitalize Key", attrs[1].ulValueLen) == 0);
+ assert ((CK_ULONG)-1 == attrs[2].ulValueLen);
+ assert_ptr_eq (NULL, attrs[2].pValue);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_set_attribute_value (CuTest *tc)
+test_set_attribute_value (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -566,7 +566,7 @@ test_set_attribute_value (CuTest *tc)
CK_ULONG bits;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
strcpy (label, "Blahooo");
bits = 1555;
@@ -579,26 +579,26 @@ test_set_attribute_value (CuTest *tc)
attrs[1].ulValueLen = sizeof (bits);
rv = (module->C_SetAttributeValue) (session, MOCK_PRIVATE_KEY_CAPITALIZE, attrs, 2);
- CuAssertTrue (tc, rv == CKR_USER_NOT_LOGGED_IN);
+ assert (rv == CKR_USER_NOT_LOGGED_IN);
rv = (module->C_SetAttributeValue) (session, MOCK_PUBLIC_KEY_CAPITALIZE, attrs, 2);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
memset (label, 0, sizeof (label));
bits = 0;
rv = (module->C_GetAttributeValue) (session, MOCK_PUBLIC_KEY_CAPITALIZE, attrs, 2);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, bits, 1555);
- CuAssertIntEquals (tc, 7, attrs[0].ulValueLen);
- CuAssertTrue (tc, memcmp (label, "Blahooo", attrs[0].ulValueLen) == 0);
+ assert_num_eq (bits, 1555);
+ assert_num_eq (7, attrs[0].ulValueLen);
+ assert (memcmp (label, "Blahooo", attrs[0].ulValueLen) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_create_object (CuTest *tc)
+test_create_object (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -608,7 +608,7 @@ test_create_object (CuTest *tc)
CK_ULONG bits;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
strcpy (label, "Blahooo");
bits = 1555;
@@ -621,27 +621,27 @@ test_create_object (CuTest *tc)
attrs[1].ulValueLen = sizeof (bits);
rv = (module->C_CreateObject) (0, attrs, 2, &object);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_CreateObject) (session, attrs, 2, &object);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
attrs[0].ulValueLen = sizeof (label);
memset (label, 0, sizeof (label));
bits = 0;
rv = (module->C_GetAttributeValue) (session, object, attrs, 2);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, bits, 1555);
- CuAssertIntEquals (tc, 7, attrs[0].ulValueLen);
- CuAssertTrue (tc, memcmp (label, "Blahooo", attrs[0].ulValueLen) == 0);
+ assert_num_eq (bits, 1555);
+ assert_num_eq (7, attrs[0].ulValueLen);
+ assert (memcmp (label, "Blahooo", attrs[0].ulValueLen) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_copy_object (CuTest *tc)
+test_copy_object (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -651,7 +651,7 @@ test_copy_object (CuTest *tc)
CK_ULONG bits;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
bits = 1555;
@@ -660,10 +660,10 @@ test_copy_object (CuTest *tc)
attrs[0].ulValueLen = sizeof (bits);
rv = (module->C_CopyObject) (session, 1333, attrs, 1, &object);
- CuAssertTrue (tc, rv == CKR_OBJECT_HANDLE_INVALID);
+ assert (rv == CKR_OBJECT_HANDLE_INVALID);
rv = (module->C_CopyObject) (session, MOCK_PUBLIC_KEY_CAPITALIZE, attrs, 1, &object);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
attrs[1].type = CKA_LABEL;
attrs[1].pValue = label;
@@ -671,17 +671,17 @@ test_copy_object (CuTest *tc)
bits = 0;
rv = (module->C_GetAttributeValue) (session, object, attrs, 2);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, bits, 1555);
- CuAssertIntEquals (tc, 21, attrs[1].ulValueLen);
- CuAssertTrue (tc, memcmp (label, "Public Capitalize Key", attrs[1].ulValueLen) == 0);
+ assert_num_eq (bits, 1555);
+ assert_num_eq (21, attrs[1].ulValueLen);
+ assert (memcmp (label, "Public Capitalize Key", attrs[1].ulValueLen) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_destroy_object (CuTest *tc)
+test_destroy_object (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -689,51 +689,51 @@ test_destroy_object (CuTest *tc)
char label[32];
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
attrs[0].type = CKA_LABEL;
attrs[0].pValue = label;
attrs[0].ulValueLen = sizeof (label);
rv = (module->C_GetAttributeValue) (session, MOCK_PUBLIC_KEY_CAPITALIZE, attrs, 1);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_DestroyObject) (0, MOCK_PUBLIC_KEY_CAPITALIZE);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_DestroyObject) (session, MOCK_PUBLIC_KEY_CAPITALIZE);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_GetAttributeValue) (session, MOCK_PUBLIC_KEY_CAPITALIZE, attrs, 1);
- CuAssertTrue (tc, rv == CKR_OBJECT_HANDLE_INVALID);
+ assert (rv == CKR_OBJECT_HANDLE_INVALID);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_get_object_size (CuTest *tc)
+test_get_object_size (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
CK_ULONG size;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_GetObjectSize) (session, 1333, &size);
- CuAssertTrue (tc, rv == CKR_OBJECT_HANDLE_INVALID);
+ assert (rv == CKR_OBJECT_HANDLE_INVALID);
rv = (module->C_GetObjectSize) (session, MOCK_PUBLIC_KEY_CAPITALIZE, &size);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
/* The number here is the length of all attributes added up */
- CuAssertIntEquals (tc, sizeof (CK_ULONG) == 8 ? 44 : 36, size);
+ assert_num_eq (sizeof (CK_ULONG) == 8 ? 44 : 36, size);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_find_objects (CuTest *tc)
+test_find_objects (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -744,55 +744,55 @@ test_find_objects (CuTest *tc)
CK_ULONG i;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_FindObjectsInit) (0, &attr, 1);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_FindObjectsInit) (session, &attr, 1);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_FindObjects) (0, objects, 16, &count);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_FindObjects) (session, objects, 16, &count);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertTrue (tc, count < 16);
+ assert (count < 16);
/* Make sure we get the capitalize public key */
for (i = 0; i < count; i++) {
if (objects[i] == MOCK_PUBLIC_KEY_CAPITALIZE)
break;
}
- CuAssertTrue (tc, i != count);
+ assert (i != count);
/* Make sure we get the prefix public key */
for (i = 0; i < count; i++) {
if (objects[i] == MOCK_PUBLIC_KEY_PREFIX)
break;
}
- CuAssertTrue (tc, i != count);
+ assert (i != count);
/* Make sure all public keys */
for (i = 0; i < count; i++) {
klass = (CK_ULONG)-1;
rv = (module->C_GetAttributeValue) (session, objects[i], &attr, 1);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertIntEquals (tc, CKO_PUBLIC_KEY, klass);
+ assert (rv == CKR_OK);
+ assert_num_eq (CKO_PUBLIC_KEY, klass);
}
rv = (module->C_FindObjectsFinal) (session);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_FindObjectsFinal) (session);
- CuAssertTrue (tc, rv == CKR_OPERATION_NOT_INITIALIZED);
+ assert (rv == CKR_OPERATION_NOT_INITIALIZED);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_encrypt (CuTest *tc)
+test_encrypt (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -801,52 +801,52 @@ test_encrypt (CuTest *tc)
CK_ULONG length;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_EncryptInit) (session, &mech, MOCK_PUBLIC_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_KEY_HANDLE_INVALID);
+ assert (rv == CKR_KEY_HANDLE_INVALID);
rv = (module->C_EncryptInit) (session, &mech, MOCK_PUBLIC_KEY_CAPITALIZE);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (data);
rv = (module->C_Encrypt) (0, (CK_BYTE_PTR)"blah", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (data);
rv = (module->C_Encrypt) (session, (CK_BYTE_PTR)"blah", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 4, length);
- CuAssertTrue (tc, memcmp (data, "BLAH", 4) == 0);
+ assert_num_eq (4, length);
+ assert (memcmp (data, "BLAH", 4) == 0);
rv = (module->C_EncryptInit) (session, &mech, MOCK_PUBLIC_KEY_CAPITALIZE);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (data);
rv = (module->C_EncryptUpdate) (0, (CK_BYTE_PTR)"blah", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (data);
rv = (module->C_EncryptUpdate) (session, (CK_BYTE_PTR)"sLurm", 5, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 5, length);
- CuAssertTrue (tc, memcmp (data, "SLURM", 5) == 0);
+ assert_num_eq (5, length);
+ assert (memcmp (data, "SLURM", 5) == 0);
length = sizeof (data);
rv = (module->C_EncryptFinal) (0, data, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (data);
rv = (module->C_EncryptFinal) (session, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_decrypt (CuTest *tc)
+test_decrypt (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -855,55 +855,55 @@ test_decrypt (CuTest *tc)
CK_ULONG length;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_Login) (session, CKU_USER, (CK_BYTE_PTR)"booo", 4);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_DecryptInit) (session, &mech, MOCK_PRIVATE_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_KEY_HANDLE_INVALID);
+ assert (rv == CKR_KEY_HANDLE_INVALID);
rv = (module->C_DecryptInit) (session, &mech, MOCK_PRIVATE_KEY_CAPITALIZE);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (data);
rv = (module->C_Decrypt) (0, (CK_BYTE_PTR)"bLAH", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (data);
rv = (module->C_Decrypt) (session, (CK_BYTE_PTR)"BLAh", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 4, length);
- CuAssertTrue (tc, memcmp (data, "blah", 4) == 0);
+ assert_num_eq (4, length);
+ assert (memcmp (data, "blah", 4) == 0);
rv = (module->C_DecryptInit) (session, &mech, MOCK_PRIVATE_KEY_CAPITALIZE);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (data);
rv = (module->C_DecryptUpdate) (0, (CK_BYTE_PTR)"blah", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (data);
rv = (module->C_DecryptUpdate) (session, (CK_BYTE_PTR)"sLuRM", 5, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 5, length);
- CuAssertTrue (tc, memcmp (data, "slurm", 5) == 0);
+ assert_num_eq (5, length);
+ assert (memcmp (data, "slurm", 5) == 0);
length = sizeof (data);
rv = (module->C_DecryptFinal) (0, data, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (data);
rv = (module->C_DecryptFinal) (session, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_digest (CuTest *tc)
+test_digest (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -912,58 +912,58 @@ test_digest (CuTest *tc)
CK_ULONG length;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_DigestInit) (0, &mech);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_DigestInit) (session, &mech);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (digest);
rv = (module->C_Digest) (0, (CK_BYTE_PTR)"bLAH", 4, digest, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (digest);
rv = (module->C_Digest) (session, (CK_BYTE_PTR)"BLAh", 4, digest, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 1, length);
- CuAssertTrue (tc, memcmp (digest, "4", 1) == 0);
+ assert_num_eq (1, length);
+ assert (memcmp (digest, "4", 1) == 0);
rv = (module->C_DigestInit) (session, &mech);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_DigestUpdate) (0, (CK_BYTE_PTR)"blah", 4);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_DigestUpdate) (session, (CK_BYTE_PTR)"sLuRM", 5);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
/* Adds the the value of object handle to hash: 6 */
- CuAssertIntEquals (tc, 6, MOCK_PUBLIC_KEY_PREFIX);
+ assert_num_eq (6, MOCK_PUBLIC_KEY_PREFIX);
rv = (module->C_DigestKey) (session, MOCK_PUBLIC_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_DigestUpdate) (session, (CK_BYTE_PTR)"Other", 5);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (digest);
rv = (module->C_DigestFinal) (0, digest, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (digest);
rv = (module->C_DigestFinal) (session, digest, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 2, length);
- CuAssertTrue (tc, memcmp (digest, "16", 2) == 0);
+ assert_num_eq (2, length);
+ assert (memcmp (digest, "16", 2) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_sign (CuTest *tc)
+test_sign (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -972,62 +972,62 @@ test_sign (CuTest *tc)
CK_ULONG length;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_Login) (session, CKU_USER, (CK_BYTE_PTR)"booo", 4);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_SignInit) (0, &mech, MOCK_PRIVATE_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_SignInit) (session, &mech, MOCK_PRIVATE_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_Login) (session, CKU_CONTEXT_SPECIFIC, (CK_BYTE_PTR)"booo", 4);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (signature);
rv = (module->C_Sign) (0, (CK_BYTE_PTR)"bLAH", 4, signature, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (signature);
rv = (module->C_Sign) (session, (CK_BYTE_PTR)"BLAh", 4, signature, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 13, length);
- CuAssertTrue (tc, memcmp (signature, "prefix:value4", 13) == 0);
+ assert_num_eq (13, length);
+ assert (memcmp (signature, "prefix:value4", 13) == 0);
rv = (module->C_SignInit) (session, &mech, MOCK_PRIVATE_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_Login) (session, CKU_CONTEXT_SPECIFIC, (CK_BYTE_PTR)"booo", 4);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_SignUpdate) (0, (CK_BYTE_PTR)"blah", 4);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_SignUpdate) (session, (CK_BYTE_PTR)"sLuRM", 5);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_SignUpdate) (session, (CK_BYTE_PTR)"Other", 5);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (signature);
rv = (module->C_SignFinal) (0, signature, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (signature);
rv = (module->C_SignFinal) (session, signature, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 14, length);
- CuAssertTrue (tc, memcmp (signature, "prefix:value10", 2) == 0);
+ assert_num_eq (14, length);
+ assert (memcmp (signature, "prefix:value10", 2) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_sign_recover (CuTest *tc)
+test_sign_recover (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -1036,36 +1036,36 @@ test_sign_recover (CuTest *tc)
CK_ULONG length;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_Login) (session, CKU_USER, (CK_BYTE_PTR)"booo", 4);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_SignRecoverInit) (0, &mech, MOCK_PRIVATE_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_SignRecoverInit) (session, &mech, MOCK_PRIVATE_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_Login) (session, CKU_CONTEXT_SPECIFIC, (CK_BYTE_PTR)"booo", 4);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (signature);
rv = (module->C_SignRecover) (0, (CK_BYTE_PTR)"bLAH", 4, signature, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (signature);
rv = (module->C_SignRecover) (session, (CK_BYTE_PTR)"BLAh", 4, signature, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 16, length);
- CuAssertTrue (tc, memcmp (signature, "prefix:valueBLAh", 16) == 0);
+ assert_num_eq (16, length);
+ assert (memcmp (signature, "prefix:valueBLAh", 16) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_verify (CuTest *tc)
+test_verify (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -1074,48 +1074,48 @@ test_verify (CuTest *tc)
CK_ULONG length;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_VerifyInit) (0, &mech, MOCK_PUBLIC_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_VerifyInit) (session, &mech, MOCK_PUBLIC_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = 13;
memcpy (signature, "prefix:value4", length);
rv = (module->C_Verify) (0, (CK_BYTE_PTR)"bLAH", 4, signature, 5);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_Verify) (session, (CK_BYTE_PTR)"BLAh", 4, signature, length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_VerifyInit) (session, &mech, MOCK_PUBLIC_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_VerifyUpdate) (0, (CK_BYTE_PTR)"blah", 4);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_VerifyUpdate) (session, (CK_BYTE_PTR)"sLuRM", 5);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_VerifyUpdate) (session, (CK_BYTE_PTR)"Other", 5);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = 14;
memcpy (signature, "prefix:value10", length);
rv = (module->C_VerifyFinal) (session, signature, 5);
- CuAssertTrue (tc, rv == CKR_SIGNATURE_LEN_RANGE);
+ assert (rv == CKR_SIGNATURE_LEN_RANGE);
rv = (module->C_VerifyFinal) (session, signature, length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_verify_recover (CuTest *tc)
+test_verify_recover (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -1124,30 +1124,30 @@ test_verify_recover (CuTest *tc)
CK_ULONG length;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_VerifyRecoverInit) (0, &mech, MOCK_PUBLIC_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_VerifyRecoverInit) (session, &mech, MOCK_PUBLIC_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (data);
rv = (module->C_VerifyRecover) (0, (CK_BYTE_PTR)"prefix:valueBLah", 16, data, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (data);
rv = (module->C_VerifyRecover) (session, (CK_BYTE_PTR)"prefix:valueBLah", 16, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 4, length);
- CuAssertTrue (tc, memcmp (data, "BLah", 4) == 0);
+ assert_num_eq (4, length);
+ assert (memcmp (data, "BLah", 4) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_digest_encrypt (CuTest *tc)
+test_digest_encrypt (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -1157,41 +1157,41 @@ test_digest_encrypt (CuTest *tc)
CK_ULONG length;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_EncryptInit) (session, &mech, MOCK_PUBLIC_KEY_CAPITALIZE);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_DigestInit) (session, &dmech);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (data);
rv = (module->C_DigestEncryptUpdate) (0, (CK_BYTE_PTR)"blah", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (data);
rv = (module->C_DigestEncryptUpdate) (session, (CK_BYTE_PTR)"blah", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 4, length);
- CuAssertTrue (tc, memcmp (data, "BLAH", 4) == 0);
+ assert_num_eq (4, length);
+ assert (memcmp (data, "BLAH", 4) == 0);
length = sizeof (data);
rv = (module->C_EncryptFinal) (session, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (data);
rv = (module->C_DigestFinal) (session, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 1, length);
- CuAssertTrue (tc, memcmp (data, "4", 1) == 0);
+ assert_num_eq (1, length);
+ assert (memcmp (data, "4", 1) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_decrypt_digest (CuTest *tc)
+test_decrypt_digest (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -1201,44 +1201,44 @@ test_decrypt_digest (CuTest *tc)
CK_ULONG length;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_Login) (session, CKU_USER, (CK_BYTE_PTR)"booo", 4);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_DecryptInit) (session, &mech, MOCK_PRIVATE_KEY_CAPITALIZE);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_DigestInit) (session, &dmech);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (data);
rv = (module->C_DecryptDigestUpdate) (0, (CK_BYTE_PTR)"BLAH", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (data);
rv = (module->C_DecryptDigestUpdate) (session, (CK_BYTE_PTR)"BLAH", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 4, length);
- CuAssertTrue (tc, memcmp (data, "blah", 4) == 0);
+ assert_num_eq (4, length);
+ assert (memcmp (data, "blah", 4) == 0);
length = sizeof (data);
rv = (module->C_DecryptFinal) (session, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (data);
rv = (module->C_DigestFinal) (session, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 1, length);
- CuAssertTrue (tc, memcmp (data, "4", 1) == 0);
+ assert_num_eq (1, length);
+ assert (memcmp (data, "4", 1) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_sign_encrypt (CuTest *tc)
+test_sign_encrypt (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -1248,47 +1248,47 @@ test_sign_encrypt (CuTest *tc)
CK_ULONG length;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_Login) (session, CKU_USER, (CK_BYTE_PTR)"booo", 4);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_EncryptInit) (session, &mech, MOCK_PUBLIC_KEY_CAPITALIZE);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_SignInit) (session, &smech, MOCK_PRIVATE_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_Login) (session, CKU_CONTEXT_SPECIFIC, (CK_BYTE_PTR)"booo", 4);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (data);
rv = (module->C_SignEncryptUpdate) (0, (CK_BYTE_PTR)"blah", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (data);
rv = (module->C_SignEncryptUpdate) (session, (CK_BYTE_PTR)"blah", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 4, length);
- CuAssertTrue (tc, memcmp (data, "BLAH", 4) == 0);
+ assert_num_eq (4, length);
+ assert (memcmp (data, "BLAH", 4) == 0);
length = sizeof (data);
rv = (module->C_EncryptFinal) (session, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (data);
rv = (module->C_SignFinal) (session, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 8, length);
- CuAssertTrue (tc, memcmp (data, "p:value4", 1) == 0);
+ assert_num_eq (8, length);
+ assert (memcmp (data, "p:value4", 1) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_decrypt_verify (CuTest *tc)
+test_decrypt_verify (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -1298,40 +1298,40 @@ test_decrypt_verify (CuTest *tc)
CK_ULONG length;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_Login) (session, CKU_USER, (CK_BYTE_PTR)"booo", 4);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_DecryptInit) (session, &mech, MOCK_PRIVATE_KEY_CAPITALIZE);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_VerifyInit) (session, &vmech, MOCK_PUBLIC_KEY_PREFIX);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
length = sizeof (data);
rv = (module->C_DecryptVerifyUpdate) (0, (CK_BYTE_PTR)"BLAH", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
length = sizeof (data);
rv = (module->C_DecryptVerifyUpdate) (session, (CK_BYTE_PTR)"BLAH", 4, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 4, length);
- CuAssertTrue (tc, memcmp (data, "blah", 4) == 0);
+ assert_num_eq (4, length);
+ assert (memcmp (data, "blah", 4) == 0);
length = sizeof (data);
rv = (module->C_DecryptFinal) (session, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_VerifyFinal) (session, (CK_BYTE_PTR)"p:value4", 8);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_generate_key (CuTest *tc)
+test_generate_key (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -1343,7 +1343,7 @@ test_generate_key (CuTest *tc)
CK_ULONG bits;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
strcpy (label, "Blahooo");
bits = 1555;
@@ -1356,13 +1356,13 @@ test_generate_key (CuTest *tc)
attrs[1].ulValueLen = sizeof (bits);
rv = (module->C_GenerateKey) (session, &mech, attrs, 2, &object);
- CuAssertTrue (tc, rv == CKR_MECHANISM_PARAM_INVALID);
+ assert (rv == CKR_MECHANISM_PARAM_INVALID);
mech.pParameter = "generate";
mech.ulParameterLen = 9;
rv = (module->C_GenerateKey) (session, &mech, attrs, 2, &object);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
attrs[0].ulValueLen = sizeof (label);
memset (label, 0, sizeof (label));
@@ -1372,19 +1372,19 @@ test_generate_key (CuTest *tc)
attrs[2].ulValueLen = sizeof (value);
rv = (module->C_GetAttributeValue) (session, object, attrs, 3);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, bits, 1555);
- CuAssertIntEquals (tc, 7, attrs[0].ulValueLen);
- CuAssertTrue (tc, memcmp (label, "Blahooo", attrs[0].ulValueLen) == 0);
- CuAssertIntEquals (tc, 9, attrs[2].ulValueLen);
- CuAssertTrue (tc, memcmp (value, "generated", attrs[2].ulValueLen) == 0);
+ assert_num_eq (bits, 1555);
+ assert_num_eq (7, attrs[0].ulValueLen);
+ assert (memcmp (label, "Blahooo", attrs[0].ulValueLen) == 0);
+ assert_num_eq (9, attrs[2].ulValueLen);
+ assert (memcmp (value, "generated", attrs[2].ulValueLen) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_generate_key_pair (CuTest *tc)
+test_generate_key_pair (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -1401,7 +1401,7 @@ test_generate_key_pair (CuTest *tc)
CK_ULONG priv_bits;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
strcpy (pub_label, "Blahooo");
pub_bits = 1555;
@@ -1423,14 +1423,14 @@ test_generate_key_pair (CuTest *tc)
rv = (module->C_GenerateKeyPair) (0, &mech, pub_attrs, 2, priv_attrs, 2,
&pub_object, &priv_object);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
mech.pParameter = "generate";
mech.ulParameterLen = 9;
rv = (module->C_GenerateKeyPair) (session, &mech, pub_attrs, 2, priv_attrs, 2,
&pub_object, &priv_object);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
pub_bits = 0;
pub_attrs[0].ulValueLen = sizeof (pub_label);
@@ -1440,13 +1440,13 @@ test_generate_key_pair (CuTest *tc)
pub_attrs[2].ulValueLen = sizeof (pub_value);
rv = (module->C_GetAttributeValue) (session, pub_object, pub_attrs, 3);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 1555, pub_bits);
- CuAssertIntEquals (tc, 7, pub_attrs[0].ulValueLen);
- CuAssertTrue (tc, memcmp (pub_label, "Blahooo", pub_attrs[0].ulValueLen) == 0);
- CuAssertIntEquals (tc, 9, pub_attrs[2].ulValueLen);
- CuAssertTrue (tc, memcmp (pub_value, "generated", pub_attrs[2].ulValueLen) == 0);
+ assert_num_eq (1555, pub_bits);
+ assert_num_eq (7, pub_attrs[0].ulValueLen);
+ assert (memcmp (pub_label, "Blahooo", pub_attrs[0].ulValueLen) == 0);
+ assert_num_eq (9, pub_attrs[2].ulValueLen);
+ assert (memcmp (pub_value, "generated", pub_attrs[2].ulValueLen) == 0);
priv_bits = 0;
priv_attrs[0].ulValueLen = sizeof (priv_label);
@@ -1456,19 +1456,19 @@ test_generate_key_pair (CuTest *tc)
priv_attrs[2].ulValueLen = sizeof (priv_value);
rv = (module->C_GetAttributeValue) (session, priv_object, priv_attrs, 3);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 1666, priv_bits);
- CuAssertIntEquals (tc, 7, priv_attrs[0].ulValueLen);
- CuAssertTrue (tc, memcmp (priv_label, "Private", priv_attrs[0].ulValueLen) == 0);
- CuAssertIntEquals (tc, 9, priv_attrs[2].ulValueLen);
- CuAssertTrue (tc, memcmp (priv_value, "generated", priv_attrs[2].ulValueLen) == 0);
+ assert_num_eq (1666, priv_bits);
+ assert_num_eq (7, priv_attrs[0].ulValueLen);
+ assert (memcmp (priv_label, "Private", priv_attrs[0].ulValueLen) == 0);
+ assert_num_eq (9, priv_attrs[2].ulValueLen);
+ assert (memcmp (priv_value, "generated", priv_attrs[2].ulValueLen) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_wrap_key (CuTest *tc)
+test_wrap_key (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -1477,26 +1477,26 @@ test_wrap_key (CuTest *tc)
CK_ULONG length;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
length = sizeof (data);
rv = (module->C_WrapKey) (session, &mech, MOCK_PUBLIC_KEY_PREFIX, MOCK_PUBLIC_KEY_PREFIX, data, &length);
- CuAssertTrue (tc, rv == CKR_MECHANISM_PARAM_INVALID);
+ assert (rv == CKR_MECHANISM_PARAM_INVALID);
mech.pParameter = "wrap";
mech.ulParameterLen = 4;
rv = (module->C_WrapKey) (session, &mech, MOCK_PUBLIC_KEY_PREFIX, MOCK_PUBLIC_KEY_PREFIX, data, &length);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, 5, length);
- CuAssertTrue (tc, memcmp (data, "value", 5) == 0);
+ assert_num_eq (5, length);
+ assert (memcmp (data, "value", 5) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_unwrap_key (CuTest *tc)
+test_unwrap_key (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -1508,7 +1508,7 @@ test_unwrap_key (CuTest *tc)
CK_ULONG bits;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
strcpy (label, "Blahooo");
bits = 1555;
@@ -1522,14 +1522,14 @@ test_unwrap_key (CuTest *tc)
rv = (module->C_UnwrapKey) (session, &mech, MOCK_PUBLIC_KEY_PREFIX,
(CK_BYTE_PTR)"wheee", 5, attrs, 2, &object);
- CuAssertTrue (tc, rv == CKR_MECHANISM_PARAM_INVALID);
+ assert (rv == CKR_MECHANISM_PARAM_INVALID);
mech.pParameter = "wrap";
mech.ulParameterLen = 4;
rv = (module->C_UnwrapKey) (session, &mech, MOCK_PUBLIC_KEY_PREFIX,
(CK_BYTE_PTR)"wheee", 5, attrs, 2, &object);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
attrs[0].ulValueLen = sizeof (label);
memset (label, 0, sizeof (label));
@@ -1539,19 +1539,19 @@ test_unwrap_key (CuTest *tc)
attrs[2].ulValueLen = sizeof (value);
rv = (module->C_GetAttributeValue) (session, object, attrs, 3);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, bits, 1555);
- CuAssertIntEquals (tc, 7, attrs[0].ulValueLen);
- CuAssertTrue (tc, memcmp (label, "Blahooo", attrs[0].ulValueLen) == 0);
- CuAssertIntEquals (tc, 5, attrs[2].ulValueLen);
- CuAssertTrue (tc, memcmp (value, "wheee", attrs[2].ulValueLen) == 0);
+ assert_num_eq (bits, 1555);
+ assert_num_eq (7, attrs[0].ulValueLen);
+ assert (memcmp (label, "Blahooo", attrs[0].ulValueLen) == 0);
+ assert_num_eq (5, attrs[2].ulValueLen);
+ assert (memcmp (value, "wheee", attrs[2].ulValueLen) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_derive_key (CuTest *tc)
+test_derive_key (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
@@ -1563,7 +1563,7 @@ test_derive_key (CuTest *tc)
CK_ULONG bits;
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
strcpy (label, "Blahooo");
bits = 1555;
@@ -1577,14 +1577,14 @@ test_derive_key (CuTest *tc)
rv = (module->C_DeriveKey) (session, &mech, MOCK_PUBLIC_KEY_PREFIX,
attrs, 2, &object);
- CuAssertTrue (tc, rv == CKR_MECHANISM_PARAM_INVALID);
+ assert (rv == CKR_MECHANISM_PARAM_INVALID);
mech.pParameter = "derive";
mech.ulParameterLen = 6;
rv = (module->C_DeriveKey) (session, &mech, MOCK_PUBLIC_KEY_PREFIX,
attrs, 2, &object);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
attrs[0].ulValueLen = sizeof (label);
memset (label, 0, sizeof (label));
@@ -1594,86 +1594,86 @@ test_derive_key (CuTest *tc)
attrs[2].ulValueLen = sizeof (value);
rv = (module->C_GetAttributeValue) (session, object, attrs, 3);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertIntEquals (tc, bits, 1555);
- CuAssertIntEquals (tc, 7, attrs[0].ulValueLen);
- CuAssertTrue (tc, memcmp (label, "Blahooo", attrs[0].ulValueLen) == 0);
- CuAssertIntEquals (tc, 7, attrs[2].ulValueLen);
- CuAssertTrue (tc, memcmp (value, "derived", attrs[2].ulValueLen) == 0);
+ assert_num_eq (bits, 1555);
+ assert_num_eq (7, attrs[0].ulValueLen);
+ assert (memcmp (label, "Blahooo", attrs[0].ulValueLen) == 0);
+ assert_num_eq (7, attrs[2].ulValueLen);
+ assert (memcmp (value, "derived", attrs[2].ulValueLen) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_random (CuTest *tc)
+test_random (void)
{
CK_FUNCTION_LIST_PTR module;
CK_SESSION_HANDLE session = 0;
CK_BYTE data[10];
CK_RV rv;
- module = setup_mock_module (tc, &session);
+ module = setup_mock_module (&session);
rv = (module->C_SeedRandom) (0, (CK_BYTE_PTR)"seed", 4);
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_SeedRandom) (session, (CK_BYTE_PTR)"seed", 4);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = (module->C_GenerateRandom) (0, data, sizeof (data));
- CuAssertTrue (tc, rv == CKR_SESSION_HANDLE_INVALID);
+ assert (rv == CKR_SESSION_HANDLE_INVALID);
rv = (module->C_GenerateRandom) (session, data, sizeof (data));
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertTrue (tc, memcmp (data, "seedseedse", sizeof (data)) == 0);
+ assert (memcmp (data, "seedseedse", sizeof (data)) == 0);
- teardown_mock_module (tc, module);
+ teardown_mock_module (module);
}
static void
-test_mock_add_tests (CuSuite *suite)
+test_mock_add_tests (const char *prefix)
{
- SUITE_ADD_TEST (suite, test_get_info);
- SUITE_ADD_TEST (suite, test_get_slot_list);
- SUITE_ADD_TEST (suite, test_get_slot_info);
- SUITE_ADD_TEST (suite, test_get_token_info);
- SUITE_ADD_TEST (suite, test_get_mechanism_list);
- SUITE_ADD_TEST (suite, test_get_mechanism_info);
- SUITE_ADD_TEST (suite, test_init_token);
- SUITE_ADD_TEST (suite, test_wait_for_slot_event);
- SUITE_ADD_TEST (suite, test_open_close_session);
- SUITE_ADD_TEST (suite, test_close_all_sessions);
- SUITE_ADD_TEST (suite, test_get_function_status);
- SUITE_ADD_TEST (suite, test_cancel_function);
- SUITE_ADD_TEST (suite, test_get_session_info);
- SUITE_ADD_TEST (suite, test_init_pin);
- SUITE_ADD_TEST (suite, test_set_pin);
- SUITE_ADD_TEST (suite, test_operation_state);
- SUITE_ADD_TEST (suite, test_login_logout);
- SUITE_ADD_TEST (suite, test_get_attribute_value);
- SUITE_ADD_TEST (suite, test_set_attribute_value);
- SUITE_ADD_TEST (suite, test_create_object);
- SUITE_ADD_TEST (suite, test_copy_object);
- SUITE_ADD_TEST (suite, test_destroy_object);
- SUITE_ADD_TEST (suite, test_get_object_size);
- SUITE_ADD_TEST (suite, test_find_objects);
- SUITE_ADD_TEST (suite, test_encrypt);
- SUITE_ADD_TEST (suite, test_decrypt);
- SUITE_ADD_TEST (suite, test_digest);
- SUITE_ADD_TEST (suite, test_sign);
- SUITE_ADD_TEST (suite, test_sign_recover);
- SUITE_ADD_TEST (suite, test_verify);
- SUITE_ADD_TEST (suite, test_verify_recover);
- SUITE_ADD_TEST (suite, test_digest_encrypt);
- SUITE_ADD_TEST (suite, test_decrypt_digest);
- SUITE_ADD_TEST (suite, test_sign_encrypt);
- SUITE_ADD_TEST (suite, test_decrypt_verify);
- SUITE_ADD_TEST (suite, test_generate_key);
- SUITE_ADD_TEST (suite, test_generate_key_pair);
- SUITE_ADD_TEST (suite, test_wrap_key);
- SUITE_ADD_TEST (suite, test_unwrap_key);
- SUITE_ADD_TEST (suite, test_derive_key);
- SUITE_ADD_TEST (suite, test_random);
+ p11_test (test_get_info, "%s/test_get_info", prefix);
+ p11_test (test_get_slot_list, "%s/test_get_slot_list", prefix);
+ p11_test (test_get_slot_info, "%s/test_get_slot_info", prefix);
+ p11_test (test_get_token_info, "%s/test_get_token_info", prefix);
+ p11_test (test_get_mechanism_list, "%s/test_get_mechanism_list", prefix);
+ p11_test (test_get_mechanism_info, "%s/test_get_mechanism_info", prefix);
+ p11_test (test_init_token, "%s/test_init_token", prefix);
+ p11_test (test_wait_for_slot_event, "%s/test_wait_for_slot_event", prefix);
+ p11_test (test_open_close_session, "%s/test_open_close_session", prefix);
+ p11_test (test_close_all_sessions, "%s/test_close_all_sessions", prefix);
+ p11_test (test_get_function_status, "%s/test_get_function_status", prefix);
+ p11_test (test_cancel_function, "%s/test_cancel_function", prefix);
+ p11_test (test_get_session_info, "%s/test_get_session_info", prefix);
+ p11_test (test_init_pin, "%s/test_init_pin", prefix);
+ p11_test (test_set_pin, "%s/test_set_pin", prefix);
+ p11_test (test_operation_state, "%s/test_operation_state", prefix);
+ p11_test (test_login_logout, "%s/test_login_logout", prefix);
+ p11_test (test_get_attribute_value, "%s/test_get_attribute_value", prefix);
+ p11_test (test_set_attribute_value, "%s/test_set_attribute_value", prefix);
+ p11_test (test_create_object, "%s/test_create_object", prefix);
+ p11_test (test_copy_object, "%s/test_copy_object", prefix);
+ p11_test (test_destroy_object, "%s/test_destroy_object", prefix);
+ p11_test (test_get_object_size, "%s/test_get_object_size", prefix);
+ p11_test (test_find_objects, "%s/test_find_objects", prefix);
+ p11_test (test_encrypt, "%s/test_encrypt", prefix);
+ p11_test (test_decrypt, "%s/test_decrypt", prefix);
+ p11_test (test_digest, "%s/test_digest", prefix);
+ p11_test (test_sign, "%s/test_sign", prefix);
+ p11_test (test_sign_recover, "%s/test_sign_recover", prefix);
+ p11_test (test_verify, "%s/test_verify", prefix);
+ p11_test (test_verify_recover, "%s/test_verify_recover", prefix);
+ p11_test (test_digest_encrypt, "%s/test_digest_encrypt", prefix);
+ p11_test (test_decrypt_digest, "%s/test_decrypt_digest", prefix);
+ p11_test (test_sign_encrypt, "%s/test_sign_encrypt", prefix);
+ p11_test (test_decrypt_verify, "%s/test_decrypt_verify", prefix);
+ p11_test (test_generate_key, "%s/test_generate_key", prefix);
+ p11_test (test_generate_key_pair, "%s/test_generate_key_pair", prefix);
+ p11_test (test_wrap_key, "%s/test_wrap_key", prefix);
+ p11_test (test_unwrap_key, "%s/test_unwrap_key", prefix);
+ p11_test (test_derive_key, "%s/test_derive_key", prefix);
+ p11_test (test_random, "%s/test_random", prefix);
}
diff --git a/p11-kit/tests/test-modules.c b/p11-kit/tests/test-modules.c
index d6b4753..d50b2d5 100644
--- a/p11-kit/tests/test-modules.c
+++ b/p11-kit/tests/test-modules.c
@@ -33,7 +33,7 @@
*/
#include "config.h"
-#include "CuTest.h"
+#include "test.h"
#include <errno.h>
#include <stdlib.h>
@@ -47,25 +47,24 @@
#include "dict.h"
static CK_FUNCTION_LIST_PTR_PTR
-initialize_and_get_modules (CuTest *tc)
+initialize_and_get_modules (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
modules = p11_kit_modules_load_and_initialize (0);
- CuAssertTrue (tc, modules != NULL && modules[0] != NULL);
+ assert (modules != NULL && modules[0] != NULL);
return modules;
}
static void
-finalize_and_free_modules (CuTest *tc,
- CK_FUNCTION_LIST_PTR_PTR modules)
+finalize_and_free_modules (CK_FUNCTION_LIST_PTR_PTR modules)
{
p11_kit_modules_finalize_and_release (modules);
}
static void
-test_no_duplicates (CuTest *tc)
+test_no_duplicates (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
p11_dict *paths;
@@ -73,7 +72,7 @@ test_no_duplicates (CuTest *tc)
char *path;
int i;
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
paths = p11_dict_new (p11_dict_str_hash, p11_dict_str_equal, NULL, NULL);
funcs = p11_dict_new (p11_dict_direct_hash, p11_dict_direct_equal, NULL, NULL);
@@ -82,26 +81,25 @@ test_no_duplicates (CuTest *tc)
path = p11_kit_config_option (modules[i], "module");
if (p11_dict_get (funcs, modules[i]))
- CuAssert (tc, "found duplicate function list pointer", 0);
+ assert_fail ("found duplicate function list pointer", NULL);
if (p11_dict_get (paths, path))
- CuAssert (tc, "found duplicate path name", 0);
+ assert_fail ("found duplicate path name", NULL);
if (!p11_dict_set (funcs, modules[i], ""))
- CuAssert (tc, "shouldn't be reached", 0);
+ assert_not_reached ();
if (!p11_dict_set (paths, path, ""))
- CuAssert (tc, "shouldn't be reached", 0);
+ assert_not_reached ();
free (path);
}
p11_dict_free (paths);
p11_dict_free (funcs);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static CK_FUNCTION_LIST_PTR
-lookup_module_with_name (CuTest *tc,
- CK_FUNCTION_LIST_PTR_PTR modules,
+lookup_module_with_name (CK_FUNCTION_LIST_PTR_PTR modules,
const char *name)
{
CK_FUNCTION_LIST_PTR match = NULL;
@@ -111,7 +109,7 @@ lookup_module_with_name (CuTest *tc,
for (i = 0; match == NULL && modules[i] != NULL; i++) {
module_name = p11_kit_module_get_name (modules[i]);
- CuAssertPtrNotNull (tc, module_name);
+ assert_ptr_not_null (module_name);
if (strcmp (module_name, name) == 0)
match = modules[i];
free (module_name);
@@ -122,14 +120,14 @@ lookup_module_with_name (CuTest *tc,
* matches the above search.
*/
module = p11_kit_module_for_name (modules, name);
- CuAssert(tc, "different result from p11_kit_module_for_name ()",
- module == match);
+ if (module != match)
+ assert_fail ("different result from p11_kit_module_for_name ()", NULL);
return match;
}
static void
-test_disable (CuTest *tc)
+test_disable (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
@@ -138,9 +136,9 @@ test_disable (CuTest *tc)
* that it has disabled.
*/
- modules = initialize_and_get_modules (tc);
- CuAssertTrue (tc, lookup_module_with_name (tc, modules, "four") != NULL);
- finalize_and_free_modules (tc, modules);
+ modules = initialize_and_get_modules ();
+ assert (lookup_module_with_name (modules, "four") != NULL);
+ finalize_and_free_modules (modules);
/*
* The module two shouldn't have been loaded, because in its config
@@ -151,15 +149,15 @@ test_disable (CuTest *tc)
p11_kit_set_progname ("test-disable");
- modules = initialize_and_get_modules (tc);
- CuAssertTrue (tc, lookup_module_with_name (tc, modules, "four") == NULL);
- finalize_and_free_modules (tc, modules);
+ modules = initialize_and_get_modules ();
+ assert (lookup_module_with_name (modules, "four") == NULL);
+ finalize_and_free_modules (modules);
p11_kit_set_progname (NULL);
}
static void
-test_disable_later (CuTest *tc)
+test_disable_later (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
@@ -173,16 +171,16 @@ test_disable_later (CuTest *tc)
p11_kit_set_progname ("test-disable");
modules = p11_kit_modules_load_and_initialize (0);
- CuAssertTrue (tc, modules != NULL && modules[0] != NULL);
+ assert (modules != NULL && modules[0] != NULL);
- CuAssertTrue (tc, lookup_module_with_name (tc, modules, "two") == NULL);
- finalize_and_free_modules (tc, modules);
+ assert (lookup_module_with_name (modules, "two") == NULL);
+ finalize_and_free_modules (modules);
p11_kit_set_progname (NULL);
}
static void
-test_enable (CuTest *tc)
+test_enable (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
@@ -191,9 +189,9 @@ test_enable (CuTest *tc)
* program.
*/
- modules = initialize_and_get_modules (tc);
- CuAssertTrue (tc, lookup_module_with_name (tc, modules, "three") == NULL);
- finalize_and_free_modules (tc, modules);
+ modules = initialize_and_get_modules ();
+ assert (lookup_module_with_name (modules, "three") == NULL);
+ finalize_and_free_modules (modules);
/*
* The module three should be loaded here , because in its config
@@ -204,15 +202,15 @@ test_enable (CuTest *tc)
p11_kit_set_progname ("test-enable");
- modules = initialize_and_get_modules (tc);
- CuAssertTrue (tc, lookup_module_with_name (tc, modules, "three") != NULL);
- finalize_and_free_modules (tc, modules);
+ modules = initialize_and_get_modules ();
+ assert (lookup_module_with_name (modules, "three") != NULL);
+ finalize_and_free_modules (modules);
p11_kit_set_progname (NULL);
}
static void
-test_priority (CuTest *tc)
+test_priority (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
char *name;
@@ -231,12 +229,12 @@ test_priority (CuTest *tc)
/* This enables module three */
p11_kit_set_progname ("test-enable");
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
/* The loaded modules should not contain duplicates */
for (i = 0; modules[i] != NULL; i++) {
name = p11_kit_module_get_name (modules[i]);
- CuAssertPtrNotNull (tc, name);
+ assert_ptr_not_null (name);
/* Either one of these can be loaded, as this is a duplicate module */
if (strcmp (name, "two-duplicate") == 0) {
@@ -244,16 +242,16 @@ test_priority (CuTest *tc)
name = strdup ("two.badname");
}
- CuAssertStrEquals (tc, expected[i], name);
+ assert_str_eq (expected[i], name);
free (name);
}
- CuAssertIntEquals (tc, 4, i);
- finalize_and_free_modules (tc, modules);
+ assert_num_eq (4, i);
+ finalize_and_free_modules (modules);
}
static void
-test_module_name (CuTest *tc)
+test_module_name (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
CK_FUNCTION_LIST_PTR module;
@@ -264,25 +262,25 @@ test_module_name (CuTest *tc)
* program.
*/
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
module = p11_kit_module_for_name (modules, "one");
- CuAssertPtrNotNull (tc, module);
+ assert_ptr_not_null (module);
name = p11_kit_module_get_name (module);
- CuAssertStrEquals (tc, "one", name);
+ assert_str_eq ("one", name);
free (name);
module = p11_kit_module_for_name (modules, "invalid");
- CuAssertPtrEquals (tc, NULL, module);
+ assert_ptr_eq (NULL, module);
module = p11_kit_module_for_name (NULL, "one");
- CuAssertPtrEquals (tc, NULL, module);
+ assert_ptr_eq (NULL, module);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
static void
-test_module_flags (CuTest *tc)
+test_module_flags (void)
{
CK_FUNCTION_LIST **modules;
CK_FUNCTION_LIST **unmanaged;
@@ -293,23 +291,23 @@ test_module_flags (CuTest *tc)
* program.
*/
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
flags = p11_kit_module_get_flags (modules[0]);
- CuAssertIntEquals (tc, 0, flags);
+ assert_num_eq (0, flags);
unmanaged = p11_kit_modules_load (NULL, P11_KIT_MODULE_UNMANAGED);
- CuAssertTrue (tc, unmanaged != NULL && unmanaged[0] != NULL);
+ assert (unmanaged != NULL && unmanaged[0] != NULL);
flags = p11_kit_module_get_flags (unmanaged[0]);
- CuAssertIntEquals (tc, P11_KIT_MODULE_UNMANAGED, flags);
+ assert_num_eq (P11_KIT_MODULE_UNMANAGED, flags);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
p11_kit_modules_release (unmanaged);
}
static void
-test_config_option (CuTest *tc)
+test_config_option (void)
{
CK_FUNCTION_LIST_PTR_PTR modules;
CK_FUNCTION_LIST_PTR module;
@@ -320,59 +318,48 @@ test_config_option (CuTest *tc)
* program.
*/
- modules = initialize_and_get_modules (tc);
+ modules = initialize_and_get_modules ();
value = p11_kit_config_option (NULL, "new");
- CuAssertStrEquals (tc, "world", value);
+ assert_str_eq ("world", value);
free (value);
module = p11_kit_module_for_name (modules, "one");
- CuAssertPtrNotNull (tc, module);
+ assert_ptr_not_null (module);
value = p11_kit_config_option (module, "setting");
- CuAssertStrEquals (tc, "user1", value);
+ assert_str_eq ("user1", value);
free (value);
value = p11_kit_config_option (NULL, "invalid");
- CuAssertPtrEquals (tc, NULL, value);
+ assert_ptr_eq (NULL, value);
value = p11_kit_config_option (module, "invalid");
- CuAssertPtrEquals (tc, NULL, value);
+ assert_ptr_eq (NULL, value);
/* Invalid but non-NULL module pointer */
value = p11_kit_config_option (module + 1, "setting");
- CuAssertPtrEquals (tc, NULL, value);
+ assert_ptr_eq (NULL, value);
- finalize_and_free_modules (tc, modules);
+ finalize_and_free_modules (modules);
}
int
-main (void)
+main (int argc,
+ char *argv[])
{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- putenv ("P11_KIT_STRICT=1");
p11_library_init ();
- SUITE_ADD_TEST (suite, test_no_duplicates);
- SUITE_ADD_TEST (suite, test_disable);
- SUITE_ADD_TEST (suite, test_disable_later);
- SUITE_ADD_TEST (suite, test_enable);
- SUITE_ADD_TEST (suite, test_priority);
- SUITE_ADD_TEST (suite, test_module_name);
- SUITE_ADD_TEST (suite, test_module_flags);
- SUITE_ADD_TEST (suite, test_config_option);
+ p11_test (test_no_duplicates, "/modules/test_no_duplicates");
+ p11_test (test_disable, "/modules/test_disable");
+ p11_test (test_disable_later, "/modules/test_disable_later");
+ p11_test (test_enable, "/modules/test_enable");
+ p11_test (test_priority, "/modules/test_priority");
+ p11_test (test_module_name, "/modules/test_module_name");
+ p11_test (test_module_flags, "/modules/test_module_flags");
+ p11_test (test_config_option, "/modules/test_config_option");
p11_kit_be_quiet ();
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
- return ret;
+ return p11_test_run (argc, argv);
}
diff --git a/p11-kit/tests/pin-test.c b/p11-kit/tests/test-pin.c
index dd020bc..ebe3efc 100644
--- a/p11-kit/tests/pin-test.c
+++ b/p11-kit/tests/test-pin.c
@@ -33,7 +33,7 @@
*/
#include "config.h"
-#include "CuTest.h"
+#include "test.h"
#include "library.h"
@@ -71,7 +71,7 @@ destroy_data (void *callback_data)
}
static void
-test_pin_register_unregister (CuTest *tc)
+test_pin_register_unregister (void)
{
int data = 33;
@@ -81,11 +81,11 @@ test_pin_register_unregister (CuTest *tc)
p11_kit_pin_unregister_callback ("/the/pin_source", callback_one,
&data);
- CuAssertIntEquals (tc, 34, data);
+ assert_num_eq (34, data);
}
static void
-test_pin_read (CuTest *tc)
+test_pin_read (void)
{
P11KitUri *uri;
P11KitPin *pin;
@@ -101,10 +101,10 @@ test_pin_read (CuTest *tc)
P11_KIT_PIN_FLAGS_USER_LOGIN);
p11_kit_uri_free (uri);
- CuAssertPtrNotNull (tc, pin);
+ assert_ptr_not_null (pin);
ptr = p11_kit_pin_get_value (pin, &length);
- CuAssertIntEquals (tc, 3, length);
- CuAssertTrue (tc, memcmp (ptr, "one", 3) == 0);
+ assert_num_eq (3, length);
+ assert (memcmp (ptr, "one", 3) == 0);
p11_kit_pin_unregister_callback ("/the/pin_source", callback_one,
&data);
@@ -113,7 +113,7 @@ test_pin_read (CuTest *tc)
}
static void
-test_pin_read_no_match (CuTest *tc)
+test_pin_read_no_match (void)
{
P11KitUri *uri;
P11KitPin *pin;
@@ -123,11 +123,11 @@ test_pin_read_no_match (CuTest *tc)
P11_KIT_PIN_FLAGS_USER_LOGIN);
p11_kit_uri_free (uri);
- CuAssertPtrEquals (tc, NULL, pin);
+ assert_ptr_eq (NULL, pin);
}
static void
-test_pin_register_duplicate (CuTest *tc)
+test_pin_register_duplicate (void)
{
P11KitUri *uri;
P11KitPin *pin;
@@ -147,10 +147,10 @@ test_pin_register_duplicate (CuTest *tc)
pin = p11_kit_pin_request ("/the/pin_source", uri, "The token",
P11_KIT_PIN_FLAGS_USER_LOGIN);
- CuAssertPtrNotNull (tc, pin);
+ assert_ptr_not_null (pin);
ptr = p11_kit_pin_get_value (pin, &length);
- CuAssertIntEquals (tc, 6, length);
- CuAssertTrue (tc, memcmp (ptr, "secret", length) == 0);
+ assert_num_eq (6, length);
+ assert (memcmp (ptr, "secret", length) == 0);
p11_kit_pin_unref (pin);
p11_kit_pin_unregister_callback ("/the/pin_source", callback_other,
@@ -159,10 +159,10 @@ test_pin_register_duplicate (CuTest *tc)
pin = p11_kit_pin_request ("/the/pin_source", uri, "The token",
P11_KIT_PIN_FLAGS_USER_LOGIN);
- CuAssertPtrNotNull (tc, pin);
+ assert_ptr_not_null (pin);
ptr = p11_kit_pin_get_value (pin, &length);
- CuAssertIntEquals (tc, 3, length);
- CuAssertTrue (tc, memcmp (ptr, "one", length) == 0);
+ assert_num_eq (3, length);
+ assert (memcmp (ptr, "one", length) == 0);
p11_kit_pin_unref (pin);
p11_kit_pin_unregister_callback ("/the/pin_source", callback_one,
@@ -171,13 +171,13 @@ test_pin_register_duplicate (CuTest *tc)
pin = p11_kit_pin_request ("/the/pin_source", uri, "The token",
P11_KIT_PIN_FLAGS_USER_LOGIN);
- CuAssertPtrEquals (tc, NULL, pin);
+ assert_ptr_eq (NULL, pin);
p11_kit_uri_free (uri);
}
static void
-test_pin_register_fallback (CuTest *tc)
+test_pin_register_fallback (void)
{
char *value = "secret";
P11KitUri *uri;
@@ -194,10 +194,10 @@ test_pin_register_fallback (CuTest *tc)
pin = p11_kit_pin_request ("/the/pin_source", uri, "The token",
P11_KIT_PIN_FLAGS_USER_LOGIN);
- CuAssertPtrNotNull (tc, pin);
+ assert_ptr_not_null (pin);
ptr = p11_kit_pin_get_value (pin, &length);
- CuAssertIntEquals (tc, 3, length);
- CuAssertTrue (tc, memcmp (ptr, "one", length) == 0);
+ assert_num_eq (3, length);
+ assert (memcmp (ptr, "one", length) == 0);
p11_kit_pin_unref (pin);
p11_kit_pin_register_callback ("/the/pin_source", callback_other,
@@ -206,10 +206,10 @@ test_pin_register_fallback (CuTest *tc)
pin = p11_kit_pin_request ("/the/pin_source", uri, "The token",
P11_KIT_PIN_FLAGS_USER_LOGIN);
- CuAssertPtrNotNull (tc, pin);
+ assert_ptr_not_null (pin);
ptr = p11_kit_pin_get_value (pin, &length);
- CuAssertIntEquals (tc, 6, length);
- CuAssertTrue (tc, memcmp (ptr, "secret", length) == 0);
+ assert_num_eq (6, length);
+ assert (memcmp (ptr, "secret", length) == 0);
p11_kit_pin_unref (pin);
p11_kit_pin_unregister_callback ("/the/pin_source", callback_other,
@@ -222,7 +222,7 @@ test_pin_register_fallback (CuTest *tc)
}
static void
-test_pin_file (CuTest *tc)
+test_pin_file (void)
{
P11KitUri *uri;
P11KitPin *pin;
@@ -237,16 +237,16 @@ test_pin_file (CuTest *tc)
pin = p11_kit_pin_request (SRCDIR "/files/test-pinfile", uri, "The token",
P11_KIT_PIN_FLAGS_USER_LOGIN);
- CuAssertPtrNotNull (tc, pin);
+ assert_ptr_not_null (pin);
ptr = p11_kit_pin_get_value (pin, &length);
- CuAssertIntEquals (tc, 12, length);
- CuAssertTrue (tc, memcmp (ptr, "yogabbagabba", length) == 0);
+ assert_num_eq (12, length);
+ assert (memcmp (ptr, "yogabbagabba", length) == 0);
p11_kit_pin_unref (pin);
pin = p11_kit_pin_request (SRCDIR "/files/nonexistant", uri, "The token",
P11_KIT_PIN_FLAGS_USER_LOGIN);
- CuAssertPtrEquals (tc, NULL, pin);
+ assert_ptr_eq (NULL, pin);
p11_kit_pin_unregister_callback (P11_KIT_PIN_FALLBACK, p11_kit_pin_file_callback,
NULL);
@@ -255,7 +255,7 @@ test_pin_file (CuTest *tc)
}
static void
-test_pin_file_large (CuTest *tc)
+test_pin_file_large (void)
{
P11KitUri *uri;
P11KitPin *pin;
@@ -270,8 +270,8 @@ test_pin_file_large (CuTest *tc)
P11_KIT_PIN_FLAGS_USER_LOGIN);
error = errno;
- CuAssertPtrEquals (tc, NULL, pin);
- CuAssertIntEquals (tc, EFBIG, error);
+ assert_ptr_eq (NULL, pin);
+ assert_num_eq (EFBIG, error);
p11_kit_pin_unregister_callback (P11_KIT_PIN_FALLBACK, p11_kit_pin_file_callback,
NULL);
@@ -280,7 +280,7 @@ test_pin_file_large (CuTest *tc)
}
static void
-test_pin_ref_unref (CuTest *tc)
+test_pin_ref_unref (void)
{
P11KitPin *pin;
P11KitPin *check;
@@ -288,38 +288,26 @@ test_pin_ref_unref (CuTest *tc)
pin = p11_kit_pin_new_for_string ("crack of lies");
check = p11_kit_pin_ref (pin);
- CuAssertPtrEquals (tc, pin, check);
+ assert_ptr_eq (pin, check);
p11_kit_pin_unref (pin);
p11_kit_pin_unref (check);
}
int
-main (void)
+main (int argc,
+ char *argv[])
{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- putenv ("P11_KIT_STRICT=1");
p11_library_init ();
- SUITE_ADD_TEST (suite, test_pin_register_unregister);
- SUITE_ADD_TEST (suite, test_pin_read);
- SUITE_ADD_TEST (suite, test_pin_read_no_match);
- SUITE_ADD_TEST (suite, test_pin_register_duplicate);
- SUITE_ADD_TEST (suite, test_pin_register_fallback);
- SUITE_ADD_TEST (suite, test_pin_file);
- SUITE_ADD_TEST (suite, test_pin_file_large);
- SUITE_ADD_TEST (suite, test_pin_ref_unref);
-
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
-
- return ret;
+ p11_test (test_pin_register_unregister, "/pin/test_pin_register_unregister");
+ p11_test (test_pin_read, "/pin/test_pin_read");
+ p11_test (test_pin_read_no_match, "/pin/test_pin_read_no_match");
+ p11_test (test_pin_register_duplicate, "/pin/test_pin_register_duplicate");
+ p11_test (test_pin_register_fallback, "/pin/test_pin_register_fallback");
+ p11_test (test_pin_file, "/pin/test_pin_file");
+ p11_test (test_pin_file_large, "/pin/test_pin_file_large");
+ p11_test (test_pin_ref_unref, "/pin/test_pin_ref_unref");
+
+ return p11_test_run (argc, argv);
}
diff --git a/p11-kit/tests/progname-test.c b/p11-kit/tests/test-progname.c
index 18a8c55..76b136d 100644
--- a/p11-kit/tests/progname-test.c
+++ b/p11-kit/tests/test-progname.c
@@ -33,7 +33,7 @@
*/
#include "config.h"
-#include "CuTest.h"
+#include "test.h"
#include "library.h"
@@ -47,52 +47,40 @@
#include "p11-kit/private.h"
static void
-test_progname_default (CuTest *tc)
+test_progname_default (void)
{
const char *progname;
progname = _p11_get_progname_unlocked ();
- CuAssertStrEquals (tc, "progname-test", progname);
+ assert_str_eq ("test-progname", progname);
}
static void
-test_progname_set (CuTest *tc)
+test_progname_set (void)
{
const char *progname;
p11_kit_set_progname ("love-generation");
progname = _p11_get_progname_unlocked ();
- CuAssertStrEquals (tc, "love-generation", progname);
+ assert_str_eq ("love-generation", progname);
_p11_set_progname_unlocked (NULL);
progname = _p11_get_progname_unlocked ();
- CuAssertStrEquals (tc, "progname-test", progname);
+ assert_str_eq ("test-progname", progname);
}
/* Defined in util.c */
extern char p11_my_progname[];
int
-main (void)
+main (int argc,
+ char *argv[])
{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- putenv ("P11_KIT_STRICT=1");
p11_library_init ();
- SUITE_ADD_TEST (suite, test_progname_default);
- SUITE_ADD_TEST (suite, test_progname_set);
-
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
- return ret;
+ p11_test (test_progname_default, "/progname/test_progname_default");
+ p11_test (test_progname_set, "/progname/test_progname_set");
+ return p11_test_run (argc, argv);
}
diff --git a/p11-kit/tests/test-proxy.c b/p11-kit/tests/test-proxy.c
index 2ebd848..bf5007d 100644
--- a/p11-kit/tests/test-proxy.c
+++ b/p11-kit/tests/test-proxy.c
@@ -35,7 +35,7 @@
#define CRYPTOKI_EXPORTS
#include "config.h"
-#include "CuTest.h"
+#include "test.h"
#include "library.h"
#include "mock.h"
@@ -62,101 +62,99 @@ static CK_ULONG mock_slots_present;
static CK_ULONG mock_slots_all;
static void
-test_initialize_finalize (CuTest *tc)
+test_initialize_finalize (void)
{
CK_FUNCTION_LIST_PTR proxy;
CK_RV rv;
rv = C_GetFunctionList (&proxy);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertTrue (tc, p11_proxy_module_check (proxy));
+ assert (p11_proxy_module_check (proxy));
rv = proxy->C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = proxy->C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
p11_proxy_module_cleanup ();
}
static void
-test_initialize_multiple (CuTest *tc)
+test_initialize_multiple (void)
{
CK_FUNCTION_LIST_PTR proxy;
CK_RV rv;
rv = C_GetFunctionList (&proxy);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertTrue (tc, p11_proxy_module_check (proxy));
+ assert (p11_proxy_module_check (proxy));
rv = proxy->C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = proxy->C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = proxy->C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = proxy->C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
rv = proxy->C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_CRYPTOKI_NOT_INITIALIZED);
+ assert (rv == CKR_CRYPTOKI_NOT_INITIALIZED);
p11_proxy_module_cleanup ();
}
static CK_FUNCTION_LIST_PTR
-setup_mock_module (CuTest *tc,
- CK_SESSION_HANDLE *session)
+setup_mock_module (CK_SESSION_HANDLE *session)
{
CK_FUNCTION_LIST_PTR proxy;
CK_SLOT_ID slots[32];
CK_RV rv;
rv = C_GetFunctionList (&proxy);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
- CuAssertTrue (tc, p11_proxy_module_check (proxy));
+ assert (p11_proxy_module_check (proxy));
rv = proxy->C_Initialize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
mock_slots_all = 32;
rv = proxy->C_GetSlotList (CK_FALSE, slots, &mock_slots_all);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertTrue (tc, mock_slots_all >= 2);
+ assert (rv == CKR_OK);
+ assert (mock_slots_all >= 2);
/* Assume this is the slot we want to deal with */
mock_slot_one_id = slots[0];
mock_slot_two_id = slots[1];
rv = proxy->C_GetSlotList (CK_TRUE, NULL, &mock_slots_present);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertTrue (tc, mock_slots_present > 1);
+ assert (rv == CKR_OK);
+ assert (mock_slots_present > 1);
if (session) {
rv = (proxy->C_OpenSession) (mock_slot_one_id,
CKF_RW_SESSION | CKF_SERIAL_SESSION,
NULL, NULL, session);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
return proxy;
}
static void
-teardown_mock_module (CuTest *tc,
- CK_FUNCTION_LIST_PTR module)
+teardown_mock_module (CK_FUNCTION_LIST_PTR module)
{
CK_RV rv;
rv = module->C_Finalize (NULL);
- CuAssertTrue (tc, rv == CKR_OK);
+ assert (rv == CKR_OK);
}
/*
@@ -182,27 +180,16 @@ static const CK_INFO mock_info = {
#include "test-mock.c"
int
-main (void)
+main (int argc,
+ char *argv[])
{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- putenv ("P11_KIT_STRICT=1");
p11_library_init ();
p11_kit_be_quiet ();
- SUITE_ADD_TEST (suite, test_initialize_finalize);
- SUITE_ADD_TEST (suite, test_initialize_multiple);
+ p11_test (test_initialize_finalize, "/proxy/initialize-finalize");
+ p11_test (test_initialize_multiple, "/proxy/initialize-multiple");
- test_mock_add_tests (suite);
+ test_mock_add_tests ("/proxy");
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
- return ret;
+ return p11_test_run (argc, argv);
}
diff --git a/p11-kit/tests/uri-test.c b/p11-kit/tests/test-uri.c
index 2bc121c..f514f7a 100644
--- a/p11-kit/tests/uri-test.c
+++ b/p11-kit/tests/test-uri.c
@@ -33,7 +33,7 @@
*/
#include "config.h"
-#include "CuTest.h"
+#include "test.h"
#include "debug.h"
#include "message.h"
@@ -75,138 +75,138 @@ are_attributes_empty (P11KitUri *uri)
}
static void
-test_uri_parse (CuTest *tc)
+test_uri_parse (void)
{
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:", P11_KIT_URI_FOR_MODULE, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
- CuAssertTrue (tc, is_module_empty (uri));
- CuAssertTrue (tc, is_token_empty (uri));
- CuAssertTrue (tc, are_attributes_empty (uri));
+ assert (is_module_empty (uri));
+ assert (is_token_empty (uri));
+ assert (are_attributes_empty (uri));
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_bad_scheme (CuTest *tc)
+test_uri_parse_bad_scheme (void)
{
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("http:\\example.com\test", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_SCHEME, ret);
+ assert_num_eq (P11_KIT_URI_BAD_SCHEME, ret);
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_with_label (CuTest *tc)
+test_uri_parse_with_label (void)
{
CK_ATTRIBUTE_PTR attr;
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:object=Test%20Label", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
- CuAssertTrue (tc, is_module_empty (uri));
- CuAssertTrue (tc, is_token_empty (uri));
+ assert (is_module_empty (uri));
+ assert (is_token_empty (uri));
attr = p11_kit_uri_get_attribute (uri, CKA_LABEL);
- CuAssertPtrNotNull (tc, attr);
- CuAssertTrue (tc, attr->ulValueLen == strlen ("Test Label"));
- CuAssertTrue (tc, memcmp (attr->pValue, "Test Label", attr->ulValueLen) == 0);
+ assert_ptr_not_null (attr);
+ assert (attr->ulValueLen == strlen ("Test Label"));
+ assert (memcmp (attr->pValue, "Test Label", attr->ulValueLen) == 0);
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_with_label_and_klass (CuTest *tc)
+test_uri_parse_with_label_and_klass (void)
{
CK_ATTRIBUTE_PTR attr;
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:object=Test%20Label;object-type=cert", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
attr = p11_kit_uri_get_attribute (uri, CKA_LABEL);
- CuAssertPtrNotNull (tc, attr);
- CuAssertTrue (tc, attr->ulValueLen == strlen ("Test Label"));
- CuAssertTrue (tc, memcmp (attr->pValue, "Test Label", attr->ulValueLen) == 0);
+ assert_ptr_not_null (attr);
+ assert (attr->ulValueLen == strlen ("Test Label"));
+ assert (memcmp (attr->pValue, "Test Label", attr->ulValueLen) == 0);
attr = p11_kit_uri_get_attribute (uri, CKA_CLASS);
- CuAssertPtrNotNull (tc, attr);
- CuAssertTrue (tc, attr->ulValueLen == sizeof (CK_OBJECT_CLASS));
- CuAssertTrue (tc, *((CK_OBJECT_CLASS_PTR)attr->pValue) == CKO_CERTIFICATE);
+ assert_ptr_not_null (attr);
+ assert (attr->ulValueLen == sizeof (CK_OBJECT_CLASS));
+ assert (*((CK_OBJECT_CLASS_PTR)attr->pValue) == CKO_CERTIFICATE);
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_with_id (CuTest *tc)
+test_uri_parse_with_id (void)
{
CK_ATTRIBUTE_PTR attr;
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:id=%54%45%53%54%00", P11_KIT_URI_FOR_OBJECT, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
/* Note that there's a NULL in the attribute (end) */
attr = p11_kit_uri_get_attribute (uri, CKA_ID);
- CuAssertPtrNotNull (tc, attr);
- CuAssertTrue (tc, attr->ulValueLen == 5);
- CuAssertTrue (tc, memcmp (attr->pValue, "TEST", 5) == 0);
+ assert_ptr_not_null (attr);
+ assert (attr->ulValueLen == 5);
+ assert (memcmp (attr->pValue, "TEST", 5) == 0);
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_with_bad_string_encoding (CuTest *tc)
+test_uri_parse_with_bad_string_encoding (void)
{
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:object=Test%", P11_KIT_URI_FOR_OBJECT, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_ENCODING, ret);
+ assert_num_eq (P11_KIT_URI_BAD_ENCODING, ret);
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_with_bad_hex_encoding (CuTest *tc)
+test_uri_parse_with_bad_hex_encoding (void)
{
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:object=T%xxest", P11_KIT_URI_FOR_OBJECT, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_ENCODING, ret);
+ assert_num_eq (P11_KIT_URI_BAD_ENCODING, ret);
p11_kit_uri_free (uri);
}
@@ -226,131 +226,131 @@ is_space_string (CK_UTF8CHAR_PTR string, CK_ULONG size, const char *check)
}
static void
-test_uri_parse_with_token (CuTest *tc)
+test_uri_parse_with_token (void)
{
P11KitUri *uri = NULL;
CK_TOKEN_INFO_PTR token;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:token=Token%20Label;serial=3333;model=Deluxe;manufacturer=Me",
P11_KIT_URI_FOR_TOKEN, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
token = p11_kit_uri_get_token_info (uri);
- CuAssertTrue (tc, is_space_string (token->label, sizeof (token->label), "Token Label"));
- CuAssertTrue (tc, is_space_string (token->serialNumber, sizeof (token->serialNumber), "3333"));
- CuAssertTrue (tc, is_space_string (token->model, sizeof (token->model), "Deluxe"));
- CuAssertTrue (tc, is_space_string (token->manufacturerID, sizeof (token->manufacturerID), "Me"));
+ assert (is_space_string (token->label, sizeof (token->label), "Token Label"));
+ assert (is_space_string (token->serialNumber, sizeof (token->serialNumber), "3333"));
+ assert (is_space_string (token->model, sizeof (token->model), "Deluxe"));
+ assert (is_space_string (token->manufacturerID, sizeof (token->manufacturerID), "Me"));
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_with_token_bad_encoding (CuTest *tc)
+test_uri_parse_with_token_bad_encoding (void)
{
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:token=Token%", P11_KIT_URI_FOR_TOKEN, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_ENCODING, ret);
+ assert_num_eq (P11_KIT_URI_BAD_ENCODING, ret);
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_with_bad_syntax (CuTest *tc)
+test_uri_parse_with_bad_syntax (void)
{
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:token", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_SYNTAX, ret);
+ assert_num_eq (P11_KIT_URI_BAD_SYNTAX, ret);
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_with_spaces (CuTest *tc)
+test_uri_parse_with_spaces (void)
{
P11KitUri *uri = NULL;
CK_INFO_PTR info;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkc\ns11: lib rary-desc\rrip \n tion =The%20Library;\n\n\nlibrary-manufacturer=\rMe",
P11_KIT_URI_FOR_MODULE, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
info = p11_kit_uri_get_module_info (uri);
- CuAssertTrue (tc, is_space_string (info->manufacturerID, sizeof (info->manufacturerID), "Me"));
- CuAssertTrue (tc, is_space_string (info->libraryDescription, sizeof (info->libraryDescription), "The Library"));
+ assert (is_space_string (info->manufacturerID, sizeof (info->manufacturerID), "Me"));
+ assert (is_space_string (info->libraryDescription, sizeof (info->libraryDescription), "The Library"));
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_with_library (CuTest *tc)
+test_uri_parse_with_library (void)
{
P11KitUri *uri = NULL;
CK_INFO_PTR info;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:library-description=The%20Library;library-manufacturer=Me",
P11_KIT_URI_FOR_MODULE, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
info = p11_kit_uri_get_module_info (uri);
- CuAssertTrue (tc, is_space_string (info->manufacturerID, sizeof (info->manufacturerID), "Me"));
- CuAssertTrue (tc, is_space_string (info->libraryDescription, sizeof (info->libraryDescription), "The Library"));
+ assert (is_space_string (info->manufacturerID, sizeof (info->manufacturerID), "Me"));
+ assert (is_space_string (info->libraryDescription, sizeof (info->libraryDescription), "The Library"));
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_with_library_bad_encoding (CuTest *tc)
+test_uri_parse_with_library_bad_encoding (void)
{
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:library-description=Library%", P11_KIT_URI_FOR_MODULE, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_ENCODING, ret);
+ assert_num_eq (P11_KIT_URI_BAD_ENCODING, ret);
p11_kit_uri_free (uri);
}
static void
-test_uri_build_empty (CuTest *tc)
+test_uri_build_empty (void)
{
P11KitUri *uri;
char *string;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
- CuAssertStrEquals (tc, "pkcs11:", string);
+ assert_num_eq (P11_KIT_URI_OK, ret);
+ assert_str_eq ("pkcs11:", string);
free (string);
p11_kit_uri_free (uri);
@@ -366,7 +366,7 @@ set_space_string (CK_BYTE_PTR buffer, CK_ULONG length, const char *string)
}
static void
-test_uri_build_with_token_info (CuTest *tc)
+test_uri_build_with_token_info (void)
{
char *string = NULL;
P11KitUri *uri;
@@ -375,7 +375,7 @@ test_uri_build_with_token_info (CuTest *tc)
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
token = p11_kit_uri_get_token_info (uri);
set_space_string (token->label, sizeof (token->label), "The Label");
@@ -384,30 +384,30 @@ test_uri_build_with_token_info (CuTest *tc)
set_space_string (token->model, sizeof (token->model), "Deluxe");
ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
- CuAssertPtrNotNull (tc, string);
+ assert_num_eq (P11_KIT_URI_OK, ret);
+ assert_ptr_not_null (string);
check = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, check);
+ assert_ptr_not_null (check);
ret = p11_kit_uri_parse (string, P11_KIT_URI_FOR_TOKEN, check);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
p11_kit_uri_match_token_info (check, p11_kit_uri_get_token_info (uri));
p11_kit_uri_free (uri);
p11_kit_uri_free (check);
- CuAssertTrue (tc, strstr (string, "token=The%20Label") != NULL);
- CuAssertTrue (tc, strstr (string, "serial=44444") != NULL);
- CuAssertTrue (tc, strstr (string, "manufacturer=Me") != NULL);
- CuAssertTrue (tc, strstr (string, "model=Deluxe") != NULL);
+ assert (strstr (string, "token=The%20Label") != NULL);
+ assert (strstr (string, "serial=44444") != NULL);
+ assert (strstr (string, "manufacturer=Me") != NULL);
+ assert (strstr (string, "model=Deluxe") != NULL);
free (string);
}
static void
-test_uri_build_with_token_null_info (CuTest *tc)
+test_uri_build_with_token_null_info (void)
{
char *string = NULL;
P11KitUri *uri;
@@ -415,23 +415,23 @@ test_uri_build_with_token_null_info (CuTest *tc)
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
token = p11_kit_uri_get_token_info (uri);
set_space_string (token->label, sizeof (token->label), "The Label");
ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
- CuAssertTrue (tc, strstr (string, "token=The%20Label") != NULL);
- CuAssertTrue (tc, strstr (string, "serial=") == NULL);
+ assert (strstr (string, "token=The%20Label") != NULL);
+ assert (strstr (string, "serial=") == NULL);
free (string);
p11_kit_uri_free (uri);
}
static void
-test_uri_build_with_token_empty_info (CuTest *tc)
+test_uri_build_with_token_empty_info (void)
{
char *string = NULL;
P11KitUri *uri;
@@ -439,24 +439,24 @@ test_uri_build_with_token_empty_info (CuTest *tc)
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
token = p11_kit_uri_get_token_info (uri);
set_space_string (token->label, sizeof (token->label), "");
set_space_string (token->serialNumber, sizeof (token->serialNumber), "");
ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
- CuAssertTrue (tc, strstr (string, "token=") != NULL);
- CuAssertTrue (tc, strstr (string, "serial=") != NULL);
+ assert (strstr (string, "token=") != NULL);
+ assert (strstr (string, "serial=") != NULL);
free (string);
p11_kit_uri_free (uri);
}
static void
-test_uri_build_with_attributes (CuTest *tc)
+test_uri_build_with_attributes (void)
{
char *string = NULL;
P11KitUri *uri;
@@ -467,7 +467,7 @@ test_uri_build_with_attributes (CuTest *tc)
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
at.type = CKA_LABEL;
at.pValue = "The Label";
@@ -486,175 +486,175 @@ test_uri_build_with_attributes (CuTest *tc)
ret = p11_kit_uri_set_attribute (uri, &at);
ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
check = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, check);
+ assert_ptr_not_null (check);
ret = p11_kit_uri_parse (string, P11_KIT_URI_FOR_ANY, check);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
attr = p11_kit_uri_get_attribute (check, CKA_LABEL);
- CuAssertPtrNotNull (tc, attr);
- CuAssertTrue (tc, attr->ulValueLen == 9);
- CuAssertTrue (tc, memcmp (attr->pValue, "The Label", attr->ulValueLen) == 0);
+ assert_ptr_not_null (attr);
+ assert (attr->ulValueLen == 9);
+ assert (memcmp (attr->pValue, "The Label", attr->ulValueLen) == 0);
attr = p11_kit_uri_get_attribute (check, CKA_CLASS);
- CuAssertPtrNotNull (tc, attr);
- CuAssertTrue (tc, attr->ulValueLen == sizeof (klass));
- CuAssertTrue (tc, *((CK_OBJECT_CLASS_PTR)attr->pValue) == klass);
+ assert_ptr_not_null (attr);
+ assert (attr->ulValueLen == sizeof (klass));
+ assert (*((CK_OBJECT_CLASS_PTR)attr->pValue) == klass);
attr = p11_kit_uri_get_attribute (check, CKA_ID);
- CuAssertPtrNotNull (tc, attr);
- CuAssertTrue (tc, attr->ulValueLen == 5);
- CuAssertTrue (tc, memcmp (attr->pValue, "HELLO", attr->ulValueLen) == 0);
+ assert_ptr_not_null (attr);
+ assert (attr->ulValueLen == 5);
+ assert (memcmp (attr->pValue, "HELLO", attr->ulValueLen) == 0);
p11_kit_uri_free (check);
- CuAssertTrue (tc, strstr (string, "object=The%20Label") != NULL);
- CuAssertTrue (tc, strstr (string, "object-type=data") != NULL);
- CuAssertTrue (tc, strstr (string, "id=%48%45%4c%4c%4f") != NULL);
+ assert (strstr (string, "object=The%20Label") != NULL);
+ assert (strstr (string, "object-type=data") != NULL);
+ assert (strstr (string, "id=%48%45%4c%4c%4f") != NULL);
free (string);
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_private_key (CuTest *tc)
+test_uri_parse_private_key (void)
{
P11KitUri *uri;
CK_ATTRIBUTE_PTR attr;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:object-type=private", P11_KIT_URI_FOR_OBJECT, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
attr = p11_kit_uri_get_attribute (uri, CKA_CLASS);
- CuAssertPtrNotNull (tc, attr);
- CuAssertTrue (tc, attr->ulValueLen == sizeof (CK_OBJECT_CLASS));
- CuAssertTrue (tc, *((CK_OBJECT_CLASS_PTR)attr->pValue) == CKO_PRIVATE_KEY);
+ assert_ptr_not_null (attr);
+ assert (attr->ulValueLen == sizeof (CK_OBJECT_CLASS));
+ assert (*((CK_OBJECT_CLASS_PTR)attr->pValue) == CKO_PRIVATE_KEY);
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_secret_key (CuTest *tc)
+test_uri_parse_secret_key (void)
{
P11KitUri *uri;
CK_ATTRIBUTE_PTR attr;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:object-type=secret-key", P11_KIT_URI_FOR_OBJECT, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
attr = p11_kit_uri_get_attribute (uri, CKA_CLASS);
- CuAssertPtrNotNull (tc, attr);
- CuAssertTrue (tc, attr->ulValueLen == sizeof (CK_OBJECT_CLASS));
- CuAssertTrue (tc, *((CK_OBJECT_CLASS_PTR)attr->pValue) == CKO_SECRET_KEY);
+ assert_ptr_not_null (attr);
+ assert (attr->ulValueLen == sizeof (CK_OBJECT_CLASS));
+ assert (*((CK_OBJECT_CLASS_PTR)attr->pValue) == CKO_SECRET_KEY);
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_library_version (CuTest *tc)
+test_uri_parse_library_version (void)
{
P11KitUri *uri;
CK_INFO_PTR info;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:library-version=2.101", P11_KIT_URI_FOR_MODULE_WITH_VERSION, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
info = p11_kit_uri_get_module_info (uri);
- CuAssertIntEquals (tc, 2, info->libraryVersion.major);
- CuAssertIntEquals (tc, 101, info->libraryVersion.minor);
+ assert_num_eq (2, info->libraryVersion.major);
+ assert_num_eq (101, info->libraryVersion.minor);
ret = p11_kit_uri_parse ("pkcs11:library-version=23", P11_KIT_URI_FOR_MODULE_WITH_VERSION, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
info = p11_kit_uri_get_module_info (uri);
- CuAssertIntEquals (tc, 23, info->libraryVersion.major);
- CuAssertIntEquals (tc, 0, info->libraryVersion.minor);
+ assert_num_eq (23, info->libraryVersion.major);
+ assert_num_eq (0, info->libraryVersion.minor);
ret = p11_kit_uri_parse ("pkcs11:library-version=23.", P11_KIT_URI_FOR_MODULE_WITH_VERSION, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_VERSION, ret);
+ assert_num_eq (P11_KIT_URI_BAD_VERSION, ret);
ret = p11_kit_uri_parse ("pkcs11:library-version=a.a", P11_KIT_URI_FOR_MODULE_WITH_VERSION, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_VERSION, ret);
+ assert_num_eq (P11_KIT_URI_BAD_VERSION, ret);
ret = p11_kit_uri_parse ("pkcs11:library-version=.23", P11_KIT_URI_FOR_MODULE_WITH_VERSION, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_VERSION, ret);
+ assert_num_eq (P11_KIT_URI_BAD_VERSION, ret);
ret = p11_kit_uri_parse ("pkcs11:library-version=1000", P11_KIT_URI_FOR_MODULE_WITH_VERSION, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_VERSION, ret);
+ assert_num_eq (P11_KIT_URI_BAD_VERSION, ret);
ret = p11_kit_uri_parse ("pkcs11:library-version=2.1000", P11_KIT_URI_FOR_MODULE_WITH_VERSION, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_VERSION, ret);
+ assert_num_eq (P11_KIT_URI_BAD_VERSION, ret);
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_parse_unknown_object_type (CuTest *tc)
+test_uri_parse_parse_unknown_object_type (void)
{
P11KitUri *uri;
CK_ATTRIBUTE_PTR attr;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:object-type=unknown", P11_KIT_URI_FOR_OBJECT, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
attr = p11_kit_uri_get_attribute (uri, CKA_CLASS);
- CuAssertPtrEquals (tc, NULL, attr);
+ assert_ptr_eq (NULL, attr);
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_unrecognized (CuTest *tc)
+test_uri_parse_unrecognized (void)
{
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:x-blah=some-value", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
ret = p11_kit_uri_any_unrecognized (uri);
- CuAssertIntEquals (tc, 1, ret);
+ assert_num_eq (1, ret);
p11_kit_uri_free (uri);
}
static void
-test_uri_parse_too_long_is_unrecognized (CuTest *tc)
+test_uri_parse_too_long_is_unrecognized (void)
{
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:model=a-value-that-is-too-long-for-the-field-that-it-goes-with",
P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
ret = p11_kit_uri_any_unrecognized (uri);
- CuAssertIntEquals (tc, 1, ret);
+ assert_num_eq (1, ret);
p11_kit_uri_free (uri);
}
@@ -662,7 +662,7 @@ test_uri_parse_too_long_is_unrecognized (CuTest *tc)
static void
-test_uri_build_object_type_cert (CuTest *tc)
+test_uri_build_object_type_cert (void)
{
CK_ATTRIBUTE attr;
CK_OBJECT_CLASS klass;
@@ -671,7 +671,7 @@ test_uri_build_object_type_cert (CuTest *tc)
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
klass = CKO_CERTIFICATE;
attr.type = CKA_CLASS;
@@ -680,15 +680,15 @@ test_uri_build_object_type_cert (CuTest *tc)
p11_kit_uri_set_attribute (uri, &attr);
ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
- CuAssertTrue (tc, strstr (string, "object-type=cert") != NULL);
+ assert_num_eq (P11_KIT_URI_OK, ret);
+ assert (strstr (string, "object-type=cert") != NULL);
p11_kit_uri_free (uri);
free (string);
}
static void
-test_uri_build_object_type_private (CuTest *tc)
+test_uri_build_object_type_private (void)
{
CK_ATTRIBUTE attr;
CK_OBJECT_CLASS klass;
@@ -697,7 +697,7 @@ test_uri_build_object_type_private (CuTest *tc)
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
klass = CKO_PRIVATE_KEY;
attr.type = CKA_CLASS;
@@ -706,15 +706,15 @@ test_uri_build_object_type_private (CuTest *tc)
p11_kit_uri_set_attribute (uri, &attr);
ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
- CuAssertTrue (tc, strstr (string, "object-type=private") != NULL);
+ assert_num_eq (P11_KIT_URI_OK, ret);
+ assert (strstr (string, "object-type=private") != NULL);
p11_kit_uri_free (uri);
free (string);
}
static void
-test_uri_build_object_type_public (CuTest *tc)
+test_uri_build_object_type_public (void)
{
CK_ATTRIBUTE attr;
CK_OBJECT_CLASS klass;
@@ -723,7 +723,7 @@ test_uri_build_object_type_public (CuTest *tc)
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
klass = CKO_PUBLIC_KEY;
attr.type = CKA_CLASS;
@@ -732,15 +732,15 @@ test_uri_build_object_type_public (CuTest *tc)
p11_kit_uri_set_attribute (uri, &attr);
ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
- CuAssertTrue (tc, strstr (string, "object-type=public") != NULL);
+ assert_num_eq (P11_KIT_URI_OK, ret);
+ assert (strstr (string, "object-type=public") != NULL);
p11_kit_uri_free (uri);
free (string);
}
static void
-test_uri_build_object_type_secret (CuTest *tc)
+test_uri_build_object_type_secret (void)
{
CK_ATTRIBUTE attr;
CK_OBJECT_CLASS klass;
@@ -749,7 +749,7 @@ test_uri_build_object_type_secret (CuTest *tc)
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
klass = CKO_SECRET_KEY;
attr.type = CKA_CLASS;
@@ -758,15 +758,15 @@ test_uri_build_object_type_secret (CuTest *tc)
p11_kit_uri_set_attribute (uri, &attr);
ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
- CuAssertTrue (tc, strstr (string, "object-type=secret-key") != NULL);
+ assert_num_eq (P11_KIT_URI_OK, ret);
+ assert (strstr (string, "object-type=secret-key") != NULL);
p11_kit_uri_free (uri);
free (string);
}
static void
-test_uri_build_with_library (CuTest *tc)
+test_uri_build_with_library (void)
{
CK_INFO_PTR info;
P11KitUri *uri;
@@ -774,21 +774,21 @@ test_uri_build_with_library (CuTest *tc)
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
info = p11_kit_uri_get_module_info (uri);
set_space_string (info->libraryDescription, sizeof (info->libraryDescription), "The Description");
ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
- CuAssertTrue (tc, strstr (string, "library-description=The%20Description") != NULL);
+ assert_num_eq (P11_KIT_URI_OK, ret);
+ assert (strstr (string, "library-description=The%20Description") != NULL);
p11_kit_uri_free (uri);
free (string);
}
static void
-test_uri_build_library_version (CuTest *tc)
+test_uri_build_library_version (void)
{
CK_INFO_PTR info;
P11KitUri *uri;
@@ -796,121 +796,121 @@ test_uri_build_library_version (CuTest *tc)
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
info = p11_kit_uri_get_module_info (uri);
info->libraryVersion.major = 2;
info->libraryVersion.minor = 10;
ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
- CuAssertTrue (tc, strstr (string, "library-version=2.10") != NULL);
+ assert_num_eq (P11_KIT_URI_OK, ret);
+ assert (strstr (string, "library-version=2.10") != NULL);
p11_kit_uri_free (uri);
free (string);
}
static void
-test_uri_get_set_unrecognized (CuTest *tc)
+test_uri_get_set_unrecognized (void)
{
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_any_unrecognized (uri);
- CuAssertIntEquals (tc, 0, ret);
+ assert_num_eq (0, ret);
p11_kit_uri_set_unrecognized (uri, 1);
ret = p11_kit_uri_any_unrecognized (uri);
- CuAssertIntEquals (tc, 1, ret);
+ assert_num_eq (1, ret);
p11_kit_uri_set_unrecognized (uri, 0);
ret = p11_kit_uri_any_unrecognized (uri);
- CuAssertIntEquals (tc, 0, ret);
+ assert_num_eq (0, ret);
p11_kit_uri_free (uri);
}
static void
-test_uri_match_token (CuTest *tc)
+test_uri_match_token (void)
{
CK_TOKEN_INFO token;
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:model=Giselle", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
set_space_string (token.label, sizeof (token.label), "A label");
set_space_string (token.model, sizeof (token.model), "Giselle");
ret = p11_kit_uri_match_token_info (uri, &token);
- CuAssertIntEquals (tc, 1, ret);
+ assert_num_eq (1, ret);
set_space_string (token.label, sizeof (token.label), "Another label");
ret = p11_kit_uri_match_token_info (uri, &token);
- CuAssertIntEquals (tc, 1, ret);
+ assert_num_eq (1, ret);
set_space_string (token.model, sizeof (token.model), "Zoolander");
ret = p11_kit_uri_match_token_info (uri, &token);
- CuAssertIntEquals (tc, 0, ret);
+ assert_num_eq (0, ret);
p11_kit_uri_set_unrecognized (uri, 1);
ret = p11_kit_uri_match_token_info (uri, &token);
- CuAssertIntEquals (tc, 0, ret);
+ assert_num_eq (0, ret);
p11_kit_uri_free (uri);
}
static void
-test_uri_match_module (CuTest *tc)
+test_uri_match_module (void)
{
CK_INFO info;
P11KitUri *uri;
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:library-description=Quiet", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
set_space_string (info.libraryDescription, sizeof (info.libraryDescription), "Quiet");
set_space_string (info.manufacturerID, sizeof (info.manufacturerID), "Someone");
ret = p11_kit_uri_match_module_info (uri, &info);
- CuAssertIntEquals (tc, 1, ret);
+ assert_num_eq (1, ret);
set_space_string (info.manufacturerID, sizeof (info.manufacturerID), "Someone else");
ret = p11_kit_uri_match_module_info (uri, &info);
- CuAssertIntEquals (tc, 1, ret);
+ assert_num_eq (1, ret);
set_space_string (info.libraryDescription, sizeof (info.libraryDescription), "Leise");
ret = p11_kit_uri_match_module_info (uri, &info);
- CuAssertIntEquals (tc, 0, ret);
+ assert_num_eq (0, ret);
p11_kit_uri_set_unrecognized (uri, 1);
ret = p11_kit_uri_match_module_info (uri, &info);
- CuAssertIntEquals (tc, 0, ret);
+ assert_num_eq (0, ret);
p11_kit_uri_free (uri);
}
static void
-test_uri_match_version (CuTest *tc)
+test_uri_match_version (void)
{
CK_INFO info;
P11KitUri *uri;
@@ -919,28 +919,28 @@ test_uri_match_version (CuTest *tc)
memset (&info, 0, sizeof (info));
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:library-version=5.8", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
info.libraryVersion.major = 5;
info.libraryVersion.minor = 8;
ret = p11_kit_uri_match_module_info (uri, &info);
- CuAssertIntEquals (tc, 1, ret);
+ assert_num_eq (1, ret);
info.libraryVersion.major = 2;
info.libraryVersion.minor = 3;
ret = p11_kit_uri_match_module_info (uri, &info);
- CuAssertIntEquals (tc, 0, ret);
+ assert_num_eq (0, ret);
p11_kit_uri_free (uri);
}
static void
-test_uri_match_attributes (CuTest *tc)
+test_uri_match_attributes (void)
{
CK_ATTRIBUTE attrs[4];
CK_OBJECT_CLASS klass;
@@ -965,40 +965,40 @@ test_uri_match_attributes (CuTest *tc)
attrs[3].ulValueLen = sizeof (klass);
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ret = p11_kit_uri_parse ("pkcs11:object=Fancy;id=Blah;object-type=data", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
ret = p11_kit_uri_match_attributes (uri, attrs, 4);
- CuAssertIntEquals (tc, 0, ret);
+ assert_num_eq (0, ret);
attrs[1].pValue = "Fancy";
attrs[1].ulValueLen = 5;
ret = p11_kit_uri_match_attributes (uri, attrs, 4);
- CuAssertIntEquals (tc, 1, ret);
+ assert_num_eq (1, ret);
p11_kit_uri_clear_attribute (uri, CKA_CLASS);
ret = p11_kit_uri_match_attributes (uri, attrs, 4);
- CuAssertIntEquals (tc, 1, ret);
+ assert_num_eq (1, ret);
attrs[2].pValue = "pink";
ret = p11_kit_uri_match_attributes (uri, attrs, 4);
- CuAssertIntEquals (tc, 1, ret);
+ assert_num_eq (1, ret);
p11_kit_uri_set_unrecognized (uri, 1);
ret = p11_kit_uri_match_attributes (uri, attrs, 4);
- CuAssertIntEquals (tc, 0, ret);
+ assert_num_eq (0, ret);
p11_kit_uri_free (uri);
}
static void
-test_uri_get_set_attribute (CuTest *tc)
+test_uri_get_set_attribute (void)
{
CK_ATTRIBUTE attr;
CK_ATTRIBUTE_PTR ptr;
@@ -1006,51 +1006,51 @@ test_uri_get_set_attribute (CuTest *tc)
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
ptr = p11_kit_uri_get_attribute (uri, CKA_LABEL);
- CuAssertPtrEquals (tc, NULL, ptr);
+ assert_ptr_eq (NULL, ptr);
ret = p11_kit_uri_clear_attribute (uri, CKA_LABEL);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
ret = p11_kit_uri_clear_attribute (uri, CKA_COLOR);
- CuAssertIntEquals (tc, P11_KIT_URI_NOT_FOUND, ret);
+ assert_num_eq (P11_KIT_URI_NOT_FOUND, ret);
attr.type = CKA_LABEL;
attr.pValue = "Test";
attr.ulValueLen = 4;
ret = p11_kit_uri_set_attribute (uri, &attr);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
/* We can set other attributes */
attr.type = CKA_COLOR;
ret = p11_kit_uri_set_attribute (uri, &attr);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
/* And get them too */
ptr = p11_kit_uri_get_attribute (uri, CKA_COLOR);
- CuAssertPtrNotNull (tc, ptr);
+ assert_ptr_not_null (ptr);
ptr = p11_kit_uri_get_attribute (uri, CKA_LABEL);
- CuAssertPtrNotNull (tc, ptr);
+ assert_ptr_not_null (ptr);
- CuAssertTrue (tc, ptr->type == CKA_LABEL);
- CuAssertTrue (tc, ptr->ulValueLen == 4);
- CuAssertTrue (tc, memcmp (ptr->pValue, "Test", 4) == 0);
+ assert (ptr->type == CKA_LABEL);
+ assert (ptr->ulValueLen == 4);
+ assert (memcmp (ptr->pValue, "Test", 4) == 0);
ret = p11_kit_uri_clear_attribute (uri, CKA_LABEL);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
ptr = p11_kit_uri_get_attribute (uri, CKA_LABEL);
- CuAssertPtrEquals (tc, NULL, ptr);
+ assert_ptr_eq (NULL, ptr);
p11_kit_uri_free (uri);
}
static void
-test_uri_get_set_attributes (CuTest *tc)
+test_uri_get_set_attributes (void)
{
CK_ATTRIBUTE_PTR attrs;
CK_OBJECT_CLASS klass;
@@ -1060,39 +1060,39 @@ test_uri_get_set_attributes (CuTest *tc)
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
attrs = p11_kit_uri_get_attributes (uri, &n_attrs);
- CuAssertPtrNotNull (tc, attrs);
- CuAssertIntEquals (tc, 0, n_attrs);
+ assert_ptr_not_null (attrs);
+ assert_num_eq (0, n_attrs);
attr.type = CKA_LABEL;
attr.pValue = "Test";
attr.ulValueLen = 4;
ret = p11_kit_uri_set_attribute (uri, &attr);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
attrs = p11_kit_uri_get_attributes (uri, &n_attrs);
- CuAssertPtrNotNull (tc, attrs);
- CuAssertIntEquals (tc, 1, n_attrs);
- CuAssertTrue (tc, attrs[0].type == CKA_LABEL);
- CuAssertTrue (tc, attrs[0].ulValueLen == 4);
- CuAssertTrue (tc, memcmp (attrs[0].pValue, "Test", 4) == 0);
+ assert_ptr_not_null (attrs);
+ assert_num_eq (1, n_attrs);
+ assert (attrs[0].type == CKA_LABEL);
+ assert (attrs[0].ulValueLen == 4);
+ assert (memcmp (attrs[0].pValue, "Test", 4) == 0);
attr.type = CKA_LABEL;
attr.pValue = "Kablooey";
attr.ulValueLen = 8;
ret = p11_kit_uri_set_attribute (uri, &attr);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
attrs = p11_kit_uri_get_attributes (uri, &n_attrs);
- CuAssertPtrNotNull (tc, attrs);
- CuAssertIntEquals (tc, 1, n_attrs);
- CuAssertTrue (tc, attrs[0].type == CKA_LABEL);
- CuAssertTrue (tc, attrs[0].ulValueLen == 8);
- CuAssertTrue (tc, memcmp (attrs[0].pValue, "Kablooey", 8) == 0);
+ assert_ptr_not_null (attrs);
+ assert_num_eq (1, n_attrs);
+ assert (attrs[0].type == CKA_LABEL);
+ assert (attrs[0].ulValueLen == 8);
+ assert (memcmp (attrs[0].pValue, "Kablooey", 8) == 0);
klass = CKO_DATA;
attr.type = CKA_CLASS;
@@ -1100,52 +1100,52 @@ test_uri_get_set_attributes (CuTest *tc)
attr.ulValueLen = sizeof (klass);
ret = p11_kit_uri_set_attribute (uri, &attr);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
attrs = p11_kit_uri_get_attributes (uri, &n_attrs);
- CuAssertPtrNotNull (tc, attrs);
- CuAssertIntEquals (tc, 2, n_attrs);
- CuAssertTrue (tc, attrs[0].type == CKA_LABEL);
- CuAssertTrue (tc, attrs[0].ulValueLen == 8);
- CuAssertTrue (tc, memcmp (attrs[0].pValue, "Kablooey", 8) == 0);
- CuAssertTrue (tc, attrs[1].type == CKA_CLASS);
- CuAssertTrue (tc, attrs[1].ulValueLen == sizeof (klass));
- CuAssertTrue (tc, memcmp (attrs[1].pValue, &klass, sizeof (klass)) == 0);
+ assert_ptr_not_null (attrs);
+ assert_num_eq (2, n_attrs);
+ assert (attrs[0].type == CKA_LABEL);
+ assert (attrs[0].ulValueLen == 8);
+ assert (memcmp (attrs[0].pValue, "Kablooey", 8) == 0);
+ assert (attrs[1].type == CKA_CLASS);
+ assert (attrs[1].ulValueLen == sizeof (klass));
+ assert (memcmp (attrs[1].pValue, &klass, sizeof (klass)) == 0);
ret = p11_kit_uri_clear_attribute (uri, CKA_LABEL);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
attrs = p11_kit_uri_get_attributes (uri, &n_attrs);
- CuAssertPtrNotNull (tc, attrs);
- CuAssertIntEquals (tc, 1, n_attrs);
- CuAssertTrue (tc, attrs[0].type == CKA_CLASS);
- CuAssertTrue (tc, attrs[0].ulValueLen == sizeof (klass));
- CuAssertTrue (tc, memcmp (attrs[0].pValue, &klass, sizeof (klass)) == 0);
+ assert_ptr_not_null (attrs);
+ assert_num_eq (1, n_attrs);
+ assert (attrs[0].type == CKA_CLASS);
+ assert (attrs[0].ulValueLen == sizeof (klass));
+ assert (memcmp (attrs[0].pValue, &klass, sizeof (klass)) == 0);
attr.type = CKA_LABEL;
attr.pValue = "Three";
attr.ulValueLen = 5;
ret = p11_kit_uri_set_attributes (uri, &attr, 1);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
attrs = p11_kit_uri_get_attributes (uri, &n_attrs);
- CuAssertPtrNotNull (tc, attrs);
- CuAssertIntEquals (tc, 1, n_attrs);
- CuAssertTrue (tc, attrs[0].type == CKA_LABEL);
- CuAssertTrue (tc, attrs[0].ulValueLen == 5);
- CuAssertTrue (tc, memcmp (attrs[0].pValue, "Three", 5) == 0);
+ assert_ptr_not_null (attrs);
+ assert_num_eq (1, n_attrs);
+ assert (attrs[0].type == CKA_LABEL);
+ assert (attrs[0].ulValueLen == 5);
+ assert (memcmp (attrs[0].pValue, "Three", 5) == 0);
p11_kit_uri_clear_attributes (uri);
attrs = p11_kit_uri_get_attributes (uri, &n_attrs);
- CuAssertPtrNotNull (tc, attrs);
- CuAssertIntEquals (tc, 0, n_attrs);
+ assert_ptr_not_null (attrs);
+ assert_num_eq (0, n_attrs);
p11_kit_uri_free (uri);
}
static void
-test_uri_pin_source (CuTest *tc)
+test_uri_pin_source (void)
{
P11KitUri *uri;
const char *pin_source;
@@ -1153,106 +1153,93 @@ test_uri_pin_source (CuTest *tc)
int ret;
uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
+ assert_ptr_not_null (uri);
p11_kit_uri_set_pin_source (uri, "|my-pin-source");
pin_source = p11_kit_uri_get_pin_source (uri);
- CuAssertStrEquals (tc, "|my-pin-source", pin_source);
+ assert_str_eq ("|my-pin-source", pin_source);
pin_source = p11_kit_uri_get_pinfile (uri);
- CuAssertStrEquals (tc, "|my-pin-source", pin_source);
+ assert_str_eq ("|my-pin-source", pin_source);
p11_kit_uri_set_pinfile (uri, "|my-pin-file");
pin_source = p11_kit_uri_get_pin_source (uri);
- CuAssertStrEquals (tc, "|my-pin-file", pin_source);
+ assert_str_eq ("|my-pin-file", pin_source);
ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
- CuAssertTrue (tc, strstr (string, "pin-source=%7cmy-pin-file") != NULL);
+ assert_num_eq (P11_KIT_URI_OK, ret);
+ assert (strstr (string, "pin-source=%7cmy-pin-file") != NULL);
free (string);
ret = p11_kit_uri_parse ("pkcs11:pin-source=blah%2Fblah", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+ assert_num_eq (P11_KIT_URI_OK, ret);
pin_source = p11_kit_uri_get_pin_source (uri);
- CuAssertStrEquals (tc, "blah/blah", pin_source);
+ assert_str_eq ("blah/blah", pin_source);
p11_kit_uri_free (uri);
}
static void
-test_uri_free_null (CuTest *tc)
+test_uri_free_null (void)
{
p11_kit_uri_free (NULL);
}
static void
-test_uri_message (CuTest *tc)
+test_uri_message (void)
{
- CuAssertTrue (tc, p11_kit_uri_message (P11_KIT_URI_OK) == NULL);
- CuAssertPtrNotNull (tc, p11_kit_uri_message (P11_KIT_URI_UNEXPECTED));
- CuAssertPtrNotNull (tc, p11_kit_uri_message (-555555));
+ assert (p11_kit_uri_message (P11_KIT_URI_OK) == NULL);
+ assert_ptr_not_null (p11_kit_uri_message (P11_KIT_URI_UNEXPECTED));
+ assert_ptr_not_null (p11_kit_uri_message (-555555));
}
int
-main (void)
+main (int argc,
+ char *argv[])
{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- putenv ("P11_KIT_STRICT=1");
- p11_debug_init ();
-
- SUITE_ADD_TEST (suite, test_uri_parse);
- SUITE_ADD_TEST (suite, test_uri_parse_bad_scheme);
- SUITE_ADD_TEST (suite, test_uri_parse_with_label);
- SUITE_ADD_TEST (suite, test_uri_parse_with_label_and_klass);
- SUITE_ADD_TEST (suite, test_uri_parse_with_id);
- SUITE_ADD_TEST (suite, test_uri_parse_with_bad_string_encoding);
- SUITE_ADD_TEST (suite, test_uri_parse_with_bad_hex_encoding);
- SUITE_ADD_TEST (suite, test_uri_parse_with_token);
- SUITE_ADD_TEST (suite, test_uri_parse_with_token_bad_encoding);
- SUITE_ADD_TEST (suite, test_uri_parse_with_bad_syntax);
- SUITE_ADD_TEST (suite, test_uri_parse_with_spaces);
- SUITE_ADD_TEST (suite, test_uri_parse_with_library);
- SUITE_ADD_TEST (suite, test_uri_parse_with_library_bad_encoding);
- SUITE_ADD_TEST (suite, test_uri_build_empty);
- SUITE_ADD_TEST (suite, test_uri_build_with_token_info);
- SUITE_ADD_TEST (suite, test_uri_build_with_token_null_info);
- SUITE_ADD_TEST (suite, test_uri_build_with_token_empty_info);
- SUITE_ADD_TEST (suite, test_uri_build_with_attributes);
- SUITE_ADD_TEST (suite, test_uri_parse_private_key);
- SUITE_ADD_TEST (suite, test_uri_parse_secret_key);
- SUITE_ADD_TEST (suite, test_uri_parse_library_version);
- SUITE_ADD_TEST (suite, test_uri_parse_parse_unknown_object_type);
- SUITE_ADD_TEST (suite, test_uri_parse_unrecognized);
- SUITE_ADD_TEST (suite, test_uri_parse_too_long_is_unrecognized);
- SUITE_ADD_TEST (suite, test_uri_build_object_type_cert);
- SUITE_ADD_TEST (suite, test_uri_build_object_type_private);
- SUITE_ADD_TEST (suite, test_uri_build_object_type_public);
- SUITE_ADD_TEST (suite, test_uri_build_object_type_secret);
- SUITE_ADD_TEST (suite, test_uri_build_with_library);
- SUITE_ADD_TEST (suite, test_uri_build_library_version);
- SUITE_ADD_TEST (suite, test_uri_get_set_unrecognized);
- SUITE_ADD_TEST (suite, test_uri_match_token);
- SUITE_ADD_TEST (suite, test_uri_match_module);
- SUITE_ADD_TEST (suite, test_uri_match_version);
- SUITE_ADD_TEST (suite, test_uri_match_attributes);
- SUITE_ADD_TEST (suite, test_uri_get_set_attribute);
- SUITE_ADD_TEST (suite, test_uri_get_set_attributes);
- SUITE_ADD_TEST (suite, test_uri_pin_source);
- SUITE_ADD_TEST (suite, test_uri_free_null);
- SUITE_ADD_TEST (suite, test_uri_message);
-
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
- return ret;
+ p11_test (test_uri_parse, "/uri/test_uri_parse");
+ p11_test (test_uri_parse_bad_scheme, "/uri/test_uri_parse_bad_scheme");
+ p11_test (test_uri_parse_with_label, "/uri/test_uri_parse_with_label");
+ p11_test (test_uri_parse_with_label_and_klass, "/uri/test_uri_parse_with_label_and_klass");
+ p11_test (test_uri_parse_with_id, "/uri/test_uri_parse_with_id");
+ p11_test (test_uri_parse_with_bad_string_encoding, "/uri/test_uri_parse_with_bad_string_encoding");
+ p11_test (test_uri_parse_with_bad_hex_encoding, "/uri/test_uri_parse_with_bad_hex_encoding");
+ p11_test (test_uri_parse_with_token, "/uri/test_uri_parse_with_token");
+ p11_test (test_uri_parse_with_token_bad_encoding, "/uri/test_uri_parse_with_token_bad_encoding");
+ p11_test (test_uri_parse_with_bad_syntax, "/uri/test_uri_parse_with_bad_syntax");
+ p11_test (test_uri_parse_with_spaces, "/uri/test_uri_parse_with_spaces");
+ p11_test (test_uri_parse_with_library, "/uri/test_uri_parse_with_library");
+ p11_test (test_uri_parse_with_library_bad_encoding, "/uri/test_uri_parse_with_library_bad_encoding");
+ p11_test (test_uri_build_empty, "/uri/test_uri_build_empty");
+ p11_test (test_uri_build_with_token_info, "/uri/test_uri_build_with_token_info");
+ p11_test (test_uri_build_with_token_null_info, "/uri/test_uri_build_with_token_null_info");
+ p11_test (test_uri_build_with_token_empty_info, "/uri/test_uri_build_with_token_empty_info");
+ p11_test (test_uri_build_with_attributes, "/uri/test_uri_build_with_attributes");
+ p11_test (test_uri_parse_private_key, "/uri/test_uri_parse_private_key");
+ p11_test (test_uri_parse_secret_key, "/uri/test_uri_parse_secret_key");
+ p11_test (test_uri_parse_library_version, "/uri/test_uri_parse_library_version");
+ p11_test (test_uri_parse_parse_unknown_object_type, "/uri/test_uri_parse_parse_unknown_object_type");
+ p11_test (test_uri_parse_unrecognized, "/uri/test_uri_parse_unrecognized");
+ p11_test (test_uri_parse_too_long_is_unrecognized, "/uri/test_uri_parse_too_long_is_unrecognized");
+ p11_test (test_uri_build_object_type_cert, "/uri/test_uri_build_object_type_cert");
+ p11_test (test_uri_build_object_type_private, "/uri/test_uri_build_object_type_private");
+ p11_test (test_uri_build_object_type_public, "/uri/test_uri_build_object_type_public");
+ p11_test (test_uri_build_object_type_secret, "/uri/test_uri_build_object_type_secret");
+ p11_test (test_uri_build_with_library, "/uri/test_uri_build_with_library");
+ p11_test (test_uri_build_library_version, "/uri/test_uri_build_library_version");
+ p11_test (test_uri_get_set_unrecognized, "/uri/test_uri_get_set_unrecognized");
+ p11_test (test_uri_match_token, "/uri/test_uri_match_token");
+ p11_test (test_uri_match_module, "/uri/test_uri_match_module");
+ p11_test (test_uri_match_version, "/uri/test_uri_match_version");
+ p11_test (test_uri_match_attributes, "/uri/test_uri_match_attributes");
+ p11_test (test_uri_get_set_attribute, "/uri/test_uri_get_set_attribute");
+ p11_test (test_uri_get_set_attributes, "/uri/test_uri_get_set_attributes");
+ p11_test (test_uri_pin_source, "/uri/test_uri_pin_source");
+ p11_test (test_uri_free_null, "/uri/test_uri_free_null");
+ p11_test (test_uri_message, "/uri/test_uri_message");
+
+ return p11_test_run (argc, argv);
}
diff --git a/p11-kit/tests/test-virtual.c b/p11-kit/tests/test-virtual.c
index 1482843..73777d3 100644
--- a/p11-kit/tests/test-virtual.c
+++ b/p11-kit/tests/test-virtual.c
@@ -40,7 +40,7 @@
#include "private.h"
#include "virtual.h"
-#include "CuTest.h"
+#include "test.h"
#include "mock.h"
@@ -57,7 +57,7 @@
typedef struct {
p11_virtual virt;
- CuTest *cu;
+ void *check;
} Override;
static CK_RV
@@ -66,8 +66,8 @@ override_initialize (CK_X_FUNCTION_LIST *self,
{
Override *over = (Override *)self;
- /* We're using CuTest both as closure and as C_Initialize arg */
- CuAssertPtrEquals (over->cu, over->cu, args);
+ assert_str_eq ("initialize-arg", args);
+ assert_str_eq ("overide-arg", over->check);
/* An arbitrary error code to check */
return CKR_NEED_TO_CREATE_THREADS;
@@ -84,7 +84,7 @@ test_destroyer (void *data)
}
static void
-test_initialize (CuTest *tc)
+test_initialize (void)
{
CK_FUNCTION_LIST_PTR module;
Override over = { };
@@ -92,21 +92,21 @@ test_initialize (CuTest *tc)
p11_virtual_init (&over.virt, &p11_virtual_stack, &mock_x_module_no_slots, test_destroyer);
over.virt.funcs.C_Initialize = override_initialize;
- over.cu = tc;
+ over.check = "overide-arg";
test_destroyed = false;
module = p11_virtual_wrap (&over.virt, (p11_destroyer)p11_virtual_uninit);
- CuAssertPtrNotNull (tc, module);
+ assert_ptr_not_null (module);
- rv = (module->C_Initialize) (tc);
- CuAssertIntEquals (tc, CKR_NEED_TO_CREATE_THREADS, rv);
+ rv = (module->C_Initialize) ("initialize-arg");
+ assert_num_eq (CKR_NEED_TO_CREATE_THREADS, rv);
p11_virtual_unwrap (module);
- CuAssertIntEquals (tc, true, test_destroyed);
+ assert_num_eq (true, test_destroyed);
}
static void
-test_fall_through (CuTest *tc)
+test_fall_through (void)
{
CK_FUNCTION_LIST_PTR module;
Override over = { };
@@ -116,22 +116,22 @@ test_fall_through (CuTest *tc)
p11_virtual_init (&base, &p11_virtual_base, &mock_module_no_slots, NULL);
p11_virtual_init (&over.virt, &p11_virtual_stack, &base, NULL);
over.virt.funcs.C_Initialize = override_initialize;
- over.cu = tc;
+ over.check = "overide-arg";
module = p11_virtual_wrap (&over.virt, NULL);
- CuAssertPtrNotNull (tc, module);
+ assert_ptr_not_null (module);
- rv = (module->C_Initialize) (tc);
- CuAssertIntEquals (tc, CKR_NEED_TO_CREATE_THREADS, rv);
+ rv = (module->C_Initialize) ("initialize-arg");
+ assert_num_eq (CKR_NEED_TO_CREATE_THREADS, rv);
/* All other functiosn should have just fallen through */
- CuAssertPtrEquals (tc, mock_module_no_slots.C_Finalize, module->C_Finalize);
+ assert_ptr_eq (mock_module_no_slots.C_Finalize, module->C_Finalize);
p11_virtual_unwrap (module);
}
static void
-test_get_function_list (CuTest *tc)
+test_get_function_list (void)
{
CK_FUNCTION_LIST_PTR module;
CK_FUNCTION_LIST_PTR list;
@@ -140,44 +140,32 @@ test_get_function_list (CuTest *tc)
p11_virtual_init (&virt, &p11_virtual_base, &mock_x_module_no_slots, NULL);
module = p11_virtual_wrap (&virt, NULL);
- CuAssertPtrNotNull (tc, module);
+ assert_ptr_not_null (module);
rv = (module->C_GetFunctionList) (&list);
- CuAssertIntEquals (tc, CKR_OK, rv);
- CuAssertPtrEquals (tc, module, list);
+ assert_num_eq (CKR_OK, rv);
+ assert_ptr_eq (module, list);
rv = (module->C_GetFunctionList) (&list);
- CuAssertIntEquals (tc, CKR_OK, rv);
+ assert_num_eq (CKR_OK, rv);
rv = (module->C_GetFunctionList) (NULL);
- CuAssertIntEquals (tc, CKR_ARGUMENTS_BAD, rv);
+ assert_num_eq (CKR_ARGUMENTS_BAD, rv);
p11_virtual_unwrap (module);
}
int
-main (void)
+main (int argc,
+ char *argv[])
{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- putenv ("P11_KIT_STRICT=1");
mock_module_init ();
p11_library_init ();
assert (p11_virtual_can_wrap ());
- SUITE_ADD_TEST (suite, test_initialize);
- SUITE_ADD_TEST (suite, test_fall_through);
- SUITE_ADD_TEST (suite, test_get_function_list);
-
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
-
- return ret;
+ p11_test (test_initialize, "/virtual/test_initialize");
+ p11_test (test_fall_through, "/virtual/test_fall_through");
+ p11_test (test_get_function_list, "/virtual/test_get_function_list");
+
+ return p11_test_run (argc, argv);
}