Branch data Line data Source code
1 : : // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
2 : : /* Copyright 2019 IBM Corp. */
3 : : #include "secvar_common_test.c"
4 : :
5 : : // Hack to include the code we actually want to test here...
6 : : #include "../secvar_api.c"
7 : : #include "../secvar_util.c"
8 : :
9 : : // Stuff from secvar_main that we need, but not enough to
10 : : // include that file
11 : : int secvar_enabled = 0;
12 : : int secvar_ready = 0;
13 : :
14 : :
15 : : /**** Helper wrappers, so the caller doesn't have to cast ****/
16 : :
17 : 10 : static int64_t secvar_get(const char *k_key, uint64_t k_key_len, void *k_data, uint64_t *k_data_size)
18 : : {
19 : 10 : return opal_secvar_get( k_key,
20 : : k_key_len,
21 : : k_data,
22 : : k_data_size);
23 : : }
24 : :
25 : 13 : static int64_t secvar_get_next(char *k_key, uint64_t *k_key_len, uint64_t k_key_size)
26 : : {
27 : :
28 : 13 : return opal_secvar_get_next( k_key,
29 : : k_key_len,
30 : : k_key_size);
31 : : }
32 : :
33 : :
34 : :
35 : 16 : static int64_t secvar_enqueue(const char *k_key, uint64_t k_key_len, void *k_data, uint64_t k_data_size)
36 : : {
37 : 16 : return opal_secvar_enqueue_update(k_key,
38 : : k_key_len,
39 : : k_data,
40 : : k_data_size);
41 : :
42 : : }
43 : :
44 : :
45 : :
46 : : // Entry point
47 : : // TODO: do some real argparsing
48 : 4 : int main(int argc, char **argv)
49 : : {
50 : : int ret;
51 : :
52 : : (void) secvar_get;
53 : : (void) secvar_get_next;
54 : : (void) secvar_enqueue;
55 : : (void) argc;
56 : : (void) argv;
57 : :
58 : 4 : secvar_enabled = 1;
59 : :
60 : 4 : list_head_init(&variable_bank);
61 : 4 : list_head_init(&update_bank);
62 : :
63 : 4 : secvar_ready = 1;
64 : :
65 : 4 : printf("Running test '%s'...", secvar_test_name);
66 : 4 : ret = run_test();
67 : 4 : if (ret)
68 : 0 : printf(COLOR_RED "FAILED" COLOR_RESET "\n");
69 : : else
70 : 4 : printf(COLOR_GREEN "OK" COLOR_RESET "\n");
71 : :
72 : : // Clean up for the test cases
73 : 4 : clear_bank_list(&variable_bank);
74 : 4 : clear_bank_list(&update_bank);
75 : :
76 : 4 : return ret;
77 : : }
78 : :
|