test: add comprehensive unit tests for write_wide_out #1245

Open
Ayoub-devv wants to merge 2 commits from upstream-pr/1255 into main
Ayoub-devv commented 2026-11-24 13:47:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Ayoub-devv on 2026-11-24T13:47:41Z.


What is in it

Adds 5 new unit tests for the write_wide_out helper in util.rs, covering:

  • null pointer / zero-size buffer (no crash, returns 0)
  • exact-fit buffer (correct length, null-terminated, no error)
  • truncation (returns size, null-terminated at size-1, sets ERROR_INSUFFICIENT_BUFFER)
  • oversized buffer (correct length, null-terminated)
  • empty string (returns 0, buffer contains only NUL)

This function is used by kernelx and previously had no direct test coverage.

Tested

  • hardware: Windows 10 x64, Rust stable-x86_64-pc-windows-msvc
  • cargo test util -- --test-threads=4: 10 passed; 0 failed; 0 ignored; 0 measured; 714 filtered out
    (5 new tests + 5 existing util tests, all ok in 0.01s)

Regression run

Not needed — this PR changes only crates/xcl/src/util.rs inside a #[cfg(test)] mod tests block. No runtime code is modified.

Not tested

  • (N/A, test-only change)

AI use

  • GitHub Copilot (frontier model) assisted with test generation from a specification prompt; all tests reviewed and verified manually against the function's documented behavior.
<!-- greyfinch-sync:ivall/xcl:issue:5473378764 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1255). Originally posted by [Ayoub-devv](https://github.com/Ayoub-devv) on 2026-11-24T13:47:41Z. --- **What is in it** Adds 5 new unit tests for the `write_wide_out` helper in `util.rs`, covering: - null pointer / zero-size buffer (no crash, returns 0) - exact-fit buffer (correct length, null-terminated, no error) - truncation (returns `size`, null-terminated at `size-1`, sets ERROR_INSUFFICIENT_BUFFER) - oversized buffer (correct length, null-terminated) - empty string (returns 0, buffer contains only NUL) This function is used by `kernelx` and previously had no direct test coverage. **Tested** - hardware: Windows 10 x64, Rust stable-x86_64-pc-windows-msvc - `cargo test util -- --test-threads=4`: 10 passed; 0 failed; 0 ignored; 0 measured; 714 filtered out (5 new tests + 5 existing util tests, all ok in 0.01s) **Regression run** Not needed — this PR changes only `crates/xcl/src/util.rs` inside a `#[cfg(test)] mod tests` block. No runtime code is modified. **Not tested** - (N/A, test-only change) **AI use** - GitHub Copilot (frontier model) assisted with test generation from a specification prompt; all tests reviewed and verified manually against the function's documented behavior.
copilot-pull-request-reviewer[bot] commented 2026-11-24 13:47:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-24T13:47:58Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:ivall/xcl:review:6040343121 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1255#pullrequestreview-6040343121). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-24T13:47:58Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Ayoub-devv commented 2026-11-24 14:06:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Ayoub-devv on 2026-11-24T13:54:59Z.


Hi maintainers — this diff only adds a #[cfg(test)] mod tests block to crates/xcl/src/util.rs; no runtime code is changed. The PR-description check flags it as a runtime change because the file lives under src/, but every added line is inside the test module. Could a maintainer approve the workflow run and, if appropriate, apply the test-only label so the smoke requirement is waived per #452? Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7133529272 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1255#issuecomment-7133529272). Originally posted by [Ayoub-devv](https://github.com/Ayoub-devv) on 2026-11-24T13:54:59Z. --- Hi maintainers — this diff only adds a `#[cfg(test)] mod tests` block to `crates/xcl/src/util.rs`; no runtime code is changed. The PR-description check flags it as a runtime change because the file lives under `src/`, but every added line is inside the test module. Could a maintainer approve the workflow run and, if appropriate, apply the test-only label so the smoke requirement is waived per #452? Thanks!
DavidM1911 commented 2026-11-24 14:06:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T14:02:11Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib lib util: 10 passed, 0 failed.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7133732133 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1255#issuecomment-7133732133). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T14:02:11Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - cargo test -p xcl --lib lib util: 10 passed, 0 failed. Thanks!
Toons29 commented 2026-11-25 04:10:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:19:44Z.


Regression run of 5e78ffe6 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 5e78ffe6b96371eb38e3e1c08030173ef3521b26
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1627 (PresentX 1627)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14812 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7151810930 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1255#issuecomment-7151810930). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-25T03:19:44Z. --- Regression run of `5e78ffe6` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 5e78ffe6b96371eb38e3e1c08030173ef3521b26 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1627 (PresentX 1627) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14812 MB ``` Against the limits in CONTRIBUTING.md: 101 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
DavidM1911 commented 2026-11-26 05:05:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T04:40:49Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7182807476 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1255#issuecomment-7182807476). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T04:40:49Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
github-actions[bot] commented 2026-12-01 02:31:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:31:39Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7298711703 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1255#issuecomment-7298711703). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-12-01T02:31:39Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 05:15:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:15:23Z.


Triage (#1607) – head 5e78ffe

No other open PR adds tests for write_wide_out. #1200 changes its zero-size behaviour (sets ERROR_INSUFFICIENT_BUFFER); test_null_or_zero_size here checks only the return value and buffer, so it stays compatible with that change.
The branch contains a merge commit from the fork's main (5e78ffe, with the default merge message); it should be rebased away, and the commit subject should use the repo's Tests: prefix instead of test:.
The PR description check is failing.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301579257 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1255#issuecomment-7301579257). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:15:23Z. --- **Triage (#1607)** – head 5e78ffe No other open PR adds tests for `write_wide_out`. #1200 changes its zero-size behaviour (sets ERROR_INSUFFICIENT_BUFFER); `test_null_or_zero_size` here checks only the return value and buffer, so it stays compatible with that change. The branch contains a merge commit from the fork's main (5e78ffe, with the default merge message); it should be rebased away, and the commit subject should use the repo's `Tests:` prefix instead of `test:`. The PR description check is failing. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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/1255:upstream-pr/1255'
git switch 'upstream-pr/1255'

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/1255'
git switch 'upstream-pr/1255'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1255'
git switch 'upstream-pr/1255'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1255'
git switch 'main'
git merge --squash 'upstream-pr/1255'
git switch 'main'
git merge --ff-only 'upstream-pr/1255'
git switch 'main'
git merge 'upstream-pr/1255'
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
xcl-dev/xcl!1245
No description provided.