summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am76
-rw-r--r--tests/conf-test.c414
-rw-r--r--tests/cutest/CuTest.c329
-rw-r--r--tests/cutest/CuTest.h111
-rw-r--r--tests/cutest/README.txt211
-rw-r--r--tests/cutest/license.txt38
-rw-r--r--tests/files/system-modules/four.module3
-rw-r--r--tests/files/system-modules/one.module3
-rw-r--r--tests/files/system-modules/two-duplicate.module3
-rw-r--r--tests/files/system-modules/two.badname5
-rw-r--r--tests/files/system-modules/win32/four.module3
-rw-r--r--tests/files/system-modules/win32/one.module3
-rw-r--r--tests/files/system-modules/win32/two-duplicate.module3
-rw-r--r--tests/files/system-modules/win32/two.badname5
-rw-r--r--tests/files/system-pkcs11.conf3
-rw-r--r--tests/files/test-1.conf6
-rw-r--r--tests/files/test-pinfile1
-rw-r--r--tests/files/test-pinfile-large53
-rw-r--r--tests/files/test-system-invalid.conf3
-rw-r--r--tests/files/test-system-merge.conf7
-rw-r--r--tests/files/test-system-none.conf8
-rw-r--r--tests/files/test-system-only.conf8
-rw-r--r--tests/files/test-user-invalid.conf3
-rw-r--r--tests/files/test-user-only.conf4
-rw-r--r--tests/files/test-user.conf3
-rw-r--r--tests/files/user-modules/one.module2
-rw-r--r--tests/files/user-modules/three.module5
-rw-r--r--tests/files/user-modules/win32/one.module2
-rw-r--r--tests/files/user-modules/win32/three.module5
-rw-r--r--tests/hash-test.c465
-rw-r--r--tests/mock-module-ep.c52
-rw-r--r--tests/mock-module.c898
-rw-r--r--tests/mock-module.h337
-rw-r--r--tests/pin-test.c323
-rw-r--r--tests/print-messages.c137
-rw-r--r--tests/progname-test.c110
-rw-r--r--tests/ptr-array-test.c257
-rw-r--r--tests/test-init.c319
-rw-r--r--tests/test-modules.c245
-rw-r--r--tests/uri-test.c1221
40 files changed, 0 insertions, 5684 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
deleted file mode 100644
index c25ed57..0000000
--- a/tests/Makefile.am
+++ /dev/null
@@ -1,76 +0,0 @@
-
-INCLUDES = \
- -I$(top_srcdir) \
- -I$(top_srcdir)/common \
- -I$(top_srcdir)/p11-kit \
- -I$(srcdir)/cutest \
- -DSRCDIR=\"$(abs_srcdir)\" \
- -DBUILDDIR=\"$(abs_builddir)\" \
- -DP11_KIT_FUTURE_UNSTABLE_API
-
-LDADD = \
- $(top_builddir)/p11-kit/libp11-kit-testable.la \
- $(LTLIBINTL)
-
-CHECK_PROGS = \
- hash-test \
- ptr-array-test \
- progname-test \
- conf-test \
- uri-test \
- pin-test \
- test-init \
- test-modules
-
-noinst_PROGRAMS = \
- print-messages \
- $(CHECK_PROGS)
-
-cutestfiles = cutest/CuTest.c cutest/CuTest.h
-
-conf_test_SOURCES = conf-test.c $(cutestfiles)
-hash_test_SOURCES = hash-test.c $(cutestfiles)
-pin_test_SOURCES = pin-test.c $(cutestfiles)
-ptr_array_test_SOURCES = ptr-array-test.c $(cutestfiles)
-progname_test_SOURCES = progname-test.c $(cutestfiles)
-test_init_SOURCES = test-init.c $(cutestfiles) \
- mock-module.c mock-module.h
-test_init_CFLAGS = $(AM_CFLAGS)
-test_modules_SOURCES = test-modules.c $(cutestfiles)
-
-uri_test_SOURCES = uri-test.c $(cutestfiles)
-
-TESTS = $(CHECK_PROGS:=$(EXEEXT))
-
-noinst_LTLIBRARIES = \
- mock-one.la \
- mock-two.la \
- mock-three.la \
- mock-four.la
-
-mock_one_la_SOURCES = \
- mock-module.c mock-module.h \
- mock-module-ep.c
-
-mock_one_la_LIBADD = \
- $(top_builddir)/p11-kit/libp11-kit-compat.la
-
-mock_one_la_LDFLAGS = \
- -module -avoid-version -rpath /nowhere \
- -no-undefined -export-symbols-regex 'C_GetFunctionList'
-
-mock_two_la_SOURCES = $(mock_one_la_SOURCES)
-mock_two_la_LDFLAGS = $(mock_one_la_LDFLAGS)
-mock_two_la_LIBADD = $(mock_one_la_LIBADD)
-
-mock_three_la_SOURCES = $(mock_one_la_SOURCES)
-mock_three_la_LDFLAGS = $(mock_one_la_LDFLAGS)
-mock_three_la_LIBADD = $(mock_one_la_LIBADD)
-
-mock_four_la_SOURCES = $(mock_one_la_SOURCES)
-mock_four_la_LDFLAGS = $(mock_one_la_LDFLAGS)
-mock_four_la_LIBADD = $(mock_one_la_LIBADD)
-
-EXTRA_DIST = \
- cutest \
- files
diff --git a/tests/conf-test.c b/tests/conf-test.c
deleted file mode 100644
index 98841a2..0000000
--- a/tests/conf-test.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Copyright (c) 2011, Collabora Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- * * The names of contributors to this software may not be
- * used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Author: Stef Walter <stefw@collabora.co.uk>
- */
-
-#include "config.h"
-#include "CuTest.h"
-
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "conf.h"
-#include "p11-kit.h"
-#include "private.h"
-
-static void
-test_parse_conf_1 (CuTest *tc)
-{
- hashmap *map;
- const char *value;
-
- map = _p11_conf_parse_file (SRCDIR "/files/test-1.conf", 0);
- CuAssertPtrNotNull (tc, map);
-
- value = _p11_hash_get (map, "key1");
- CuAssertStrEquals (tc, "value1", value);
-
- value = _p11_hash_get (map, "with-colon");
- CuAssertStrEquals (tc, "value-of-colon", value);
-
- value = _p11_hash_get (map, "with-whitespace");
- CuAssertStrEquals (tc, "value-with-whitespace", value);
-
- value = _p11_hash_get (map, "embedded-comment");
- CuAssertStrEquals (tc, "this is # not a comment", value);
-
- _p11_hash_free (map);
-}
-
-static void
-test_parse_ignore_missing (CuTest *tc)
-{
- hashmap *map;
-
- map = _p11_conf_parse_file (SRCDIR "/files/non-existant.conf", CONF_IGNORE_MISSING);
- CuAssertPtrNotNull (tc, map);
-
- CuAssertIntEquals (tc, 0, _p11_hash_size (map));
- CuAssertPtrEquals (tc, NULL, (void*)p11_kit_message ());
- _p11_hash_free (map);
-}
-
-static void
-test_parse_fail_missing (CuTest *tc)
-{
- hashmap *map;
-
- map = _p11_conf_parse_file (SRCDIR "/files/non-existant.conf", 0);
- CuAssertPtrEquals (tc, map, NULL);
- CuAssertPtrNotNull (tc, p11_kit_message ());
-}
-
-static void
-test_merge_defaults (CuTest *tc)
-{
- hashmap *values;
- hashmap *defaults;
-
- values = _p11_hash_create (_p11_hash_string_hash, _p11_hash_string_equal, free, free);
- defaults = _p11_hash_create (_p11_hash_string_hash, _p11_hash_string_equal, free, free);
-
- _p11_hash_set (values, strdup ("one"), strdup ("real1"));
- _p11_hash_set (values, strdup ("two"), strdup ("real2"));
-
- _p11_hash_set (defaults, strdup ("two"), strdup ("default2"));
- _p11_hash_set (defaults, strdup ("three"), strdup ("default3"));
-
- if (_p11_conf_merge_defaults (values, defaults) < 0)
- CuFail (tc, "should not be reached");
-
- _p11_hash_free (defaults);
-
- CuAssertStrEquals (tc, _p11_hash_get (values, "one"), "real1");
- CuAssertStrEquals (tc, _p11_hash_get (values, "two"), "real2");
- CuAssertStrEquals (tc, _p11_hash_get (values, "three"), "default3");
-
- _p11_hash_free (values);
-}
-
-static void
-test_load_globals_merge (CuTest *tc)
-{
- int user_mode = -1;
- hashmap *config;
-
- _p11_kit_clear_message ();
-
- 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_kit_message ());
- CuAssertIntEquals (tc, CONF_USER_MERGE, user_mode);
-
- CuAssertStrEquals (tc, _p11_hash_get (config, "key1"), "system1");
- CuAssertStrEquals (tc, _p11_hash_get (config, "key2"), "user2");
- CuAssertStrEquals (tc, _p11_hash_get (config, "key3"), "user3");
-
- _p11_hash_free (config);
-}
-
-static void
-test_load_globals_no_user (CuTest *tc)
-{
- int user_mode = -1;
- hashmap *config;
-
- _p11_kit_clear_message ();
-
- 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_kit_message ());
- CuAssertIntEquals (tc, CONF_USER_NONE, user_mode);
-
- CuAssertStrEquals (tc, _p11_hash_get (config, "key1"), "system1");
- CuAssertStrEquals (tc, _p11_hash_get (config, "key2"), "system2");
- CuAssertStrEquals (tc, _p11_hash_get (config, "key3"), "system3");
-
- _p11_hash_free (config);
-}
-
-static void
-test_load_globals_user_sets_only (CuTest *tc)
-{
- int user_mode = -1;
- hashmap *config;
-
- _p11_kit_clear_message ();
-
- 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_kit_message ());
- CuAssertIntEquals (tc, CONF_USER_ONLY, user_mode);
-
- CuAssertStrEquals (tc, _p11_hash_get (config, "key1"), NULL);
- CuAssertStrEquals (tc, _p11_hash_get (config, "key2"), "user2");
- CuAssertStrEquals (tc, _p11_hash_get (config, "key3"), "user3");
-
- _p11_hash_free (config);
-}
-
-static void
-test_load_globals_system_sets_only (CuTest *tc)
-{
- int user_mode = -1;
- hashmap *config;
-
- _p11_kit_clear_message ();
-
- 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_kit_message ());
- CuAssertIntEquals (tc, CONF_USER_ONLY, user_mode);
-
- CuAssertStrEquals (tc, _p11_hash_get (config, "key1"), NULL);
- CuAssertStrEquals (tc, _p11_hash_get (config, "key2"), "user2");
- CuAssertStrEquals (tc, _p11_hash_get (config, "key3"), "user3");
-
- _p11_hash_free (config);
-}
-
-static void
-test_load_globals_system_sets_invalid (CuTest *tc)
-{
- int user_mode = -1;
- hashmap *config;
- int error;
-
- _p11_kit_clear_message ();
-
- config = _p11_conf_load_globals (SRCDIR "/files/test-system-invalid.conf",
- SRCDIR "/files/non-existant.conf",
- &user_mode);
- error = errno;
- CuAssertPtrEquals (tc, NULL, config);
- CuAssertIntEquals (tc, EINVAL, error);
- CuAssertPtrNotNull (tc, p11_kit_message ());
-
- _p11_hash_free (config);
-}
-
-static void
-test_load_globals_user_sets_invalid (CuTest *tc)
-{
- int user_mode = -1;
- hashmap *config;
- int error;
-
- _p11_kit_clear_message ();
-
- config = _p11_conf_load_globals (SRCDIR "/files/test-system-merge.conf",
- SRCDIR "/files/test-user-invalid.conf",
- &user_mode);
- error = errno;
- CuAssertPtrEquals (tc, NULL, config);
- CuAssertIntEquals (tc, EINVAL, error);
- CuAssertPtrNotNull (tc, p11_kit_message ());
-
- _p11_hash_free (config);
-}
-
-static int
-assert_msg_contains (const char *msg,
- const char *text)
-{
- if (msg == NULL)
- return 0;
- return strstr (msg, text) ? 1 : 0;
-}
-
-static void
-test_load_modules_merge (CuTest *tc)
-{
- hashmap *configs;
- hashmap *config;
-
- _p11_kit_clear_message ();
-
- configs = _p11_conf_load_modules (CONF_USER_MERGE,
- SRCDIR "/files/system-modules",
- SRCDIR "/files/user-modules");
- CuAssertPtrNotNull (tc, configs);
- CuAssertTrue (tc, assert_msg_contains (p11_kit_message (), "invalid config filename"));
-
- config = _p11_hash_get (configs, "one");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-one.so", _p11_hash_get (config, "module"));
- CuAssertStrEquals (tc, _p11_hash_get (config, "setting"), "user1");
-
- config = _p11_hash_get (configs, "two.badname");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-two.so", _p11_hash_get (config, "module"));
- CuAssertStrEquals (tc, _p11_hash_get (config, "setting"), "system2");
-
- config = _p11_hash_get (configs, "three");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-three.so", _p11_hash_get (config, "module"));
- CuAssertStrEquals (tc, _p11_hash_get (config, "setting"), "user3");
-
- _p11_hash_free (configs);
-}
-
-static void
-test_load_modules_user_none (CuTest *tc)
-{
- hashmap *configs;
- hashmap *config;
-
- _p11_kit_clear_message ();
-
- configs = _p11_conf_load_modules (CONF_USER_NONE,
- SRCDIR "/files/system-modules",
- SRCDIR "/files/user-modules");
- CuAssertPtrNotNull (tc, configs);
- CuAssertTrue (tc, assert_msg_contains (p11_kit_message (), "invalid config filename"));
-
- config = _p11_hash_get (configs, "one");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-one.so", _p11_hash_get (config, "module"));
- CuAssertStrEquals (tc, _p11_hash_get (config, "setting"), "system1");
-
- config = _p11_hash_get (configs, "two.badname");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-two.so", _p11_hash_get (config, "module"));
- CuAssertStrEquals (tc, _p11_hash_get (config, "setting"), "system2");
-
- config = _p11_hash_get (configs, "three");
- CuAssertPtrEquals (tc, NULL, config);
-
- _p11_hash_free (configs);
-}
-
-static void
-test_load_modules_user_only (CuTest *tc)
-{
- hashmap *configs;
- hashmap *config;
-
- _p11_kit_clear_message ();
-
- configs = _p11_conf_load_modules (CONF_USER_ONLY,
- SRCDIR "/files/system-modules",
- SRCDIR "/files/user-modules");
- CuAssertPtrNotNull (tc, configs);
- CuAssertPtrEquals (tc, NULL, (void *)p11_kit_message ());
-
- config = _p11_hash_get (configs, "one");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, _p11_hash_get (config, "module"), NULL);
- CuAssertStrEquals (tc, _p11_hash_get (config, "setting"), "user1");
-
- config = _p11_hash_get (configs, "two.badname");
- CuAssertPtrEquals (tc, NULL, config);
-
- config = _p11_hash_get (configs, "three");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-three.so", _p11_hash_get (config, "module"));
- CuAssertStrEquals (tc, _p11_hash_get (config, "setting"), "user3");
-
- _p11_hash_free (configs);
-}
-
-static void
-test_load_modules_no_user (CuTest *tc)
-{
- hashmap *configs;
- hashmap *config;
-
- _p11_kit_clear_message ();
-
- configs = _p11_conf_load_modules (CONF_USER_MERGE,
- SRCDIR "/files/system-modules",
- SRCDIR "/files/non-existant");
- CuAssertPtrNotNull (tc, configs);
- CuAssertTrue (tc, assert_msg_contains (p11_kit_message (), "invalid config filename"));
-
- config = _p11_hash_get (configs, "one");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-one.so", _p11_hash_get (config, "module"));
- CuAssertStrEquals (tc, _p11_hash_get (config, "setting"), "system1");
-
- config = _p11_hash_get (configs, "two.badname");
- CuAssertPtrNotNull (tc, config);
- CuAssertStrEquals (tc, "mock-two.so", _p11_hash_get (config, "module"));
- CuAssertStrEquals (tc, _p11_hash_get (config, "setting"), "system2");
-
- config = _p11_hash_get (configs, "three");
- CuAssertPtrEquals (tc, NULL, config);
-
- _p11_hash_free (configs);
-}
-
-int
-main (void)
-{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- _p11_library_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);
-
- 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;
-}
diff --git a/tests/cutest/CuTest.c b/tests/cutest/CuTest.c
deleted file mode 100644
index b033483..0000000
--- a/tests/cutest/CuTest.c
+++ /dev/null
@@ -1,329 +0,0 @@
-#include <assert.h>
-#include <setjmp.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-
-#include "CuTest.h"
-
-/*-------------------------------------------------------------------------*
- * CuStr
- *-------------------------------------------------------------------------*/
-
-char* CuStrAlloc(int size)
-{
- char* newStr = (char*) malloc( sizeof(char) * (size) );
- return newStr;
-}
-
-char* CuStrCopy(const char* old)
-{
- int len = strlen(old);
- char* newStr = CuStrAlloc(len + 1);
- strcpy(newStr, old);
- return newStr;
-}
-
-/*-------------------------------------------------------------------------*
- * CuString
- *-------------------------------------------------------------------------*/
-
-void CuStringInit(CuString* str)
-{
- str->length = 0;
- str->size = STRING_MAX;
- str->buffer = (char*) malloc(sizeof(char) * str->size);
- str->buffer[0] = '\0';
-}
-
-CuString* CuStringNew(void)
-{
- CuString* str = (CuString*) malloc(sizeof(CuString));
- str->length = 0;
- str->size = STRING_MAX;
- str->buffer = (char*) malloc(sizeof(char) * str->size);
- str->buffer[0] = '\0';
- return str;
-}
-
-void CuStringDelete(CuString *str)
-{
- if (!str) return;
- free(str->buffer);
- free(str);
-}
-
-void CuStringResize(CuString* str, int newSize)
-{
- str->buffer = (char*) realloc(str->buffer, sizeof(char) * newSize);
- str->size = newSize;
-}
-
-void CuStringAppend(CuString* str, const char* text)
-{
- int length;
-
- if (text == NULL) {
- text = "NULL";
- }
-
- length = strlen(text);
- if (str->length + length + 1 >= str->size)
- CuStringResize(str, str->length + length + 1 + STRING_INC);
- str->length += length;
- strcat(str->buffer, text);
-}
-
-void CuStringAppendChar(CuString* str, char ch)
-{
- char text[2];
- text[0] = ch;
- text[1] = '\0';
- CuStringAppend(str, text);
-}
-
-void CuStringAppendFormat(CuString* str, const char* format, ...)
-{
- va_list argp;
- char buf[HUGE_STRING_LEN];
- va_start(argp, format);
- vsprintf(buf, format, argp);
- va_end(argp);
- CuStringAppend(str, buf);
-}
-
-void CuStringInsert(CuString* str, const char* text, int pos)
-{
- int length = strlen(text);
- if (pos > str->length)
- pos = str->length;
- if (str->length + length + 1 >= str->size)
- CuStringResize(str, str->length + length + 1 + STRING_INC);
- memmove(str->buffer + pos + length, str->buffer + pos, (str->length - pos) + 1);
- str->length += length;
- memcpy(str->buffer + pos, text, length);
-}
-
-/*-------------------------------------------------------------------------*
- * CuTest
- *-------------------------------------------------------------------------*/
-
-void CuTestInit(CuTest* t, const char* name, TestFunction function)
-{
- t->name = CuStrCopy(name);
- t->failed = 0;
- t->ran = 0;
- t->message = NULL;
- t->function = function;
- t->jumpBuf = NULL;
-}
-
-CuTest* CuTestNew(const char* name, TestFunction function)
-{
- CuTest* tc = CU_ALLOC(CuTest);
- CuTestInit(tc, name, function);
- return tc;
-}
-
-void CuTestDelete(CuTest *t)
-{
- if (!t) return;
- free(t->name);
- free(t);
-}
-
-void CuTestRun(CuTest* tc)
-{
- jmp_buf buf;
- tc->jumpBuf = &buf;
- if (setjmp(buf) == 0)
- {
- tc->ran = 1;
- (tc->function)(tc);
- }
- tc->jumpBuf = 0;
-}
-
-static void CuFailInternal(CuTest* tc, const char* file, int line, CuString* string)
-{
- char buf[HUGE_STRING_LEN];
-
- sprintf(buf, "%s:%d: ", file, line);
- CuStringInsert(string, buf, 0);
-
- tc->failed = 1;
- tc->message = string->buffer;
- if (tc->jumpBuf != 0) longjmp(*(tc->jumpBuf), 0);
-}
-
-void CuFail_Line(CuTest* tc, const char* file, int line, const char* message2, const char* message)
-{
- CuString string;
-
- CuStringInit(&string);
- if (message2 != NULL)
- {
- CuStringAppend(&string, message2);
- CuStringAppend(&string, ": ");
- }
- CuStringAppend(&string, message);
- CuFailInternal(tc, file, line, &string);
-}
-
-void CuAssert_Line(CuTest* tc, const char* file, int line, const char* message, int condition)
-{
- if (condition) return;
- CuFail_Line(tc, file, line, NULL, message);
-}
-
-void CuAssertStrEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message,
- const char* expected, const char* actual)
-{
- CuString string;
- if ((expected == NULL && actual == NULL) ||
- (expected != NULL && actual != NULL &&
- strcmp(expected, actual) == 0))
- {
- return;
- }
-
- CuStringInit(&string);
- if (message != NULL)
- {
- CuStringAppend(&string, message);
- CuStringAppend(&string, ": ");
- }
- CuStringAppend(&string, "expected <");
- CuStringAppend(&string, expected);
- CuStringAppend(&string, "> but was <");
- CuStringAppend(&string, actual);
- CuStringAppend(&string, ">");
- CuFailInternal(tc, file, line, &string);
-}
-
-void CuAssertIntEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message,
- int expected, int actual)
-{
- char buf[STRING_MAX];
- if (expected == actual) return;
- sprintf(buf, "expected <%d> but was <%d>", expected, actual);
- CuFail_Line(tc, file, line, message, buf);
-}
-
-void CuAssertPtrEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message,
- void* expected, void* actual)
-{
- char buf[STRING_MAX];
- if (expected == actual) return;
- sprintf(buf, "expected pointer <0x%p> but was <0x%p>", expected, actual);
- CuFail_Line(tc, file, line, message, buf);
-}
-
-
-/*-------------------------------------------------------------------------*
- * CuSuite
- *-------------------------------------------------------------------------*/
-
-void CuSuiteInit(CuSuite* testSuite)
-{
- testSuite->count = 0;
- testSuite->failCount = 0;
- memset(testSuite->list, 0, sizeof(testSuite->list));
-}
-
-CuSuite* CuSuiteNew(void)
-{
- CuSuite* testSuite = CU_ALLOC(CuSuite);
- CuSuiteInit(testSuite);
- return testSuite;
-}
-
-void CuSuiteDelete(CuSuite *testSuite)
-{
- unsigned int n;
- for (n=0; n < MAX_TEST_CASES; n++)
- {
- if (testSuite->list[n])
- {
- CuTestDelete(testSuite->list[n]);
- }
- }
- free(testSuite);
-
-}
-
-void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase)
-{
- assert(testSuite->count < MAX_TEST_CASES);
- testSuite->list[testSuite->count] = testCase;
- testSuite->count++;
-}
-
-void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2)
-{
- int i;
- for (i = 0 ; i < testSuite2->count ; ++i)
- {
- CuTest* testCase = testSuite2->list[i];
- CuSuiteAdd(testSuite, testCase);
- }
-}
-
-void CuSuiteRun(CuSuite* testSuite)
-{
- int i;
- for (i = 0 ; i < testSuite->count ; ++i)
- {
- CuTest* testCase = testSuite->list[i];
- CuTestRun(testCase);
- if (testCase->failed) { testSuite->failCount += 1; }
- }
-}
-
-void CuSuiteSummary(CuSuite* testSuite, CuString* summary)
-{
- int i;
- for (i = 0 ; i < testSuite->count ; ++i)
- {
- CuTest* testCase = testSuite->list[i];
- CuStringAppend(summary, testCase->failed ? "F" : ".");
- }
- CuStringAppend(summary, "\n\n");
-}
-
-void CuSuiteDetails(CuSuite* testSuite, CuString* details)
-{
- int i;
- int failCount = 0;
-
- if (testSuite->failCount == 0)
- {
- int passCount = testSuite->count - testSuite->failCount;
- const char* testWord = passCount == 1 ? "test" : "tests";
- CuStringAppendFormat(details, "OK (%d %s)\n", passCount, testWord);
- }
- else
- {
- if (testSuite->failCount == 1)
- CuStringAppend(details, "There was 1 failure:\n");
- else
- CuStringAppendFormat(details, "There were %d failures:\n", testSuite->failCount);
-
- for (i = 0 ; i < testSuite->count ; ++i)
- {
- CuTest* testCase = testSuite->list[i];
- if (testCase->failed)
- {
- failCount++;
- CuStringAppendFormat(details, "%d) %s: %s\n",
- failCount, testCase->name, testCase->message);
- }
- }
- CuStringAppend(details, "\n!!!FAILURES!!!\n");
-
- CuStringAppendFormat(details, "Runs: %d ", testSuite->count);
- CuStringAppendFormat(details, "Passes: %d ", testSuite->count - testSuite->failCount);
- CuStringAppendFormat(details, "Fails: %d\n", testSuite->failCount);
- }
-}
diff --git a/tests/cutest/CuTest.h b/tests/cutest/CuTest.h
deleted file mode 100644
index b82d05b..0000000
--- a/tests/cutest/CuTest.h
+++ /dev/null
@@ -1,111 +0,0 @@
-#ifndef CU_TEST_H
-#define CU_TEST_H
-
-#include <setjmp.h>
-#include <stdarg.h>
-
-#define CUTEST_VERSION "CuTest 1.5"
-
-/* CuString */
-
-char* CuStrAlloc(int size);
-char* CuStrCopy(const char* old);
-
-#define CU_ALLOC(TYPE) ((TYPE*) malloc(sizeof(TYPE)))
-
-#define HUGE_STRING_LEN 8192
-#define STRING_MAX 256
-#define STRING_INC 256
-
-typedef struct
-{
- int length;
- int size;
- char* buffer;
-} CuString;
-
-void CuStringInit(CuString* str);
-CuString* CuStringNew(void);
-void CuStringRead(CuString* str, const char* path);
-void CuStringAppend(CuString* str, const char* text);
-void CuStringAppendChar(CuString* str, char ch);
-void CuStringAppendFormat(CuString* str, const char* format, ...);
-void CuStringInsert(CuString* str, const char* text, int pos);
-void CuStringResize(CuString* str, int newSize);
-void CuStringDelete(CuString* str);
-
-/* CuTest */
-
-typedef struct CuTest CuTest;
-
-typedef void (*TestFunction)(CuTest *);
-
-struct CuTest
-{
- char* name;
- TestFunction function;
- int failed;
- int ran;
- const char* message;
- jmp_buf *jumpBuf;
-};
-
-void CuTestInit(CuTest* t, const char* name, TestFunction function);
-CuTest* CuTestNew(const char* name, TestFunction function);
-void CuTestRun(CuTest* tc);
-void CuTestDelete(CuTest *t);
-
-/* Internal versions of assert functions -- use the public versions */
-void CuFail_Line(CuTest* tc, const char* file, int line, const char* message2, const char* message);
-void CuAssert_Line(CuTest* tc, const char* file, int line, const char* message, int condition);
-void CuAssertStrEquals_LineMsg(CuTest* tc,
- const char* file, int line, const char* message,
- const char* expected, const char* actual);
-void CuAssertIntEquals_LineMsg(CuTest* tc,
- const char* file, int line, const char* message,
- int expected, int actual);
-void CuAssertPtrEquals_LineMsg(CuTest* tc,
- const char* file, int line, const char* message,
- void* expected, void* actual);
-
-/* public assert functions */
-
-#define CuFail(tc, ms) CuFail_Line( (tc), __FILE__, __LINE__, NULL, (ms))
-#define CuAssert(tc, ms, cond) CuAssert_Line((tc), __FILE__, __LINE__, (ms), (cond))
-#define CuAssertTrue(tc, cond) CuAssert_Line((tc), __FILE__, __LINE__, "assert failed", (cond))
-
-#define CuAssertStrEquals(tc,ex,ac) CuAssertStrEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac))
-#define CuAssertStrEquals_Msg(tc,ms,ex,ac) CuAssertStrEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac))
-#define CuAssertIntEquals(tc,ex,ac) CuAssertIntEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac))
-#define CuAssertIntEquals_Msg(tc,ms,ex,ac) CuAssertIntEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac))
-#define CuAssertPtrEquals(tc,ex,ac) CuAssertPtrEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac))
-#define CuAssertPtrEquals_Msg(tc,ms,ex,ac) CuAssertPtrEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac))
-
-#define CuAssertPtrNotNull(tc,p) CuAssert_Line((tc),__FILE__,__LINE__,"null pointer unexpected",(p != NULL))
-#define CuAssertPtrNotNullMsg(tc,msg,p) CuAssert_Line((tc),__FILE__,__LINE__,(msg),(p != NULL))
-
-/* CuSuite */
-
-#define MAX_TEST_CASES 1024
-
-#define SUITE_ADD_TEST(SUITE,TEST) CuSuiteAdd(SUITE, CuTestNew(#TEST, TEST))
-
-typedef struct
-{
- int count;
- CuTest* list[MAX_TEST_CASES];
- int failCount;
-
-} CuSuite;
-
-
-void CuSuiteInit(CuSuite* testSuite);
-CuSuite* CuSuiteNew(void);
-void CuSuiteDelete(CuSuite *testSuite);
-void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase);
-void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2);
-void CuSuiteRun(CuSuite* testSuite);
-void CuSuiteSummary(CuSuite* testSuite, CuString* summary);
-void CuSuiteDetails(CuSuite* testSuite, CuString* details);
-
-#endif /* CU_TEST_H */
diff --git a/tests/cutest/README.txt b/tests/cutest/README.txt
deleted file mode 100644
index 96e8853..0000000
--- a/tests/cutest/README.txt
+++ /dev/null
@@ -1,211 +0,0 @@
-HOW TO USE
-
-You can use CuTest to create unit tests to drive your development
-in the style of Extreme Programming. You can also add unit tests to
-existing code to ensure that it works as you suspect.
-
-Your unit tests are an investment. They let you to change your
-code and add new features confidently without worrying about
-accidentally breaking earlier features.
-
-
-LICENSING
-
-For details on licensing see license.txt.
-
-
-GETTING STARTED
-
-To add unit testing to your C code the only files you need are
-CuTest.c and CuTest.h.
-
-CuTestTest.c and AllTests.c have been included to provide an
-example of how to write unit tests and then how to aggregate them
-into suites and into a single AllTests.c file. Suites allow you
-to put group tests into logical sets. AllTests.c combines all the
-suites and runs them.
-
-You should not have to look inside CuTest.c. Looking in
-CuTestTest.c and AllTests.c (for example usage) should be
-sufficient.
-
-After downloading the sources, run your compiler to create an
-executable called AllTests.exe. For example, if you are using
-Windows with the cl.exe compiler you would type:
-
- cl.exe AllTests.c CuTest.c CuTestTest.c
- AllTests.exe
-
-This will run all the unit tests associated with CuTest and print
-the output on the console. You can replace cl.exe with gcc or
-your favorite compiler in the command above.
-
-
-DETAILED EXAMPLE
-
-Here is a more detailed example. We will work through a simple
-test first exercise. The goal is to create a library of string
-utilities. First, lets write a function that converts a
-null-terminated string to all upper case.
-
-Ensure that CuTest.c and CuTest.h are accessible from your C
-project. Next, create a file called StrUtil.c with these
-contents:
-
- #include "CuTest.h"
-
- char* StrToUpper(char* str) {
- return str;
- }
-
- void TestStrToUpper(CuTest *tc) {
- char* input = strdup("hello world");
- char* actual = StrToUpper(input);
- char* expected = "HELLO WORLD";
- CuAssertStrEquals(tc, expected, actual);
- }
-
- CuSuite* StrUtilGetSuite() {
- CuSuite* suite = CuSuiteNew();
- SUITE_ADD_TEST(suite, TestStrToUpper);
- return suite;
- }
-
-Create another file called AllTests.c with these contents:
-
- #include "CuTest.h"
-
- CuSuite* StrUtilGetSuite();
-
- void RunAllTests(void) {
- CuString *output = CuStringNew();
- CuSuite* suite = CuSuiteNew();
-
- CuSuiteAddSuite(suite, StrUtilGetSuite());
-
- CuSuiteRun(suite);
- CuSuiteSummary(suite, output);
- CuSuiteDetails(suite, output);
- printf("%s\n", output->buffer);
- }
-
- int main(void) {
- RunAllTests();
- }
-
-Then type this on the command line:
-
- gcc AllTests.c CuTest.c StrUtil.c
-
-to compile. You can replace gcc with your favorite compiler.
-CuTest should be portable enough to handle all Windows and Unix
-compilers. Then to run the tests type:
-
- a.out
-
-This will print an error because we haven't implemented the
-StrToUpper function correctly. We are just returning the string
-without changing it to upper case.
-
- char* StrToUpper(char* str) {
- return str;
- }
-
-Rewrite this as follows:
-
- char* StrToUpper(char* str) {
- char* p;
- for (p = str ; *p ; ++p) *p = toupper(*p);
- return str;
- }
-
-Recompile and run the tests again. The test should pass this
-time.
-
-
-WHAT TO DO NEXT
-
-At this point you might want to write more tests for the
-StrToUpper function. Here are some ideas:
-
-TestStrToUpper_EmptyString : pass in ""
-TestStrToUpper_UpperCase : pass in "HELLO WORLD"
-TestStrToUpper_MixedCase : pass in "HELLO world"
-TestStrToUpper_Numbers : pass in "1234 hello"
-
-As you write each one of these tests add it to StrUtilGetSuite
-function. If you don't the tests won't be run. Later as you write
-other functions and write tests for them be sure to include those
-in StrUtilGetSuite also. The StrUtilGetSuite function should
-include all the tests in StrUtil.c
-
-Over time you will create another file called FunkyStuff.c
-containing other functions unrelated to StrUtil. Follow the same
-pattern. Create a FunkyStuffGetSuite function in FunkyStuff.c.
-And add FunkyStuffGetSuite to AllTests.c.
-
-The framework is designed in the way it is so that it is easy to
-organize a lot of tests.
-
-THE BIG PICTURE
-
-Each individual test corresponds to a CuTest. These are grouped
-to form a CuSuite. CuSuites can hold CuTests or other CuSuites.
-AllTests.c collects all the CuSuites in the program into a single
-CuSuite which it then runs as a single CuSuite.
-
-The project is open source so feel free to take a peek under the
-hood at the CuTest.c file to see how it works. CuTestTest.c
-contains tests for CuTest.c. So CuTest tests itself.
-
-Since AllTests.c has a main() you will need to exclude this when
-you are building your product. Here is a nicer way to do this if
-you want to avoid messing with multiple builds. Remove the main()
-in AllTests.c. Note that it just calls RunAllTests(). Instead
-we'll call this directly from the main program.
-
-Now in the main() of the actual program check to see if the
-command line option "--test" was passed. If it was then I call
-RunAllTests() from AllTests.c. Otherwise run the real program.
-
-Shipping the tests with the code can be useful. If you customers
-complain about a problem you can ask them to run the unit tests
-and send you the output. This can help you to quickly isolate the
-piece of your system that is malfunctioning in the customer's
-environment.
-
-CuTest offers a rich set of CuAssert functions. Here is a list:
-
-void CuAssert(CuTest* tc, char* message, int condition);
-void CuAssertTrue(CuTest* tc, int condition);
-void CuAssertStrEquals(CuTest* tc, char* expected, char* actual);
-void CuAssertIntEquals(CuTest* tc, int expected, int actual);
-void CuAssertPtrEquals(CuTest* tc, void* expected, void* actual);
-void CuAssertPtrNotNull(CuTest* tc, void* pointer);
-
-The project is open source and so you can add other more powerful
-asserts to make your tests easier to write and more concise.
-Please feel free to send me changes you make so that I can
-incorporate them into future releases.
-
-If you see any errors in this document please contact me at
-asimjalis@peakprogramming.com.
-
-
-AUTOMATING TEST SUITE GENERATION
-
-make-tests.sh will grep through all the .c files in the current
-directory and generate the code to run all the tests contained in
-them. Using this script you don't have to worry about writing
-AllTests.c or dealing with any of the other suite code.
-
-
-CREDITS
-
-These people have contributed useful code changes to the CuTest project.
-Thanks!
-
-- [02.23.2003] Dave Glowacki <dglo@hyde.ssec.wisc.edu>
-- [04.17.2009] Tobias Lippert <herrmarder@googlemail.com>
-- [11.13.2009] Eli Bendersky <eliben@gmail.com>
-- [12.14.2009] Andrew Brown <abrown@datasci.com>
diff --git a/tests/cutest/license.txt b/tests/cutest/license.txt
deleted file mode 100644
index 3d94167..0000000
--- a/tests/cutest/license.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-NOTE
-
-The license is based on the zlib/libpng license. For more details see
-http://www.opensource.org/licenses/zlib-license.html. The intent of the
-license is to:
-
-- keep the license as simple as possible
-- encourage the use of CuTest in both free and commercial applications
- and libraries
-- keep the source code together
-- give credit to the CuTest contributors for their work
-
-If you ship CuTest in source form with your source distribution, the
-following license document must be included with it in unaltered form.
-If you find CuTest useful we would like to hear about it.
-
-LICENSE
-
-Copyright (c) 2003 Asim Jalis
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any damages
-arising from the use of this software.
-
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must not
-claim that you wrote the original software. If you use this software in
-a product, an acknowledgment in the product documentation would be
-appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and must not
-be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
diff --git a/tests/files/system-modules/four.module b/tests/files/system-modules/four.module
deleted file mode 100644
index 6eace3c..0000000
--- a/tests/files/system-modules/four.module
+++ /dev/null
@@ -1,3 +0,0 @@
-
-module: mock-four.so
-disable-in: test-disable, test-other
diff --git a/tests/files/system-modules/one.module b/tests/files/system-modules/one.module
deleted file mode 100644
index 3620869..0000000
--- a/tests/files/system-modules/one.module
+++ /dev/null
@@ -1,3 +0,0 @@
-
-module: mock-one.so
-setting: system1 \ No newline at end of file
diff --git a/tests/files/system-modules/two-duplicate.module b/tests/files/system-modules/two-duplicate.module
deleted file mode 100644
index 907aa75..0000000
--- a/tests/files/system-modules/two-duplicate.module
+++ /dev/null
@@ -1,3 +0,0 @@
-
-# This is a duplicate of the 'two' module
-module: mock-two.so
diff --git a/tests/files/system-modules/two.badname b/tests/files/system-modules/two.badname
deleted file mode 100644
index 0d41cac..0000000
--- a/tests/files/system-modules/two.badname
+++ /dev/null
@@ -1,5 +0,0 @@
-# This module doesn't have a .module extension, but p11-kit doesn't yet
-# enforce the naming, just warns, so it should still be loaded
-
-module: mock-two.so
-setting: system2
diff --git a/tests/files/system-modules/win32/four.module b/tests/files/system-modules/win32/four.module
deleted file mode 100644
index 7fd1540..0000000
--- a/tests/files/system-modules/win32/four.module
+++ /dev/null
@@ -1,3 +0,0 @@
-
-module: mock-four.dll
-disable-in: test-disable, test-other
diff --git a/tests/files/system-modules/win32/one.module b/tests/files/system-modules/win32/one.module
deleted file mode 100644
index 5f80304..0000000
--- a/tests/files/system-modules/win32/one.module
+++ /dev/null
@@ -1,3 +0,0 @@
-
-module: mock-one.dll
-setting: system1 \ No newline at end of file
diff --git a/tests/files/system-modules/win32/two-duplicate.module b/tests/files/system-modules/win32/two-duplicate.module
deleted file mode 100644
index e80c9e8..0000000
--- a/tests/files/system-modules/win32/two-duplicate.module
+++ /dev/null
@@ -1,3 +0,0 @@
-
-# This is a duplicate of the 'two' module
-module: mock-two.dll
diff --git a/tests/files/system-modules/win32/two.badname b/tests/files/system-modules/win32/two.badname
deleted file mode 100644
index ae44b83..0000000
--- a/tests/files/system-modules/win32/two.badname
+++ /dev/null
@@ -1,5 +0,0 @@
-# This module doesn't have a .module extension, but p11-kit doesn't yet
-# enforce the naming, just warns, so it should still be loaded
-
-module: mock-two.dll
-setting: system2
diff --git a/tests/files/system-pkcs11.conf b/tests/files/system-pkcs11.conf
deleted file mode 100644
index 20741e7..0000000
--- a/tests/files/system-pkcs11.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-
-# Merge in user config
-user-config: merge \ No newline at end of file
diff --git a/tests/files/test-1.conf b/tests/files/test-1.conf
deleted file mode 100644
index d4ae0a1..0000000
--- a/tests/files/test-1.conf
+++ /dev/null
@@ -1,6 +0,0 @@
-key1:value1
-with-whitespace : value-with-whitespace
-with-colon: value-of-colon
-
-# A comment
-embedded-comment: this is # not a comment
diff --git a/tests/files/test-pinfile b/tests/files/test-pinfile
deleted file mode 100644
index f646f3d..0000000
--- a/tests/files/test-pinfile
+++ /dev/null
@@ -1 +0,0 @@
-yogabbagabba \ No newline at end of file
diff --git a/tests/files/test-pinfile-large b/tests/files/test-pinfile-large
deleted file mode 100644
index 506668d..0000000
--- a/tests/files/test-pinfile-large
+++ /dev/null
@@ -1,53 +0,0 @@
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba yogabbagabba
-yogabbagabba yogabbagabba yogabbagabba yo \ No newline at end of file
diff --git a/tests/files/test-system-invalid.conf b/tests/files/test-system-invalid.conf
deleted file mode 100644
index 344ee96..0000000
--- a/tests/files/test-system-invalid.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-
-# Invalid user-config setting
-user-config: bad
diff --git a/tests/files/test-system-merge.conf b/tests/files/test-system-merge.conf
deleted file mode 100644
index 978427d..0000000
--- a/tests/files/test-system-merge.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-
-# Merge in user config
-user-config: merge
-
-key1: system1
-key2: system2
-key3: system3 \ No newline at end of file
diff --git a/tests/files/test-system-none.conf b/tests/files/test-system-none.conf
deleted file mode 100644
index 95351e6..0000000
--- a/tests/files/test-system-none.conf
+++ /dev/null
@@ -1,8 +0,0 @@
-
-# Only user config
-user-config: none
-
-# These values will not be overriden
-key1: system1
-key2: system2
-key3: system3 \ No newline at end of file
diff --git a/tests/files/test-system-only.conf b/tests/files/test-system-only.conf
deleted file mode 100644
index 589f1c7..0000000
--- a/tests/files/test-system-only.conf
+++ /dev/null
@@ -1,8 +0,0 @@
-
-# Only user config
-user-config: only
-
-# This stuff will be ignored
-key1: system1
-key2: system2
-key3: system3 \ No newline at end of file
diff --git a/tests/files/test-user-invalid.conf b/tests/files/test-user-invalid.conf
deleted file mode 100644
index 344ee96..0000000
--- a/tests/files/test-user-invalid.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-
-# Invalid user-config setting
-user-config: bad
diff --git a/tests/files/test-user-only.conf b/tests/files/test-user-only.conf
deleted file mode 100644
index 3224c01..0000000
--- a/tests/files/test-user-only.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-
-user-config: only
-key2: user2
-key3: user3 \ No newline at end of file
diff --git a/tests/files/test-user.conf b/tests/files/test-user.conf
deleted file mode 100644
index 369544a..0000000
--- a/tests/files/test-user.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-
-key2: user2
-key3: user3 \ No newline at end of file
diff --git a/tests/files/user-modules/one.module b/tests/files/user-modules/one.module
deleted file mode 100644
index c371e4a..0000000
--- a/tests/files/user-modules/one.module
+++ /dev/null
@@ -1,2 +0,0 @@
-
-setting: user1 \ No newline at end of file
diff --git a/tests/files/user-modules/three.module b/tests/files/user-modules/three.module
deleted file mode 100644
index 00caab5..0000000
--- a/tests/files/user-modules/three.module
+++ /dev/null
@@ -1,5 +0,0 @@
-
-module: mock-three.so
-setting: user3
-
-enable-in: test-enable \ No newline at end of file
diff --git a/tests/files/user-modules/win32/one.module b/tests/files/user-modules/win32/one.module
deleted file mode 100644
index c371e4a..0000000
--- a/tests/files/user-modules/win32/one.module
+++ /dev/null
@@ -1,2 +0,0 @@
-
-setting: user1 \ No newline at end of file
diff --git a/tests/files/user-modules/win32/three.module b/tests/files/user-modules/win32/three.module
deleted file mode 100644
index 58f883d..0000000
--- a/tests/files/user-modules/win32/three.module
+++ /dev/null
@@ -1,5 +0,0 @@
-
-module: mock-three.dll
-setting: user3
-
-enable-in: test-enable \ No newline at end of file
diff --git a/tests/hash-test.c b/tests/hash-test.c
deleted file mode 100644
index cf77094..0000000
--- a/tests/hash-test.c
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * Copyright (c) 2011, Collabora Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- * * The names of contributors to this software may not be
- * used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Author: Stef Walter <stefw@collabora.co.uk>
- */
-
-#include "config.h"
-#include "CuTest.h"
-
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "hashmap.h"
-
-static void
-test_create (CuTest *tc)
-{
- hashmap *map;
-
- map = _p11_hash_create (_p11_hash_direct_hash, _p11_hash_direct_equal, NULL, NULL);
- CuAssertPtrNotNull (tc, map);
- _p11_hash_free (map);
-}
-
-static void
-test_free_null (CuTest *tc)
-{
- _p11_hash_free (NULL);
-}
-
-typedef struct {
- int value;
- int freed;
-} Key;
-
-static unsigned int
-key_hash (const void *ptr)
-{
- const Key *k = ptr;
- assert (!k->freed);
- return _p11_hash_intptr_hash (&k->value);
-}
-
-static int
-key_equal (const void *one,
- const void *two)
-{
- const Key *k1 = one;
- const Key *k2 = two;
- assert (!k1->freed);
- assert (!k2->freed);
- return _p11_hash_intptr_equal (&k1->value, &k2->value);
-}
-
-static void
-key_destroy (void *data)
-{
- Key *k = data;
- assert (!k->freed);
- k->freed = 1;
-}
-
-static void
-value_destroy (void *data)
-{
- int *value = data;
- *value = 2;
-}
-
-static void
-test_free_destroys (CuTest *tc)
-{
- hashmap *map;
- Key key = { 8, 0 };
- int value = 0;
-
- map = _p11_hash_create (key_hash, key_equal, key_destroy, value_destroy);
- CuAssertPtrNotNull (tc, map);
- if (!_p11_hash_set (map, &key, &value))
- CuFail (tc, "should not be reached");
- _p11_hash_free (map);
-
- CuAssertIntEquals (tc, 1, key.freed);
- CuAssertIntEquals (tc, 2, value);
-}
-
-static void
-test_iterate (CuTest *tc)
-{
- hashmap *map;
- hashiter iter;
- int key = 1;
- int value = 2;
- void *pkey;
- void *pvalue;
- int ret;
-
- map = _p11_hash_create (_p11_hash_direct_hash, _p11_hash_direct_equal, NULL, NULL);
- CuAssertPtrNotNull (tc, map);
- if (!_p11_hash_set (map, &key, &value))
- CuFail (tc, "should not be reached");
-
- _p11_hash_iterate (map, &iter);
-
- ret = _p11_hash_next (&iter, &pkey, &pvalue);
- CuAssertIntEquals (tc, 1, ret);
- CuAssertPtrEquals (tc, pkey, &key);
- CuAssertPtrEquals (tc, pvalue, &value);
-
- ret = _p11_hash_next (&iter, &pkey, &pvalue);
- CuAssertIntEquals (tc, 0, ret);
-
- _p11_hash_free (map);
-}
-
-static void
-test_set_get (CuTest *tc)
-{
- char *key = "KEY";
- char *value = "VALUE";
- char *check;
- hashmap *map;
-
- map = _p11_hash_create (_p11_hash_string_hash, _p11_hash_string_equal, NULL, NULL);
- _p11_hash_set (map, key, value);
- check = _p11_hash_get (map, key);
- CuAssertPtrEquals (tc, check, value);
-
- _p11_hash_free (map);
-}
-
-static void
-test_set_get_remove (CuTest *tc)
-{
- char *key = "KEY";
- char *value = "VALUE";
- char *check;
- hashmap *map;
- int ret;
-
- map = _p11_hash_create (_p11_hash_string_hash, _p11_hash_string_equal, NULL, NULL);
-
- if (!_p11_hash_set (map, key, value))
- CuFail (tc, "should not be reached");
-
- check = _p11_hash_get (map, key);
- CuAssertPtrEquals (tc, check, value);
-
- ret = _p11_hash_remove (map, key);
- CuAssertIntEquals (tc, ret, 1);
- ret = _p11_hash_remove (map, key);
- CuAssertIntEquals (tc, ret, 0);
-
- check = _p11_hash_get (map, key);
- CuAssert (tc, "should be null", check == NULL);
-
- _p11_hash_free (map);
-}
-
-static void
-test_set_clear (CuTest *tc)
-{
- char *key = "KEY";
- char *value = "VALUE";
- char *check;
- hashmap *map;
-
- map = _p11_hash_create (_p11_hash_direct_hash, _p11_hash_direct_equal, NULL, NULL);
-
- if (!_p11_hash_set (map, key, value))
- CuFail (tc, "should not be reached");
-
- _p11_hash_clear (map);
-
- check = _p11_hash_get (map, key);
- CuAssert (tc, "should be null", check == NULL);
-
- _p11_hash_free (map);
-}
-
-static void
-test_remove_destroys (CuTest *tc)
-{
- hashmap *map;
- Key key = { 8, 0 };
- int value = 0;
- int ret;
-
- map = _p11_hash_create (key_hash, key_equal, key_destroy, value_destroy);
- CuAssertPtrNotNull (tc, map);
- if (!_p11_hash_set (map, &key, &value))
- CuFail (tc, "should not be reached");
-
- ret = _p11_hash_remove (map, &key);
- CuAssertIntEquals (tc, ret, 1);
- CuAssertIntEquals (tc, 1, key.freed);
- CuAssertIntEquals (tc, 2, value);
-
- /* should not be destroyed again */
- key.freed = 0;
- value = 0;
-
- ret = _p11_hash_remove (map, &key);
- CuAssertIntEquals (tc, ret, 0);
- CuAssertIntEquals (tc, 0, key.freed);
- CuAssertIntEquals (tc, 0, value);
-
- /* should not be destroyed again */
- key.freed = 0;
- value = 0;
-
- _p11_hash_free (map);
-
- CuAssertIntEquals (tc, 0, key.freed);
- CuAssertIntEquals (tc, 0, value);
-}
-
-static void
-test_set_destroys (CuTest *tc)
-{
- hashmap *map;
- Key key = { 8, 0 };
- Key key2 = { 8, 0 };
- int value, value2;
- int ret;
-
- map = _p11_hash_create (key_hash, key_equal, key_destroy, value_destroy);
- CuAssertPtrNotNull (tc, map);
- if (!_p11_hash_set (map, &key, &value))
- CuFail (tc, "should not be reached");
-
- key.freed = key2.freed = value = value2 = 0;
-
- /* Setting same key and value, should not be destroyed */
- ret = _p11_hash_set (map, &key, &value);
- CuAssertIntEquals (tc, ret, 1);
- CuAssertIntEquals (tc, 0, key.freed);
- CuAssertIntEquals (tc, 0, key2.freed);
- CuAssertIntEquals (tc, 0, value);
- CuAssertIntEquals (tc, 0, value2);
-
- key.freed = key2.freed = value = value2 = 0;
-
- /* Setting a new key same value, key should be destroyed */
- ret = _p11_hash_set (map, &key2, &value);
- CuAssertIntEquals (tc, ret, 1);
- CuAssertIntEquals (tc, 1, key.freed);
- CuAssertIntEquals (tc, 0, key2.freed);
- CuAssertIntEquals (tc, 0, value);
- CuAssertIntEquals (tc, 0, value2);
-
- key.freed = key2.freed = value = value2 = 0;
-
- /* Setting same key, new value, value should be destroyed */
- ret = _p11_hash_set (map, &key2, &value2);
- CuAssertIntEquals (tc, ret, 1);
- CuAssertIntEquals (tc, 0, key.freed);
- CuAssertIntEquals (tc, 0, key2.freed);
- CuAssertIntEquals (tc, 2, value);
- CuAssertIntEquals (tc, 0, value2);
-
- key.freed = key2.freed = value = value2 = 0;
-
- /* Setting new key new value, both should be destroyed */
- ret = _p11_hash_set (map, &key, &value);
- CuAssertIntEquals (tc, ret, 1);
- CuAssertIntEquals (tc, 0, key.freed);
- CuAssertIntEquals (tc, 1, key2.freed);
- CuAssertIntEquals (tc, 0, value);
- CuAssertIntEquals (tc, 2, value2);
-
- key.freed = key2.freed = value = value2 = 0;
-
- _p11_hash_free (map);
- CuAssertIntEquals (tc, 1, key.freed);
- CuAssertIntEquals (tc, 2, value);
- CuAssertIntEquals (tc, 0, key2.freed);
- CuAssertIntEquals (tc, 0, value2);
-}
-
-
-static void
-test_clear_destroys (CuTest *tc)
-{
- hashmap *map;
- Key key = { 18, 0 };
- int value = 0;
-
- map = _p11_hash_create (key_hash, key_equal, key_destroy, value_destroy);
- CuAssertPtrNotNull (tc, map);
- if (!_p11_hash_set (map, &key, &value))
- CuFail (tc, "should not be reached");
-
- _p11_hash_clear (map);
- CuAssertIntEquals (tc, 1, key.freed);
- CuAssertIntEquals (tc, 2, value);
-
- /* should not be destroyed again */
- key.freed = 0;
- value = 0;
-
- _p11_hash_clear (map);
- CuAssertIntEquals (tc, 0, key.freed);
- CuAssertIntEquals (tc, 0, value);
-
- /* should not be destroyed again */
- key.freed = 0;
- value = 0;
-
- _p11_hash_free (map);
-
- CuAssertIntEquals (tc, 0, key.freed);
- CuAssertIntEquals (tc, 0, value);
-}
-
-static unsigned int
-test_hash_intptr_with_collisions (const void *data)
-{
- /* lots and lots of collisions, only returns 100 values */
- return (unsigned int)(*((int*)data) % 100);
-}
-
-static void
-test_hash_add_check_lots_and_collisions (CuTest *tc)
-{
- hashmap *map;
- int *value;
- int i;
-
- map = _p11_hash_create (test_hash_intptr_with_collisions,
- _p11_hash_intptr_equal, NULL, free);
-
- for (i = 0; i < 20000; ++i) {
- value = malloc (sizeof (int));
- *value = i;
- if (!_p11_hash_set (map, value, value))
- CuFail (tc, "should not be reached");
- }
-
- for (i = 0; i < 20000; ++i) {
- value = _p11_hash_get (map, &i);
- CuAssertPtrNotNull (tc, value);
- CuAssertIntEquals (tc, i, *value);
- }
-
- _p11_hash_free (map);
-}
-
-static void
-test_hash_count (CuTest *tc)
-{
- hashmap *map;
- int *value;
- int i, ret;
-
- map = _p11_hash_create (_p11_hash_intptr_hash, _p11_hash_intptr_equal, NULL, free);
-
- CuAssertIntEquals (tc, 0, _p11_hash_size (map));
-
- for (i = 0; i < 20000; ++i) {
- value = malloc (sizeof (int));
- *value = i;
- if (!_p11_hash_set (map, value, value))
- CuFail (tc, "should not be reached");
- CuAssertIntEquals (tc, i + 1, _p11_hash_size (map));
- }
-
- for (i = 0; i < 20000; ++i) {
- ret = _p11_hash_remove (map, &i);
- CuAssertIntEquals (tc, 1, ret);
- CuAssertIntEquals (tc, 20000 - (i + 1), _p11_hash_size (map));
- }
-
- _p11_hash_clear (map);
- CuAssertIntEquals (tc, 0, _p11_hash_size (map));
-
- _p11_hash_free (map);
-}
-
-static void
-test_hash_ulongptr (CuTest *tc)
-{
- hashmap *map;
- unsigned long *value;
- unsigned long i;
-
- map = _p11_hash_create (_p11_hash_ulongptr_hash, _p11_hash_ulongptr_equal, NULL, free);
-
- for (i = 0; i < 20000; ++i) {
- value = malloc (sizeof (unsigned long));
- *value = i;
- if (!_p11_hash_set (map, value, value))
- CuFail (tc, "should not be reached");
- }
-
- for (i = 0; i < 20000; ++i) {
- value = _p11_hash_get (map, &i);
- CuAssertPtrNotNull (tc, value);
- CuAssertIntEquals (tc, i, *value);
- }
-
- _p11_hash_free (map);
-}
-
-int
-main (void)
-{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- SUITE_ADD_TEST (suite, test_create);
- SUITE_ADD_TEST (suite, test_set_get);
- SUITE_ADD_TEST (suite, test_set_get_remove);
- SUITE_ADD_TEST (suite, test_remove_destroys);
- SUITE_ADD_TEST (suite, test_set_clear);
- SUITE_ADD_TEST (suite, test_set_destroys);
- SUITE_ADD_TEST (suite, test_clear_destroys);
- SUITE_ADD_TEST (suite, test_free_null);
- SUITE_ADD_TEST (suite, test_free_destroys);
- SUITE_ADD_TEST (suite, test_iterate);
- SUITE_ADD_TEST (suite, test_hash_add_check_lots_and_collisions);
- SUITE_ADD_TEST (suite, test_hash_count);
- SUITE_ADD_TEST (suite, test_hash_ulongptr);
-
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
-
- return ret;
-}
diff --git a/tests/mock-module-ep.c b/tests/mock-module-ep.c
deleted file mode 100644
index 7440a74..0000000
--- a/tests/mock-module-ep.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2012 Stefan Walter
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- * * The names of contributors to this software may not be
- * used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Author: Stef Walter <stef@thewalter.net>
- */
-
-#include "config.h"
-
-#define CRYPTOKI_EXPORTS 1
-#include "pkcs11.h"
-#include "mock-module.h"
-
-#ifdef OS_WIN32
-__declspec(dllexport)
-#endif
-CK_RV
-C_GetFunctionList (CK_FUNCTION_LIST_PTR_PTR list)
-{
- mock_module_init ();
- if (list == NULL)
- return CKR_ARGUMENTS_BAD;
- *list = &mock_module_no_slots;
- return CKR_OK;
-}
diff --git a/tests/mock-module.c b/tests/mock-module.c
deleted file mode 100644
index 99cde50..0000000
--- a/tests/mock-module.c
+++ /dev/null
@@ -1,898 +0,0 @@
-/*
- * Copyright (c) 2011, Collabora Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- * * The names of contributors to this software may not be
- * used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Author: Stef Walter <stefw@collabora.co.uk>
- */
-
-#include "config.h"
-
-#define CRYPTOKI_EXPORTS
-#include "pkcs11.h"
-#include "mock-module.h"
-
-#include "p11-kit/util.h"
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-/* -------------------------------------------------------------------
- * GLOBALS / DEFINES
- */
-
-/* Various mutexes */
-static mutex_t init_mutex;
-
-/* Whether we've been initialized, and on what process id it happened */
-static int pkcs11_initialized = 0;
-static pid_t pkcs11_initialized_pid = 0;
-
-/* -----------------------------------------------------------------------------
- * LOGGING and DEBUGGING
- */
-
-#define DEBUG_OUTPUT 0
-
-#if DEBUG_OUTPUT
-#define debug(x) mock_log x
-#else
-#define debug(x)
-#endif
-
-#define warning(x) mock_log x
-
-#define return_val_if_fail(x, v) \
- if (!(x)) { mock_log ("'%s' not true at %s", #x, __func__); return v; }
-
-static void
-mock_log (const char *format, ...)
-{
- va_list va;
- va_start (va, format);
- fprintf (stderr, "mock-module: ");
- vfprintf (stderr, format, va);
- fprintf (stderr, "\n");
- va_end (va);
-}
-
-/* -------------------------------------------------------------------
- * INITIALIZATION and 'GLOBAL' CALLS
- */
-
-CK_RV
-mock_C_Initialize (CK_VOID_PTR init_args)
-{
- CK_C_INITIALIZE_ARGS_PTR args = NULL;
- CK_RV ret = CKR_OK;
- pid_t pid;
-
- debug (("C_Initialize: enter"));
-
- _p11_mutex_lock (&init_mutex);
-
- if (init_args != NULL) {
- int supplied_ok;
-
- /* pReserved must be NULL */
- args = init_args;
-
- /* ALL supplied function pointers need to have the value either NULL or non-NULL. */
- supplied_ok = (args->CreateMutex == NULL && args->DestroyMutex == NULL &&
- args->LockMutex == NULL && args->UnlockMutex == NULL) ||
- (args->CreateMutex != NULL && args->DestroyMutex != NULL &&
- args->LockMutex != NULL && args->UnlockMutex != NULL);
- if (!supplied_ok) {
- warning (("invalid set of mutex calls supplied"));
- ret = CKR_ARGUMENTS_BAD;
- goto done;
- }
-
- /*
- * When the CKF_OS_LOCKING_OK flag isn't set return an error.
- * We must be able to use our pthread functionality.
- */
- if (!(args->flags & CKF_OS_LOCKING_OK)) {
- warning (("can't do without os locking"));
- ret = CKR_CANT_LOCK;
- goto done;
- }
- }
-
- pid = getpid ();
- if (pkcs11_initialized) {
-
- /* This process has called C_Initialize already */
- if (pid == pkcs11_initialized_pid) {
- warning (("C_Initialize called twice for same process"));
- ret = CKR_CRYPTOKI_ALREADY_INITIALIZED;
- goto done;
- }
- }
-
-done:
- /* Mark us as officially initialized */
- if (ret == CKR_OK) {
- pkcs11_initialized = 1;
- pkcs11_initialized_pid = pid;
- } else if (ret != CKR_CRYPTOKI_ALREADY_INITIALIZED) {
- pkcs11_initialized = 0;
- pkcs11_initialized_pid = 0;
- }
-
- _p11_mutex_unlock (&init_mutex);
-
- debug (("C_Initialize: %d", ret));
- return ret;
-}
-
-CK_RV
-mock_C_Finalize (CK_VOID_PTR reserved)
-{
- debug (("C_Finalize: enter"));
- return_val_if_fail (pkcs11_initialized != 0, CKR_CRYPTOKI_NOT_INITIALIZED);
- return_val_if_fail (reserved == NULL, CKR_ARGUMENTS_BAD);
-
- _p11_mutex_lock (&init_mutex);
-
- /* This should stop all other calls in */
- pkcs11_initialized = 0;
- pkcs11_initialized_pid = 0;
-
- _p11_mutex_unlock (&init_mutex);
-
- debug (("C_Finalize: %d", CKR_OK));
- return CKR_OK;
-}
-
-static const CK_INFO MOCK_INFO = {
- { CRYPTOKI_VERSION_MAJOR, CRYPTOKI_VERSION_MINOR },
- "MOCK MANUFACTURER ",
- 0,
- "MOCK LIBRARY ",
- { 45, 145 }
-};
-
-
-CK_RV
-mock_C_GetInfo (CK_INFO_PTR info)
-{
- return_val_if_fail (info, CKR_ARGUMENTS_BAD);
-
- memcpy (info, &MOCK_INFO, sizeof (*info));
- return CKR_OK;
-}
-
-CK_RV
-mock_C_GetFunctionList (CK_FUNCTION_LIST_PTR_PTR list)
-{
- /* This would be a strange call to receive */
- return C_GetFunctionList (list);
-}
-
-CK_RV
-mock_C_GetSlotList__no_tokens (CK_BBOOL token_present,
- CK_SLOT_ID_PTR slot_list,
- CK_ULONG_PTR count)
-{
- return_val_if_fail (count, CKR_ARGUMENTS_BAD);
-
- /* No tokens */
- *count = 0;
- return CKR_OK;
-}
-
-CK_RV
-mock_C_GetSlotInfo__invalid_slotid (CK_SLOT_ID id,
- CK_SLOT_INFO_PTR info)
-{
- return_val_if_fail (info, CKR_ARGUMENTS_BAD);
-
- return CKR_SLOT_ID_INVALID;
-}
-
-CK_RV
-mock_C_GetTokenInfo__invalid_slotid (CK_SLOT_ID id,
- CK_TOKEN_INFO_PTR info)
-{
- return_val_if_fail (info, CKR_ARGUMENTS_BAD);
-
- return CKR_SLOT_ID_INVALID;
-}
-
-CK_RV
-mock_C_GetMechanismList__invalid_slotid (CK_SLOT_ID id,
- CK_MECHANISM_TYPE_PTR mechanism_list,
- CK_ULONG_PTR count)
-{
- return_val_if_fail (count, CKR_ARGUMENTS_BAD);
-
- return CKR_SLOT_ID_INVALID;
-}
-
-CK_RV
-mock_C_GetMechanismInfo__invalid_slotid (CK_SLOT_ID id,
- CK_MECHANISM_TYPE type,
- CK_MECHANISM_INFO_PTR info)
-{
- return_val_if_fail (info, CKR_ARGUMENTS_BAD);
-
- return CKR_SLOT_ID_INVALID;
-}
-
-CK_RV
-mock_C_InitToken__invalid_slotid (CK_SLOT_ID id,
- CK_UTF8CHAR_PTR pin,
- CK_ULONG pin_len,
- CK_UTF8CHAR_PTR label)
-{
- return CKR_SLOT_ID_INVALID;
-}
-
-CK_RV
-mock_C_WaitForSlotEvent__no_event (CK_FLAGS flags,
- CK_SLOT_ID_PTR slot,
- CK_VOID_PTR reserved)
-{
- return_val_if_fail (slot, CKR_ARGUMENTS_BAD);
-
- return CKR_NO_EVENT;
-}
-
-CK_RV
-mock_C_OpenSession__invalid_slotid (CK_SLOT_ID id,
- CK_FLAGS flags,
- CK_VOID_PTR user_data,
- CK_NOTIFY callback,
- CK_SESSION_HANDLE_PTR session)
-{
- return_val_if_fail (session, CKR_ARGUMENTS_BAD);
-
- return CKR_SLOT_ID_INVALID;
-}
-
-CK_RV
-mock_C_CloseSession__invalid_handle (CK_SESSION_HANDLE session)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_CloseAllSessions__invalid_slotid (CK_SLOT_ID id)
-{
- return CKR_SLOT_ID_INVALID;
-}
-
-CK_RV
-mock_C_GetFunctionStatus__not_parallel (CK_SESSION_HANDLE session)
-{
- return CKR_FUNCTION_NOT_PARALLEL;
-}
-
-CK_RV
-mock_C_CancelFunction__not_parallel (CK_SESSION_HANDLE session)
-{
- return CKR_FUNCTION_NOT_PARALLEL;
-}
-
-CK_RV
-mock_C_GetSessionInfo__invalid_handle (CK_SESSION_HANDLE session,
- CK_SESSION_INFO_PTR info)
-{
- return_val_if_fail (info, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_InitPIN__invalid_handle (CK_SESSION_HANDLE session,
- CK_UTF8CHAR_PTR pin,
- CK_ULONG pin_len)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_SetPIN__invalid_handle (CK_SESSION_HANDLE session,
- CK_UTF8CHAR_PTR old_pin,
- CK_ULONG old_pin_len,
- CK_UTF8CHAR_PTR new_pin,
- CK_ULONG new_pin_len)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_GetOperationState__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR operation_state,
- CK_ULONG_PTR operation_state_len)
-{
- return_val_if_fail (operation_state_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_SetOperationState__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR operation_state,
- CK_ULONG operation_state_len,
- CK_OBJECT_HANDLE encryption_key,
- CK_OBJECT_HANDLE authentication_key)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_Login__invalid_handle (CK_SESSION_HANDLE session,
- CK_USER_TYPE user_type,
- CK_UTF8CHAR_PTR pin,
- CK_ULONG pin_len)
-{
- return CKR_SESSION_HANDLE_INVALID;
-
-}
-
-CK_RV
-mock_C_Logout__invalid_handle (CK_SESSION_HANDLE session)
-{
- return CKR_SESSION_HANDLE_INVALID;
-
-}
-
-CK_RV
-mock_C_CreateObject__invalid_handle (CK_SESSION_HANDLE session,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count,
- CK_OBJECT_HANDLE_PTR new_object)
-{
- return_val_if_fail (new_object, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_CopyObject__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE object,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count,
- CK_OBJECT_HANDLE_PTR new_object)
-{
- return_val_if_fail (new_object, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-
-CK_RV
-mock_C_DestroyObject__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE object)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_GetObjectSize__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE object,
- CK_ULONG_PTR size)
-{
- return_val_if_fail (size, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_GetAttributeValue__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE object,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_SetAttributeValue__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE object,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_FindObjectsInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_FindObjects__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE_PTR objects,
- CK_ULONG max_count,
- CK_ULONG_PTR count)
-{
- return_val_if_fail (count, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_FindObjectsFinal__invalid_handle (CK_SESSION_HANDLE session)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_EncryptInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE key)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_Encrypt__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR data, CK_ULONG data_len,
- CK_BYTE_PTR encrypted_data,
- CK_ULONG_PTR encrypted_data_len)
-{
- return_val_if_fail (encrypted_data_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_EncryptUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR part,
- CK_ULONG part_len,
- CK_BYTE_PTR encrypted_part,
- CK_ULONG_PTR encrypted_part_len)
-{
- return_val_if_fail (encrypted_part_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_EncryptFinal__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR last_part,
- CK_ULONG_PTR last_part_len)
-{
- return_val_if_fail (last_part_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_DecryptInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE key)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_Decrypt__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR enc_data,
- CK_ULONG enc_data_len,
- CK_BYTE_PTR data,
- CK_ULONG_PTR data_len)
-{
- return_val_if_fail (data_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_DecryptUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR enc_part,
- CK_ULONG enc_part_len,
- CK_BYTE_PTR part,
- CK_ULONG_PTR part_len)
-{
- return_val_if_fail (part_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_DecryptFinal__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR last_part,
- CK_ULONG_PTR last_part_len)
-{
- return_val_if_fail (last_part_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_DigestInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_Digest__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR data,
- CK_ULONG data_len,
- CK_BYTE_PTR digest,
- CK_ULONG_PTR digest_len)
-{
- return_val_if_fail (digest_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_DigestUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR part,
- CK_ULONG part_len)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_DigestKey__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE key)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_DigestFinal__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR digest,
- CK_ULONG_PTR digest_len)
-{
- return_val_if_fail (digest_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_SignInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE key)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_Sign__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR data,
- CK_ULONG data_len,
- CK_BYTE_PTR signature,
- CK_ULONG_PTR signature_len)
-{
- return_val_if_fail (signature_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_SignUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR part,
- CK_ULONG part_len)
-{
- return_val_if_fail (part_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_SignFinal__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR signature,
- CK_ULONG_PTR signature_len)
-{
- return_val_if_fail (signature_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_SignRecoverInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE key)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_SignRecover__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR data,
- CK_ULONG data_len,
- CK_BYTE_PTR signature,
- CK_ULONG_PTR signature_len)
-{
- return_val_if_fail (signature_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_VerifyInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE key)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_Verify__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR data,
- CK_ULONG data_len,
- CK_BYTE_PTR signature,
- CK_ULONG signature_len)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_VerifyUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR part,
- CK_ULONG part_len)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_VerifyFinal__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR signature,
- CK_ULONG signature_len)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_VerifyRecoverInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE key)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_VerifyRecover__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR signature,
- CK_ULONG signature_len,
- CK_BYTE_PTR data,
- CK_ULONG_PTR data_len)
-{
- return_val_if_fail (data_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_DigestEncryptUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR part,
- CK_ULONG part_len, CK_BYTE_PTR enc_part,
- CK_ULONG_PTR enc_part_len)
-{
- return_val_if_fail (enc_part_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_DecryptDigestUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR enc_part,
- CK_ULONG enc_part_len,
- CK_BYTE_PTR part,
- CK_ULONG_PTR part_len)
-{
- return_val_if_fail (part_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_SignEncryptUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR part,
- CK_ULONG part_len,
- CK_BYTE_PTR enc_part,
- CK_ULONG_PTR enc_part_len)
-{
- return_val_if_fail (enc_part_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_DecryptVerifyUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR enc_part,
- CK_ULONG enc_part_len,
- CK_BYTE_PTR part,
- CK_ULONG_PTR part_len)
-{
- return_val_if_fail (part_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_GenerateKey__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count,
- CK_OBJECT_HANDLE_PTR key)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_GenerateKeyPair__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_ATTRIBUTE_PTR pub_template,
- CK_ULONG pub_count,
- CK_ATTRIBUTE_PTR priv_template,
- CK_ULONG priv_count,
- CK_OBJECT_HANDLE_PTR pub_key,
- CK_OBJECT_HANDLE_PTR priv_key)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_WrapKey__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE wrapping_key,
- CK_OBJECT_HANDLE key,
- CK_BYTE_PTR wrapped_key,
- CK_ULONG_PTR wrapped_key_len)
-{
- return_val_if_fail (wrapped_key_len, CKR_ARGUMENTS_BAD);
-
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_UnwrapKey__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE unwrapping_key,
- CK_BYTE_PTR wrapped_key,
- CK_ULONG wrapped_key_len,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count,
- CK_OBJECT_HANDLE_PTR key)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_DeriveKey__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE base_key,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count,
- CK_OBJECT_HANDLE_PTR key)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_SeedRandom__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR seed,
- CK_ULONG seed_len)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_RV
-mock_C_GenerateRandom__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR random_data,
- CK_ULONG random_len)
-{
- return CKR_SESSION_HANDLE_INVALID;
-}
-
-CK_FUNCTION_LIST mock_module_no_slots = {
- { CRYPTOKI_VERSION_MAJOR, CRYPTOKI_VERSION_MINOR }, /* version */
- mock_C_Initialize,
- mock_C_Finalize,
- mock_C_GetInfo,
- mock_C_GetFunctionList,
- mock_C_GetSlotList__no_tokens,
- mock_C_GetSlotInfo__invalid_slotid,
- mock_C_GetTokenInfo__invalid_slotid,
- mock_C_GetMechanismList__invalid_slotid,
- mock_C_GetMechanismInfo__invalid_slotid,
- mock_C_InitToken__invalid_slotid,
- mock_C_InitPIN__invalid_handle,
- mock_C_SetPIN__invalid_handle,
- mock_C_OpenSession__invalid_slotid,
- mock_C_CloseSession__invalid_handle,
- mock_C_CloseAllSessions__invalid_slotid,
- mock_C_GetSessionInfo__invalid_handle,
- mock_C_GetOperationState__invalid_handle,
- mock_C_SetOperationState__invalid_handle,
- mock_C_Login__invalid_handle,
- mock_C_Logout__invalid_handle,
- mock_C_CreateObject__invalid_handle,
- mock_C_CopyObject__invalid_handle,
- mock_C_DestroyObject__invalid_handle,
- mock_C_GetObjectSize__invalid_handle,
- mock_C_GetAttributeValue__invalid_handle,
- mock_C_SetAttributeValue__invalid_handle,
- mock_C_FindObjectsInit__invalid_handle,
- mock_C_FindObjects__invalid_handle,
- mock_C_FindObjectsFinal__invalid_handle,
- mock_C_EncryptInit__invalid_handle,
- mock_C_Encrypt__invalid_handle,
- mock_C_EncryptUpdate__invalid_handle,
- mock_C_EncryptFinal__invalid_handle,
- mock_C_DecryptInit__invalid_handle,
- mock_C_Decrypt__invalid_handle,
- mock_C_DecryptUpdate__invalid_handle,
- mock_C_DecryptFinal__invalid_handle,
- mock_C_DigestInit__invalid_handle,
- mock_C_Digest__invalid_handle,
- mock_C_DigestUpdate__invalid_handle,
- mock_C_DigestKey__invalid_handle,
- mock_C_DigestFinal__invalid_handle,
- mock_C_SignInit__invalid_handle,
- mock_C_Sign__invalid_handle,
- mock_C_SignUpdate__invalid_handle,
- mock_C_SignFinal__invalid_handle,
- mock_C_SignRecoverInit__invalid_handle,
- mock_C_SignRecover__invalid_handle,
- mock_C_VerifyInit__invalid_handle,
- mock_C_Verify__invalid_handle,
- mock_C_VerifyUpdate__invalid_handle,
- mock_C_VerifyFinal__invalid_handle,
- mock_C_VerifyRecoverInit__invalid_handle,
- mock_C_VerifyRecover__invalid_handle,
- mock_C_DigestEncryptUpdate__invalid_handle,
- mock_C_DecryptDigestUpdate__invalid_handle,
- mock_C_SignEncryptUpdate__invalid_handle,
- mock_C_DecryptVerifyUpdate__invalid_handle,
- mock_C_GenerateKey__invalid_handle,
- mock_C_GenerateKeyPair__invalid_handle,
- mock_C_WrapKey__invalid_handle,
- mock_C_UnwrapKey__invalid_handle,
- mock_C_DeriveKey__invalid_handle,
- mock_C_SeedRandom__invalid_handle,
- mock_C_GenerateRandom__invalid_handle,
- mock_C_GetFunctionStatus__not_parallel,
- mock_C_CancelFunction__not_parallel,
- mock_C_WaitForSlotEvent__no_event,
-};
-
-void
-mock_module_init (void)
-{
- static int initialized = 0;
- if (!initialized) {
- _p11_mutex_init (&init_mutex);
- initialized = 1;
- }
-}
diff --git a/tests/mock-module.h b/tests/mock-module.h
deleted file mode 100644
index 9557f70..0000000
--- a/tests/mock-module.h
+++ /dev/null
@@ -1,337 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* mock-module.c - a mock PKCS#11 module
-
- Copyright (C) 2011 Collabora Ltd.
-
- The Gnome Keyring Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Keyring Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: Stef Walter <stefw@collabora.co.uk>
-*/
-
-#ifndef __MOCK_MODULE_H__
-#define __MOCK_MODULE_H__
-
-#include "pkcs11.h"
-
-extern CK_FUNCTION_LIST mock_module_no_slots;
-
-void mock_module_init (void);
-
-CK_RV mock_C_Initialize (CK_VOID_PTR init_args);
-
-CK_RV mock_C_Finalize (CK_VOID_PTR reserved);
-
-CK_RV mock_C_GetInfo (CK_INFO_PTR info);
-
-CK_RV mock_C_GetFunctionList (CK_FUNCTION_LIST_PTR_PTR list);
-
-CK_RV mock_C_GetSlotList__no_tokens (CK_BBOOL token_present,
- CK_SLOT_ID_PTR slot_list,
- CK_ULONG_PTR count);
-
-CK_RV mock_C_GetSlotInfo__invalid_slotid (CK_SLOT_ID id,
- CK_SLOT_INFO_PTR info);
-
-CK_RV mock_C_GetTokenInfo__invalid_slotid (CK_SLOT_ID id,
- CK_TOKEN_INFO_PTR info);
-
-CK_RV mock_C_GetMechanismList__invalid_slotid (CK_SLOT_ID id,
- CK_MECHANISM_TYPE_PTR mechanism_list,
- CK_ULONG_PTR count);
-
-CK_RV mock_C_GetMechanismInfo__invalid_slotid (CK_SLOT_ID id,
- CK_MECHANISM_TYPE type,
- CK_MECHANISM_INFO_PTR info);
-
-CK_RV mock_C_InitToken__invalid_slotid (CK_SLOT_ID id,
- CK_UTF8CHAR_PTR pin,
- CK_ULONG pin_len,
- CK_UTF8CHAR_PTR label);
-
-CK_RV mock_C_WaitForSlotEvent__no_event (CK_FLAGS flags,
- CK_SLOT_ID_PTR slot,
- CK_VOID_PTR reserved);
-
-CK_RV mock_C_OpenSession__invalid_slotid (CK_SLOT_ID id,
- CK_FLAGS flags,
- CK_VOID_PTR user_data,
- CK_NOTIFY callback,
- CK_SESSION_HANDLE_PTR session);
-
-CK_RV mock_C_CloseSession__invalid_handle (CK_SESSION_HANDLE session);
-
-CK_RV mock_C_CloseAllSessions__invalid_slotid (CK_SLOT_ID id);
-
-CK_RV mock_C_GetFunctionStatus__not_parallel (CK_SESSION_HANDLE session);
-
-CK_RV mock_C_CancelFunction__not_parallel (CK_SESSION_HANDLE session);
-
-CK_RV mock_C_GetSessionInfo__invalid_handle (CK_SESSION_HANDLE session,
- CK_SESSION_INFO_PTR info);
-
-CK_RV mock_C_InitPIN__invalid_handle (CK_SESSION_HANDLE session,
- CK_UTF8CHAR_PTR pin,
- CK_ULONG pin_len);
-
-CK_RV mock_C_SetPIN__invalid_handle (CK_SESSION_HANDLE session,
- CK_UTF8CHAR_PTR old_pin,
- CK_ULONG old_pin_len,
- CK_UTF8CHAR_PTR new_pin,
- CK_ULONG new_pin_len);
-
-CK_RV mock_C_GetOperationState__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR operation_state,
- CK_ULONG_PTR operation_state_len);
-
-CK_RV mock_C_SetOperationState__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR operation_state,
- CK_ULONG operation_state_len,
- CK_OBJECT_HANDLE encryption_key,
- CK_OBJECT_HANDLE authentication_key);
-
-CK_RV mock_C_Login__invalid_handle (CK_SESSION_HANDLE session,
- CK_USER_TYPE user_type,
- CK_UTF8CHAR_PTR pin,
- CK_ULONG pin_len);
-
-CK_RV mock_C_Logout__invalid_handle (CK_SESSION_HANDLE session);
-
-CK_RV mock_C_CreateObject__invalid_handle (CK_SESSION_HANDLE session,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count,
- CK_OBJECT_HANDLE_PTR new_object);
-
-CK_RV mock_C_CopyObject__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE object,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count,
- CK_OBJECT_HANDLE_PTR new_object);
-
-CK_RV mock_C_DestroyObject__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE object);
-
-CK_RV mock_C_GetObjectSize__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE object,
- CK_ULONG_PTR size);
-
-CK_RV mock_C_GetAttributeValue__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE object,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count);
-
-CK_RV mock_C_SetAttributeValue__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE object,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count);
-
-CK_RV mock_C_FindObjectsInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count);
-
-CK_RV mock_C_FindObjects__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE_PTR objects,
- CK_ULONG max_count,
- CK_ULONG_PTR count);
-
-CK_RV mock_C_FindObjectsFinal__invalid_handle (CK_SESSION_HANDLE session);
-
-CK_RV mock_C_EncryptInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE key);
-
-CK_RV mock_C_Encrypt__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR data,
- CK_ULONG data_len,
- CK_BYTE_PTR encrypted_data,
- CK_ULONG_PTR encrypted_data_len);
-
-CK_RV mock_C_EncryptUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR part,
- CK_ULONG part_len,
- CK_BYTE_PTR encrypted_part,
- CK_ULONG_PTR encrypted_part_len);
-
-CK_RV mock_C_EncryptFinal__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR last_part,
- CK_ULONG_PTR last_part_len);
-
-CK_RV mock_C_DecryptInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE key);
-
-CK_RV mock_C_Decrypt__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR enc_data,
- CK_ULONG enc_data_len,
- CK_BYTE_PTR data,
- CK_ULONG_PTR data_len);
-
-CK_RV mock_C_DecryptUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR enc_part,
- CK_ULONG enc_part_len,
- CK_BYTE_PTR part,
- CK_ULONG_PTR part_len);
-
-CK_RV mock_C_DecryptFinal__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR last_part,
- CK_ULONG_PTR last_part_len);
-
-CK_RV mock_C_DigestInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism);
-
-CK_RV mock_C_Digest__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR data,
- CK_ULONG data_len,
- CK_BYTE_PTR digest,
- CK_ULONG_PTR digest_len);
-
-CK_RV mock_C_DigestUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR part,
- CK_ULONG part_len);
-
-CK_RV mock_C_DigestKey__invalid_handle (CK_SESSION_HANDLE session,
- CK_OBJECT_HANDLE key);
-
-CK_RV mock_C_DigestFinal__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR digest,
- CK_ULONG_PTR digest_len);
-
-CK_RV mock_C_SignInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE key);
-
-CK_RV mock_C_Sign__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR data,
- CK_ULONG data_len,
- CK_BYTE_PTR signature,
- CK_ULONG_PTR signature_len);
-
-CK_RV mock_C_SignUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR part,
- CK_ULONG part_len);
-
-CK_RV mock_C_SignFinal__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR signature,
- CK_ULONG_PTR signature_len);
-
-CK_RV mock_C_SignRecoverInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE key);
-
-CK_RV mock_C_SignRecover__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR data,
- CK_ULONG data_len,
- CK_BYTE_PTR signature,
- CK_ULONG_PTR signature_len);
-
-CK_RV mock_C_VerifyInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE key);
-
-CK_RV mock_C_Verify__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR data,
- CK_ULONG data_len,
- CK_BYTE_PTR signature,
- CK_ULONG signature_len);
-
-CK_RV mock_C_VerifyUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR part,
- CK_ULONG part_len);
-
-CK_RV mock_C_VerifyFinal__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR signature,
- CK_ULONG signature_len);
-
-CK_RV mock_C_VerifyRecoverInit__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE key);
-
-CK_RV mock_C_VerifyRecover__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR signature,
- CK_ULONG signature_len,
- CK_BYTE_PTR data,
- CK_ULONG_PTR data_len);
-
-CK_RV mock_C_DigestEncryptUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR part,
- CK_ULONG part_len,
- CK_BYTE_PTR enc_part,
- CK_ULONG_PTR enc_part_len);
-
-CK_RV mock_C_DecryptDigestUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR enc_part,
- CK_ULONG enc_part_len,
- CK_BYTE_PTR part,
- CK_ULONG_PTR part_len);
-
-CK_RV mock_C_SignEncryptUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR part,
- CK_ULONG part_len,
- CK_BYTE_PTR enc_part,
- CK_ULONG_PTR enc_part_len);
-
-CK_RV mock_C_DecryptVerifyUpdate__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR enc_part,
- CK_ULONG enc_part_len,
- CK_BYTE_PTR part,
- CK_ULONG_PTR part_len);
-
-CK_RV mock_C_GenerateKey__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count,
- CK_OBJECT_HANDLE_PTR key);
-
-CK_RV mock_C_GenerateKeyPair__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_ATTRIBUTE_PTR pub_template,
- CK_ULONG pub_count,
- CK_ATTRIBUTE_PTR priv_template,
- CK_ULONG priv_count,
- CK_OBJECT_HANDLE_PTR pub_key,
- CK_OBJECT_HANDLE_PTR priv_key);
-
-CK_RV mock_C_WrapKey__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE wrapping_key,
- CK_OBJECT_HANDLE key,
- CK_BYTE_PTR wrapped_key,
- CK_ULONG_PTR wrapped_key_len);
-
-CK_RV mock_C_UnwrapKey__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE unwrapping_key,
- CK_BYTE_PTR wrapped_key,
- CK_ULONG wrapped_key_len,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count,
- CK_OBJECT_HANDLE_PTR key);
-
-CK_RV mock_C_DeriveKey__invalid_handle (CK_SESSION_HANDLE session,
- CK_MECHANISM_PTR mechanism,
- CK_OBJECT_HANDLE base_key,
- CK_ATTRIBUTE_PTR template,
- CK_ULONG count,
- CK_OBJECT_HANDLE_PTR key);
-
-CK_RV mock_C_SeedRandom__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR seed,
- CK_ULONG seed_len);
-
-CK_RV mock_C_GenerateRandom__invalid_handle (CK_SESSION_HANDLE session,
- CK_BYTE_PTR random_data,
- CK_ULONG random_len);
-
-#endif /* __MOCK_MODULE_H__ */
diff --git a/tests/pin-test.c b/tests/pin-test.c
deleted file mode 100644
index 7e7dda8..0000000
--- a/tests/pin-test.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright (c) 2011, Collabora Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- * * The names of contributors to this software may not be
- * used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Author: Stef Walter <stefw@collabora.co.uk>
- */
-
-#include "config.h"
-#include "CuTest.h"
-
-#include <assert.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "p11-kit/pin.h"
-#include "p11-kit/private.h"
-
-static P11KitPin *
-callback_one (const char *pin_source, P11KitUri *pin_uri, const char *pin_description,
- P11KitPinFlags pin_flags, void *callback_data)
-{
- int *data = callback_data;
- assert (*data == 33);
- return p11_kit_pin_new_for_buffer ((unsigned char*)strdup ("one"), 3, free);
-}
-
-static P11KitPin*
-callback_other (const char *pin_source, P11KitUri *pin_uri, const char *pin_description,
- P11KitPinFlags pin_flags, void *callback_data)
-{
- char *data = callback_data;
- return p11_kit_pin_new_for_string (data);
-}
-
-static void
-destroy_data (void *callback_data)
-{
- int *data = callback_data;
- (*data)++;
-}
-
-static void
-test_pin_register_unregister (CuTest *tc)
-{
- int data = 33;
-
- p11_kit_pin_register_callback ("/the/pin_source", callback_one,
- &data, destroy_data);
-
- p11_kit_pin_unregister_callback ("/the/pin_source", callback_one,
- &data);
-
- CuAssertIntEquals (tc, 34, data);
-}
-
-static void
-test_pin_read (CuTest *tc)
-{
- P11KitUri *uri;
- P11KitPin *pin;
- int data = 33;
- size_t length;
- const unsigned char *ptr;
-
- p11_kit_pin_register_callback ("/the/pin_source", callback_one,
- &data, destroy_data);
-
- uri = p11_kit_uri_new ();
- pin = p11_kit_pin_request ("/the/pin_source", uri, "The token",
- P11_KIT_PIN_FLAGS_USER_LOGIN);
- p11_kit_uri_free (uri);
-
- CuAssertPtrNotNull (tc, pin);
- ptr = p11_kit_pin_get_value (pin, &length);
- CuAssertIntEquals (tc, 3, length);
- CuAssertTrue (tc, memcmp (ptr, "one", 3) == 0);
-
- p11_kit_pin_unregister_callback ("/the/pin_source", callback_one,
- &data);
-
- p11_kit_pin_ref (pin);
- p11_kit_pin_unref (pin);
-}
-
-static void
-test_pin_read_no_match (CuTest *tc)
-{
- P11KitUri *uri;
- P11KitPin *pin;
-
- uri = p11_kit_uri_new ();
- pin = p11_kit_pin_request ("/the/pin_source", uri, "The token",
- P11_KIT_PIN_FLAGS_USER_LOGIN);
- p11_kit_uri_free (uri);
-
- CuAssertPtrEquals (tc, NULL, pin);
-}
-
-static void
-test_pin_register_duplicate (CuTest *tc)
-{
- P11KitUri *uri;
- P11KitPin *pin;
- char *value = "secret";
- int data = 33;
- size_t length;
- const unsigned char *ptr;
-
- uri = p11_kit_uri_new ();
-
- p11_kit_pin_register_callback ("/the/pin_source", callback_one,
- &data, destroy_data);
-
- p11_kit_pin_register_callback ("/the/pin_source", callback_other,
- value, NULL);
-
- pin = p11_kit_pin_request ("/the/pin_source", uri, "The token",
- P11_KIT_PIN_FLAGS_USER_LOGIN);
-
- CuAssertPtrNotNull (tc, pin);
- ptr = p11_kit_pin_get_value (pin, &length);
- CuAssertIntEquals (tc, 6, length);
- CuAssertTrue (tc, memcmp (ptr, "secret", length) == 0);
- p11_kit_pin_unref (pin);
-
- p11_kit_pin_unregister_callback ("/the/pin_source", callback_other,
- value);
-
- pin = p11_kit_pin_request ("/the/pin_source", uri, "The token",
- P11_KIT_PIN_FLAGS_USER_LOGIN);
-
- CuAssertPtrNotNull (tc, pin);
- ptr = p11_kit_pin_get_value (pin, &length);
- CuAssertIntEquals (tc, 3, length);
- CuAssertTrue (tc, memcmp (ptr, "one", length) == 0);
- p11_kit_pin_unref (pin);
-
- p11_kit_pin_unregister_callback ("/the/pin_source", callback_one,
- &data);
-
- pin = p11_kit_pin_request ("/the/pin_source", uri, "The token",
- P11_KIT_PIN_FLAGS_USER_LOGIN);
-
- CuAssertPtrEquals (tc, NULL, pin);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_pin_register_fallback (CuTest *tc)
-{
- char *value = "secret";
- P11KitUri *uri;
- P11KitPin *pin;
- int data = 33;
- size_t length;
- const unsigned char *ptr;
-
- uri = p11_kit_uri_new ();
-
- p11_kit_pin_register_callback (P11_KIT_PIN_FALLBACK, callback_one,
- &data, destroy_data);
-
- pin = p11_kit_pin_request ("/the/pin_source", uri, "The token",
- P11_KIT_PIN_FLAGS_USER_LOGIN);
-
- CuAssertPtrNotNull (tc, pin);
- ptr = p11_kit_pin_get_value (pin, &length);
- CuAssertIntEquals (tc, 3, length);
- CuAssertTrue (tc, memcmp (ptr, "one", length) == 0);
- p11_kit_pin_unref (pin);
-
- p11_kit_pin_register_callback ("/the/pin_source", callback_other,
- value, NULL);
-
- pin = p11_kit_pin_request ("/the/pin_source", uri, "The token",
- P11_KIT_PIN_FLAGS_USER_LOGIN);
-
- CuAssertPtrNotNull (tc, pin);
- ptr = p11_kit_pin_get_value (pin, &length);
- CuAssertIntEquals (tc, 6, length);
- CuAssertTrue (tc, memcmp (ptr, "secret", length) == 0);
- p11_kit_pin_unref (pin);
-
- p11_kit_pin_unregister_callback ("/the/pin_source", callback_other,
- value);
-
- p11_kit_pin_unregister_callback (P11_KIT_PIN_FALLBACK, callback_one,
- &data);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_pin_file (CuTest *tc)
-{
- P11KitUri *uri;
- P11KitPin *pin;
- size_t length;
- const unsigned char *ptr;
-
- uri = p11_kit_uri_new ();
-
- p11_kit_pin_register_callback (P11_KIT_PIN_FALLBACK, p11_kit_pin_file_callback,
- NULL, NULL);
-
- pin = p11_kit_pin_request (SRCDIR "/files/test-pinfile", uri, "The token",
- P11_KIT_PIN_FLAGS_USER_LOGIN);
-
- CuAssertPtrNotNull (tc, pin);
- ptr = p11_kit_pin_get_value (pin, &length);
- CuAssertIntEquals (tc, 12, length);
- CuAssertTrue (tc, 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);
-
- p11_kit_pin_unregister_callback (P11_KIT_PIN_FALLBACK, p11_kit_pin_file_callback,
- NULL);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_pin_file_large (CuTest *tc)
-{
- P11KitUri *uri;
- P11KitPin *pin;
- int error;
-
- uri = p11_kit_uri_new ();
-
- p11_kit_pin_register_callback (P11_KIT_PIN_FALLBACK, p11_kit_pin_file_callback,
- NULL, NULL);
-
- pin = p11_kit_pin_request (SRCDIR "/files/test-pinfile-large", uri, "The token",
- P11_KIT_PIN_FLAGS_USER_LOGIN);
-
- error = errno;
- CuAssertPtrEquals (tc, NULL, pin);
- CuAssertIntEquals (tc, EFBIG, error);
-
- p11_kit_pin_unregister_callback (P11_KIT_PIN_FALLBACK, p11_kit_pin_file_callback,
- NULL);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_pin_ref_unref (CuTest *tc)
-{
- P11KitPin *pin;
- P11KitPin *check;
-
- pin = p11_kit_pin_new_for_string ("crack of lies");
-
- check = p11_kit_pin_ref (pin);
- CuAssertPtrEquals (tc, pin, check);
-
- p11_kit_pin_unref (pin);
- p11_kit_pin_unref (check);
-}
-
-int
-main (void)
-{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- _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;
-}
diff --git a/tests/print-messages.c b/tests/print-messages.c
deleted file mode 100644
index 5870ad1..0000000
--- a/tests/print-messages.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2011, Collabora Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met);
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- * * The names of contributors to this software may not be
- * used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Author: Stef Walter <stefw@collabora.co.uk>
- */
-
-#include "config.h"
-
-#include <assert.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "p11-kit.h"
-
-int
-main (int argc, char *argv[])
-{
- if (argc != 1) {
- fprintf (stderr, "usage: print-messages\n");
- exit (2);
- }
-
- #define X(x) printf ("%s: %s\n", #x, p11_kit_strerror (x))
- X(CKR_CANCEL);
- X(CKR_FUNCTION_CANCELED);
- X(CKR_HOST_MEMORY);
- X(CKR_SLOT_ID_INVALID);
- X(CKR_GENERAL_ERROR);
- X(CKR_FUNCTION_FAILED);
- X(CKR_ARGUMENTS_BAD);
- X(CKR_NEED_TO_CREATE_THREADS);
- X(CKR_CANT_LOCK);
- X(CKR_ATTRIBUTE_READ_ONLY);
- X(CKR_ATTRIBUTE_SENSITIVE);
- X(CKR_ATTRIBUTE_TYPE_INVALID);
- X(CKR_ATTRIBUTE_VALUE_INVALID);
- X(CKR_DATA_INVALID);
- X(CKR_DATA_LEN_RANGE);
- X(CKR_DEVICE_ERROR);
- X(CKR_DEVICE_MEMORY);
- X(CKR_DEVICE_REMOVED);
- X(CKR_ENCRYPTED_DATA_INVALID);
- X(CKR_ENCRYPTED_DATA_LEN_RANGE);
- X(CKR_FUNCTION_NOT_SUPPORTED);
- X(CKR_KEY_HANDLE_INVALID);
- X(CKR_KEY_SIZE_RANGE);
- X(CKR_KEY_TYPE_INCONSISTENT);
- X(CKR_KEY_NOT_NEEDED);
- X(CKR_KEY_CHANGED);
- X(CKR_KEY_NEEDED);
- X(CKR_KEY_INDIGESTIBLE);
- X(CKR_KEY_FUNCTION_NOT_PERMITTED);
- X(CKR_KEY_NOT_WRAPPABLE);
- X(CKR_KEY_UNEXTRACTABLE);
- X(CKR_MECHANISM_INVALID);
- X(CKR_MECHANISM_PARAM_INVALID);
- X(CKR_OBJECT_HANDLE_INVALID);
- X(CKR_OPERATION_ACTIVE);
- X(CKR_OPERATION_NOT_INITIALIZED);
- X(CKR_PIN_INCORRECT);
- X(CKR_PIN_INVALID);
- X(CKR_PIN_LEN_RANGE);
- X(CKR_PIN_EXPIRED);
- X(CKR_PIN_LOCKED);
- X(CKR_SESSION_CLOSED);
- X(CKR_SESSION_COUNT);
- X(CKR_SESSION_HANDLE_INVALID);
- X(CKR_SESSION_READ_ONLY);
- X(CKR_SESSION_EXISTS);
- X(CKR_SESSION_READ_ONLY_EXISTS);
- X(CKR_SESSION_READ_WRITE_SO_EXISTS);
- X(CKR_SIGNATURE_INVALID);
- X(CKR_SIGNATURE_LEN_RANGE);
- X(CKR_TEMPLATE_INCOMPLETE);
- X(CKR_TEMPLATE_INCONSISTENT);
- X(CKR_TOKEN_NOT_PRESENT);
- X(CKR_TOKEN_NOT_RECOGNIZED);
- X(CKR_TOKEN_WRITE_PROTECTED);
- X(CKR_UNWRAPPING_KEY_HANDLE_INVALID);
- X(CKR_UNWRAPPING_KEY_SIZE_RANGE);
- X(CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT);
- X(CKR_USER_ALREADY_LOGGED_IN);
- X(CKR_USER_NOT_LOGGED_IN);
- X(CKR_USER_PIN_NOT_INITIALIZED);
- X(CKR_USER_TYPE_INVALID);
- X(CKR_USER_ANOTHER_ALREADY_LOGGED_IN);
- X(CKR_USER_TOO_MANY_TYPES);
- X(CKR_WRAPPED_KEY_INVALID);
- X(CKR_WRAPPED_KEY_LEN_RANGE);
- X(CKR_WRAPPING_KEY_HANDLE_INVALID);
- X(CKR_WRAPPING_KEY_SIZE_RANGE);
- X(CKR_WRAPPING_KEY_TYPE_INCONSISTENT);
- X(CKR_RANDOM_SEED_NOT_SUPPORTED);
- X(CKR_RANDOM_NO_RNG);
- X(CKR_DOMAIN_PARAMS_INVALID);
- X(CKR_BUFFER_TOO_SMALL);
- X(CKR_SAVED_STATE_INVALID);
- X(CKR_INFORMATION_SENSITIVE);
- X(CKR_STATE_UNSAVEABLE);
- X(CKR_CRYPTOKI_NOT_INITIALIZED);
- X(CKR_CRYPTOKI_ALREADY_INITIALIZED);
- X(CKR_MUTEX_BAD);
- X(CKR_MUTEX_NOT_LOCKED);
- X(CKR_FUNCTION_REJECTED);
- #undef X
-
- return 0;
-}
diff --git a/tests/progname-test.c b/tests/progname-test.c
deleted file mode 100644
index 1e42056..0000000
--- a/tests/progname-test.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2012 Stefan Walter
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- * * The names of contributors to this software may not be
- * used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Author: Stef Walter <stef@thewalter.net>
- */
-
-#include "config.h"
-#include "CuTest.h"
-
-#include <assert.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "p11-kit/uri.h"
-#include "p11-kit/p11-kit.h"
-#include "p11-kit/private.h"
-
-static void
-test_progname_default (CuTest *tc)
-{
- const char *progname;
-
- progname = _p11_get_progname_unlocked ();
- CuAssertStrEquals (tc, "progname-test", progname);
-}
-
-static void
-test_progname_set (CuTest *tc)
-{
- const char *progname;
-
- p11_kit_set_progname ("love-generation");
-
- progname = _p11_get_progname_unlocked ();
- CuAssertStrEquals (tc, "love-generation", progname);
-
- _p11_set_progname_unlocked (NULL);
-
- progname = _p11_get_progname_unlocked ();
- CuAssertStrEquals (tc, "progname-test", progname);
-}
-
-/* Defined in util.c */
-extern char *_p11_my_progname;
-
-static void
-test_progname_uninit_clears (CuTest *tc)
-{
- _p11_set_progname_unlocked ("love-generation");
- CuAssertStrEquals (tc, "love-generation", _p11_my_progname);
-
- /* Inititialize should clear above variable */
- _p11_library_uninit ();
-
- CuAssertPtrEquals (tc, NULL, _p11_my_progname);
-}
-
-int
-main (void)
-{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- _p11_library_init ();
-
- SUITE_ADD_TEST (suite, test_progname_default);
- SUITE_ADD_TEST (suite, test_progname_set);
-
- /* This test should be last, as it uninitializes the library */
- SUITE_ADD_TEST (suite, test_progname_uninit_clears);
-
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
- return ret;
-}
diff --git a/tests/ptr-array-test.c b/tests/ptr-array-test.c
deleted file mode 100644
index b75614f..0000000
--- a/tests/ptr-array-test.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright (c) 2011, Collabora Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- * * The names of contributors to this software may not be
- * used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Author: Stef Walter <stefw@collabora.co.uk>
- */
-
-#include "config.h"
-#include "CuTest.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "ptr-array.h"
-
-static void
-test__p11_ptr_array_create (CuTest *tc)
-{
- ptr_array_t *array;
-
- array = _p11_ptr_array_create (NULL);
- CuAssertPtrNotNull (tc, array);
- _p11_ptr_array_free (array);
-}
-
-static void
-test__p11_ptr_array_free_null (CuTest *tc)
-{
- _p11_ptr_array_free (NULL);
-}
-
-static void
-destroy_value (void *data)
-{
- int *value = data;
- *value = 2;
-}
-
-static void
-test__p11_ptr_array_free_destroys (CuTest *tc)
-{
- ptr_array_t *array;
- int value = 0;
-
- array = _p11_ptr_array_create (destroy_value);
- CuAssertPtrNotNull (tc, array);
- if (!_p11_ptr_array_add (array, &value))
- CuFail (tc, "should not be reached");
- _p11_ptr_array_free (array);
-
- CuAssertIntEquals (tc, 2, value);
-}
-
-#if 0
-static void
-test__p11_hash_iterate (CuTest *tc)
-{
- hash_t *ht;
- hash_iter_t hi;
- int key = 1;
- int value = 2;
- void *pkey;
- void *pvalue;
- int ret;
-
- ht = _p11_hash_create (_p11_hash_direct_hash, _p11_hash_direct_equal, NULL, NULL);
- CuAssertPtrNotNull (tc, ht);
- if (!_p11_hash_set (ht, &key, &value))
- CuFail (tc, "should not be reached");
-
- _p11_hash_iterate (ht, &hi);
-
- ret = _p11_hash_next (&hi, &pkey, &pvalue);
- CuAssertIntEquals (tc, 1, ret);
- CuAssertPtrEquals (tc, pkey, &key);
- CuAssertPtrEquals (tc, pvalue, &value);
-
- ret = _p11_hash_next (&hi, &pkey, &pvalue);
- CuAssertIntEquals (tc, 0, ret);
-
- _p11_hash_free (ht);
-}
-
-#endif
-
-static void
-test__p11_ptr_array_add (CuTest *tc)
-{
- char *value = "VALUE";
- char *check;
- ptr_array_t *array;
-
- array = _p11_ptr_array_create (NULL);
- if (!_p11_ptr_array_add (array, value))
- CuFail (tc, "should not be reached");
-
- CuAssertIntEquals (tc, 1, _p11_ptr_array_count (array));
-
- check = _p11_ptr_array_at (array, 0);
- CuAssertPtrEquals (tc, check, value);
-
- _p11_ptr_array_free (array);
-}
-
-static void
-test__p11_ptr_array_add_remove (CuTest *tc)
-{
- char *value = "VALUE";
- char *check;
- ptr_array_t *array;
-
- array = _p11_ptr_array_create (NULL);
- if (!_p11_ptr_array_add (array, value))
- CuFail (tc, "should not be reached");
-
- CuAssertIntEquals (tc, 1, _p11_ptr_array_count (array));
-
- check = _p11_ptr_array_at (array, 0);
- CuAssertPtrEquals (tc, check, value);
-
- _p11_ptr_array_remove (array, 0);
-
- CuAssertIntEquals (tc, 0, _p11_ptr_array_count (array));
-
- _p11_ptr_array_free (array);
-}
-
-static void
-test__p11_ptr_array_remove_destroys (CuTest *tc)
-{
- ptr_array_t *array;
- int value = 0;
-
- array = _p11_ptr_array_create (destroy_value);
- if (!_p11_ptr_array_add (array, &value))
- CuFail (tc, "should not be reached");
-
- _p11_ptr_array_remove (array, 0);
-
- CuAssertIntEquals (tc, 2, value);
-
- /* should not be destroyed again */
- value = 0;
-
- _p11_ptr_array_free (array);
-
- CuAssertIntEquals (tc, 0, value);
-}
-
-static void
-test__p11_ptr_array_remove_and_count (CuTest *tc)
-{
- ptr_array_t *array;
- int *value;
- int i;
-
- array = _p11_ptr_array_create (free);
-
- CuAssertIntEquals (tc, 0, _p11_ptr_array_count (array));
-
- for (i = 0; i < 20000; ++i) {
- value = malloc (sizeof (int));
- *value = i;
- if (!_p11_ptr_array_add (array, value))
- CuFail (tc, "should not be reached");
- CuAssertIntEquals (tc, i + 1, _p11_ptr_array_count (array));
- }
-
- for (i = 10; i < 20000; ++i) {
- _p11_ptr_array_remove (array, 10);
- CuAssertIntEquals (tc, 20010 - (i + 1), _p11_ptr_array_count (array));
- }
-
- CuAssertIntEquals (tc, 10, _p11_ptr_array_count (array));
-
- _p11_ptr_array_free (array);
-}
-
-static void
-test__p11_ptr_array_snapshot (CuTest *tc)
-{
- ptr_array_t *array;
- void **snapshot;
-
- array = _p11_ptr_array_create (NULL);
-
- _p11_ptr_array_add (array, "1");
- _p11_ptr_array_add (array, "2");
- _p11_ptr_array_add (array, "3");
- _p11_ptr_array_add (array, "4");
- CuAssertIntEquals (tc, 4, _p11_ptr_array_count (array));
-
- snapshot = _p11_ptr_array_snapshot (array);
-
- CuAssertStrEquals (tc, "1", snapshot[0]);
- CuAssertStrEquals (tc, "2", snapshot[1]);
- CuAssertStrEquals (tc, "3", snapshot[2]);
- CuAssertStrEquals (tc, "4", snapshot[3]);
-
- free (snapshot);
- _p11_ptr_array_free (array);
-}
-
-int
-main (void)
-{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- SUITE_ADD_TEST (suite, test__p11_ptr_array_create);
- SUITE_ADD_TEST (suite, test__p11_ptr_array_add);
- SUITE_ADD_TEST (suite, test__p11_ptr_array_add_remove);
- SUITE_ADD_TEST (suite, test__p11_ptr_array_remove_destroys);
- SUITE_ADD_TEST (suite, test__p11_ptr_array_remove_and_count);
- SUITE_ADD_TEST (suite, test__p11_ptr_array_free_null);
- SUITE_ADD_TEST (suite, test__p11_ptr_array_free_destroys);
- SUITE_ADD_TEST (suite, test__p11_ptr_array_snapshot);
-
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
-
- return ret;
-}
diff --git a/tests/test-init.c b/tests/test-init.c
deleted file mode 100644
index d872afa..0000000
--- a/tests/test-init.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Copyright (c) 2011, Collabora Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- * * The names of contributors to this software may not be
- * used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Author: Stef Walter <stefw@collabora.co.uk>
- */
-
-#include "config.h"
-#include "CuTest.h"
-
-#include <sys/types.h>
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#include "p11-kit/p11-kit.h"
-#include "p11-kit/util.h"
-
-#include "mock-module.h"
-
-CK_FUNCTION_LIST module;
-
-#ifdef OS_UNIX
-
-#include <sys/wait.h>
-
-static CK_RV
-mock_C_Initialize__with_fork (CK_VOID_PTR init_args)
-{
- struct timespec ts = { 0, 100 * 1000 * 1000 };
- CK_RV rv;
- pid_t child;
- pid_t ret;
- int status;
-
- rv = mock_C_Initialize (init_args);
- assert (rv == CKR_OK);
-
- /* Fork during the initialization */
- child = fork ();
- if (child == 0) {
- nanosleep (&ts, NULL);
- exit (66);
- }
-
- ret = waitpid (child, &status, 0);
- assert (ret == child);
- assert (WIFEXITED (status));
- assert (WEXITSTATUS (status) == 66);
-
- return CKR_OK;
-}
-
-static void
-test_fork_initialization (CuTest *tc)
-{
- CK_RV rv;
-
- /* 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);
-
- rv = p11_kit_finalize_module (&module);
- CuAssertTrue (tc, rv == CKR_OK);
-}
-
-#endif /* OS_UNIX */
-
-static CK_RV
-mock_C_Initialize__with_recursive (CK_VOID_PTR init_args)
-{
- CK_RV rv;
-
- rv = mock_C_Initialize (init_args);
- assert (rv == CKR_OK);
-
- /* Recursively initialize, this is broken */
- return p11_kit_initialize_module (&module);
-}
-
-static void
-test_recursive_initialization (CuTest *tc)
-{
- CK_RV rv;
-
- /* 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);
-}
-
-static mutex_t race_mutex;
-static int initialization_count = 0;
-static int finalization_count = 0;
-
-#include "private.h"
-
-static CK_RV
-mock_C_Initialize__threaded_race (CK_VOID_PTR init_args)
-{
- /* Atomically increment value */
- _p11_mutex_lock (&race_mutex);
- initialization_count += 1;
- _p11_mutex_unlock (&race_mutex);
-
- _p11_sleep_ms (100);
- return CKR_OK;
-}
-
-static CK_RV
-mock_C_Finalize__threaded_race (CK_VOID_PTR reserved)
-{
- /* Atomically increment value */
- _p11_mutex_lock (&race_mutex);
- finalization_count += 1;
- _p11_mutex_unlock (&race_mutex);
-
- _p11_sleep_ms (100);
- return CKR_OK;
-}
-
-static void *
-initialization_thread (void *data)
-{
- CuTest *tc = data;
- CK_RV rv;
-
- rv = p11_kit_initialize_module (&module);
- CuAssertTrue (tc, rv == CKR_OK);
-
- return tc;
-}
-
-static void *
-finalization_thread (void *data)
-{
- CuTest *tc = data;
- CK_RV rv;
-
- rv = p11_kit_finalize_module (&module);
- CuAssertTrue (tc, rv == CKR_OK);
-
- return tc;
-}
-
-static void
-test_threaded_initialization (CuTest *tc)
-{
- static const int num_threads = 2;
- thread_t threads[num_threads];
- int ret;
- int i;
-
- /* Build up our own function list */
- memcpy (&module, &mock_module_no_slots, sizeof (CK_FUNCTION_LIST));
- module.C_Initialize = mock_C_Initialize__threaded_race;
- module.C_Finalize = mock_C_Finalize__threaded_race;
-
- initialization_count = 0;
- 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);
- }
-
- for (i = 0; i < num_threads; i++) {
- ret = _p11_thread_join (threads[i]);
- CuAssertIntEquals (tc, 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);
- }
-
- for (i = 0; i < num_threads; i++) {
- ret = _p11_thread_join (threads[i]);
- CuAssertIntEquals (tc, 0, ret);
- threads[i] = 0;
- }
-
- /* C_Initialize should have been called exactly once */
- CuAssertIntEquals (tc, 1, initialization_count);
- CuAssertIntEquals (tc, 1, finalization_count);
-}
-
-static CK_RV
-mock_C_Initialize__test_mutexes (CK_VOID_PTR args)
-{
- CK_C_INITIALIZE_ARGS_PTR init_args;
- void *mutex = NULL;
- CK_RV rv;
-
- assert (args != NULL);
- init_args = args;
-
- rv = (init_args->CreateMutex) (&mutex);
- assert (rv == CKR_OK);
-
- rv = (init_args->LockMutex) (mutex);
- assert (rv == CKR_OK);
-
- rv = (init_args->UnlockMutex) (mutex);
- assert (rv == CKR_OK);
-
- rv = (init_args->DestroyMutex) (mutex);
- assert (rv == CKR_OK);
-
- return CKR_OK;
-}
-
-static void
-test_mutexes (CuTest *tc)
-{
- CK_RV rv;
-
- /* 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);
-
- rv = p11_kit_finalize_module (&module);
- CuAssertTrue (tc, rv == CKR_OK);
-}
-
-static void
-test_load_and_initialize (CuTest *tc)
-{
- CK_FUNCTION_LIST_PTR module;
- CK_INFO info;
- CK_RV rv;
- int ret;
-
- rv = p11_kit_load_initialize_module (BUILDDIR "/.libs/mock-one" SHLEXT, &module);
- CuAssertTrue (tc, rv == CKR_OK);
- CuAssertTrue (tc, module != NULL);
-
- rv = (module->C_GetInfo) (&info);
- CuAssertTrue (tc, rv == CKR_OK);
-
- ret = memcmp (info.manufacturerID, "MOCK MANUFACTURER ", 32);
- CuAssertTrue (tc, ret == 0);
-
- rv = p11_kit_finalize_module (module);
- CuAssertTrue (tc, ret == CKR_OK);
-}
-
-int
-main (void)
-{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- _p11_mutex_init (&race_mutex);
- mock_module_init ();
- _p11_library_init ();
-
-#ifdef OS_UNIX
- SUITE_ADD_TEST (suite, 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);
-
- CuSuiteRun (suite);
- CuSuiteSummary (suite, output);
- CuSuiteDetails (suite, output);
- printf ("%s\n", output->buffer);
- ret = suite->failCount;
- CuSuiteDelete (suite);
- CuStringDelete (output);
-
- return ret;
-}
diff --git a/tests/test-modules.c b/tests/test-modules.c
deleted file mode 100644
index 74560d9..0000000
--- a/tests/test-modules.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Copyright (c) 2012 Red Hat Inc
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- * * The names of contributors to this software may not be
- * used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Author: Stef Walter <stefw@redhat.com>
- */
-
-#include "config.h"
-#include "CuTest.h"
-
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "p11-kit.h"
-#include "private.h"
-#include "hashmap.h"
-
-static CK_FUNCTION_LIST_PTR_PTR
-initialize_and_get_modules (CuTest *tc)
-{
- CK_FUNCTION_LIST_PTR_PTR modules;
- CK_RV rv;
-
- rv = p11_kit_initialize_registered ();
- CuAssertIntEquals (tc, CKR_OK, rv);
- modules = p11_kit_registered_modules ();
- CuAssertTrue (tc, modules != NULL && modules[0] != NULL);
-
- return modules;
-}
-
-static void
-finalize_and_free_modules (CuTest *tc,
- CK_FUNCTION_LIST_PTR_PTR modules)
-{
- CK_RV rv;
-
- free (modules);
- rv = p11_kit_finalize_registered ();
- CuAssertIntEquals (tc, CKR_OK, rv);
-}
-
-static void
-test_no_duplicates (CuTest *tc)
-{
- CK_FUNCTION_LIST_PTR_PTR modules;
- hashmap *paths;
- hashmap *funcs;
- char *path;
- int i;
-
- modules = initialize_and_get_modules (tc);
- paths = _p11_hash_create (_p11_hash_string_hash, _p11_hash_string_equal, NULL, NULL);
- funcs = _p11_hash_create (_p11_hash_direct_hash, _p11_hash_direct_equal, NULL, NULL);
-
- /* The loaded modules should not contain duplicates */
- for (i = 0; modules[i] != NULL; i++) {
- path = p11_kit_registered_option (modules[i], "module");
-
- if (_p11_hash_get (funcs, modules[i]))
- CuAssert (tc, "found duplicate function list pointer", 0);
- if (_p11_hash_get (paths, path))
- CuAssert (tc, "found duplicate path name", 0);
-
- if (!_p11_hash_set (funcs, modules[i], ""))
- CuAssert (tc, "shouldn't be reached", 0);
- if (!_p11_hash_set (paths, path, ""))
- CuAssert (tc, "shouldn't be reached", 0);
- }
-
- _p11_hash_free (paths);
- _p11_hash_free (funcs);
- finalize_and_free_modules (tc, modules);
-}
-
-static CK_FUNCTION_LIST_PTR
-lookup_module_with_name (CuTest *tc,
- CK_FUNCTION_LIST_PTR_PTR modules,
- const char *name)
-{
- CK_FUNCTION_LIST_PTR match = NULL;
- CK_FUNCTION_LIST_PTR module;
- char *module_name;
- int i;
-
- for (i = 0; match == NULL && modules[i] != NULL; i++) {
- module_name = p11_kit_registered_module_to_name (modules[i]);
- CuAssertPtrNotNull (tc, module_name);
- if (strcmp (module_name, name) == 0)
- match = modules[i];
- free (module_name);
- }
-
- /*
- * As a side effect, we should check that the results of this function
- * 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);
-
- return match;
-}
-
-static void
-test_disable (CuTest *tc)
-{
- CK_FUNCTION_LIST_PTR_PTR modules;
-
- /*
- * The module four should be present, as we don't match any prognames
- * 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);
-
- /*
- * The module two shouldn't have been loaded, because in its config
- * file we have:
- *
- * disable-in: test-disable
- */
-
- 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);
-
- p11_kit_set_progname (NULL);
-}
-
-static void
-test_disable_later (CuTest *tc)
-{
- CK_FUNCTION_LIST_PTR_PTR modules;
- CK_RV rv;
-
- /*
- * The module two shouldn't be matched, because in its config
- * file we have:
- *
- * disable-in: test-disable
- */
-
- rv = p11_kit_initialize_registered ();
- CuAssertIntEquals (tc, CKR_OK, rv);
-
- p11_kit_set_progname ("test-disable");
-
- modules = p11_kit_registered_modules ();
- CuAssertTrue (tc, modules != NULL && modules[0] != NULL);
-
- CuAssertTrue (tc, lookup_module_with_name (tc, modules, "two") == NULL);
- finalize_and_free_modules (tc, modules);
-
- p11_kit_set_progname (NULL);
-}
-
-static void
-test_enable (CuTest *tc)
-{
- CK_FUNCTION_LIST_PTR_PTR modules;
-
- /*
- * The module three should not be present, as we don't match the current
- * program.
- */
-
- modules = initialize_and_get_modules (tc);
- CuAssertTrue (tc, lookup_module_with_name (tc, modules, "three") == NULL);
- finalize_and_free_modules (tc, modules);
-
- /*
- * The module three should be loaded here , because in its config
- * file we have:
- *
- * enable-in: test-enable
- */
-
- 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);
-
- p11_kit_set_progname (NULL);
-}
-
-int
-main (void)
-{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- _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_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;
-}
diff --git a/tests/uri-test.c b/tests/uri-test.c
deleted file mode 100644
index 4780e4e..0000000
--- a/tests/uri-test.c
+++ /dev/null
@@ -1,1221 +0,0 @@
-/*
- * Copyright (c) 2011, Collabora Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- * * The names of contributors to this software may not be
- * used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Author: Stef Walter <stefw@collabora.co.uk>
- */
-
-#include "config.h"
-#include "CuTest.h"
-
-#include <assert.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "p11-kit/uri.h"
-#include "p11-kit/private.h"
-
-static int
-is_module_empty (P11KitUri *uri)
-{
- CK_INFO_PTR info = p11_kit_uri_get_module_info (uri);
- return (info->libraryDescription[0] == 0 &&
- info->manufacturerID[0] == 0 &&
- info->libraryVersion.major == (CK_BYTE)-1 &&
- info->libraryVersion.minor == (CK_BYTE)-1);
-}
-
-static int
-is_token_empty (P11KitUri *uri)
-{
- CK_TOKEN_INFO_PTR token = p11_kit_uri_get_token_info (uri);
- return (token->serialNumber[0] == 0 &&
- token->manufacturerID[0] == 0 &&
- token->label[0] == 0 &&
- token->model[0] == 0);
-}
-
-static int
-are_attributes_empty (P11KitUri *uri)
-{
- return (p11_kit_uri_get_attribute (uri, CKA_LABEL) == NULL &&
- p11_kit_uri_get_attribute (uri, CKA_ID) == NULL &&
- p11_kit_uri_get_attribute (uri, CKA_CLASS) == NULL);
-}
-
-static void
-test_uri_parse (CuTest *tc)
-{
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("pkcs11:", P11_KIT_URI_FOR_MODULE, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
-
- CuAssertTrue (tc, is_module_empty (uri));
- CuAssertTrue (tc, is_token_empty (uri));
- CuAssertTrue (tc, are_attributes_empty (uri));
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_bad_scheme (CuTest *tc)
-{
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("http:\\example.com\test", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_SCHEME, ret);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_with_label (CuTest *tc)
-{
- CK_ATTRIBUTE_PTR attr;
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("pkcs11:object=Test%20Label", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
-
- CuAssertTrue (tc, is_module_empty (uri));
- CuAssertTrue (tc, 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);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_with_label_and_klass (CuTest *tc)
-{
- CK_ATTRIBUTE_PTR attr;
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, 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);
-
- 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);
-
- 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);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_with_id (CuTest *tc)
-{
- CK_ATTRIBUTE_PTR attr;
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, 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);
-
- /* 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);
-
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_with_bad_string_encoding (CuTest *tc)
-{
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("pkcs11:object=Test%", P11_KIT_URI_FOR_OBJECT, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_ENCODING, ret);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_with_bad_hex_encoding (CuTest *tc)
-{
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("pkcs11:object=T%xxest", P11_KIT_URI_FOR_OBJECT, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_ENCODING, ret);
-
- p11_kit_uri_free (uri);
-}
-
-static int
-is_space_string (CK_UTF8CHAR_PTR string, CK_ULONG size, const char *check)
-{
- size_t i, len = strlen (check);
- if (len > size)
- return 0;
- if (memcmp (string, check, len) != 0)
- return 0;
- for (i = len; i < size; ++i)
- if (string[i] != ' ')
- return 0;
- return 1;
-}
-
-static void
-test_uri_parse_with_token (CuTest *tc)
-{
- P11KitUri *uri = NULL;
- CK_TOKEN_INFO_PTR token;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, 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);
-
- 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"));
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_with_token_bad_encoding (CuTest *tc)
-{
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("pkcs11:token=Token%", P11_KIT_URI_FOR_TOKEN, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_ENCODING, ret);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_with_bad_syntax (CuTest *tc)
-{
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("pkcs11:token", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_SYNTAX, ret);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_with_spaces (CuTest *tc)
-{
- P11KitUri *uri = NULL;
- CK_INFO_PTR info;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, 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);
-
- 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"));
-
- p11_kit_uri_free (uri);
-}
-
-
-static void
-test_uri_parse_with_library (CuTest *tc)
-{
- P11KitUri *uri = NULL;
- CK_INFO_PTR info;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, 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);
-
- 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"));
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_with_library_bad_encoding (CuTest *tc)
-{
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("pkcs11:library-description=Library%", P11_KIT_URI_FOR_MODULE, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_BAD_ENCODING, ret);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_build_empty (CuTest *tc)
-{
- P11KitUri *uri;
- char *string;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
- CuAssertStrEquals (tc, "pkcs11:", string);
- free (string);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-set_space_string (CK_BYTE_PTR buffer, CK_ULONG length, const char *string)
-{
- size_t len = strlen (string);
- assert (len <= length);
- memset (buffer, ' ', length);
- memcpy (buffer, string, len);
-}
-
-static void
-test_uri_build_with_token_info (CuTest *tc)
-{
- char *string = NULL;
- P11KitUri *uri;
- P11KitUri *check;
- CK_TOKEN_INFO_PTR token;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- token = p11_kit_uri_get_token_info (uri);
- set_space_string (token->label, sizeof (token->label), "The Label");
- set_space_string (token->serialNumber, sizeof (token->serialNumber), "44444");
- set_space_string (token->manufacturerID, sizeof (token->manufacturerID), "Me");
- 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);
-
- check = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, check);
-
- ret = p11_kit_uri_parse (string, P11_KIT_URI_FOR_TOKEN, check);
- CuAssertIntEquals (tc, 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);
-
- free (string);
-}
-
-static void
-test_uri_build_with_token_null_info (CuTest *tc)
-{
- char *string = NULL;
- P11KitUri *uri;
- CK_TOKEN_INFO_PTR token;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, 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);
-
- CuAssertTrue (tc, strstr (string, "token=The%20Label") != NULL);
- CuAssertTrue (tc, strstr (string, "serial=") == NULL);
-
- free (string);
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_build_with_token_empty_info (CuTest *tc)
-{
- char *string = NULL;
- P11KitUri *uri;
- CK_TOKEN_INFO_PTR token;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, 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);
-
- CuAssertTrue (tc, strstr (string, "token=") != NULL);
- CuAssertTrue (tc, strstr (string, "serial=") != NULL);
-
- free (string);
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_build_with_attributes (CuTest *tc)
-{
- char *string = NULL;
- P11KitUri *uri;
- P11KitUri *check;
- CK_OBJECT_CLASS klass;
- CK_ATTRIBUTE_PTR attr;
- CK_ATTRIBUTE at;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- at.type = CKA_LABEL;
- at.pValue = "The Label";
- at.ulValueLen = 9;
- ret = p11_kit_uri_set_attribute (uri, &at);
-
- at.type = CKA_ID;
- at.pValue = "HELLO";
- at.ulValueLen = 5;
- ret = p11_kit_uri_set_attribute (uri, &at);
-
- klass = CKO_DATA;
- at.type = CKA_CLASS;
- at.pValue = &klass;
- at.ulValueLen = sizeof (klass);
- 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);
-
- check = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, check);
-
- ret = p11_kit_uri_parse (string, P11_KIT_URI_FOR_ANY, check);
- CuAssertIntEquals (tc, 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);
-
- 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);
-
- 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);
-
- 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);
-
- free (string);
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_private_key (CuTest *tc)
-{
- P11KitUri *uri;
- CK_ATTRIBUTE_PTR attr;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("pkcs11:object-type=private", P11_KIT_URI_FOR_OBJECT, uri);
- CuAssertIntEquals (tc, 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);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_secret_key (CuTest *tc)
-{
- P11KitUri *uri;
- CK_ATTRIBUTE_PTR attr;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("pkcs11:object-type=secret-key", P11_KIT_URI_FOR_OBJECT, uri);
- CuAssertIntEquals (tc, 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);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_library_version (CuTest *tc)
-{
- P11KitUri *uri;
- CK_INFO_PTR info;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, 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);
-
- info = p11_kit_uri_get_module_info (uri);
- CuAssertIntEquals (tc, 2, info->libraryVersion.major);
- CuAssertIntEquals (tc, 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);
-
- info = p11_kit_uri_get_module_info (uri);
- CuAssertIntEquals (tc, 23, info->libraryVersion.major);
- CuAssertIntEquals (tc, 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);
-
- 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);
-
- 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);
-
- 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);
-
- 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);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_parse_unknown_object_type (CuTest *tc)
-{
- P11KitUri *uri;
- CK_ATTRIBUTE_PTR attr;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("pkcs11:object-type=unknown", P11_KIT_URI_FOR_OBJECT, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
-
- attr = p11_kit_uri_get_attribute (uri, CKA_CLASS);
- CuAssertPtrEquals (tc, NULL, attr);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_unrecognized (CuTest *tc)
-{
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("pkcs11:x-blah=some-value", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
-
- ret = p11_kit_uri_any_unrecognized (uri);
- CuAssertIntEquals (tc, 1, ret);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_parse_too_long_is_unrecognized (CuTest *tc)
-{
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, 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);
-
- ret = p11_kit_uri_any_unrecognized (uri);
- CuAssertIntEquals (tc, 1, ret);
-
- p11_kit_uri_free (uri);
-}
-
-
-
-static void
-test_uri_build_object_type_cert (CuTest *tc)
-{
- CK_ATTRIBUTE attr;
- CK_OBJECT_CLASS klass;
- P11KitUri *uri;
- char *string;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- klass = CKO_CERTIFICATE;
- attr.type = CKA_CLASS;
- attr.pValue = &klass;
- attr.ulValueLen = sizeof (klass);
- 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);
-
- p11_kit_uri_free (uri);
- free (string);
-}
-
-static void
-test_uri_build_object_type_private (CuTest *tc)
-{
- CK_ATTRIBUTE attr;
- CK_OBJECT_CLASS klass;
- P11KitUri *uri;
- char *string;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- klass = CKO_PRIVATE_KEY;
- attr.type = CKA_CLASS;
- attr.pValue = &klass;
- attr.ulValueLen = sizeof (klass);
- 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);
-
- p11_kit_uri_free (uri);
- free (string);
-}
-
-static void
-test_uri_build_object_type_public (CuTest *tc)
-{
- CK_ATTRIBUTE attr;
- CK_OBJECT_CLASS klass;
- P11KitUri *uri;
- char *string;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- klass = CKO_PUBLIC_KEY;
- attr.type = CKA_CLASS;
- attr.pValue = &klass;
- attr.ulValueLen = sizeof (klass);
- 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);
-
- p11_kit_uri_free (uri);
- free (string);
-}
-
-static void
-test_uri_build_object_type_secret (CuTest *tc)
-{
- CK_ATTRIBUTE attr;
- CK_OBJECT_CLASS klass;
- P11KitUri *uri;
- char *string;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- klass = CKO_SECRET_KEY;
- attr.type = CKA_CLASS;
- attr.pValue = &klass;
- attr.ulValueLen = sizeof (klass);
- 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);
-
- p11_kit_uri_free (uri);
- free (string);
-}
-
-static void
-test_uri_build_with_library (CuTest *tc)
-{
- CK_INFO_PTR info;
- P11KitUri *uri;
- char *string;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, 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);
-
- p11_kit_uri_free (uri);
- free (string);
-}
-
-static void
-test_uri_build_library_version (CuTest *tc)
-{
- CK_INFO_PTR info;
- P11KitUri *uri;
- char *string;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, 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);
-
- p11_kit_uri_free (uri);
- free (string);
-}
-
-static void
-test_uri_get_set_unrecognized (CuTest *tc)
-{
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_any_unrecognized (uri);
- CuAssertIntEquals (tc, 0, ret);
-
- p11_kit_uri_set_unrecognized (uri, 1);
-
- ret = p11_kit_uri_any_unrecognized (uri);
- CuAssertIntEquals (tc, 1, ret);
-
- p11_kit_uri_set_unrecognized (uri, 0);
-
- ret = p11_kit_uri_any_unrecognized (uri);
- CuAssertIntEquals (tc, 0, ret);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_match_token (CuTest *tc)
-{
- CK_TOKEN_INFO token;
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("pkcs11:model=Giselle", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, 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);
-
- set_space_string (token.label, sizeof (token.label), "Another label");
-
- ret = p11_kit_uri_match_token_info (uri, &token);
- CuAssertIntEquals (tc, 1, ret);
-
- set_space_string (token.model, sizeof (token.model), "Zoolander");
-
- ret = p11_kit_uri_match_token_info (uri, &token);
- CuAssertIntEquals (tc, 0, ret);
-
- p11_kit_uri_set_unrecognized (uri, 1);
-
- ret = p11_kit_uri_match_token_info (uri, &token);
- CuAssertIntEquals (tc, 0, ret);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_match_module (CuTest *tc)
-{
- CK_INFO info;
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ret = p11_kit_uri_parse ("pkcs11:library-description=Quiet", P11_KIT_URI_FOR_ANY, uri);
- CuAssertIntEquals (tc, 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);
-
- set_space_string (info.manufacturerID, sizeof (info.manufacturerID), "Someone else");
-
- ret = p11_kit_uri_match_module_info (uri, &info);
- CuAssertIntEquals (tc, 1, ret);
-
- set_space_string (info.libraryDescription, sizeof (info.libraryDescription), "Leise");
-
- ret = p11_kit_uri_match_module_info (uri, &info);
- CuAssertIntEquals (tc, 0, ret);
-
- p11_kit_uri_set_unrecognized (uri, 1);
-
- ret = p11_kit_uri_match_module_info (uri, &info);
- CuAssertIntEquals (tc, 0, ret);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_match_attributes (CuTest *tc)
-{
- CK_ATTRIBUTE attrs[4];
- CK_OBJECT_CLASS klass;
- P11KitUri *uri;
- int ret;
-
- attrs[0].type = CKA_ID;
- attrs[0].pValue = "Blah";
- attrs[0].ulValueLen = 4;
-
- attrs[1].type = CKA_LABEL;
- attrs[1].pValue = "Junk";
- attrs[1].ulValueLen = 4;
-
- attrs[2].type = CKA_COLOR;
- attrs[2].pValue = "blue";
- attrs[2].ulValueLen = 4;
-
- klass = CKO_DATA;
- attrs[3].type = CKA_CLASS;
- attrs[3].pValue = &klass;
- attrs[3].ulValueLen = sizeof (klass);
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, 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);
-
- ret = p11_kit_uri_match_attributes (uri, attrs, 4);
- CuAssertIntEquals (tc, 0, ret);
-
- attrs[1].pValue = "Fancy";
- attrs[1].ulValueLen = 5;
-
- ret = p11_kit_uri_match_attributes (uri, attrs, 4);
- CuAssertIntEquals (tc, 1, ret);
-
- p11_kit_uri_clear_attribute (uri, CKA_CLASS);
-
- ret = p11_kit_uri_match_attributes (uri, attrs, 4);
- CuAssertIntEquals (tc, 1, ret);
-
- attrs[2].pValue = "pink";
-
- ret = p11_kit_uri_match_attributes (uri, attrs, 4);
- CuAssertIntEquals (tc, 1, ret);
-
- p11_kit_uri_set_unrecognized (uri, 1);
-
- ret = p11_kit_uri_match_attributes (uri, attrs, 4);
- CuAssertIntEquals (tc, 0, ret);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_get_set_attribute (CuTest *tc)
-{
- CK_ATTRIBUTE attr;
- CK_ATTRIBUTE_PTR ptr;
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- ptr = p11_kit_uri_get_attribute (uri, CKA_LABEL);
- CuAssertPtrEquals (tc, NULL, ptr);
-
- ret = p11_kit_uri_clear_attribute (uri, CKA_LABEL);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
-
- ret = p11_kit_uri_clear_attribute (uri, CKA_COLOR);
- CuAssertIntEquals (tc, 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);
-
- attr.type = CKA_COLOR;
- ret = p11_kit_uri_set_attribute (uri, &attr);
- CuAssertIntEquals (tc, P11_KIT_URI_NOT_FOUND, ret);
-
- ptr = p11_kit_uri_get_attribute (uri, CKA_COLOR);
- CuAssertPtrEquals (tc, NULL, ptr);
-
- ptr = p11_kit_uri_get_attribute (uri, CKA_LABEL);
- CuAssertPtrNotNull (tc, ptr);
-
- CuAssertTrue (tc, ptr->type == CKA_LABEL);
- CuAssertTrue (tc, ptr->ulValueLen == 4);
- CuAssertTrue (tc, memcmp (ptr->pValue, "Test", 4) == 0);
-
- ret = p11_kit_uri_clear_attribute (uri, CKA_LABEL);
- CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
-
- ptr = p11_kit_uri_get_attribute (uri, CKA_LABEL);
- CuAssertPtrEquals (tc, NULL, ptr);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_get_set_attributes (CuTest *tc)
-{
- CK_ATTRIBUTE_PTR attrs;
- CK_OBJECT_CLASS klass;
- CK_ATTRIBUTE attr;
- CK_ULONG n_attrs;
- P11KitUri *uri;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, uri);
-
- attrs = p11_kit_uri_get_attributes (uri, &n_attrs);
- CuAssertPtrNotNull (tc, attrs);
- CuAssertIntEquals (tc, 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);
-
- 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);
-
- 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);
-
- 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);
-
- klass = CKO_DATA;
- attr.type = CKA_CLASS;
- attr.pValue = &klass;
- attr.ulValueLen = sizeof (klass);
-
- ret = p11_kit_uri_set_attribute (uri, &attr);
- CuAssertIntEquals (tc, 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);
-
- ret = p11_kit_uri_clear_attribute (uri, CKA_LABEL);
- CuAssertIntEquals (tc, 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);
-
- 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);
-
- 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);
-
- p11_kit_uri_clear_attributes (uri);
-
- attrs = p11_kit_uri_get_attributes (uri, &n_attrs);
- CuAssertPtrNotNull (tc, attrs);
- CuAssertIntEquals (tc, 0, n_attrs);
-
- p11_kit_uri_free (uri);
-}
-static void
-test_uri_pin_source (CuTest *tc)
-{
- P11KitUri *uri;
- const char *pin_source;
- char *string;
- int ret;
-
- uri = p11_kit_uri_new ();
- CuAssertPtrNotNull (tc, 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);
-
- pin_source = p11_kit_uri_get_pinfile (uri);
- CuAssertStrEquals (tc, "|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);
-
- 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);
- 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);
-
- pin_source = p11_kit_uri_get_pin_source (uri);
- CuAssertStrEquals (tc, "blah/blah", pin_source);
-
- p11_kit_uri_free (uri);
-}
-
-static void
-test_uri_free_null (CuTest *tc)
-{
- p11_kit_uri_free (NULL);
-}
-
-static void
-test_uri_message (CuTest *tc)
-{
- 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));
-}
-
-int
-main (void)
-{
- CuString *output = CuStringNew ();
- CuSuite* suite = CuSuiteNew ();
- int ret;
-
- _p11_library_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_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;
-}