Skip to content

Commit 5f4636e

Browse files
committed
patina: test: Add test on event callback support
adds a new attribute for the `#[patina_test]` attribute macro that allows the user to specify a UEFI event that the test should be executed on. When the UEFI event callback is fired, the patina_test will be executed. This new attribute is `#[on(protocol = <REAL_GUID>)]` e.g. `#[on(protocol = r_efi::efi::EVENT_GROUP_READY_TO_BOOT)]`. After this change, not all patina_tests are executed immediately during the `TestRunner` component. Due To this, test result reporting is delayed to two separate event callbacks. Test results are now reported once at READY_TO_BOOT and once at EXIT_BOOT_SERVICES. Additionally, this change introduces a optional callback that the platform can register, that is executed anytime a test fails. Example Test reporting: INFO - INFO - Patina on-system unit-test results: INFO - patina_adv_logger::integration_test::adv_logger_test ... ok (1 passes) INFO - patina_dxe_core::memory_manager::memory_manager_allocations_test ... ok (1 passes) INFO - patina_dxe_core::memory_manager::memory_manager_attributes_test ... ok (1 passes) INFO - qemu_q35_dxe_core::my_test ... ok (413 passes) INFO - qemu_q35_dxe_core::ready_to_boot_test ... ok (1 passes)
1 parent 89a34c1 commit 5f4636e

File tree

4 files changed

+440
-63
lines changed

4 files changed

+440
-63
lines changed

sdk/patina/src/boot_services/c_ptr.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use core::{
1212
marker::PhantomData,
1313
mem::{self, ManuallyDrop},
1414
ops::Deref,
15-
ptr,
15+
ptr::{self, NonNull},
1616
};
1717

1818
#[derive(Copy)]
@@ -218,6 +218,14 @@ unsafe impl<'a, R: CRef<'a, Type = T>, T> CRef<'a> for ManuallyDrop<R> {}
218218
// SAFETY: Memory layout and mutability are respected for these types.
219219
unsafe impl<'a, R: CMutRef<'a, Type = T>, T> CMutRef<'a> for ManuallyDrop<R> {}
220220

221+
unsafe impl<T> CPtr<'_> for NonNull<T> {
222+
type Type = T;
223+
224+
fn as_ptr(&self) -> *const Self::Type {
225+
Self::as_ptr(*self)
226+
}
227+
}
228+
221229
#[cfg(test)]
222230
#[coverage(off)]
223231
mod tests {

0 commit comments

Comments
 (0)