[PATCH v2] efi_selftest: add hii database protocol test cases

Vincent Stehlé vincent.stehle at arm.com
Fri Jan 6 10:24:32 CET 2023


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é <vincent.stehle at arm.com>
Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
---


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:
-- 
2.39.0



More information about the U-Boot mailing list