HLE: expand synthetic unit tests for apu.rs (1 -> 19 tests) #1212

Open
geiyiliyabumo wants to merge 1 commit from upstream-pr/1212 into main
geiyiliyabumo commented 2026-11-24 16:26:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T16:26:19Z.


Summary

Closes #1120

Full verification details and change notes are documented in #1120 (commit d10138b, based on main ffe310e).

 crates/victory-hle/src/modules/apu.rs | 679 ++++++++++++++++++++++++++++++++++
 1 file changed, 679 insertions(+)

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check on edited files: PASS
  • cargo xtask policy: PASS (zero game files/data)
  • cargo clippy --all-targets --locked -- -D warnings (default + --features diagnostics where applicable): PASS
  • Targeted & crate unit/GPU tests: PASS

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6586476385 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1212). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T16:26:19Z. --- ### Summary Closes #1120 Full verification details and change notes are documented in #1120 (commit `d10138b`, based on `main` `ffe310e`). ```text crates/victory-hle/src/modules/apu.rs | 679 ++++++++++++++++++++++++++++++++++ 1 file changed, 679 insertions(+) ``` ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check` on edited files: **PASS** - `cargo xtask policy`: **PASS** (zero game files/data) - `cargo clippy --all-targets --locked -- -D warnings` (default + `--features diagnostics` where applicable): **PASS** - Targeted & crate unit/GPU tests: **PASS** *AI-assisted; synthetic tests only, no game files.*
Zipettte commented 2026-11-24 18:06:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T17:59:59Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at d10138b: cargo test -p victory-hle passes, 113 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140009986 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1212#issuecomment-7140009986). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T17:59:59Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at d10138b: `cargo test -p victory-hle` passes, 113 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
mercuryVM commented 2026-11-24 19:02:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T18:11:21Z.

Review: APPROVED


Tested d10138b9 on Windows 11, RTX 5070, MSVC: cargo test -p victory-hle passes on the head (112 passed). The tests are synthetic: they exercise connect, activate, process and dequeue, and the ABI layouts, with encoded tones.

They read well. They don't merge into our fork, though: #1214 also appends tests to apu.rs, and it changed the channel-count check to run before decoding. Once one of these two lands upstream, the other needs a rebase, and any test here that expects the old error path should be checked against #1214's order.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6044807117 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1212#pullrequestreview-6044807117). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T18:11:21Z. **Review:** APPROVED --- Tested d10138b9 on Windows 11, RTX 5070, MSVC: `cargo test -p victory-hle` passes on the head (112 passed). The tests are synthetic: they exercise connect, activate, process and dequeue, and the ABI layouts, with encoded tones. They read well. They don't merge into our fork, though: #1214 also appends tests to `apu.rs`, and it changed the channel-count check to run before decoding. Once one of these two lands upstream, the other needs a rebase, and any test here that expects the old error path should be checked against #1214's order. AI-assisted (Claude Code).
upipibi commented 2026-11-24 21:03:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T20:33:42Z.


Duplicate check: this PR and #1137 have the same diff (681 changed lines, no differences) and commits by the same author (给伊莉雅补魔). Only one of the two needs review; the other can be closed.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7143734218 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1212#issuecomment-7143734218). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T20:33:42Z. --- Duplicate check: this PR and #1137 have the same diff (681 changed lines, no differences) and commits by the same author (给伊莉雅补魔). Only one of the two needs review; the other can be closed.
geiyiliyabumo commented 2026-11-24 21:28:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T21:07:16Z.


