Skip to contentSkip to conversation

efi_selftest: add hii database protocol test cases

PATCH New Vincent Stehlé 1 participant 1 message Jan 6, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 efi_selftest: add hii database protocol test cases

Add a couple of tests for the cases when the HII database protocol get_package_list_handle() function is called with invalid parameters.

Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>

---

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(+)
lib/efi_selftest/efi_selftest_hii.c +19 -0
index eaf3b0995d4..608e3982399 100644
@@ -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:
Signature · 1 line
2.39.0