Skip to content

Conversation

@Javagedes
Copy link
Contributor

@Javagedes Javagedes commented Oct 17, 2025

Please Note: This PR is finished, and ready for review, however this is marked as draft, as some tests are disabled until RFC 0017 is completed.

Description

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(event= <REAL_GUID>)] e.g. #[on(event = 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.

The fail_fast config feature has been removed. This is because not all tests happen within the control of the TestRunner component, and thus cannot fail if it wanted to. Instead, an optional callback can be registered by the platform to handle an error however the platform prefers, 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)
  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

How This Was Tested

Boot to QEMUQ35 with various tests that use the event callback logic.

Integration Instructions

  1. Developers can now edit or write patina_tests that use the newly created attribute macro. This attribute macro allows you to specify an event guid to have your test executed on. Example seen below. Please note that if an invalid guid is provided, or the event never fires, the test results will report the test as "not triggered"
#[patina_test]
#[on(event = r_efi::efi::EVENT_GROUP_READY_TO_BOOT)]
fn my_patina_test() -> Result {
  Ok(())
}
  1. Developers can now register a callback function that is executed if a test fails
let component = TestRunner::default().with_callback(|test_name, err_msg| {
    panic!("{test_name} errored with result {err_msg});
});
  1. Remove any configuration of fail_fast e.g. fail_fast(...). Replace with custom error handling when a patina test fails with .with_callback(fn(&'static str, &'static str))

@github-actions github-actions bot added impact:testing Affects testing type:documentation Improvements or additions to documentation labels Oct 17, 2025
@Javagedes Javagedes force-pushed the personal/joeyvagedes/patina-test branch 2 times, most recently from 1b7c4b4 to 5f4636e Compare October 17, 2025 20:33
@github-actions github-actions bot added the impact:breaking-change Requires integration attention label Oct 17, 2025
@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 92.85714% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
sdk/patina/src/test.rs 89.66% 9 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Javagedes Javagedes force-pushed the personal/joeyvagedes/patina-test branch from 5f4636e to 96141a9 Compare November 18, 2025 23:11
@Javagedes Javagedes marked this pull request as ready for review November 18, 2025 23:11
@Javagedes
Copy link
Contributor Author

Added #927 as a todo to write unit tests for this code, which will not happen until #944 is competed.

@os-d
Copy link
Contributor

os-d commented Nov 19, 2025

@cfernald @makubacki this PR is now ready for review (although @Javagedes you'll need to rebase it). Can you please help review?

@os-d os-d force-pushed the personal/joeyvagedes/patina-test branch from 96141a9 to 9556fca Compare November 19, 2025 16:45
@Javagedes Javagedes force-pushed the personal/joeyvagedes/patina-test branch from 730f0b7 to dedf9f9 Compare November 19, 2025 17:04
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)
@os-d os-d force-pushed the personal/joeyvagedes/patina-test branch from 74a6804 to 68487d8 Compare November 19, 2025 18:20
@Javagedes Javagedes linked an issue Nov 19, 2025 that may be closed by this pull request
@Javagedes Javagedes merged commit 0e9c2c1 into OpenDevicePartnership:main Nov 19, 2025
7 checks passed
@Javagedes Javagedes removed the impact:breaking-change Requires integration attention label Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:testing Affects testing type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: patina_test event callback unit tests

3 participants