Thanks @upipibi for flagging this! Just to clarify provenance: this PR (#1212) is the original author PR (authored by geiyiliyabumo, already reviewed/approved by @mercuryVM). #1137 was opened by another account (@Vittorio17) using our commit from our fork branch, so #1212 is the canonical one to keep.

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7144502587 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1212#issuecomment-7144502587). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T21:07:16Z. --- Thanks @upipibi for flagging this! Just to clarify provenance: this PR (#1212) is the original author PR (authored by `geiyiliyabumo`, already reviewed/approved by @mercuryVM). #1137 was opened by another account (`@Vittorio17`) using our commit from our fork branch, so #1212 is the canonical one to keep. *AI-assisted; synthetic tests only, no game files.*
Marvisak commented 2026-11-25 02:05:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:18:53Z.


Automated triage for the maintainers.

Merge candidate. This PR only adds tests to crates/victory-hle/src/modules/apu.rs and leaves the production code alone. Each assertion agrees with XApuConnect, XApuEnqueueCommand, process, XApuDequeueResult and XApuGetResultCount in main. The tests cover the connect argument ranges, zeroed memory and the optional event, refused activations, first_frame/frame_count/output-room clamping, deinterleaved and mono output, BAD_PACKET, the decoder history reset, per-stream queue limits and the auto-reset result event. The decode checks compare against an independent OpusDecoder, not against the code's own output. One test pins E_NOTIMPL for other processing kinds, which main marks as a shortcut, so it will need updating if that shortcut is ever implemented. CI (check) passes.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149420736 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1212#issuecomment-7149420736). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:18:53Z. --- <!-- victory-triage v1 head=b9efa5e5be914628401f636b23cec3ad4a26ffd1 verdict=merge-candidate at=2026-11-25T03:23:00Z --> Automated triage for the maintainers. **Merge candidate.** This PR only adds tests to `crates/victory-hle/src/modules/apu.rs` and leaves the production code alone. Each assertion agrees with `XApuConnect`, `XApuEnqueueCommand`, `process`, `XApuDequeueResult` and `XApuGetResultCount` in `main`. The tests cover the connect argument ranges, zeroed memory and the optional event, refused activations, `first_frame`/`frame_count`/output-room clamping, deinterleaved and mono output, `BAD_PACKET`, the decoder history reset, per-stream queue limits and the auto-reset result event. The decode checks compare against an independent `OpusDecoder`, not against the code's own output. One test pins `E_NOTIMPL` for other processing kinds, which `main` marks as a shortcut, so it will need updating if that shortcut is ever implemented. CI (`check`) passes. --- _Generated by [Claude Code](https://claude.ai/code)_
geiyiliyabumo commented 2026-11-25 03:03:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-25T02:16:33Z.


Rebased cleanly onto \main\ (\ccfb029). \cargo test -p victory-hle --locked modules::apu::tests\ (20 passed, 0 failed), \cargo clippy -p victory-hle --all-targets --locked -- -D warnings, and \cargo xtask policy\ all pass.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150521978 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1212#issuecomment-7150521978). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-25T02:16:33Z. --- Rebased cleanly onto \main\ (\ccfb029\). \cargo test -p victory-hle --locked modules::apu::tests\ (20 passed, 0 failed), \cargo clippy -p victory-hle --all-targets --locked -- -D warnings\, and \cargo xtask policy\ all pass.
fuzeofficlal commented 2026-11-26 02:06:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:13:05Z.


Code review and Windows 11 verification at head b9efa5e5be91 merged cleanly onto main (63bcca43c6a0):

  • Code & isolation audit (crates/victory-hle/src/modules/apu.rs:419-846+):
    • All 18 new unit tests use purely synthetic sine-wave Opus packets (opus_pure::OpusEncoder vs reference OpusDecoder) and synthetic malformed packets, with no external paths or files.
    • Covers ABI layout, XApuConnect validation/alignment/zeroing, RESULT_EVENT auto-reset, Activate/ALREADY_ACTIVE, mono/stereo/planar decoding, clamping, Reset, per-stream FIFO/QUEUE_FULL, malformed packet handling, and XApuGetResultCount. Each test uses an isolated Fixture with Drop -> XApuDisconnect for clean parallel execution.
  • Verified (Windows 11, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy --locked -p victory-hle --tests -- -D warnings: 0 warnings
    • victory-hle -- apu: 21/21 passed; full victory-hle -- --test-threads=1: 170/170 lib + fidelityfx + no_dll_planting passed.

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179551031 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1212#issuecomment-7179551031). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T01:13:05Z. --- Code review and Windows 11 verification at head `b9efa5e5be91` merged cleanly onto `main` (`63bcca43c6a0`): - **Code & isolation audit (`crates/victory-hle/src/modules/apu.rs:419-846+`)**: - All 18 new unit tests use purely synthetic sine-wave Opus packets (`opus_pure::OpusEncoder` vs reference `OpusDecoder`) and synthetic malformed packets, with no external paths or files. - Covers ABI layout, `XApuConnect` validation/alignment/zeroing, `RESULT_EVENT` auto-reset, `Activate`/`ALREADY_ACTIVE`, mono/stereo/planar decoding, clamping, `Reset`, per-stream FIFO/`QUEUE_FULL`, malformed packet handling, and `XApuGetResultCount`. Each test uses an isolated `Fixture` with `Drop -> XApuDisconnect` for clean parallel execution. - **Verified (Windows 11, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy --locked -p victory-hle --tests -- -D warnings`: 0 warnings - `victory-hle -- apu`: **21/21 passed**; full `victory-hle -- --test-threads=1`: **170/170 lib + `fidelityfx` + `no_dll_planting`** passed. LGTM.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1212:upstream-pr/1212'
git switch 'upstream-pr/1212'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1212'
git switch 'upstream-pr/1212'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1212'
git switch 'upstream-pr/1212'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1212'
git switch 'main'
git merge --squash 'upstream-pr/1212'
git switch 'main'
git merge --ff-only 'upstream-pr/1212'
git switch 'main'
git merge 'upstream-pr/1212'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!1212
No description provided.