Skip to content

PE tests: read a synthetic import library so ImportLibrary is covered - #268

Closed
SkippySteve wants to merge 1 commit into
Marvisak:mainfrom
SkippySteve:SkippySteve/victory-pr-own-next9
Closed

SkippySteve wants to merge 1 commit into
Marvisak:mainfrom
SkippySteve:SkippySteve/victory-pr-own-next9

Conversation

@SkippySteve

Copy link
Copy Markdown

crates/victory-pe/src/implib.rs (the reader behind victory lib-exports) had no tests. This adds two. Each builds an in-memory !<arch> archive of short-format import objects, so the tests need no SDK .lib and no game data and run on every host.

  • reads_short_imports_sorted_and_deduplicated: covers each name type: by name, no-prefix (_Prefixed → Prefixed), undecorated (_Stdcall@8 → Stdcall) and by ordinal. Each export keeps its code/data/const kind. The output is sorted. A repeat of an export under a different hint becomes one entry, because the hint is not part of the key. A member that is not a short import object is counted in other_members instead of being dropped.
  • rejects_what_is_not_an_archive: a file that is not an archive returns an error, and an empty archive has no imports.

This is a test-only change; no library code changes.

Testing on Linux:

  • cargo test -p victory-pe implib: 2 passed.
  • cargo clippy -p victory-pe --all-targets -- -D warnings: clean.
  • cargo fmt --check: clean.
  • cargo xtask policy: ok.

The other four image::tests failures under cargo test -p victory-pe on Linux already fail on main, because those tests parse the host test binary as a PE. #257 deals with them, and this PR does not touch them.

implib.rs, the reader behind `victory lib-exports`, had no tests. Two are
added, built from an in-memory `!<arch>` archive of short-format import
objects (no SDK .lib, no game data), so they run on every host:

- every name type maps to the export the linker would bind (by name,
  no-prefix, undecorated, by ordinal), with its code/data/const kind;
- the result is sorted, and a repeat of an export under another hint is
  one entry (the hint is not part of the key);
- a member that is not a short import object is counted in
  other_members rather than dropped;
- a file that is not an archive is an error, an empty archive has no
  imports.
@SkippySteve

Copy link
Copy Markdown
Author

superseded by #287 (combined PE/loader hermetic synthetic tests)

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.

1 participant