Skip to content

test(tools): round trip between texpack build and the runtime pack reader - #64

Merged
github-actions[bot] merged 2 commits into
masterfrom
chore/texpack-roundtrip-56
Nov 5, 2026
Merged

github-actions[bot] merged 2 commits into
masterfrom
chore/texpack-roundtrip-56

Conversation

@endercodezz

Copy link
Copy Markdown
Owner

The New 3DS texture pack format is written in Rust (tools/texpack/src/build.rs) and read in C++ (core/src/ge/texture_pack.cpp). This adds a CTest round trip so the two sides can't drift apart unnoticed.

  • p3p_texpack_build_rgba8 / p3p_texpack_build_auto (CTest fixture setup) run p3p-texpack build on tools/texpack/tests/fixtures, using the new textures.ini there: four synthetic images plus a keep-original entry.
  • p3p_texpack_roundtrip (tests/test_texture_pack_roundtrip.cpp) reads both packs with the runtime's TexturePack. It checks entry count, flags, sizes, format codes and alignment, and compares every texel with the fixture formulas after the format's rules (alpha 0 -> transparent black, truncation, bit expansion).
  • Registered only when CMake finds cargo, run from tools/texpack so the pinned toolchain and build directory apply. Linux CI has cargo; the MSYS2 Windows job skips it.

Verified (Windows): CTest 31/31, cargo test 14/14. Three deliberate format changes each made the test fail, then were reverted:

  • no row flip in build.rs: every RGBA8 texel differs;
  • RGB565 green bits moved in pica.rs: RGB565 entries differ;
  • width read from the height field in texture_pack.cpp: the pack is rejected as invalid.

Closes #63

…ader

The New 3DS texture pack format is written in Rust and read in C++.
CTest now builds two packs from the texpack fixtures with
`p3p-texpack build` (RGBA8 and the automatic format) and reads them with
the runtime's TexturePack, comparing every texel with the fixture
formulas. The test is registered when CMake finds cargo.

Verified: CTest 31/31, cargo test 14/14. Removing the row flip in
build.rs, moving the RGB565 green bits in pica.rs, and reading the width
from the height field in texture_pack.cpp each made the test fail.
@github-actions
github-actions Bot enabled auto-merge November 5, 2026 21:33
On a fresh Linux runner both setup tests ran in parallel and each
installed the pinned Rust toolchain through rustup; rustup's downloads
raced ("could not rename 'downloaded' file") and p3p_texpack_build_auto
failed. A shared RESOURCE_LOCK keeps the two cargo runs sequential.

Verified: CTest -j6 runs them one after another, 31/31 pass.
@endercodezz

Copy link
Copy Markdown
Owner Author

Linux CI failed in p3p_texpack_build_auto: both round-trip setup tests installed the pinned Rust toolchain through rustup at the same time and rustup's download raced (could not rename 'downloaded' file). Fixed by a shared RESOURCE_LOCK so the two cargo runs are sequential.

@github-actions
github-actions Bot merged commit 1aada75 into master Nov 5, 2026
6 checks passed
@endercodezz
endercodezz deleted the chore/texpack-roundtrip-56 branch November 6, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests: round trip between texpack build (Rust) and the runtime pack reader (C++)

1 participant