summaryrefslogtreecommitdiff
path: root/src/p11-tests.c
blob: a77cceaef6297766bb55af07959ee18d04d0ce40 (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


#include "p11-tests.h"

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

static void
usage()
{
	fprintf(stderr, "usage: p11-tests module [init_string]\n");
	exit(2);
}

int
main(int argc, char* argv[])
{
	int ch;

	while((ch = getopt(argc, argv, "")) != -1)
	{
		switch(ch)
		{
		case '?':
		default:
			usage();
			break;
		}
	}

	argc -= optind;
	argv += optind;

	if(argc < 1 || argc > 2)
		usage();

	/* Basic module tests */
	p11t_module_load(argv[0]);
	p11t_module_initialize(argc == 2 ? argv[1] : NULL);

	p11t_slot_tests();
	p11t_session_tests();

	/* Remaining module tests */
	p11t_module_finalize();
	p11t_module_unload();

	return 0;
}