From 363a869b000ee1c9337bc0086108f6a5960da326 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sun, 15 Nov 2009 20:26:16 +0000 Subject: Allow use of p11-tests as a library. --- src/p11-tests-lib.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/p11-tests-lib.c (limited to 'src/p11-tests-lib.c') 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 +#include + +#include +#include + +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(); +} -- cgit v1.2.3