From patchwork Wed Mar 26 16:53:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 876318 Delivered-To: patch@linaro.org Received: by 2002:a5d:5f4c:0:b0:38f:210b:807b with SMTP id cm12csp3277349wrb; Wed, 26 Mar 2025 09:54:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWDfkSeeqQXha1hC6ulglRu98gdxJ1mvP4sSr3ATthzsG7GuOHCiG++ftmpyXp/SgMXteZzBw==@linaro.org X-Google-Smtp-Source: AGHT+IFQp+3Q2Ip4YRqT8byhY9N1PIPh493NgRSFlzj8pkoMrZZ/eZ1vxpebFcKIgiRPxGYcHsU6 X-Received: by 2002:a05:6102:8015:b0:4b1:14f3:5d6d with SMTP id ada2fe7eead31-4c586f5bf13mr832023137.6.1743008040487; Wed, 26 Mar 2025 09:54:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1743008040; cv=none; d=google.com; s=arc-20240605; b=CsEaSX0UmZxHw50V2fVvl0KgKEFW/W+HzoftklBA7MSorxcz8hfcYCaqX5daCBuJGD Zby+T3k1I/7LL/Aq3J5pqgsn4RelBBS3q4NI5iFrQxCmdLbyMUVpgnC1V+LBhFw+1d/p UwF8EmO3LpRAKEcbwYTuWZBOBFIezzvzzNPtmk2kKzUq6S+8cYCyKki+DivFIXYnk1pT G5Tkz/+lMgvUON/pCmQSRPG61Z042mowYX3APZz3UE9lmMwLK+Xz2ZpzEEkDkKVT/epp KUd0NYst9a0nKJtmY8pjP1a7SI+0jqK4O0kA8l3oKULqG/J7pe5DUdLI7Q330VCGuePF dqYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=XI4i7X9z3UnC03OioubSq02Jk112fimlDLQf8xJYfiY=; fh=08JUTgpa0A/sy1wetcwWnr/J8MBB06B4A0KCtdMGJ54=; b=c04c5uO0Evd+cWzzM7HNZyY3hcPyA45HKsq10o8ekQjnxKqoWmwtKHFtNwjIjk6DKZ wH5EerAI/bQP0yXndZJt+1j3T8fDqFK48TaGrQuT60KiT22QpCfnFsxG+3Y6ZA0HA2aZ iX9y4WU39ZILPOzeFFREbZ6JpTc0IOZf4n4DBEOvmVqinoxh5RD6dA92p1tQ335tR67M d68a7XEq3Hiqx1Zy/hGPGT7SAkJYg8fFHnGlQqVmHwqPZRKSCI7pPpX39nnv0OTG2lVR leDL7xOMcZhnVOeC1gmFmVoolRbQH4/Z7Pa1ImKioCm9H+SQOjuj1vv4BWpMyZ2Sq6cp PDbw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id ada2fe7eead31-4c50c03d93dsi2894430137.515.2025.03.26.09.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Mar 2025 09:54:00 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9917F81253; Wed, 26 Mar 2025 17:53:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id F0A1381C84; Wed, 26 Mar 2025 17:53:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 95183810E8 for ; Wed, 26 Mar 2025 17:53:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 504241424; Wed, 26 Mar 2025 09:53:59 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 529593F58B; Wed, 26 Mar 2025 09:53:52 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Tom Rini , Sughosh Ganu Subject: [PATCH] test: lmb: fix the lmb_alloc_addr() based test cases Date: Wed, 26 Mar 2025 22:23:36 +0530 Message-Id: <20250326165336.547689-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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 --- 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 */