Skip to content

type-c-service: Create integration test framework #843

Open
RobertZ2011 wants to merge 2 commits into
OpenDevicePartnership:v0.2.0from
RobertZ2011:type-c-integration-test-framework
Open

type-c-service: Create integration test framework #843
RobertZ2011 wants to merge 2 commits into
OpenDevicePartnership:v0.2.0from
RobertZ2011:type-c-integration-test-framework

Conversation

@RobertZ2011
Copy link
Copy Markdown
Contributor

No description provided.

@RobertZ2011 RobertZ2011 self-assigned this May 13, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

Cargo Vet Audit Passed

cargo vet has passed in this PR. No new unvetted dependencies were found.

@github-actions github-actions Bot added the cargo vet PRs pending auditor review label May 13, 2026
@RobertZ2011 RobertZ2011 force-pushed the type-c-integration-test-framework branch 17 times, most recently from 040f6ee to c995657 Compare May 18, 2026 16:59
@RobertZ2011 RobertZ2011 changed the title Type c integration test framework type-c-service: Create integration test framework May 18, 2026
@RobertZ2011 RobertZ2011 force-pushed the type-c-integration-test-framework branch from c995657 to f1f75a0 Compare May 18, 2026 17:25
@RobertZ2011 RobertZ2011 requested a review from Copilot May 18, 2026 17:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-service integration test framework (tests/common) plus an initial power attach/detach test (tests/power.rs).
  • Add a new type-c-interface-mocks workspace crate to support service/controller mocking in tests.
  • Update Type-C service construction API (Service::createService::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_data sets local_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 distinct LocalPortIds 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)),
                },
            ],

Comment thread type-c-service/tests/common/mod.rs
Comment thread type-c-service/tests/common/mod.rs Outdated
Comment thread type-c-service/tests/common/mod.rs
Comment thread type-c-service/tests/common/mod.rs
Create a framework for writing integration tests that initializes the
power-policy-service, type-c-service, and provides serveral type-C ports
for tests.
@RobertZ2011 RobertZ2011 force-pushed the type-c-integration-test-framework branch from f1f75a0 to 1bff44e Compare May 18, 2026 17:38
@RobertZ2011 RobertZ2011 marked this pull request as ready for review May 18, 2026 17:45
@RobertZ2011 RobertZ2011 requested review from a team as code owners May 18, 2026 17:45
Comment thread type-c-service/tests/common/mod.rs Outdated
Comment thread type-c-service/src/service/power.rs
Comment thread type-c-interface-mocks/src/controller/pd.rs
@RobertZ2011 RobertZ2011 force-pushed the type-c-integration-test-framework branch from a23e71b to a0f3688 Compare May 19, 2026 17:05
@RobertZ2011 RobertZ2011 requested a review from jerrysxie May 19, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cargo vet PRs pending auditor review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants