Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / lib / libtcplay / tcplay_api_test.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <assert.h>
5
6 #include "tcplay_api.h"
7
8 int
9 main(void)
10 {
11         tc_api_opts api_opts;
12         int error;
13
14         error = tc_api_init(/* verbose */1);
15         assert(error == 0);
16
17         memset(&api_opts, 0, sizeof(api_opts));
18         api_opts.tc_device = "/dev/vn1s0";
19         api_opts.tc_passphrase = "apitest2";
20         api_opts.tc_keyfiles = NULL;
21         api_opts.tc_keyfiles_hidden = NULL;
22         api_opts.tc_size_hidden_in_bytes = 12000*512;
23         api_opts.tc_passphrase_hidden = "apihidden";
24         api_opts.tc_cipher = "AES-256-XTS,TWOFISH-256-XTS,SERPENT-256-XTS";
25         api_opts.tc_cipher_hidden = "SERPENT-256-XTS,TWOFISH-256-XTS";
26         api_opts.tc_prf_hash = "whirlpool";
27         api_opts.tc_prf_hash_hidden = "RIPEMD160";
28
29         error = tc_api_create_volume(&api_opts);
30         if (error)
31                 printf("API ERROR: %s\n", tc_api_get_error_msg());
32         assert(error == 0);
33
34         error = tc_api_uninit();
35         assert(error == 0);
36
37         error = tc_api_init(/*verbose */ 1);
38         assert(error == 0);
39
40         api_opts.tc_passphrase = NULL;
41         api_opts.tc_map_name = "dragonfly-test";
42         api_opts.tc_password_retries = 5;
43         api_opts.tc_interactive_prompt = 1;
44         api_opts.tc_prompt_timeout = 5;
45         error = tc_api_map_volume(&api_opts);
46         if (error)
47                 printf("API MAP ERROR: %s\n", tc_api_get_error_msg());
48         assert(error == 0);
49
50         system("dmsetup ls");
51         tc_api_unmap_volume(&api_opts);
52
53         error = tc_api_uninit();
54         assert(error == 0);
55
56         return 0;
57 }
58