aboutsummaryrefslogtreecommitdiff
path: root/libstb/secvar
diff options
context:
space:
mode:
authorEric Richter <erichte@linux.vnet.ibm.com>2020-09-16 11:21:19 -0500
committerOliver O'Halloran <oohall@gmail.com>2020-10-01 13:44:06 +1000
commit84a430a4f57f028ab223292576e49d4c07effb8d (patch)
tree8d7f0ce3d43702ae29ef24f63a48f3bd6c964cbd /libstb/secvar
parent262f5e883eff64486c627c82fab08887e382f615 (diff)
downloadskiboot-84a430a4f57f028ab223292576e49d4c07effb8d.zip
skiboot-84a430a4f57f028ab223292576e49d4c07effb8d.tar.gz
skiboot-84a430a4f57f028ab223292576e49d4c07effb8d.tar.bz2
secvar/test: update API tests for new secvar struct
This patch adjusts the API unit tests to use the secvar struct rather than the old secvar_node. Where applicable, some manual allocations have also been replaced with the util functions. Signed-off-by: Eric Richter <erichte@linux.ibm.com> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Diffstat (limited to 'libstb/secvar')
-rw-r--r--libstb/secvar/test/secvar-test-enqueue.c6
-rw-r--r--libstb/secvar/test/secvar-test-getvar.c21
-rw-r--r--libstb/secvar/test/secvar-test-nextvar.c26
3 files changed, 14 insertions, 39 deletions
diff --git a/libstb/secvar/test/secvar-test-enqueue.c b/libstb/secvar/test/secvar-test-enqueue.c
index 61c22d1..b4b2c14 100644
--- a/libstb/secvar/test/secvar-test-enqueue.c
+++ b/libstb/secvar/test/secvar-test-enqueue.c
@@ -16,7 +16,7 @@ int run_test(void)
{
int64_t rc;
- struct secvar_node *node;
+ struct secvar *var;
char key[1024] = {0};
uint64_t data_size = 128;
@@ -106,8 +106,8 @@ int run_test(void)
rc = secvar_enqueue(key, 4, data, data_size);
ASSERT(rc == OPAL_SUCCESS);
ASSERT(list_length(&update_bank) == 3); // should not increase
- node = list_tail(&update_bank, struct secvar_node, link);
- ASSERT(!memcmp(node->var->key, key, 4)) // should be at end
+ var = list_tail(&update_bank, struct secvar, link);
+ ASSERT(!memcmp(var->key, key, 4)) // should be at end
// Unstage the variable update
rc = secvar_enqueue(key, 4, NULL, 0);
diff --git a/libstb/secvar/test/secvar-test-getvar.c b/libstb/secvar/test/secvar-test-getvar.c
index 53885ea..a2e0668 100644
--- a/libstb/secvar/test/secvar-test-getvar.c
+++ b/libstb/secvar/test/secvar-test-getvar.c
@@ -14,32 +14,25 @@ int run_test(void)
{
int64_t rc;
- uint64_t size = 4;
+ uint64_t size;
char *temp = zalloc(100);
char key[1024] = {0};
- struct secvar_node *node = zalloc(sizeof(struct secvar_node));
- struct secvar *var = zalloc(sizeof(struct secvar) + 1024); // over-allocate for now, this should be rewritten
+ struct secvar *var;
size_t data_size = sizeof("foobar");
char *data = zalloc(data_size);
uint64_t key_len = 4;
memcpy(data, "foobar", data_size);
-
memcpy(key, "test", 4);
// List should be empty at start
- rc = secvar_get(key, key_len, data, &data_size);
+ rc = secvar_get(key, key_len, temp, &size);
ASSERT(rc == OPAL_EMPTY);
ASSERT(list_length(&variable_bank) == 0);
// Manually add variables, and check get_variable call
- var->key_len = key_len;
- memcpy(var->key, key, key_len);
- var->data_size = data_size;
- memcpy(var->data, data, data_size);
-
- node->var = var;
- list_add_tail(&variable_bank, &node->link);
+ var = new_secvar(key, key_len, data, data_size, 0);
+ list_add_tail(&variable_bank, &var->link);
ASSERT(list_length(&variable_bank) == 1);
@@ -88,10 +81,6 @@ int run_test(void)
ASSERT(rc == OPAL_RESOURCE);
secvar_ready = 1;
- list_del(&node->link);
-
- free(var);
- free(node);
free(data);
free(temp);
diff --git a/libstb/secvar/test/secvar-test-nextvar.c b/libstb/secvar/test/secvar-test-nextvar.c
index 0b3dea4..dcd9e9d 100644
--- a/libstb/secvar/test/secvar-test-nextvar.c
+++ b/libstb/secvar/test/secvar-test-nextvar.c
@@ -10,37 +10,23 @@ int run_test(void)
int64_t rc;
struct secvar *tmpvar;
- struct secvar_node *tmpnode;
char key[1024] = {0};
uint64_t key_len = 16;
-
// Load up the bank with some variables.
// If these fail, we have bigger issues.
ASSERT(list_length(&variable_bank) == 0);
- tmpvar = zalloc(sizeof(struct secvar) + 6);
- tmpnode = zalloc(sizeof(struct secvar_node));
- memcpy(tmpvar->key, "test1", 6); // ascii w/ null
- tmpvar->key_len = 6;
- tmpnode->var = tmpvar;
- list_add_tail(&variable_bank, &tmpnode->link);
+ tmpvar = new_secvar("test1", 6, NULL, 0, 0);
+ list_add_tail(&variable_bank, &tmpvar->link);
ASSERT(list_length(&variable_bank) == 1);
- tmpvar = zalloc(sizeof(struct secvar) + 5);
- tmpnode = zalloc(sizeof(struct secvar_node));
- memcpy(tmpvar->key, "test2", 5); // ascii w/o null
- tmpvar->key_len = 5;
- tmpnode->var = tmpvar;
- list_add_tail(&variable_bank, &tmpnode->link);
+ tmpvar = new_secvar("test2", 5, NULL, 0, 0); // ascii w/o null
+ list_add_tail(&variable_bank, &tmpvar->link);
ASSERT(list_length(&variable_bank) == 2);
- tmpvar = zalloc(sizeof(struct secvar) + 5*2);
- tmpnode = zalloc(sizeof(struct secvar_node));
- memcpy(tmpvar->key, L"test3", 5*2); // wide char "unicode"
- tmpvar->key_len = 10;
- tmpnode->var = tmpvar;
- list_add_tail(&variable_bank, &tmpnode->link);
+ tmpvar = new_secvar((const char*) L"test3", 5*2, NULL, 0, 0); // wide char "unicode"
+ list_add_tail(&variable_bank, &tmpvar->link);
ASSERT(list_length(&variable_bank) == 3);
// Test sequential nexts