diff options
author | Simon Glass <sjg@chromium.org> | 2025-01-10 17:00:03 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2025-01-22 15:58:03 -0600 |
commit | 7ba7c1dd86cf212c7d489dbf0a07301d1a3b4d2c (patch) | |
tree | 3a642d4e47b8d0439248966cfa1eb981133c872a /test/lib/abuf.c | |
parent | d887432807af8bdc943e7c8caa2a528dc516f6b3 (diff) |
abuf: Provide a constant buffer
Add a new initialiser which can accept a constant pointer.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/lib/abuf.c')
-rw-r--r-- | test/lib/abuf.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/lib/abuf.c b/test/lib/abuf.c index 5d61f9261c6..b38690fe1a9 100644 --- a/test/lib/abuf.c +++ b/test/lib/abuf.c @@ -46,6 +46,28 @@ static int lib_test_abuf_set(struct unit_test_state *uts) } LIB_TEST(lib_test_abuf_set, 0); +/* Test abuf_init_const() */ +static int lib_test_abuf_init_const(struct unit_test_state *uts) +{ + struct abuf buf; + ulong start; + void *ptr; + + start = ut_check_free(); + + ptr = map_sysmem(0x100, 0); + + abuf_init_const(&buf, ptr, 10); + ut_asserteq_ptr(ptr, buf.data); + ut_asserteq(10, buf.size); + + /* No memory should have been allocated */ + ut_assertok(ut_check_delta(start)); + + return 0; +} +LIB_TEST(lib_test_abuf_init_const, 0); + /* Test abuf_map_sysmem() and abuf_addr() */ static int lib_test_abuf_map_sysmem(struct unit_test_state *uts) { |