aboutsummaryrefslogtreecommitdiff
path: root/libstb/secvar/test/secvar_api_test.c
blob: 8beb1b635d7ae7254d97fa42e11fdbb59c1b443e (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
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
/* Copyright 2019 IBM Corp. */
#include "secvar_common_test.c"

// Hack to include the code we actually want to test here...
#include "../secvar_api.c"
#include "../secvar_util.c"

// Stuff from secvar_main that we need, but not enough to
// include that file
int secvar_enabled = 0;
int secvar_ready = 0;


/**** Helper wrappers, so the caller doesn't have to cast ****/

static int64_t secvar_get(const char *k_key, uint64_t k_key_len, void *k_data, uint64_t *k_data_size)
{
	return opal_secvar_get( k_key,
				 k_key_len,
				 k_data,
				 k_data_size);
}

static int64_t secvar_get_next(char *k_key, uint64_t *k_key_len, uint64_t k_key_size)
{

	return opal_secvar_get_next( k_key,
					k_key_len,
					k_key_size);
}



static int64_t secvar_enqueue(const char *k_key, uint64_t k_key_len, void *k_data, uint64_t k_data_size)
{
	return opal_secvar_enqueue_update(k_key,
				k_key_len,
				k_data,
				k_data_size);

}



// Entry point
// TODO: do some real argparsing
int main(int argc, char **argv)
{
	int ret;

	(void) secvar_get;
	(void) secvar_get_next;
	(void) secvar_enqueue;
	(void) argc;
	(void) argv;

        secvar_enabled = 1;

        list_head_init(&variable_bank);
        list_head_init(&update_bank);

	secvar_ready = 1;

	printf("Running test '%s'...", secvar_test_name);
	ret = run_test();
	if (ret)
		printf(COLOR_RED "FAILED" COLOR_RESET "\n");
	else
		printf(COLOR_GREEN "OK" COLOR_RESET "\n");

	// Clean up for the test cases
	clear_bank_list(&variable_bank);
	clear_bank_list(&update_bank);

	return ret;
}