mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
test: add tests for main() argument handling
This test provides missing coverage for __wasi_args_get() and __wasi_args_sizes_get(), which translate to argc and argv in WASI applications. PR-URL: https://github.com/nodejs/node/pull/31426 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
10
test/wasi/c/main_args.c
Normal file
10
test/wasi/c/main_args.c
Normal file
@@ -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;
|
||||
}
|
||||
@@ -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'),
|
||||
@@ -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' });
|
||||
|
||||
BIN
test/wasi/wasm/main_args.wasm
Executable file
BIN
test/wasi/wasm/main_args.wasm
Executable file
Binary file not shown.
Reference in New Issue
Block a user