summaryrefslogtreecommitdiff
path: root/test/common/bloblist.c
diff options
context:
space:
mode:
authorRaymond Mao <raymond.mao@linaro.org>2025-01-27 06:49:34 -0800
committerIlias Apalodimas <ilias.apalodimas@linaro.org>2025-01-28 08:59:21 +0200
commitbb894c5da5151e0858e217407c0cdeb989725a4a (patch)
tree6910b8f99af21e99e812a1dfe50272e5c0bacba9 /test/common/bloblist.c
parentb8eaa52612bf34164e7f495a094a5a419903a3ed (diff)
bloblist: add api to get blob with size
bloblist_find function only returns the pointer of blob data, which is fine for those self-describing data like FDT. But as a common scenario, an interface is needed to retrieve both the pointer and the size of the blob data. Add a few ut test cases for the new api. Signed-off-by: Raymond Mao <raymond.mao@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'test/common/bloblist.c')
-rw-r--r--test/common/bloblist.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/common/bloblist.c b/test/common/bloblist.c
index 9467abfa8e1..ab8f41c6808 100644
--- a/test/common/bloblist.c
+++ b/test/common/bloblist.c
@@ -98,10 +98,12 @@ static int bloblist_test_blob(struct unit_test_state *uts)
struct bloblist_hdr *hdr;
struct bloblist_rec *rec, *rec2;
char *data;
+ int size = 0;
/* At the start there should be no records */
hdr = clear_bloblist();
ut_assertnull(bloblist_find(TEST_TAG, TEST_BLOBLIST_SIZE));
+ ut_assertnull(bloblist_get_blob(TEST_TAG, &size));
ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0));
ut_asserteq(sizeof(struct bloblist_hdr), bloblist_get_size());
ut_asserteq(TEST_BLOBLIST_SIZE, bloblist_get_total_size());
@@ -114,6 +116,8 @@ static int bloblist_test_blob(struct unit_test_state *uts)
ut_asserteq_addr(rec + 1, data);
data = bloblist_find(TEST_TAG, TEST_SIZE);
ut_asserteq_addr(rec + 1, data);
+ ut_asserteq_addr(bloblist_get_blob(TEST_TAG, &size), data);
+ ut_asserteq(size, TEST_SIZE);
/* Check the data is zeroed */
ut_assertok(check_zero(data, TEST_SIZE));