summaryrefslogtreecommitdiff
path: root/src/p11-tests-lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/p11-tests-lib.c')
-rw-r--r--src/p11-tests-lib.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/p11-tests-lib.c b/src/p11-tests-lib.c
new file mode 100644
index 0000000..4e51a12
--- /dev/null
+++ b/src/p11-tests-lib.c
@@ -0,0 +1,94 @@
+
+
+#include "p11-tests.h"
+#include "p11-tests-lib.h"
+#include "compat.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <openssl/err.h>
+#include <openssl/evp.h>
+
+int p11t_test_unexpected = 1;
+int p11t_test_write_session = 0;
+
+int
+p11_tests_get_unexpected (void)
+{
+ return p11t_test_unexpected = 1;
+}
+
+void
+p11_tests_set_unexpected (int value)
+{
+ p11t_test_unexpected = value ? 1 : 0;
+}
+
+int
+p11_tests_get_write_session (void)
+{
+ return p11t_test_write_session;
+}
+
+void
+p11_tests_set_write_session (int value)
+{
+ p11t_test_write_session = value ? 1 : 0;
+}
+
+int
+p11_tests_get_verbose (void)
+{
+ return p11t_check_verbose;
+}
+
+void
+p11_tests_set_verbose (int value)
+{
+ p11t_check_verbose = value ? 1 : 0;
+}
+
+int
+p11_tests_load_config (const char *config)
+{
+ return p11t_config_parse (config);
+}
+
+P11TestsLogFunc
+p11_tests_get_log_func (void)
+{
+ return p11t_log_func;
+}
+
+void
+p11_tests_set_log_func (P11TestsLogFunc func)
+{
+ p11t_log_func = func;
+}
+
+void
+p11_tests_perform (CK_FUNCTION_LIST_PTR module)
+{
+ ERR_load_crypto_strings();
+ OpenSSL_add_all_digests();
+
+ /* Basic module tests */
+ p11t_module_funcs = module;
+ if (p11t_module_initialize () != CONTINUE)
+ return;
+
+ p11t_slot_tests();
+ p11t_session_tests();
+ p11t_object_tests();
+ p11t_key_tests();
+ p11t_certificate_tests();
+ p11t_rsa_tests();
+ p11t_dsa_tests();
+
+ /* Remaining module tests */
+ p11t_module_finalize();
+
+ p11t_slot_cleanup();
+ p11t_config_cleanup();
+}