summaryrefslogtreecommitdiff
path: root/test/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-08-14 16:40:22 -0600
committerTom Rini <trini@konsulko.com>2023-08-25 13:54:33 -0400
commit34ecba1f7616b388ee28490e8a3ed43fb1463011 (patch)
treed2c174f76f0afe9055d7e03daefac4b810407424 /test/lib
parent633b3dc75536a7a878126c41babc248c095b66fe (diff)
downloadu-boot-34ecba1f7616b388ee28490e8a3ed43fb1463011.tar.gz
u-boot-34ecba1f7616b388ee28490e8a3ed43fb1463011.tar.bz2
u-boot-34ecba1f7616b388ee28490e8a3ed43fb1463011.zip
abuf: Allow incrementing the size
Provide a convenience function to increment the size of the abuf. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/abuf.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/lib/abuf.c b/test/lib/abuf.c
index 42ee4c1755..42803b20e2 100644
--- a/test/lib/abuf.c
+++ b/test/lib/abuf.c
@@ -155,6 +155,31 @@ static int lib_test_abuf_realloc_size(struct unit_test_state *uts)
}
LIB_TEST(lib_test_abuf_realloc_size, 0);
+/* Test abuf_realloc_inc() */
+static int lib_test_abuf_realloc_inc(struct unit_test_state *uts)
+{
+ struct abuf buf;
+ ulong start;
+
+ start = ut_check_free();
+
+ abuf_init(&buf);
+ ut_asserteq(0, buf.size);
+ ut_asserteq(false, buf.alloced);
+
+ abuf_realloc_inc(&buf, 20);
+ ut_asserteq(20, buf.size);
+ ut_asserteq(true, buf.alloced);
+
+ abuf_uninit(&buf);
+
+ /* Check for memory leaks */
+ ut_assertok(ut_check_delta(start));
+
+ return 0;
+}
+LIB_TEST(lib_test_abuf_realloc_inc, 0);
+
/* Test handling of buffers that are too large */
static int lib_test_abuf_large(struct unit_test_state *uts)
{