summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-07-06 01:32:55 +0300
committerSimon Glass <sjg@chromium.org>2021-07-21 19:27:34 +0300
commit1f618d528e234d2b7b0047750284dd531f5d718f (patch)
tree7c07e13de91bfa3e6d6d418f5dda739ef401e1b3 /test
parentfaff554292824037c4f098020ddbc8d979900415 (diff)
downloadu-boot-1f618d528e234d2b7b0047750284dd531f5d718f.tar.xz
bloblist: Correct condition in bloblist_addrec()
It is possible to add a blob that ends at the end of the bloblist, but at present this is not supported. Fix it and add a regression test for this case. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/bloblist.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/bloblist.c b/test/bloblist.c
index 345eb181ff..4104e6a92f 100644
--- a/test/bloblist.c
+++ b/test/bloblist.c
@@ -576,6 +576,29 @@ static int bloblist_test_resize_last(struct unit_test_state *uts)
}
BLOBLIST_TEST(bloblist_test_resize_last, 0);
+/* Check a completely full bloblist */
+static int bloblist_test_blob_maxsize(struct unit_test_state *uts)
+{
+ void *ptr;
+ int size;
+
+ /* At the start there should be no records */
+ clear_bloblist();
+ ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0));
+
+ /* Add a blob that takes up all space */
+ size = TEST_BLOBLIST_SIZE - sizeof(struct bloblist_hdr) -
+ sizeof(struct bloblist_rec);
+ ptr = bloblist_add(TEST_TAG, size, 0);
+ ut_assertnonnull(ptr);
+
+ ptr = bloblist_add(TEST_TAG, size + 1, 0);
+ ut_assertnull(ptr);
+
+ return 0;
+}
+BLOBLIST_TEST(bloblist_test_blob_maxsize, 0);
+
int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{