summaryrefslogtreecommitdiff
path: root/src/p11-tests-lib.c
blob: 4e51a12f12478a5d284f618ecc75502b866922db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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();
}