@@ -9,7 +9,7 @@ use uefi::table::boot::{
99 Tpl ,
1010} ;
1111use uefi:: table:: { Boot , SystemTable } ;
12- use uefi:: { boot, guid, Event , Guid , Identify } ;
12+ use uefi:: { boot, guid, Event , Guid , Identify , Status } ;
1313
1414pub fn test ( st : & SystemTable < Boot > ) {
1515 let bt = st. boot_services ( ) ;
@@ -24,6 +24,7 @@ pub fn test(st: &SystemTable<Boot>) {
2424 test_watchdog ( bt) ;
2525 info ! ( "Testing protocol handler services..." ) ;
2626 test_register_protocol_notify ( bt) ;
27+ test_protocol_interface_management ( ) ;
2728 test_install_protocol_interface ( bt) ;
2829 test_reinstall_protocol_interface ( bt) ;
2930 test_uninstall_protocol_interface ( bt) ;
@@ -133,6 +134,48 @@ fn test_register_protocol_notify(bt: &BootServices) {
133134 . expect ( "Failed to register protocol notify fn" ) ;
134135}
135136
137+ fn test_protocol_interface_management ( ) {
138+ let mut interface = TestProtocol { data : 123 } ;
139+ let interface_ptr: * mut _ = & mut interface;
140+
141+ // Install the protocol.
142+ let handle = unsafe {
143+ boot:: install_protocol_interface ( None , & TestProtocol :: GUID , interface_ptr. cast ( ) )
144+ }
145+ . unwrap ( ) ;
146+
147+ // Verify the handle was installed.
148+ assert_eq ! (
149+ & * boot:: locate_handle_buffer( SearchType :: from_proto:: <TestProtocol >( ) ) . unwrap( ) ,
150+ [ handle]
151+ ) ;
152+
153+ // Re-install the protocol.
154+ unsafe {
155+ boot:: reinstall_protocol_interface (
156+ handle,
157+ & TestProtocol :: GUID ,
158+ interface_ptr. cast ( ) ,
159+ interface_ptr. cast ( ) ,
160+ )
161+ }
162+ . unwrap ( ) ;
163+
164+ // Uninstall the protocol.
165+ unsafe {
166+ boot:: uninstall_protocol_interface ( handle, & TestProtocol :: GUID , interface_ptr. cast ( ) )
167+ }
168+ . unwrap ( ) ;
169+
170+ // Verify the protocol was uninstalled.
171+ assert_eq ! (
172+ boot:: locate_handle_buffer( SearchType :: from_proto:: <TestProtocol >( ) )
173+ . unwrap_err( )
174+ . status( ) ,
175+ Status :: NOT_FOUND
176+ ) ;
177+ }
178+
136179fn test_install_protocol_interface ( bt : & BootServices ) {
137180 info ! ( "Installing TestProtocol" ) ;
138181
0 commit comments