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

Closed
Vittorio17 wants to merge 1 commit from upstream-pr/1137 into main
Vittorio17 commented 2026-11-24 16:07:16 +00:00 (Migrated from github.com)

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


Summary

Audits crates/victory-hle/src/modules/apu.rs and expands its deterministic synthetic unit tests from 1 to 19 passing tests. Packets are synthetic two-tone Opus streams encoded at test time via opus_pure, so there are no fixtures and no game data. Production code is unchanged.

Closes #1120.

Tests added

  • Connect validation matrix: null arguments, streams 0/501, commands_per_stream 0/17, memory 0, frames_per_output, E_NOTIMPL, and both accepted range endpoints.
  • Connect memory and event: 16-byte-aligned zeroed memory, and the result event created only when requested.
  • Activation: rejected channel counts leave the stream idle, ALREADY_ACTIVE on a second activation, mono and stereo streams.
  • Decode: determinism against a fresh decoder, first_frame and output-room clamping, planar DEINTERLEAVED_OUTPUT, mono output and stereo-to-mono downmix.
  • Process errors: null/empty input and output buffers, and BAD_PACKET leaving the title buffer untouched.
  • Commands: RESET restores initial decoder state; one result per command in order; per-stream QUEUE_FULL and slot release on dequeue; rejected commands leave no result behind.
  • Results: identity echo, PENDING_RESULTS, null arguments on every export, and SIGNAL/auto-reset event behaviour.
  • ABI: the console's structure sizes.

Verification (Windows 11 x64 MSVC, Rust 1.98.1)

  • rustfmt --edition 2024 --check crates/victory-hle/src/modules/apu.rs: PASS
  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: PASS (0 warnings)
  • cargo clippy -p victory-hle --all-targets --locked --features diagnostics -- -D warnings: PASS (0 warnings)
  • cargo test -p victory-hle --locked -- "modules::apu::tests": 19 passed, 0 failed

Cherry-picked from geiyiliyabumo/VIctory@d10138b (branch test/hle-apu-audit), as suggested in the issue.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6586105651 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1137). Originally posted by [Vittorio17](https://github.com/Vittorio17) on 2026-11-24T16:07:16Z. --- ## Summary Audits `crates/victory-hle/src/modules/apu.rs` and expands its deterministic synthetic unit tests from 1 to 19 passing tests. Packets are synthetic two-tone Opus streams encoded at test time via `opus_pure`, so there are no fixtures and no game data. Production code is unchanged. Closes #1120. ## Tests added - **Connect validation matrix**: null arguments, streams 0/501, commands_per_stream 0/17, memory 0, frames_per_output, E_NOTIMPL, and both accepted range endpoints. - **Connect memory and event**: 16-byte-aligned zeroed memory, and the result event created only when requested. - **Activation**: rejected channel counts leave the stream idle, `ALREADY_ACTIVE` on a second activation, mono and stereo streams. - **Decode**: determinism against a fresh decoder, `first_frame` and output-room clamping, planar `DEINTERLEAVED_OUTPUT`, mono output and stereo-to-mono downmix. - **Process errors**: null/empty input and output buffers, and `BAD_PACKET` leaving the title buffer untouched. - **Commands**: `RESET` restores initial decoder state; one result per command in order; per-stream `QUEUE_FULL` and slot release on dequeue; rejected commands leave no result behind. - **Results**: identity echo, `PENDING_RESULTS`, null arguments on every export, and `SIGNAL`/auto-reset event behaviour. - **ABI**: the console's structure sizes. ## Verification (Windows 11 x64 MSVC, Rust 1.98.1) - `rustfmt --edition 2024 --check crates/victory-hle/src/modules/apu.rs`: PASS - `cargo xtask policy`: PASS (154 files ok) - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: PASS (0 warnings) - `cargo clippy -p victory-hle --all-targets --locked --features diagnostics -- -D warnings`: PASS (0 warnings) - `cargo test -p victory-hle --locked -- "modules::apu::tests"`: 19 passed, 0 failed Cherry-picked from `geiyiliyabumo/VIctory@d10138b` (branch `test/hle-apu-audit`), as suggested in the issue.
Zipettte commented 2026-11-24 18:06:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:01:26Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 7d94b72: 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:7140045287 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1137#issuecomment-7140045287). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T18:01:26Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 7d94b72: `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)._
upstream-sync closed this pull request 2026-11-25 01:05:40 +00:00
Marvisak commented 2026-11-25 01:08:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:32:51Z.


Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #1212.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148621101 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1137#issuecomment-7148621101). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:32:51Z. --- Automated triage for the maintainers. Closing because another open pull request covers the same change. See #1212. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

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!1137
No description provided.