diff options
author | Stef Walter <stef@memberwebs.com> | 2009-11-15 20:26:16 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2009-11-15 20:30:45 +0000 |
commit | 363a869b000ee1c9337bc0086108f6a5960da326 (patch) | |
tree | 04b9d0575a5bab921699d76a8d1c9b2640d779a8 /src/p11-tests-lib.c | |
parent | 6c610fd305c965e7ab83d3ffc0ab0e94733f01e6 (diff) |
Allow use of p11-tests as a library.
Diffstat (limited to 'src/p11-tests-lib.c')
-rw-r--r-- | src/p11-tests-lib.c | 94 |
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(); +} |