[PATCH] test: lmb: fix the lmb_alloc_addr() based test cases
Sughosh Ganu
sughosh.ganu at linaro.org
Wed Mar 26 17:53:36 CET 2025
Commit 56f186a68b3 ("lmb: check if a region can be reserved by
lmb_reserve()") fixed the lmb_reserve() and lmb_alloc_addr() API's for
some corner case scenarios, and also added corresonding test cases for
these corner cases. These tests were checking, among other things, the
lmb_alloc_addr() API. The above commit was applied to the next branch.
Subsequently, there was commit 67be24906fe
("lmb: change the return code on lmb_alloc_addr()") which was first
applied on the master branch, and subsequently got merged to next as
part of the rebase. The second commit changes the return value of the
lmb_alloc_addr() API, which now results in some of the tests added as
part of the first commit to fail. Fix those test cases.
Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
---
Note: To be applied on next
test/lib/lmb.c | 50 +++++++++++++++++++++++++-------------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/test/lib/lmb.c b/test/lib/lmb.c
index ad916740d90..3bf558f7f4f 100644
--- a/test/lib/lmb.c
+++ b/test/lib/lmb.c
@@ -591,21 +591,21 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
* region 2. Should fail.
*/
a = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NONE);
- ut_asserteq(a, alloc_addr_a);
+ ut_asserteq(a, 0);
b = lmb_alloc_addr(alloc_addr_a + 0x4000, 0x1000, LMB_NOOVERWRITE);
- ut_asserteq(b, alloc_addr_a + 0x4000);
- ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, a, 0x1000,
- b, 0x1000, 0, 0);
+ ut_asserteq(b, 0);
+ ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, alloc_addr_a, 0x1000,
+ alloc_addr_a + 0x4000, 0x1000, 0, 0);
c = lmb_alloc_addr(alloc_addr_a + 0x1000, 0x5000, LMB_NONE);
- ut_asserteq(c, 0);
- ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, a, 0x1000,
- b, 0x1000, 0, 0);
+ ut_asserteq(c, -1);
+ ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, alloc_addr_a, 0x1000,
+ alloc_addr_a + 0x4000, 0x1000, 0, 0);
- ret = lmb_free(a, 0x1000);
+ ret = lmb_free(alloc_addr_a, 0x1000);
ut_asserteq(ret, 0);
- ret = lmb_free(b, 0x1000);
+ ret = lmb_free(alloc_addr_a + 0x4000, 0x1000);
ut_asserteq(ret, 0);
/*
@@ -616,19 +616,19 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
* single region.
*/
a = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NONE);
- ut_asserteq(a, alloc_addr_a);
+ ut_asserteq(a, 0);
b = lmb_alloc_addr(alloc_addr_a + 0x4000, 0x1000, LMB_NONE);
- ut_asserteq(b, alloc_addr_a + 0x4000);
- ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, a, 0x1000,
- b, 0x1000, 0, 0);
+ ut_asserteq(b, 0);
+ ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, alloc_addr_a, 0x1000,
+ alloc_addr_a + 0x4000, 0x1000, 0, 0);
c = lmb_alloc_addr(alloc_addr_a + 0x1000, 0x5000, LMB_NONE);
- ut_asserteq(c, alloc_addr_a + 0x1000);
- ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, a, 0x6000,
+ ut_asserteq(c, 0);
+ ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1, alloc_addr_a, 0x6000,
0, 0, 0, 0);
- ret = lmb_free(a, 0x6000);
+ ret = lmb_free(alloc_addr_a, 0x6000);
ut_asserteq(ret, 0);
/*
@@ -638,21 +638,21 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
* region 2. Should fail.
*/
a = lmb_alloc_addr(alloc_addr_a, 0x1000, LMB_NOOVERWRITE);
- ut_asserteq(a, alloc_addr_a);
+ ut_asserteq(a, 0);
b = lmb_alloc_addr(alloc_addr_a + 0x4000, 0x1000, LMB_NOOVERWRITE);
- ut_asserteq(b, alloc_addr_a + 0x4000);
- ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, a, 0x1000,
- b, 0x1000, 0, 0);
+ ut_asserteq(b, 0);
+ ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, alloc_addr_a, 0x1000,
+ alloc_addr_a + 0x4000, 0x1000, 0, 0);
c = lmb_alloc_addr(alloc_addr_a + 0x1000, 0x5000, LMB_NOOVERWRITE);
- ut_asserteq(c, 0);
- ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, a, 0x1000,
- b, 0x1000, 0, 0);
+ ut_asserteq(c, -1);
+ ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 2, alloc_addr_a, 0x1000,
+ alloc_addr_a + 0x4000, 0x1000, 0, 0);
- ret = lmb_free(a, 0x1000);
+ ret = lmb_free(alloc_addr_a, 0x1000);
ut_asserteq(ret, 0);
- ret = lmb_free(b, 0x1000);
+ ret = lmb_free(alloc_addr_a + 0x4000, 0x1000);
ut_asserteq(ret, 0);
/* reserve 3 blocks */
--
2.34.1
More information about the U-Boot
mailing list