diff mbox series

[RFC,24/31] test: lmb: add a test case for checking overlapping region add

Message ID 20240607185240.1892031-25-sughosh.ganu@linaro.org
State New
Headers show
Series Make U-Boot memory reservations coherent | expand

Commit Message

Sughosh Ganu June 7, 2024, 6:52 p.m. UTC
Memory managed by LMB is now persistent and global. With that, it
could be possible for multiple callers to try to add memory that has
already been added. Add a test case to check that the LMB module
handles it as expected.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
 test/lib/lmb.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/test/lib/lmb.c b/test/lib/lmb.c
index 260ebcfcd3..9b0e023b67 100644
--- a/test/lib/lmb.c
+++ b/test/lib/lmb.c
@@ -419,6 +419,22 @@  static int lib_test_lmb_at_0(struct unit_test_state *uts)
 }
 LIB_TEST(lib_test_lmb_at_0, 0);
 
+static int lib_test_lmb_overlapping_add(struct unit_test_state *uts)
+{
+	const phys_addr_t ram = 0x40000000;
+	const phys_size_t ram_size = 0x20000000;
+	long ret;
+
+	ret = lmb_add(ram, ram_size);
+	ut_asserteq(ret, 0);
+
+	ret = lmb_add(ram, ram_size);
+	ut_asserteq(ret, 0);
+
+	return 0;
+}
+LIB_TEST(lib_test_lmb_overlapping_add, 0);
+
 /* Check that calling lmb_reserve with overlapping regions fails. */
 static int lib_test_lmb_overlapping_reserve(struct unit_test_state *uts)
 {