diff mbox series

test: lmb: fix the lmb_alloc_addr() based test cases

Message ID 20250326165336.547689-1-sughosh.ganu@linaro.org
State New
Headers show
Series test: lmb: fix the lmb_alloc_addr() based test cases | expand

Commit Message

Sughosh Ganu March 26, 2025, 4:53 p.m. UTC
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@linaro.org>
---

Note: To be applied on next

 test/lib/lmb.c | 50 +++++++++++++++++++++++++-------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

Comments

Tom Rini March 26, 2025, 8:06 p.m. UTC | #1
On Wed, 26 Mar 2025 22:23:36 +0530, Sughosh Ganu wrote:

> 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.
> 
> [...]

Applied to u-boot/next, thanks!

[1/1] test: lmb: fix the lmb_alloc_addr() based test cases
      commit: b052de94fa14577cb5d9e724edeb09fee674d582
diff mbox series

Patch

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 */