Repository navigation
PE tests: parse a synthetic image so ImageInfo is covered on every host - #257
Closed
SkippySteve wants to merge 1 commit into
Closed
SkippySteve wants to merge 1 commit into
SkippySteve wants to merge 1 commit into
Conversation
The ImageInfo unit tests that read imports, TLS and section mapping parse the test binary itself, which is a PE only on Windows. Add an integration test that builds a small PE32+ executable in memory (one section, a KERNEL32.dll import by name and by ordinal, two TLS callbacks) and checks headers, sections, imports and their IAT slots, TLS callback order, rva_to_file_offset (padding past the virtual size, the 4 GiB limit), an IAT running outside the image, other machines and truncated input. No game data or files on disk.
|
Independent validation on Debian 13 (Trixie). I tested this PR locally with the following results:
One note: workspace-wide No game data or external fixtures were used. Thanks for the contribution! |
Author
|
superseded by #287 (combined PE/loader hermetic synthetic tests) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
ImageInfounit tests invictory-pethat cover imports, TLS and section mapping parse the test binary itself. That binary is a PE only on Windows, so on Linux they fail withUnknown file magic, and #235 limits them to Windows. This PR adds coverage that runs on every host and doesn't touch those tests or any non-test code.What it adds
crates/victory-pe/tests/synthetic_image.rsbuilds a small PE32+ executable in memory: one section, aKERNEL32.dllimport by name (with a hint) and by ordinal, and two TLS callbacks. It checks:rva_to_file_offset: section data maps correctly, headers and the section end don't map, raw padding past the virtual size isn't section data, and an offset near 4 GiB doesn't wrapSizeOfImage, including at the 4 GiB limit, is reported asMalformedUnsupported, and truncated input errors without panickingThe image is built byte by byte in the test. No game data, fixtures or files on disk.
Testing
On Arch Linux (x86_64-unknown-linux-gnu):
cargo test -p victory-pe --test synthetic_image: 8 passedcargo clippy -p victory-pe --all-targets -- -D warnings,cargo fmt --checkandcargo xtask policyare cleanimage.rs: the IAT bound, the virtual-size clamp and the TLS null terminator. Each one made a test fail.cargo test -p victory-peon Linux still shows the 4 existing own-binary failures frommain. #235 handles those. I haven't run this on Windows; the new file uses only the public API and doesn't depend on the host.