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


#include "p11-tests.h"

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

int p11t_test_unexpected = 1;

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

int
main(int argc, char* argv[])
{
	const char *config = NULL;
	int ch;

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

	argc -= optind;
	argv += optind;

	if(argc != 1)
		usage();

	if(config)
		p11t_config_parse(config);

	/* Basic module tests */
	p11t_module_load(argv[0]);
	p11t_module_initialize();

	p11t_slot_tests();
	p11t_session_tests();

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

	p11t_config_cleanup();

	return 0;
}