From patchwork Mon Dec 1 17:04:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 781 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1764608882; bh=1bDTovj55HpmtaHkoMAdwSvzonfZ9MC3OXFFq8VexyE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=B9qBtKOfJUc8Fr/Xg05HIIAxKDm/O+Ypw81xHn4fVNknLotC4iXPfGN3pEUHJH9+N ohtggJC2gWU8ozLN+NMQg1XfES2Beyi2XqemwVYlpb77UUdU7jBl/Ks59Xie0EEt6i p2RB7gT5ZeS9JDtLN3a4vKm26sN6zVzwZh9CxozvwISgYVBFNdeKiByFguKTKg2dlj K/RwkvCyyOXAgEbRnzQq/jvWja4+57M0zJrRD3Ta0jVjPC5iuE3IEQz3ZV+812RnOh VOK/qaZl3f2kolVbd3jvS1gro2t8oL1sr8xQfGX55wLwWDHKeUUVi1LM4qAeC2gXMi W7d6rdhQ3ciOQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 50F3A688C2 for ; Mon, 1 Dec 2025 10:08:02 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 23EA5bTGM1qS for ; Mon, 1 Dec 2025 10:08:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1764608880; bh=1bDTovj55HpmtaHkoMAdwSvzonfZ9MC3OXFFq8VexyE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=fsakBZi4UbVtAMmF9FDdBwkYELnsG3d7TkbhwKVo8Wc5UN+IgYoiDGGUVtxmo+XF/ ZsP+JqtTH/77bnoEVNvz0qf+8354daNjx+4OAWZ1RkdenDFqpQxls2oNXatDo7uyy7 7KrcSlDIg9zOGD7wBlMk94V2GzYuaMoJqOjR7AnEfWi0I4oH5lnDLTqNVJwyjrH55p 3uTmrfBmXwEaFM9uiYVap1LbXVMAqqgMJ5UHvkJ5TeODDIe+rtuxdGqqVSybDBrEkb kNZQeOWcyxRA5hlf8/Qbpvk3ZW2k5tvgrc6oeJbzYzRzj3hx3pkYrp1gkj1beyKnsB nEK+B5dycWKEw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5720A688C5 for ; Mon, 1 Dec 2025 10:08:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1764608878; bh=e/CX3Ehj1KBmKxt+ul0vqSviQNWnItYJ54HHn5VcrOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pMaiiksGHPSYCsqVWLbRVZdETZMpWsVPkYdVmcbfP4cyolfyM6UmFCithZ6jAgsaB YOzFsiTLnQBl92xfEiA4s9IzWqc1omlLmqlORjetUu0wwkzfL5jgSQTsnx3SyjPrbv 7O98wwQ0hUcVRPmaBuDCnJT7mTnuMf9Z7xD0XOc2RNJVrQ63pN7QzhAoaz9q+SNkEt PnR3dlHr0yEc+7wDfUJUOc7L/oG6rJja2zqkVoT0qYeERUpUvV9p0fRrtR6yNyi5LY DGJhdO67cUncu9sxhKh5tbQUj2hDL2wZ70t4JrRr1wvd7kzyzecGnFAJxuFdFRro9U n74Bn3OoUqhxg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 34B9668891; Mon, 1 Dec 2025 10:07:58 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id flGAEEQEdGQq; Mon, 1 Dec 2025 10:07:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1764608877; bh=hf3OPrVsxTYYS5ighbns4tN5VcuZ+R7lpugK+iGm+iU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TYuKaZ+OL0+UzWoMPAXORUgtyEs+Teu4Az7C0k7j6HsnqHtEzI4sw+jA8prvjfSJm lz68uzXfyV3AC1cEVa+/V+R89GmXS1IHrID1iXewiZLmpWoI3O0uOyENvuuugI1HN4 qYEtBfGVk5mioD6lVeo65B26DiUC+1xFqor71aE6u6zGRgEQGJgUzQ83URMcsJYmLx WcSieCNO2wORDFoXMMBNgv5r8FiVa0I2Orbuny460FZ5c6L67tvLFRGHoLPmq+qC/z tfh5hkqTFN+jfntne18KTzpkNK6Yj543ierVmZXVlXGxhO6xHC3c98tNsGQWudRGzP XpdMKd/5s9Mpw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9133A6881A; Mon, 1 Dec 2025 10:07:57 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 1 Dec 2025 10:04:43 -0700 Message-ID: <20251201170529.3237986-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251201170529.3237986-1-sjg@u-boot.org> References: <20251201170529.3237986-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YSINU3EKISPRRK47JAF4AYS33DRMNQ5S X-Message-ID-Hash: YSINU3EKISPRRK47JAF4AYS33DRMNQ5S X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/37] test: Use TOTAL_MALLOC_LEN for abuf and alist tests List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Several tests use CONFIG_SYS_MALLOC_LEN to test allocations that should fail due to exceeding pool size. However, the actual malloc pool size is TOTAL_MALLOC_LEN, which includes CONFIG_ENV_SIZE for boards that need to store the environment in RAM. The extra space accommodates: - the hash table allocated via calloc() - strdup() calls for each environment variable key - strdup() calls for each environment variable value This is an estimate and typically consumes less than CONFIG_ENV_SIZE, leaving more free space in the malloc pool than was reserved. On qemu-x86_64, CONFIG_ENV_SIZE is 0x40000, making the actual pool 0x240000 bytes. Tests expecting malloc(CONFIG_SYS_MALLOC_LEN) to fail might unexpectedly succeed since there's more space available. Update all tests to use TOTAL_MALLOC_LEN to correctly reflect the actual malloc pool size. Co-developed-by: Claude --- test/lib/abuf.c | 5 +++-- test/lib/alist.c | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/lib/abuf.c b/test/lib/abuf.c index 9cbb627d0b6..e97bb8b66bc 100644 --- a/test/lib/abuf.c +++ b/test/lib/abuf.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -244,7 +245,7 @@ static int lib_test_abuf_large(struct unit_test_state *uts) /* Try an impossible size */ abuf_init(&buf); - ut_asserteq(false, abuf_realloc(&buf, CONFIG_SYS_MALLOC_LEN)); + ut_asserteq(false, abuf_realloc(&buf, TOTAL_MALLOC_LEN)); ut_assertnull(buf.data); ut_asserteq(0, buf.size); ut_asserteq(false, buf.alloced); @@ -264,7 +265,7 @@ static int lib_test_abuf_large(struct unit_test_state *uts) ut_assert(delta > 0); /* try to increase it */ - ut_asserteq(false, abuf_realloc(&buf, CONFIG_SYS_MALLOC_LEN)); + ut_asserteq(false, abuf_realloc(&buf, TOTAL_MALLOC_LEN)); ut_asserteq_ptr(ptr, buf.data); ut_asserteq(TEST_DATA_LEN, buf.size); ut_asserteq(true, buf.alloced); diff --git a/test/lib/alist.c b/test/lib/alist.c index 0bf24578d2e..108eaed8d92 100644 --- a/test/lib/alist.c +++ b/test/lib/alist.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -41,7 +42,7 @@ static int lib_test_alist_init(struct unit_test_state *uts) /* use an impossible size */ ut_asserteq(false, alist_init(&lst, obj_size, - CONFIG_SYS_MALLOC_LEN)); + TOTAL_MALLOC_LEN)); ut_assertnull(lst.data); ut_asserteq(0, lst.count); ut_asserteq(0, lst.alloc);