diff --git a/test/run-wasi-test.py b/test/run-wasi-test.py index d642499..d5d3a9f 100755 --- a/test/run-wasi-test.py +++ b/test/run-wasi-test.py @@ -4,7 +4,7 @@ # Usage: # ./run-wasi-test.py # ./run-wasi-test.py --exec ../custom_build/wasm3 --timeout 120 -# ./run-wasi-test.py --exec "wasmer run" +# ./run-wasi-test.py --exec "wasmer run --dir=." # import argparse @@ -63,13 +63,13 @@ commands = [ { "name": "Simple WASI test", "wasm": "./wasi/test.wasm", - "args": ["args", "test"], - "expect_pattern": "Hello world*Constructor OK*Args: *; args; test;*fib(20) = 6765*[* ms]*=== done ===*" + "args": ["cat", "./wasi/0.txt"], + "expect_pattern": "Hello world*Constructor OK*Args: *; cat; ./wasi/0.txt;*fib(20) = 6765*[* ms]*48 65 6c 6c 6f 20 77 6f 72 6c 64*=== done ===*" }, { "name": "Simple WASI test (wasm-opt -O3)", "wasm": "./wasi/test-opt.wasm", - "args": ["args", "test"], - "expect_pattern": "Hello world*Constructor OK*Args: *; args; test;*fib(20) = 6765*[* ms]*=== done ===*" + "args": ["cat", "./wasi/0.txt"], + "expect_pattern": "Hello world*Constructor OK*Args: *; cat; ./wasi/0.txt;*fib(20) = 6765*[* ms]*48 65 6c 6c 6f 20 77 6f 72 6c 64*=== done ===*" }, { "name": "mandelbrot", "wasm": "./benchmark/mandelbrot/mandel.wasm", @@ -97,6 +97,7 @@ commands = [ "wasm": "./benchmark/stream/stream.wasm", "expect_pattern": "----*Solution Validates:*on all three arrays*----*" }, { + # TODO "if": { "file_exists": "./self-hosting/wasm3-fib.wasm" }, "name": "Self-hosting", "wasm": "./self-hosting/wasm3-fib.wasm", "expect_pattern": "wasm3 on WASM*Result: 832040*Elapsed: * ms*" diff --git a/test/wasi/test-opt.wasm b/test/wasi/test-opt.wasm index 443a9a0..db11c80 100644 Binary files a/test/wasi/test-opt.wasm and b/test/wasi/test-opt.wasm differ diff --git a/test/wasi/test.c b/test/wasi/test.c index 0ca6b34..8e72c2f 100644 --- a/test/wasi/test.c +++ b/test/wasi/test.c @@ -3,6 +3,9 @@ #include #include +#include +#include + /* * Helpers */ @@ -105,6 +108,20 @@ void test_perf_fib(uint32_t n) { printf("%d [%.3f ms]\n", result, fms); } +void test_cat(char* fn) { + int file = open(fn, O_RDONLY); + if (file >= 0) { + char c = 0; + while (read(file, &c, sizeof(c)) > 0) { + printf("%02x ", c); + } + close(file); + puts(""); + } else { + printf("Cannot open %s\n", fn); + } +} + /* * Main */ @@ -116,9 +133,13 @@ int main(int argc, char **argv) test_printf(); test_args(argc, argv); test_gettime(); - test_random(); + //test_random(); test_perf_fib(20); + if (0 == strcmp(argv[1], "cat")) { + test_cat(argv[2]); + } + puts("=== done ==="); return 0; } diff --git a/test/wasi/test.wasm b/test/wasi/test.wasm index a299332..e516740 100755 Binary files a/test/wasi/test.wasm and b/test/wasi/test.wasm differ