Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add zware-run to run wasm binaries from the command-line #231

Merged
merged 1 commit into from
Oct 20, 2024

Conversation

marler8997
Copy link
Contributor

An initial version of a command-line program that can take a WASM binary on the command line and a function name and execute it.

It will find missing imports and populate them with "stubs". The stub will log the call and then populate the results with "zeroed" values. An enhancement could be to take multiple files on the command line and link them together before execution.

A few examples of binaries I could use with this was:

  • binaries from the test suite
  • WASM4 binaries
  • the Zig wasm executable

Of the ones I tested this seems like a viable strategy to quickly run the binaries from the test suite. The WASM4/Zig binaries would usually just call a function or two and then hit an assert because of the "zeroed" results that are produced by the stubs.

@malcolmstill
Copy link
Owner

@marler8997 this looks really useful, thanks!

Would it be possible to move the src/cmdlinerunner.zig / zware-run into the tools/ directory? My intention for tools/ was to be the place to put binaries that depend on zware (or are otherwise useful, e.g. zware-gen) that someone consuming the library may use (where src/ is the more or less just the library part of zware and the binaries in tests/ are specific to testing the library).

It sounds to me then like zware-run fits within the intention of tools/?

Let me know what you think?

src/cmdlinerunner.zig Outdated Show resolved Hide resolved
An initial version of a command-line program that can take a WASM binary
on the command line and a function name and execute it.

It will find missing imports and populate them with "stubs". The stub will
log the call and then populate the results with "zeroed" values. An
enhancement could be to take multiple files on the command line and link
them together before execution.

A few examples of binaries I could use with this was:

   - binaries from the test suite
   - WASM4 binaries
   - the Zig wasm executable

Of the ones I tested this seems like a viable strategy to quickly run
the binaries from the test suite.  The WASM4/Zig binaries would usually
just call a function or two and then hit an assert because of the "zeroed"
results that are produced by the stubs.
@marler8997
Copy link
Contributor Author

Yeah putting this in the tools directory makes sense. I've gone ahead and moved it there.

@malcolmstill malcolmstill merged commit 3ad3f4e into malcolmstill:master Oct 20, 2024
16 checks passed
@malcolmstill
Copy link
Owner

Thanks @marler8997, merged!

@marler8997 marler8997 deleted the cmdlinerunner branch October 20, 2024 21:37
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.

2 participants