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

Open
opened 2026-11-26 04:14:09 +00:00 by github-bot · 1 comment
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 14:09 UTC · original

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.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 14:09 UTC · [original](https://github.com/Marvisak/VIctory/issues/919) ### 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.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:09 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:59 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 06:59 UTC · [original](https://github.com/Marvisak/VIctory/issues/919#issuecomment-7155374062) <!-- 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)_
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#919
No description provided.