type-c-service: Create integration test framework #843
Open
RobertZ2011 wants to merge 2 commits into
Open
Conversation
Cargo Vet Audit Passed
|
040f6ee to
c995657
Compare
c995657 to
f1f75a0
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a Type-C service integration test harness (with controller mocks) and a first power/consumer attach test, alongside a few supporting API/CI tweaks to make the framework usable across the workspace.
Changes:
- Introduce
type-c-serviceintegration test framework (tests/common) plus an initial power attach/detach test (tests/power.rs). - Add a new
type-c-interface-mocksworkspace crate to support service/controller mocking in tests. - Update Type-C service construction API (
Service::create→Service::new), refine UCSI-related power-policy notification behavior, and adjust CI exclusions for std-only crates.
Reviewed changes
Copilot reviewed 24 out of 27 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
type-c-service/tests/power.rs |
Adds a basic consumer attach/detach integration test using the new harness. |
type-c-service/tests/common/mod.rs |
Adds the shared test harness: mocked ports, event routing, and service tasks. |
type-c-service/src/service/ucsi.rs |
Expands visibility of internal UCSI state fields to support cross-module access. |
type-c-service/src/service/power.rs |
Gates pending-UCSI notifications on whether the relevant UCSI notification is enabled. |
type-c-service/src/service/mod.rs |
Renames the service constructor from create to new. |
type-c-service/Cargo.toml |
Adds dev-dependencies needed for the integration tests and wires log/defmt features through power-policy-service. |
type-c-interface/src/service/event.rs |
Adds PartialEq, Eq derives to enable equality assertions in tests/consumers. |
type-c-interface/src/control/usb.rs |
Adds Eq derive to UsbControlConfig. |
type-c-interface/src/control/tbt.rs |
Adds Eq derive to TbtConfig. |
type-c-interface/src/control/retimer.rs |
Adds Eq derive to RetimerFwUpdateState. |
type-c-interface/src/control/pd.rs |
Adds PartialEq, Eq derive to PortStatus. |
type-c-interface/src/control/dp.rs |
Adds PartialEq, Eq derives to DP status/config types. |
type-c-interface-mocks/src/lib.rs |
New mocks crate root module. |
type-c-interface-mocks/src/controller/mod.rs |
Adds a mock controller with recorded calls and configurable next results. |
type-c-interface-mocks/src/controller/pd.rs |
Implements the PD controller mock trait surface. |
type-c-interface-mocks/src/controller/ucsi.rs |
Implements the UCSI LPM mock trait surface. |
type-c-interface-mocks/Cargo.toml |
Declares the new type-c-interface-mocks crate. |
examples/std/src/bin/type_c/unconstrained.rs |
Updates example to use Service::new. |
examples/std/src/bin/type_c/ucsi.rs |
Updates example to use Service::new. |
examples/std/src/bin/type_c/service.rs |
Updates example to use Service::new. |
examples/std/Cargo.lock |
Updates example lockfile due to dependency updates. |
examples/rt685s-evk/src/bin/type_c.rs |
Updates example to use Service::new. |
examples/rt685s-evk/src/bin/type_c_cfu.rs |
Updates example to use Service::new. |
examples/rt685s-evk/Cargo.lock |
Updates example lockfile due to dependency updates. |
Cargo.toml |
Adds type-c-interface-mocks to workspace members and workspace dependencies. |
Cargo.lock |
Adds the new workspace crate and updates dependency resolution. |
.github/workflows/check.yml |
Updates embedded-target exclusions to include type-c-interface-mocks and renames the exclusion env var. |
Comments suppressed due to low confidence (1)
type-c-service/tests/common/mod.rs:311
TypeCRegistrationType::port_datasetslocal_port: Some(LocalPortId(0))for every entry. If this metadata is used for UCSI numbering/port mapping, duplicating the same local ID for all ports can lead to incorrect connector change reporting in tests. Use distinctLocalPortIds matching the registered ports.
TypeCRegistrationType {
ports: [&port0, &port1, &port2],
port_data: [
PortData {
local_port: Some(LocalPortId(0)),
},
PortData {
local_port: Some(LocalPortId(0)),
},
PortData {
local_port: Some(LocalPortId(0)),
},
],
Create a framework for writing integration tests that initializes the power-policy-service, type-c-service, and provides serveral type-C ports for tests.
f1f75a0 to
1bff44e
Compare
jerrysxie
requested changes
May 19, 2026
a23e71b to
a0f3688
Compare
jerrysxie
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.