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

test: add tests for main() argument handling #31426

Merged
merged 1 commit into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/wasi/c/main_args.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <assert.h>
#include <string.h>

int main(int argc, char** argv) {
assert(argc == 3);
assert(0 == strcmp(argv[0], "foo"));
assert(0 == strcmp(argv[1], "-bar"));
assert(0 == strcmp(argv[2], "--baz=value"));
return 0;
}
3 changes: 2 additions & 1 deletion test/wasi/test-wasi.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (process.argv[2] === 'wasi-child') {
tmpdir.refresh();
const wasmDir = path.join(__dirname, 'wasm');
const wasi = new WASI({
args: [],
args: ['foo', '-bar', '--baz=value'],
env: process.env,
preopens: {
'/sandbox': fixtures.path('wasi'),
Expand Down Expand Up @@ -64,6 +64,7 @@ if (process.argv[2] === 'wasi-child') {
runWASI({ test: 'getentropy' });
runWASI({ test: 'getrusage' });
runWASI({ test: 'gettimeofday' });
runWASI({ test: 'main_args' });
runWASI({ test: 'notdir' });
// runWASI({ test: 'poll' });
runWASI({ test: 'preopen_populates' });
Expand Down
Binary file added test/wasi/wasm/main_args.wasm
Binary file not shown.