Skip to content

[Feature]: Allow execution of patina_test routines at TPL_APPLICATION. #2012

Open

Description

@joschock

Feature Overview

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.

Urgency

Medium

Are you going to implement the feature request?

Someone else needs to implement the feature

Do you need maintainer feedback?

No maintainer feedback needed

Anything else?

No response

Activity

  1. added
    state:needs-triage
    type:feature-request
    on Nov 19, 2026
  2. added
    urgency:medium
    state:needs-owner
    on Nov 19, 2026
  3. moved this to Backlog in Patinaon Nov 19, 2026
  4. added this to the Backlog milestone on Nov 19, 2026
  5. Javagedes commented on Nov 20, 2026

    @Javagedes
    Contributor

    @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

  6. joschock commented on Nov 20, 2026

    @joschock
    ContributorAuthor

    I'm not sure that would work, events queued at TPL_APPLICATION never get called because TPL can't go lower than TPL_APPLICATION.

  7. os-d commented on Nov 20, 2026

    @os-d
    Contributor

    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.

  8. removed
    state:needs-owner
    on Nov 20, 2026
  9. Javagedes commented on Nov 20, 2026

    @Javagedes
    Contributor

    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 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:

    1. Create two separate components in patina-test. One that runs all "Immediate" tests - and one that registers all scheduled tests.
    2. 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 👎
  10. joschock commented on Nov 20, 2026

    @joschock
    ContributorAuthor

    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?

    i.e.

    #[patina_test]
    #[cfg_attr(target_arch = "aarch64", skip)]
    fn my_test(protocols: Service<dyn ProtocolServices>) -> Result { todo!() }

    -> 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.

    #[patina_test]
    #[on(event = patina::pi::event::END_OF_DXE_EVENT_GROUP_GUID)]
    fn my_test() -> Result { todo!() }

    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.

  11. Javagedes commented on Nov 21, 2026

    @Javagedes
    Contributor

    It is definitely possible to make the patina-tests just components behind the scenes. There are two main issues with this method though:

    1. 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.
    2. 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).
  12. Javagedes commented on Nov 25, 2026

    @Javagedes
    Contributor

    @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.

  13. joschock commented on Nov 25, 2026

    @joschock
    ContributorAuthor

    @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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

state:needs-triagetype:feature-requesturgency:medium

Type

No type

Projects

  • Status
    Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions