GPU: guard non-positive frames and add unit tests for copystat.rs #919

Open
opened 2026-11-24 14:09:56 +00:00 by geiyiliyabumo · 1 comment
geiyiliyabumo commented 2026-11-24 14:09:56 +00:00 (Migrated from github.com)
Contributor

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T14:09:56Z.


Summary

Adds 5 deterministic unit tests for crates/victory-gpu/src/copystat.rs (previously 0 tests) and guards log(frames) against zero/non-finite frame counts so per-frame divisions never emit NaN/inf.

Because external PR creation is currently restricted (collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:

  • Branch: geiyiliyabumo/VIctory@test/gpu-copystat-tests
  • Commit: geiyiliyabumo/VIctory@6765a7b (based on main ffe310e)

Changes (crates/victory-gpu/src/copystat.rs)

  • Extracted parse_mode(Option<&str>) -> u8 for deterministic VICTORY_COPY_MODE parsing without mutating process env.
  • Guarded log(frames: f64) to clamp non-positive / non-finite frames to 1.0.
  • Added 5 unit tests under copystat::tests:
    • counter_enum_matches_array_length
    • parse_mode_maps_known_and_unknown_values
    • range_accumulates_same_key_and_separates_distinct_ranges
    • add_and_log_drain_counters_and_ranges
    • page_faults_queries_current_process

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check crates/victory-gpu/src/copystat.rs: PASS
  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings (default + --features diagnostics): PASS (0 warnings)
  • cargo test -p victory-gpu --features diagnostics --locked -- copystat::: 5 passed, 0 failed

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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6583681182 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/919). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T14:09:56Z. --- ### Summary Adds 5 deterministic unit tests for `crates/victory-gpu/src/copystat.rs` (previously 0 tests) and guards `log(frames)` against zero/non-finite frame counts so per-frame divisions never emit `NaN`/`inf`. Because external PR creation is currently restricted (`collaborators_only`), the CI-green branch is ready on my fork for cherry-pick / review: - **Branch**: `geiyiliyabumo/VIctory@test/gpu-copystat-tests` - **Commit**: `geiyiliyabumo/VIctory@6765a7b` (based on `main` `ffe310e`) ### Changes (`crates/victory-gpu/src/copystat.rs`) - Extracted `parse_mode(Option<&str>) -> u8` for deterministic `VICTORY_COPY_MODE` parsing without mutating process env. - Guarded `log(frames: f64)` to clamp non-positive / non-finite `frames` to `1.0`. - Added 5 unit tests under `copystat::tests`: - `counter_enum_matches_array_length` - `parse_mode_maps_known_and_unknown_values` - `range_accumulates_same_key_and_separates_distinct_ranges` - `add_and_log_drain_counters_and_ranges` - `page_faults_queries_current_process` ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check crates/victory-gpu/src/copystat.rs`: **PASS** - `cargo xtask policy`: **PASS** (`154 files ok`) - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` (default + `--features diagnostics`): **PASS** (0 warnings) - `cargo test -p victory-gpu --features diagnostics --locked -- copystat::`: **5 passed, 0 failed** *AI-assisted; synthetic tests only, no game files.*
Marvisak commented 2026-11-25 07:03:31 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T06:59:43Z.


Automated triage for the maintainers.

The pull request for this branch, #1188, was reviewed and closed: on current main its counter_enum_matches_array_length test fails (the counter list in crates/victory-gpu/src/copystat.rs has grown), and the guard in log protects an f64 division, which cannot panic (a zero frame count gives inf/NaN in a log line, nothing worse). If you still want these tests, a rebased PR against current main is welcome; whether to take them is for the maintainers.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7155374062 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/919#issuecomment-7155374062). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T06:59:43Z. --- <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-24T14:09:56Z at=2026-11-25T06:59:43Z --> Automated triage for the maintainers. The pull request for this branch, #1188, was reviewed and closed: on current `main` its `counter_enum_matches_array_length` test fails (the counter list in `crates/victory-gpu/src/copystat.rs` has grown), and the guard in `log` protects an `f64` division, which cannot panic (a zero frame count gives `inf`/`NaN` in a log line, nothing worse). If you still want these tests, a rebased PR against current `main` is welcome; whether to take them is for the maintainers. --- _Generated by [Claude Code](https://claude.ai/code)_
Sign in to join this conversation.
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#919
No description provided.