Add thermal service unit test - #950
Merged
jerrysxie merged 3 commits intoAug 24, 2026
Merged
Conversation
Exercise fan state transitions, manual overrides, sampling, and failure events through the service runner. Cover sensor retries, thresholds, hysteresis, sampling control, and buffer behavior. Assisted-by: GitHub Copilot:GPT 5.3 Codex
Extend the fan and sensor service test suites to close coverage gaps identified in review. Sensor: assert immediate reads ignore offset, exercise the threshold getter and sample-period setter, cover the fast-sampling branch, verify event fan-out to multiple senders, and check prochot/critical hysteresis clearing. Fan: cover the cool-down state transitions through hysteresis, the RPM sampling and update period setters, the rpm_immediate error path, and event fan-out to multiple senders. Add a scripted RPM-read failure hook to the fan test fake to enable the error path. Assisted-by: GitHub Copilot:claude-opus-4.8
jerrysxie
commented
Aug 21, 2026
jerrysxie
marked this pull request as ready for review
August 21, 2026 22:08
jerrysxie
requested review from
RobertZ2011,
tullom and
williampMSFT
and
a lite review from Copilot
and removed request for
Copilot
August 21, 2026 22:08
RobertZ2011
requested changes
Aug 21, 2026
kurtjd
previously approved these changes
Aug 24, 2026
Apply the configured sensor offset to immediate temperature reads. This keeps immediate values consistent with periodically sampled values. Update the regression test to cover the corrected result. Assisted-by: GitHub Copilot:claude-opus-4.6
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands thermal-service test coverage by adding new integration tests for the sensor and fan services, plus unit tests for SampleBuf, and it aligns temperature_immediate() behavior with the runner’s offset handling.
Changes:
- Add comprehensive
#[tokio::test]integration tests forthermal_service::sensorandthermal_service::fanbehaviors (thresholds, hysteresis, enable/disable flows, retries, and event broadcasting). - Fix
thermal-servicesensor API behavior sotemperature_immediate()applies the configured offset. - Add
SampleBufunit tests and introducethermal-servicedev-dependencies needed to run the new async tests on std.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| thermal-service/tests/sensor.rs | New integration tests covering sensor retries, offset, sampling enable/disable, thresholds/hysteresis, and event fan-out. |
| thermal-service/tests/fan.rs | New integration tests covering fan auto-control state transitions, manual overrides, sampling averages, failure events, and event fan-out. |
| thermal-service/src/utils.rs | Adds unit tests for SampleBuf behavior (empty/default, average, eviction, accumulator width). |
| thermal-service/src/sensor.rs | Makes temperature_immediate() apply the configured offset, matching sampled temperature behavior. |
| thermal-service/Cargo.toml | Adds std/dev deps (tokio, embassy-* std features, critical-section/std) for the new tests. |
| Cargo.lock | Records the new dev-dependency additions for thermal-service. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
kurtjd
approved these changes
Aug 24, 2026
williampMSFT
approved these changes
Aug 24, 2026
jerrysxie
enabled auto-merge (squash)
August 24, 2026 19:02
RobertZ2011
approved these changes
Aug 24, 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.
Add new unit test to thermal service with the assistance of AI, discover 2 quirks in the thermal service behavior that needs some clarifications
sensor.rsfan.rsutils.rslib.rs