From patchwork Fri Jun 7 18:52:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 802335 Delivered-To: patch@linaro.org Received: by 2002:adf:f147:0:b0:35b:5a80:51b4 with SMTP id y7csp949804wro; Fri, 7 Jun 2024 11:57:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWsVSs8LahQFTOrEDBcY28/3B1EXWHNKe8VjajFM7281eStAxr8wUOefLjRY5ZMj1IPBKZN3+ttnHdSCZSdrDH9 X-Google-Smtp-Source: AGHT+IExqDcnohl7H8XO/EG5NvDj88hVA+Brbr8z+4q6gXPB1weoqkaDJ7n3hTGsZBwKNNr/B0u1 X-Received: by 2002:a50:f689:0:b0:578:62e7:e5a7 with SMTP id 4fb4d7f45d1cf-57c4deb9402mr3154068a12.4.1717786660539; Fri, 07 Jun 2024 11:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717786660; cv=none; d=google.com; s=arc-20160816; b=zisYmKhCVH7jXZCCZ0zcvoKrej7POKPquiWeReJke5uaTrPy/6iFyqx5PM/eXTnPb+ X/Y/+xF7F2yoow+HS3rvTUcWIO6TtbgHH7mLseUWsuIy1B1iSQrFyXoPzTQPw/d7CcNy sQIJyMKZ8AHZm7kAk3ssBkvvohOXTeVTzrUZW/7TYQnvbkLBgIoTAvLc1YNVbQgg/994 Df6tfUWCAMPMYWC4n7cTINlE4NrUvJiEAtBy9dgQZSXf9EJHecqMGXWjcv6lRgDZlnj8 eD7hFgRKnZ27fuxH1/nusNwuKMmnNHQU47TMM1PJnPtwl/Ony7eHTjCGrNi2LHV2hGze dBqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=8qxHElhftvHY/EAeWixToo29Wrm4SgNzJfY6HVq3MTY=; fh=xLSOOz5Q0Mrmzd+lwBRTYS7D/8TpUWM8TEHgIjpMzow=; b=dUP1aPu7c4N46deN3Nry1WpoiETVbd4z8H6uTSQIRX/bBMYEKrcjcTGCwrbTzKJNg+ mbRxjFUxihZZcee7AFIvLc8ueqbsUGq3OlBXyxUWPg7GQg13f4VWctHiBaLwFkHlacIR E38r0AcGMeiYrmFeFJ2pwVMAowcxA+vtDdlWmQG58F29e0IcRIuu+38Gh+q0auEoJFRB AwKAGl3rMn8h7iydXvkImBh8Y9qODttBvRFzxHIeKGs2bAApS34lScod0tcwJ2WclyfM laj9Q7wQvQRT8er+WO900sl+YeYPRatTC44yfmrolWFA8pIBDqB+ESyIq9u5I2vKsGUN 1l9A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae1fc568si2037386a12.246.2024.06.07.11.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 11:57:40 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 0136B884B0; Fri, 7 Jun 2024 20:54:54 +0200 (CEST) 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 9659F88445; Fri, 7 Jun 2024 20:54:52 +0200 (CEST) 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_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 A7274884B0 for ; Fri, 7 Jun 2024 20:54:50 +0200 (CEST) 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 847CF1480; Fri, 7 Jun 2024 11:55:14 -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 6ADDF3F792; Fri, 7 Jun 2024 11:54:47 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Tom Rini , Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Marek Vasut , Mark Kettenis , Fabio Estevam , Sughosh Ganu Subject: [RFC PATCH 24/31] test: lmb: add a test case for checking overlapping region add Date: Sat, 8 Jun 2024 00:22:33 +0530 Message-Id: <20240607185240.1892031-25-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240607185240.1892031-1-sughosh.ganu@linaro.org> References: <20240607185240.1892031-1-sughosh.ganu@linaro.org> 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 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 --- test/lib/lmb.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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) {