From patchwork Fri Jan 6 09:24:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Vincent_Stehl=C3=A9?= X-Patchwork-Id: 1722343 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NpHx30dLqz23dq for ; Fri, 6 Jan 2023 20:24:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 66E68855EA; Fri, 6 Jan 2023 10:24:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com 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 4999B855EA; Fri, 6 Jan 2023 10:24:48 +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.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 5BA66855CB for ; Fri, 6 Jan 2023 10:24:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=vincent.stehle@arm.com 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 8A83A11FB; Fri, 6 Jan 2023 01:25:26 -0800 (PST) Received: from localhost.localdomain (unknown [10.57.12.250]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EF6F33F23F; Fri, 6 Jan 2023 01:24:43 -0800 (PST) From: =?utf-8?q?Vincent_Stehl=C3=A9?= To: u-boot@lists.denx.de Cc: =?utf-8?q?Vincent_Stehl=C3=A9?= , Heinrich Schuchardt , Ilias Apalodimas Subject: [PATCH v2] efi_selftest: add hii database protocol test cases Date: Fri, 6 Jan 2023 10:24:32 +0100 Message-Id: <20230106092432.3358862-1-vincent.stehle@arm.com> X-Mailer: git-send-email 2.39.0 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.6 at phobos.denx.de X-Virus-Status: Clean Add a couple of tests for the cases when the HII database protocol get_package_list_handle() function is called with invalid parameters. Signed-off-by: Vincent Stehlé Cc: Heinrich Schuchardt Cc: Ilias Apalodimas --- Hi, Thanks Heinrich for your review and feedbacks; here is v2 of this patch. Best regards, Vincent. Changes in v2: - Change initialization of driver_handle to a non-NULL value, which will never get allocated. - Add a second test for the case when driver handle is invalid. v1 reference(s): - https://lists.denx.de/pipermail/u-boot/2022-December/502213.html - https://lists.denx.de/pipermail/u-boot/2023-January/503718.html lib/efi_selftest/efi_selftest_hii.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/efi_selftest/efi_selftest_hii.c b/lib/efi_selftest/efi_selftest_hii.c index eaf3b0995d4..608e3982399 100644 --- a/lib/efi_selftest/efi_selftest_hii.c +++ b/lib/efi_selftest/efi_selftest_hii.c @@ -605,6 +605,25 @@ static int test_hii_database_get_package_list_handle(void) goto out; } + /* Invalid package list handle. */ + driver_handle = (efi_handle_t)~1UL; + ret = hii_database_protocol->get_package_list_handle( + hii_database_protocol, NULL, &driver_handle); + if (ret != EFI_INVALID_PARAMETER) { + efi_st_error("get_package_list_handle returned %u not invalid\n", + (unsigned int)ret); + goto out; + } + + /* Invalid driver handle. */ + ret = hii_database_protocol->get_package_list_handle( + hii_database_protocol, handle, NULL); + if (ret != EFI_INVALID_PARAMETER) { + efi_st_error("get_package_list_handle returned %u not invalid\n", + (unsigned int)ret); + goto out; + } + result = EFI_ST_SUCCESS; out: