summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-01-12 19:26:16 -0700
committerSimon Glass <sjg@chromium.org>2022-01-13 09:13:41 -0700
commitff3bd4983c1fe53975e44668619b07e10f8a0cd9 (patch)
treef3f4baf4202b775466e556061cbe0700978b0a21 /test
parentf350f67764fe2c18b92da38eec75be359fc825ec (diff)
bloblist: Put the magic number first
It seems best to put the magic number right at the start of the bloblist header, so it is easier to check. This is how devicetree works. Make this change now, before other projects make use of bloblist. Other changes may be needed / discussed, but that is TBD. Add a checker function as well. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/bloblist.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/bloblist.c b/test/bloblist.c
index b48be38dc3..525e94b721 100644
--- a/test/bloblist.c
+++ b/test/bloblist.c
@@ -71,7 +71,9 @@ static int bloblist_test_init(struct unit_test_state *uts)
hdr = clear_bloblist();
ut_asserteq(-ENOENT, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
+ ut_asserteq_ptr(NULL, bloblist_check_magic(TEST_ADDR));
ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0));
+ ut_asserteq_ptr(hdr, bloblist_check_magic(TEST_ADDR));
hdr->version++;
ut_asserteq(-EPROTONOSUPPORT, bloblist_check(TEST_ADDR,
TEST_BLOBLIST_SIZE));
@@ -83,6 +85,11 @@ static int bloblist_test_init(struct unit_test_state *uts)
ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
ut_assertok(bloblist_finish());
ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
+
+ hdr->magic++;
+ ut_asserteq_ptr(NULL, bloblist_check_magic(TEST_ADDR));
+ hdr->magic--;
+
hdr->flags++;
ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));