You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: Allow execution of patina_test routines at TPL_APPLICATION. #2012
Present implementation of "patina_test" platform testing (https://opendevicepartnership.github.io/patina/dev/testing/platform.html) dispatches all test routines not otherwise configured in a ReadyToBoot callback running at TPL_CALLBACK. This precludes tests that require execution at TPL_APPLICATION (e.g. to verify the results of a TPL_CALLBACK event notify routine).
Feature request is to provide a mechanism to configure patina_tests so that they execute at TPL_APPLICATION.
Solution Overview
Provide a configuration mechanism (or make it default) akin to the existing event triggers that allow a test to be marked for execution at TPL_APPLICATION.
Alternatives Considered
*Custom components that dispatch tests in the entry point without being #[patina_test] using #[patina_test] only to record results. This is not great since it means the bulk of the test is not marked as such, and special components have to be built in just to dispatch test code.
*TPL shenanigans where #[patina_test] violates UEFI spec to artificially lower TPL to APP for test execution (i.e. RaiseTpl to HIGH and then RestoreTpl to APP). This breaks spec.
@os-d@cfernald I'm just going to update the events to TPL_APPLICATION as that makes sense to me. You have both actually used the patina_test quite a bit. Do either of you need TPL_CALLBACK? If so, I can update the macro to allow you to set the necessary TPL. But I'm not going to add that configuration option if it is not necessary
Yeah, as John said it won't work to have events at TPL_APPLICATION. I don't have any concerns with running the tests at TPL_APPLICATION, but it will have to be through a different mechanism.
Currently, we defer all patina_tests without a special trigger to execute via one of two events (READY_TO_BOOT, EXIT_BOOT_SERVICES) to give the most likelyhood that any test dependencies are available before attempting to execute. This has the side effect noted in this issue that we are at TPL_CALLBACK when this executes.
Without creating a special custom hook in the core for this explicit purpose, which I do not want to do, the only way I can think to resolve this is to make the TestRunner component self-aware of the individual patina_test dependencies and not dispatch until all dependencies have been resolved. I can do this. However, it then causes an issue that the patina_tests that are timer based and event based will also be delayed from being registered until the component executes.
I can see two solutions:
Create two separate components in patina-test. One that runs all "Immediate" tests - and one that registers all scheduled tests.
Hack the patina component model such that when we check if the component is ready to dispatch, also check if UEFI event services are available, and if they are, register the scheduled tests regardless of if the component is going to dispatch 👎
from the docs, I initially thought until digging into it that the original intent was for #[patina_test] to be similar to #[component] i.e. would be scheduled by component dispatcher same way once their dependencies (if any) were met. Do they need to be marshalled by TestRunner? Could they instead depend on a TestRunner service for results reporting?
-> the macro would build a new component with a dependency on ProtocolServices and TestRunnerServices, then run my_test in the entry point passing it ProtocolServices and then submit the Result into the TestRunnerServices. Component dispatcher would then just dispatch it whenever it resolves.
For event-based tests (e.g. timer triggered, or event triggered), you could just make a wrapper component with a dependency on the event services and then use the event services to register the appropriate callback for the test.
would build a new component with dependency on EventServices and TestRunnerServices, then in the entrypoint would setup an event callback on EndOfDxe which would then run my_test in the callback and submit the result to TestRunnerService.
It is definitely possible to make the patina-tests just components behind the scenes. There are two main issues with this method though:
I don't have a way to automatically register these patina-tests as additional components. Two solutions to that would be (1) to make it such that patina-test is no longer a component, but instead something that runs outside the component model that can collect and register each individual patina-test as its own component or (2) remove patina-test all together - moving the patina-test collection logic directly into patina-dxe-core and the public facing code for writing patina-tests into patina.
Adding each individual test as a separate component may cause some confusion with some of our debug logs when people are reviewing components registered but not dispatched and they see a bunch of components in the results that they did not register, but exist (because we automatically collected them).
@joschock based off of your feedback, I liked the idea of the patina-test framework converting each in patina test into its own component. Not only is this cleaner, but it also fixes this issue.
However I'm going to hold off on creating a PR from it as Michael will be creating an RFC related to components that may influence this design, and I don't want there to be two back-to-back breaking changes related to patina-test.
@Javagedes looked over the changes briefly, esp. the doc parts describing usage, and looks good to me. I'm not in a super rush for this; I plan to use it to write some patina_tests for the USB/UEFI hid components in OpenDevicePartnership/patina-components#8 once available, but I'm not planning to hold the PR for that.
Activity
Javagedes commentedon Nov 20, 2026
@os-d @cfernald I'm just going to update the events to TPL_APPLICATION as that makes sense to me. You have both actually used the
patina_testquite a bit. Do either of you need TPL_CALLBACK? If so, I can update the macro to allow you to set the necessary TPL. But I'm not going to add that configuration option if it is not necessaryjoschock commentedon Nov 20, 2026
I'm not sure that would work, events queued at TPL_APPLICATION never get called because TPL can't go lower than TPL_APPLICATION.
os-d commentedon Nov 20, 2026
Yeah, as John said it won't work to have events at TPL_APPLICATION. I don't have any concerns with running the tests at TPL_APPLICATION, but it will have to be through a different mechanism.
Javagedes commentedon Nov 20, 2026
I see. That makes these much more complicated.
Currently, we defer all
patina_tests without a special trigger to execute via one of two events (READY_TO_BOOT, EXIT_BOOT_SERVICES) to give the most likelyhood that any test dependencies are available before attempting to execute. This has the side effect noted in this issue that we are at TPL_CALLBACK when this executes.Without creating a special custom hook in the core for this explicit purpose, which I do not want to do, the only way I can think to resolve this is to make the
TestRunnercomponent self-aware of the individualpatina_testdependencies and not dispatch until all dependencies have been resolved. I can do this. However, it then causes an issue that thepatina_tests that are timer based and event based will also be delayed from being registered until the component executes.I can see two solutions:
joschock commentedon Nov 20, 2026
from the docs, I initially thought until digging into it that the original intent was for
#[patina_test]to be similar to#[component]i.e. would be scheduled by component dispatcher same way once their dependencies (if any) were met. Do they need to be marshalled byTestRunner? Could they instead depend on a TestRunner service for results reporting?i.e.
-> the macro would build a new component with a dependency on ProtocolServices and TestRunnerServices, then run my_test in the entry point passing it ProtocolServices and then submit the Result into the TestRunnerServices. Component dispatcher would then just dispatch it whenever it resolves.
For event-based tests (e.g. timer triggered, or event triggered), you could just make a wrapper component with a dependency on the event services and then use the event services to register the appropriate callback for the test.
i.e.
would build a new component with dependency on EventServices and TestRunnerServices, then in the entrypoint would setup an event callback on EndOfDxe which would then run
my_testin the callback and submit the result to TestRunnerService.Javagedes commentedon Nov 21, 2026
It is definitely possible to make the patina-tests just components behind the scenes. There are two main issues with this method though:
patina-testis no longer a component, but instead something that runs outside the component model that can collect and register each individual patina-test as its own component or (2) remove patina-test all together - moving the patina-test collection logic directly intopatina-dxe-coreand the public facing code for writing patina-tests intopatina.Javagedes commentedon Nov 25, 2026
@joschock based off of your feedback, I liked the idea of the patina-test framework converting each in patina test into its own component. Not only is this cleaner, but it also fixes this issue.
I have a full solution here: feature/major/patina-tests-as-components
However I'm going to hold off on creating a PR from it as Michael will be creating an RFC related to components that may influence this design, and I don't want there to be two back-to-back breaking changes related to patina-test.
joschock commentedon Nov 25, 2026
@Javagedes looked over the changes briefly, esp. the doc parts describing usage, and looks good to me. I'm not in a super rush for this; I plan to use it to write some patina_tests for the USB/UEFI hid components in OpenDevicePartnership/patina-components#8 once available, but I'm not planning to hold the PR for that.