Skip to content

Commit 9556fca

Browse files
Javagedesos-d
authored andcommitted
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 bc6d2ef commit 9556fca

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
@@ -13,7 +13,7 @@ use core::{
1313
mem::{self, ManuallyDrop},
1414
num::NonZeroUsize,
1515
ops::Deref,
16-
ptr,
16+
ptr::{self, NonNull},
1717
};
1818

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

234+
unsafe impl<T> CPtr<'_> for NonNull<T> {
235+
type Type = T;
236+
237+
fn as_ptr(&self) -> *const Self::Type {
238+
Self::as_ptr(*self)
239+
}
240+
}
241+
234242
#[cfg(test)]
235243
#[coverage(off)]
236244
mod tests {

0 commit comments

Comments
 (0)