summaryrefslogtreecommitdiff
path: root/lib/efi_selftest
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-06-16 19:05:52 -0400
committerTom Rini <trini@konsulko.com>2023-06-16 19:05:52 -0400
commit1c30e10017ec8bcd0ffec0d8c7d17539ae73dfa7 (patch)
tree6120a7d1a99c25b50896a7d932d431145570f5a4 /lib/efi_selftest
parent2f4664f5c3edc55b18d8906f256a4c8e303243c0 (diff)
parent5669591dd8d2b21bc79237b161107300eb7f2b12 (diff)
Merge tag 'efi-2023-07-rc5' of https://source.denx.de/u-boot/custodians/u-boot-efi
Pull request efi-2023-07-rc5 Documentation: * man-page for imxtract * correct EVT_DM_POST_INIT_F description UEFI: * bootm: don't call booti_setup for EFI images * simplify efi_disk_remove * fix tests that failed when executed repeatedly
Diffstat (limited to 'lib/efi_selftest')
-rw-r--r--lib/efi_selftest/efi_selftest_controllers.c26
-rw-r--r--lib/efi_selftest/efi_selftest_manageprotocols.c2
-rw-r--r--lib/efi_selftest/efi_selftest_register_notify.c25
3 files changed, 52 insertions, 1 deletions
diff --git a/lib/efi_selftest/efi_selftest_controllers.c b/lib/efi_selftest/efi_selftest_controllers.c
index d2bbd1c4f65..63e674bedc0 100644
--- a/lib/efi_selftest/efi_selftest_controllers.c
+++ b/lib/efi_selftest/efi_selftest_controllers.c
@@ -271,6 +271,8 @@ static int setup(const efi_handle_t img_handle,
efi_status_t ret;
boottime = systable->boottime;
+ handle_controller = NULL;
+ handle_driver = NULL;
/* Create controller handle */
ret = boottime->install_protocol_interface(
@@ -402,14 +404,36 @@ static int execute(void)
/* Check number of child controllers */
ret = count_child_controllers(handle_controller, &guid_controller,
&count);
- if (ret == EFI_SUCCESS)
+ if (ret == EFI_SUCCESS || count) {
efi_st_error("Uninstall failed\n");
+ return EFI_ST_FAILURE;
+ }
+
+
return EFI_ST_SUCCESS;
}
+ /*
+ * Tear down unit test.
+ *
+ */
+static int teardown(void)
+{
+ efi_status_t ret;
+ /* Uninstall binding protocol */
+ ret = boottime->uninstall_protocol_interface(handle_driver,
+ &guid_driver_binding_protocol,
+ &binding_interface);
+ if (ret != EFI_SUCCESS)
+ efi_st_error("Failed to uninstall protocols\n");
+
+ return ret;
+}
+
EFI_UNIT_TEST(controllers) = {
.name = "controllers",
.phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
.setup = setup,
.execute = execute,
+ .teardown = teardown,
};
diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
index 8edb1e4d467..097b2ae3545 100644
--- a/lib/efi_selftest/efi_selftest_manageprotocols.c
+++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
@@ -79,6 +79,8 @@ static int setup(const efi_handle_t img_handle,
efi_status_t ret;
efi_handle_t handle;
+ handle1 = NULL;
+ handle2 = NULL;
boottime = systable->boottime;
ret = boottime->install_protocol_interface(&handle1, &guid3,
diff --git a/lib/efi_selftest/efi_selftest_register_notify.c b/lib/efi_selftest/efi_selftest_register_notify.c
index ad4bcce1a10..adf5dd00a1e 100644
--- a/lib/efi_selftest/efi_selftest_register_notify.c
+++ b/lib/efi_selftest/efi_selftest_register_notify.c
@@ -124,6 +124,7 @@ static int execute(void)
{
efi_status_t ret;
efi_handle_t handle1 = NULL, handle2 = NULL;
+ struct interface *interface;
struct interface interface1, interface2;
ret = boottime->install_protocol_interface(&handle1, &guid1,
@@ -145,6 +146,18 @@ static int execute(void)
efi_st_error("LocateHandle failed\n");
return EFI_ST_FAILURE;
}
+ interface = NULL;
+ ret = boottime->open_protocol(handle1, &guid1, (void**)&interface,
+ NULL, NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Cannot find installed protocol on handle\n");
+ return EFI_ST_FAILURE;
+ }
+ if (interface != &interface1) {
+ efi_st_error("Wrong interface after install\n");
+ return EFI_ST_FAILURE;
+ }
ret = boottime->free_pool(context.handles);
if (ret != EFI_SUCCESS) {
efi_st_error("FreePool failed\n");
@@ -186,6 +199,18 @@ static int execute(void)
efi_st_error("FreePool failed\n");
return EFI_ST_FAILURE;
}
+ interface = NULL;
+ ret = boottime->open_protocol(handle1, &guid1, (void**)&interface,
+ NULL, NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Cannot find reinstalled protocol on handle\n");
+ return EFI_ST_FAILURE;
+ }
+ if (interface != &interface2) {
+ efi_st_error("Wrong interface after reinstall\n");
+ return EFI_ST_FAILURE;
+ }
context.notify_count = 0;
ret = boottime->install_protocol_interface(&handle2, &guid1,
EFI_NATIVE_INTERFACE,