From ca50074a64fa8deea7b7d3b9a00e83e362fb31be Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Tue, 24 Sep 2024 15:58:26 -0700 Subject: [PATCH 1/3] chore(*) isolate test suites by Wasm target * Remove WASI spillover from test crates compatible with the `wasm32-unknown-unknown` target. * Default all tests crates to compile `wasm32-wasip1` targets. * Can set `TEST_NGINX_CARGO_RUSTTARGET` to override. * Cleanup build tests framework. * CI: add a job with `wasm32-unknown-unknown` target. --- .github/workflows/ci.yml | 14 +- .github/workflows/job-unit-tests.yml | 11 ++ Makefile | 2 +- t/01-wasm/hfuncs/wasi/000-non_host_wasi.t | 2 + t/01-wasm/hfuncs/wasi/001-random_get.t | 2 + t/01-wasm/hfuncs/wasi/002-environ_sizes_get.t | 2 + t/01-wasm/hfuncs/wasi/003-environ_get.t | 2 + t/01-wasm/hfuncs/wasi/004-clock_time_get.t | 2 + t/01-wasm/hfuncs/wasi/005-args_sizes_get.t | 2 + t/01-wasm/hfuncs/wasi/006-args_get.t | 2 + t/01-wasm/hfuncs/wasi/007-fd_write.t | 2 + t/01-wasm/hfuncs/wasi/008-fd_close.t | 2 + t/01-wasm/hfuncs/wasi/009-fd_fdstat_get.t | 2 + t/01-wasm/hfuncs/wasi/010-fd_prestat_get.t | 2 + .../hfuncs/wasi/011-fd_prestat_dir_name.t | 2 + t/01-wasm/hfuncs/wasi/012-fd_read.t | 2 + t/01-wasm/hfuncs/wasi/013-fd_seek.t | 2 + t/01-wasm/hfuncs/wasi/014-path_open.t | 2 + .../hfuncs/101-proxy_get_current_time.t | 2 +- t/10-build/001-build_options.t | 2 +- t/10-build/002-runtime_linking.t | 2 +- t/10-build/003-dynamic_module.t | 2 +- t/10-build/004-ngx_wasm_rs_linking.t | 2 +- t/TestBuild.pm | 9 + t/TestWasmX.pm | 7 + t/lib/Cargo.lock | 184 +----------------- t/lib/ngx-rust-tests/Cargo.toml | 1 - t/lib/proxy-wasm-tests/hostcalls/Cargo.toml | 1 - .../hostcalls/src/tests/mod.rs | 5 +- util/test.sh | 10 +- 30 files changed, 86 insertions(+), 198 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c91fdf3b0..f3ccd2622 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,6 +65,17 @@ jobs: ssl: ssl debug: debug hup: no_hup + # wasm32-unknown-unknown + - runtime: wasmtime + wasmtime: 23.0.2 + os: ubuntu-latest + cc: gcc-12 + ngx: 1.27.1 + ipc: no_ipc + ssl: no_ssl + debug: debug + hup: no_hup + wasm_target: wasm32-unknown-unknown # Old Nginx - label: old_nginx os: ubuntu-latest @@ -146,6 +157,7 @@ jobs: ssl: ${{ matrix.ssl }} debug: ${{ matrix.debug }} hup: ${{ matrix.hup }} + wasm_target: ${{ matrix.wasm_target }} module_type: ${{ matrix.module_type }} coverage: true secrets: inherit @@ -162,7 +174,7 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} parallel-finished: true - carryforward: 'unit-ngx_1.27.1-wasmer-no_ipc-ssl-debug-no_hup-static,unit-ngx_1.27.1-wasmer-no_ipc-ssl-no_debug-no_hup-static,unit-ngx_1.27.1-wasmtime-no_ipc-ssl-debug-hup-static,unit-ngx_1.27.1-wasmtime-no_ipc-ssl-debug-hup-dynamic,unit-ngx_1.27.1-v8-no_ipc-ssl-debug-no_hup-static,unit-ngx_1.21.6-wasmer-no_ipc-ssl-debug-no_hup-static,unit-ngx_1.27.1-wasmer-no_ipc-no_ssl-no_debug-no_hup-static,unit-openresty_1.25.3.2-wasmtime-no_ipc-ssl-debug-no_hup-static,unit-openresty_1.25.3.2-wasmtime-no_ipc-ssl-debug-no_hup-dynamic,unit-ngx_1.27.1-wasmtime-ipc-no_ssl-debug-no_hup-static' + carryforward: 'unit-ngx_1.27.1-wasmer-no_ipc-ssl-debug-no_hup-static,unit-ngx_1.27.1-wasmer-no_ipc-ssl-no_debug-no_hup-static,unit-ngx_1.27.1-wasmtime-no_ipc-ssl-debug-hup-static,unit-ngx_1.27.1-wasmtime-no_ipc-ssl-debug-hup-dynamic,unit-ngx_1.27.1-v8-no_ipc-ssl-debug-no_hup-static,unit-ngx_1.27.1-wasmtime-no_ipc-no_ssl-debug-no_hup-static-wasm32-unknown-unknown,unit-ngx_1.21.6-wasmer-no_ipc-ssl-debug-no_hup-static,unit-ngx_1.27.1-wasmer-no_ipc-no_ssl-no_debug-no_hup-static,unit-openresty_1.25.3.2-wasmtime-no_ipc-ssl-debug-no_hup-static,unit-openresty_1.25.3.2-wasmtime-no_ipc-ssl-debug-no_hup-dynamic,unit-ngx_1.27.1-wasmtime-ipc-no_ssl-debug-no_hup-static' valgrind: name: 'Valgrind' diff --git a/.github/workflows/job-unit-tests.yml b/.github/workflows/job-unit-tests.yml index 70d2037d1..b825bea76 100644 --- a/.github/workflows/job-unit-tests.yml +++ b/.github/workflows/job-unit-tests.yml @@ -39,6 +39,9 @@ on: hup: required: true type: string + wasm_target: + required: false + type: string module_type: required: true type: string @@ -64,6 +67,7 @@ env: TEST_NGINX_TIMEOUT: 60 TEST_NGINX_EXTERNAL_TIMEOUT: 60s TEST_NGINX_EXTERNAL_RESOLVER: 127.0.0.1:8053 + TEST_NGINX_CARGO_RUSTTARGET: ${{ inputs.wasm_target }} jobs: tests: @@ -103,6 +107,10 @@ jobs: uses: dtolnay/rust-toolchain@stable with: target: wasm32-wasip1 + - name: Add wasm32-unknown-unknown target + if: ${{ inputs.wasm_target == 'wasm32-unknown-unknown' }} + run: | + rustup target add wasm32-unknown-unknown - name: Setup Go if: ${{ !env.ACT }} uses: actions/setup-go@v5 @@ -170,6 +178,9 @@ jobs: else name="$name-static" fi + if [ -n "${{ inputs.wasm_target }}" ]; then + name="$name-${{ inputs.wasm_target }}" + fi echo "name=$name" >> $GITHUB_OUTPUT - name: Coveralls Upload if: ${{ !env.ACT && inputs.coverage }} diff --git a/Makefile b/Makefile index 50cc8dc26..166e3f0be 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ setup: .PHONY: test test: - @util/test.sh t/0* + @util/test.sh t/ .PHONY: test-build test-build: diff --git a/t/01-wasm/hfuncs/wasi/000-non_host_wasi.t b/t/01-wasm/hfuncs/wasi/000-non_host_wasi.t index 1ed456625..8e6a1112a 100644 --- a/t/01-wasm/hfuncs/wasi/000-non_host_wasi.t +++ b/t/01-wasm/hfuncs/wasi/000-non_host_wasi.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + our $nginxV = $t::TestWasmX::nginxV; plan_tests(4); diff --git a/t/01-wasm/hfuncs/wasi/001-random_get.t b/t/01-wasm/hfuncs/wasi/001-random_get.t index c4fd6eb16..0689dfc62 100644 --- a/t/01-wasm/hfuncs/wasi/001-random_get.t +++ b/t/01-wasm/hfuncs/wasi/001-random_get.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/01-wasm/hfuncs/wasi/002-environ_sizes_get.t b/t/01-wasm/hfuncs/wasi/002-environ_sizes_get.t index d7814e6f4..b58cac71a 100644 --- a/t/01-wasm/hfuncs/wasi/002-environ_sizes_get.t +++ b/t/01-wasm/hfuncs/wasi/002-environ_sizes_get.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/01-wasm/hfuncs/wasi/003-environ_get.t b/t/01-wasm/hfuncs/wasi/003-environ_get.t index 55f9163da..de0d3ec7e 100644 --- a/t/01-wasm/hfuncs/wasi/003-environ_get.t +++ b/t/01-wasm/hfuncs/wasi/003-environ_get.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/01-wasm/hfuncs/wasi/004-clock_time_get.t b/t/01-wasm/hfuncs/wasi/004-clock_time_get.t index 20908d7e9..131ce3448 100644 --- a/t/01-wasm/hfuncs/wasi/004-clock_time_get.t +++ b/t/01-wasm/hfuncs/wasi/004-clock_time_get.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/01-wasm/hfuncs/wasi/005-args_sizes_get.t b/t/01-wasm/hfuncs/wasi/005-args_sizes_get.t index 8b2a3cb3a..deb710c99 100644 --- a/t/01-wasm/hfuncs/wasi/005-args_sizes_get.t +++ b/t/01-wasm/hfuncs/wasi/005-args_sizes_get.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/01-wasm/hfuncs/wasi/006-args_get.t b/t/01-wasm/hfuncs/wasi/006-args_get.t index e2f5600a2..3397c2e17 100644 --- a/t/01-wasm/hfuncs/wasi/006-args_get.t +++ b/t/01-wasm/hfuncs/wasi/006-args_get.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/01-wasm/hfuncs/wasi/007-fd_write.t b/t/01-wasm/hfuncs/wasi/007-fd_write.t index ecfe5a0e4..383c8c576 100644 --- a/t/01-wasm/hfuncs/wasi/007-fd_write.t +++ b/t/01-wasm/hfuncs/wasi/007-fd_write.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/01-wasm/hfuncs/wasi/008-fd_close.t b/t/01-wasm/hfuncs/wasi/008-fd_close.t index 8fca9a49a..22897526c 100644 --- a/t/01-wasm/hfuncs/wasi/008-fd_close.t +++ b/t/01-wasm/hfuncs/wasi/008-fd_close.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/01-wasm/hfuncs/wasi/009-fd_fdstat_get.t b/t/01-wasm/hfuncs/wasi/009-fd_fdstat_get.t index af00db446..911c7d192 100644 --- a/t/01-wasm/hfuncs/wasi/009-fd_fdstat_get.t +++ b/t/01-wasm/hfuncs/wasi/009-fd_fdstat_get.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/01-wasm/hfuncs/wasi/010-fd_prestat_get.t b/t/01-wasm/hfuncs/wasi/010-fd_prestat_get.t index e9744f316..cc608ad15 100644 --- a/t/01-wasm/hfuncs/wasi/010-fd_prestat_get.t +++ b/t/01-wasm/hfuncs/wasi/010-fd_prestat_get.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/01-wasm/hfuncs/wasi/011-fd_prestat_dir_name.t b/t/01-wasm/hfuncs/wasi/011-fd_prestat_dir_name.t index bc643ca83..81ed0f854 100644 --- a/t/01-wasm/hfuncs/wasi/011-fd_prestat_dir_name.t +++ b/t/01-wasm/hfuncs/wasi/011-fd_prestat_dir_name.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/01-wasm/hfuncs/wasi/012-fd_read.t b/t/01-wasm/hfuncs/wasi/012-fd_read.t index 1efe44e8d..08673deed 100644 --- a/t/01-wasm/hfuncs/wasi/012-fd_read.t +++ b/t/01-wasm/hfuncs/wasi/012-fd_read.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/01-wasm/hfuncs/wasi/013-fd_seek.t b/t/01-wasm/hfuncs/wasi/013-fd_seek.t index 46963a992..ca2cd162f 100644 --- a/t/01-wasm/hfuncs/wasi/013-fd_seek.t +++ b/t/01-wasm/hfuncs/wasi/013-fd_seek.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/01-wasm/hfuncs/wasi/014-path_open.t b/t/01-wasm/hfuncs/wasi/014-path_open.t index b0d8a37b6..217db6eb9 100644 --- a/t/01-wasm/hfuncs/wasi/014-path_open.t +++ b/t/01-wasm/hfuncs/wasi/014-path_open.t @@ -4,6 +4,8 @@ use strict; use lib '.'; use t::TestWasmX; +skip_no_wasi(); + plan_tests(3); run_tests(); diff --git a/t/03-proxy_wasm/hfuncs/101-proxy_get_current_time.t b/t/03-proxy_wasm/hfuncs/101-proxy_get_current_time.t index c8d632937..547886605 100644 --- a/t/03-proxy_wasm/hfuncs/101-proxy_get_current_time.t +++ b/t/03-proxy_wasm/hfuncs/101-proxy_get_current_time.t @@ -21,6 +21,6 @@ should produce a log with the current time (ms as ~ns) --- response_body ok --- error_log eval -qr/\[info\] .*? now: 2.*? UTC/, +qr/\[info\] .*? now: SystemTime\(\d+\.\d+s\)/, --- no_error_log [error] diff --git a/t/10-build/001-build_options.t b/t/10-build/001-build_options.t index be4df8b82..ff0b44d65 100644 --- a/t/10-build/001-build_options.t +++ b/t/10-build/001-build_options.t @@ -4,7 +4,7 @@ use strict; use lib '.'; use t::TestBuild; -skip_valgrind(); +skip_no_test_nginx(); our $buildroot = $t::TestBuild::buildroot; our $openssl_ver = get_variable_from_makefile("OPENSSL"); diff --git a/t/10-build/002-runtime_linking.t b/t/10-build/002-runtime_linking.t index 14033c338..e06c4927a 100644 --- a/t/10-build/002-runtime_linking.t +++ b/t/10-build/002-runtime_linking.t @@ -4,7 +4,7 @@ use strict; use lib '.'; use t::TestBuild; -skip_valgrind(); +skip_no_test_nginx(); our $buildroot = $t::TestBuild::buildroot; diff --git a/t/10-build/003-dynamic_module.t b/t/10-build/003-dynamic_module.t index a34054c74..9cd942cd4 100644 --- a/t/10-build/003-dynamic_module.t +++ b/t/10-build/003-dynamic_module.t @@ -4,7 +4,7 @@ use strict; use lib '.'; use t::TestBuild; -skip_valgrind(); +skip_no_test_nginx(); our $buildroot = $t::TestBuild::buildroot; diff --git a/t/10-build/004-ngx_wasm_rs_linking.t b/t/10-build/004-ngx_wasm_rs_linking.t index 883cd5d25..db81ddaba 100644 --- a/t/10-build/004-ngx_wasm_rs_linking.t +++ b/t/10-build/004-ngx_wasm_rs_linking.t @@ -4,7 +4,7 @@ use strict; use lib '.'; use t::TestBuild; -skip_valgrind(); +skip_no_test_nginx(); our $buildroot = $t::TestBuild::buildroot; diff --git a/t/TestBuild.pm b/t/TestBuild.pm index fb91e0f8b..4f004593d 100644 --- a/t/TestBuild.pm +++ b/t/TestBuild.pm @@ -17,6 +17,7 @@ our $buildroot = $ENV{NGX_BUILD_DIR_BUILDROOT}; our @EXPORT = qw( $buildroot skip_valgrind + skip_no_test_nginx get_variable_from_makefile run_tests ); @@ -45,6 +46,14 @@ sub skip_valgrind { } } +sub skip_no_test_nginx { + if (!defined $ENV{TEST_NGINX_NO_TEST_NGINX} + || $ENV{TEST_NGINX_NO_TEST_NGINX} != 1) + { + plan(skip_all => "skip without build test mode (\$TEST_NGINX_NO_TEST_NGINX=1)"); + } +} + sub get_variable_from_makefile($) { my $name = shift; diff --git a/t/TestWasmX.pm b/t/TestWasmX.pm index e89cc1b47..a59fb2605 100644 --- a/t/TestWasmX.pm +++ b/t/TestWasmX.pm @@ -40,6 +40,7 @@ our @EXPORT = qw( skip_no_debug skip_no_go_sdk skip_no_assemblyscript_sdk + skip_no_wasi ); $ENV{TEST_NGINX_USE_HUP} ||= 0; @@ -103,6 +104,12 @@ sub skip_no_assemblyscript_sdk { } } +sub skip_no_wasi { + if ($ENV{TEST_NGINX_CARGO_RUSTTARGET} !~ m/wasi/) { + plan(skip_all => "skip without WASI target (\$TEST_NGINX_CARGO_RUSTTARGET is set to \"$ENV{TEST_NGINX_CARGO_RUSTTARGET}\")"); + } +} + sub load_nginx_modules (@) { splice @nginx_modules, 0, 0, @_; } diff --git a/t/lib/Cargo.lock b/t/lib/Cargo.lock index 1c9a1cff3..c1fe84706 100644 --- a/t/lib/Cargo.lock +++ b/t/lib/Cargo.lock @@ -46,21 +46,6 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "arrayref" version = "0.3.9" @@ -73,12 +58,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - [[package]] name = "backtrace" version = "0.3.74" @@ -105,12 +84,6 @@ dependencies = [ "proxy-wasm 0.2.2", ] -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - [[package]] name = "blake3" version = "1.5.4" @@ -124,12 +97,6 @@ dependencies = [ "constant_time_eq", ] -[[package]] -name = "bumpalo" -version = "3.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" - [[package]] name = "bytes" version = "1.7.2" @@ -151,20 +118,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "js-sys", - "num-traits", - "wasm-bindgen", - "windows-targets", -] - [[package]] name = "constant_time_eq" version = "0.3.1" @@ -179,12 +132,6 @@ dependencies = [ "proxy-wasm 0.2.2", ] -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - [[package]] name = "enum-utils" version = "0.1.2" @@ -232,7 +179,7 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -270,7 +217,6 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" name = "hostcalls" version = "0.1.0" dependencies = [ - "chrono", "enum-utils", "http", "log", @@ -289,29 +235,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "iana-time-zone" -version = "0.1.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - [[package]] name = "instance-lifecycle" version = "0.1.0" @@ -326,15 +249,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "js-sys" -version = "0.3.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "libc" version = "0.2.158" @@ -378,16 +292,6 @@ name = "ngx-rust-tests" version = "0.1.0" dependencies = [ "ngx", - "wasi 0.13.2+wasi-0.2.1", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", ] [[package]] @@ -537,21 +441,12 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasi" -version = "0.13.2+wasi-0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9860ef2271bc7a6e1f985ac4438862a165137fe585ac10bdfad0a8aeb37ba25" -dependencies = [ - "wit-bindgen-rt", -] - [[package]] name = "wasi-host-tests" version = "0.1.0" dependencies = [ "ngx", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -559,71 +454,7 @@ name = "wasi-vm-tests" version = "0.1.0" dependencies = [ "ngx", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "wasm-bindgen" -version = "0.2.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" -dependencies = [ - "cfg-if", - "once_cell", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.77", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.77", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" - -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets", + "wasi", ] [[package]] @@ -690,15 +521,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "wit-bindgen-rt" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b18e27825442721d23ed98591a80f55220cfe0bf883d92b1ead6c9be237bb34" -dependencies = [ - "bitflags", -] - [[package]] name = "zerocopy" version = "0.7.35" diff --git a/t/lib/ngx-rust-tests/Cargo.toml b/t/lib/ngx-rust-tests/Cargo.toml index aed8933ee..e19c4c90b 100644 --- a/t/lib/ngx-rust-tests/Cargo.toml +++ b/t/lib/ngx-rust-tests/Cargo.toml @@ -9,4 +9,3 @@ crate-type = ["cdylib"] [dependencies] ngx = { path = "../../../lib/ngx-rust" } -wasi = "*" diff --git a/t/lib/proxy-wasm-tests/hostcalls/Cargo.toml b/t/lib/proxy-wasm-tests/hostcalls/Cargo.toml index 4fc4c8beb..dad9e5d85 100644 --- a/t/lib/proxy-wasm-tests/hostcalls/Cargo.toml +++ b/t/lib/proxy-wasm-tests/hostcalls/Cargo.toml @@ -11,6 +11,5 @@ crate-type = ["cdylib"] proxy-wasm = "0.2" log = "0.4" http = "0.2" -chrono = "0.4" enum-utils = "0.1.2" urlencoding = "2.1.2" diff --git a/t/lib/proxy-wasm-tests/hostcalls/src/tests/mod.rs b/t/lib/proxy-wasm-tests/hostcalls/src/tests/mod.rs index 82993ef99..ae4ffb612 100644 --- a/t/lib/proxy-wasm-tests/hostcalls/src/tests/mod.rs +++ b/t/lib/proxy-wasm-tests/hostcalls/src/tests/mod.rs @@ -2,7 +2,6 @@ pub mod echo; pub mod host; use crate::{types::*, *}; -use chrono::{DateTime, Utc}; use log::*; use proxy_wasm::hostcalls::*; use proxy_wasm::types::*; @@ -27,8 +26,8 @@ pub(crate) fn test_log_levels(_: &TestHttp) { } pub(crate) fn test_log_current_time(ctx: &TestHttp) { - let now: DateTime = ctx.get_current_time().into(); - info!("now: {}", now) + let now = ctx.get_current_time(); + info!("now: {:?}", now) } pub(crate) fn test_log_request_header(ctx: &TestHttp) { diff --git a/util/test.sh b/util/test.sh index 82a4d568f..798f4a7cc 100755 --- a/util/test.sh +++ b/util/test.sh @@ -18,7 +18,7 @@ source $NGX_WASM_DIR/util/_lib.sh while (( "$#" )); do case "$1" in --no-test-nginx) - NO_TEST_NGINX=1 + export TEST_NGINX_NO_TEST_NGINX=1 shift ;; -j) @@ -42,7 +42,7 @@ export PERL5LIB=$DIR_CPANM/lib/perl5:$PERL5LIB # Test::Build -if [[ "$NO_TEST_NGINX" == 1 ]]; then +if [[ "$TEST_NGINX_NO_TEST_NGINX" == 1 ]]; then export TEST_NGINX_NPROC=$(n_jobs) exec prove $@ fi @@ -72,6 +72,7 @@ export LD_PRELOAD=$DIR_MOCKEAGAIN/mockeagain.so #export TEST_NGINX_NO_CLEAN=1 #export TEST_NGINX_BENCHMARK='1000 10' export TEST_NGINX_CLEAN_LOG=${TEST_NGINX_CLEAN_LOG:=0} +export TEST_NGINX_CARGO_RUSTTARGET=${TEST_NGINX_CARGO_RUSTTARGET:=wasm32-wasip1} export TEST_NGINX_CARGO_RUSTFLAGS=${TEST_NGINX_CARGO_RUSTFLAGS:=} export TEST_NGINX_CARGO_PROFILE=${TEST_NGINX_CARGO_PROFILE:=release} @@ -102,15 +103,14 @@ if [ "$TEST_NGINX_CARGO_PROFILE" = release ]; then args+="--release" fi -export RUSTTARGET=wasm32-wasip1 export RUSTFLAGS="$TEST_NGINX_CARGO_RUSTFLAGS" eval cargo build \ --manifest-path t/lib/Cargo.toml \ --lib \ - --target $RUSTTARGET \ + --target $TEST_NGINX_CARGO_RUSTTARGET \ "${args[@]}" -eval cp t/lib/target/$RUSTTARGET/$TEST_NGINX_CARGO_PROFILE/*.wasm \ +eval cp t/lib/target/$TEST_NGINX_CARGO_RUSTTARGET/$TEST_NGINX_CARGO_PROFILE/*.wasm \ $DIR_TESTS_LIB_WASM $NGX_WASM_DIR/util/sdk.sh -S go --install From 6c78e48aa0752dab93fc9f6ea3cf158afde7c3b5 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Tue, 24 Sep 2024 17:58:46 -0700 Subject: [PATCH 2/3] tests(*) isolate WASI test suites --- .../hfuncs/wasi/000-non_host_wasi.t => 05-wasi/001-sanity.t} | 0 .../hfuncs/wasi/006-args_get.t => 05-wasi/wasi-p1/args_get.t} | 0 .../005-args_sizes_get.t => 05-wasi/wasi-p1/args_sizes_get.t} | 0 .../004-clock_time_get.t => 05-wasi/wasi-p1/clock_time_get.t} | 0 .../wasi/003-environ_get.t => 05-wasi/wasi-p1/environ_get.t} | 0 .../wasi-p1/environ_sizes_get.t} | 0 .../hfuncs/wasi/008-fd_close.t => 05-wasi/wasi-p1/fd_close.t} | 0 .../wasi/009-fd_fdstat_get.t => 05-wasi/wasi-p1/fd_fdstat_get.t} | 0 .../wasi-p1/fd_prestat_dir_name.t} | 0 .../010-fd_prestat_get.t => 05-wasi/wasi-p1/fd_prestat_get.t} | 0 .../hfuncs/wasi/012-fd_read.t => 05-wasi/wasi-p1/fd_read.t} | 0 .../hfuncs/wasi/013-fd_seek.t => 05-wasi/wasi-p1/fd_seek.t} | 0 .../hfuncs/wasi/007-fd_write.t => 05-wasi/wasi-p1/fd_write.t} | 0 .../hfuncs/wasi/014-path_open.t => 05-wasi/wasi-p1/path_open.t} | 0 .../hfuncs/wasi/001-random_get.t => 05-wasi/wasi-p1/random_get.t} | 0 t/{05-others => 06-others}/001-socket_buffer_reuse.t | 0 t/{05-others => 06-others}/002-resolver_add_sanity.t | 0 t/{05-others => 06-others}/010-client_connection_abort.t | 0 t/{05-others => 06-others}/011-upstream_connection_abort.t | 0 .../001-metrics_sighup.t => 06-others/020-metrics_sighup.t} | 0 .../002-histograms_sighup.t => 06-others/021-histograms_sighup.t} | 0 t/{06-ipc => 07-ipc}/001-ipc_block.t | 0 22 files changed, 0 insertions(+), 0 deletions(-) rename t/{01-wasm/hfuncs/wasi/000-non_host_wasi.t => 05-wasi/001-sanity.t} (100%) rename t/{01-wasm/hfuncs/wasi/006-args_get.t => 05-wasi/wasi-p1/args_get.t} (100%) rename t/{01-wasm/hfuncs/wasi/005-args_sizes_get.t => 05-wasi/wasi-p1/args_sizes_get.t} (100%) rename t/{01-wasm/hfuncs/wasi/004-clock_time_get.t => 05-wasi/wasi-p1/clock_time_get.t} (100%) rename t/{01-wasm/hfuncs/wasi/003-environ_get.t => 05-wasi/wasi-p1/environ_get.t} (100%) rename t/{01-wasm/hfuncs/wasi/002-environ_sizes_get.t => 05-wasi/wasi-p1/environ_sizes_get.t} (100%) rename t/{01-wasm/hfuncs/wasi/008-fd_close.t => 05-wasi/wasi-p1/fd_close.t} (100%) rename t/{01-wasm/hfuncs/wasi/009-fd_fdstat_get.t => 05-wasi/wasi-p1/fd_fdstat_get.t} (100%) rename t/{01-wasm/hfuncs/wasi/011-fd_prestat_dir_name.t => 05-wasi/wasi-p1/fd_prestat_dir_name.t} (100%) rename t/{01-wasm/hfuncs/wasi/010-fd_prestat_get.t => 05-wasi/wasi-p1/fd_prestat_get.t} (100%) rename t/{01-wasm/hfuncs/wasi/012-fd_read.t => 05-wasi/wasi-p1/fd_read.t} (100%) rename t/{01-wasm/hfuncs/wasi/013-fd_seek.t => 05-wasi/wasi-p1/fd_seek.t} (100%) rename t/{01-wasm/hfuncs/wasi/007-fd_write.t => 05-wasi/wasi-p1/fd_write.t} (100%) rename t/{01-wasm/hfuncs/wasi/014-path_open.t => 05-wasi/wasi-p1/path_open.t} (100%) rename t/{01-wasm/hfuncs/wasi/001-random_get.t => 05-wasi/wasi-p1/random_get.t} (100%) rename t/{05-others => 06-others}/001-socket_buffer_reuse.t (100%) rename t/{05-others => 06-others}/002-resolver_add_sanity.t (100%) rename t/{05-others => 06-others}/010-client_connection_abort.t (100%) rename t/{05-others => 06-others}/011-upstream_connection_abort.t (100%) rename t/{07-metrics/001-metrics_sighup.t => 06-others/020-metrics_sighup.t} (100%) rename t/{07-metrics/002-histograms_sighup.t => 06-others/021-histograms_sighup.t} (100%) rename t/{06-ipc => 07-ipc}/001-ipc_block.t (100%) diff --git a/t/01-wasm/hfuncs/wasi/000-non_host_wasi.t b/t/05-wasi/001-sanity.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/000-non_host_wasi.t rename to t/05-wasi/001-sanity.t diff --git a/t/01-wasm/hfuncs/wasi/006-args_get.t b/t/05-wasi/wasi-p1/args_get.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/006-args_get.t rename to t/05-wasi/wasi-p1/args_get.t diff --git a/t/01-wasm/hfuncs/wasi/005-args_sizes_get.t b/t/05-wasi/wasi-p1/args_sizes_get.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/005-args_sizes_get.t rename to t/05-wasi/wasi-p1/args_sizes_get.t diff --git a/t/01-wasm/hfuncs/wasi/004-clock_time_get.t b/t/05-wasi/wasi-p1/clock_time_get.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/004-clock_time_get.t rename to t/05-wasi/wasi-p1/clock_time_get.t diff --git a/t/01-wasm/hfuncs/wasi/003-environ_get.t b/t/05-wasi/wasi-p1/environ_get.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/003-environ_get.t rename to t/05-wasi/wasi-p1/environ_get.t diff --git a/t/01-wasm/hfuncs/wasi/002-environ_sizes_get.t b/t/05-wasi/wasi-p1/environ_sizes_get.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/002-environ_sizes_get.t rename to t/05-wasi/wasi-p1/environ_sizes_get.t diff --git a/t/01-wasm/hfuncs/wasi/008-fd_close.t b/t/05-wasi/wasi-p1/fd_close.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/008-fd_close.t rename to t/05-wasi/wasi-p1/fd_close.t diff --git a/t/01-wasm/hfuncs/wasi/009-fd_fdstat_get.t b/t/05-wasi/wasi-p1/fd_fdstat_get.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/009-fd_fdstat_get.t rename to t/05-wasi/wasi-p1/fd_fdstat_get.t diff --git a/t/01-wasm/hfuncs/wasi/011-fd_prestat_dir_name.t b/t/05-wasi/wasi-p1/fd_prestat_dir_name.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/011-fd_prestat_dir_name.t rename to t/05-wasi/wasi-p1/fd_prestat_dir_name.t diff --git a/t/01-wasm/hfuncs/wasi/010-fd_prestat_get.t b/t/05-wasi/wasi-p1/fd_prestat_get.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/010-fd_prestat_get.t rename to t/05-wasi/wasi-p1/fd_prestat_get.t diff --git a/t/01-wasm/hfuncs/wasi/012-fd_read.t b/t/05-wasi/wasi-p1/fd_read.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/012-fd_read.t rename to t/05-wasi/wasi-p1/fd_read.t diff --git a/t/01-wasm/hfuncs/wasi/013-fd_seek.t b/t/05-wasi/wasi-p1/fd_seek.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/013-fd_seek.t rename to t/05-wasi/wasi-p1/fd_seek.t diff --git a/t/01-wasm/hfuncs/wasi/007-fd_write.t b/t/05-wasi/wasi-p1/fd_write.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/007-fd_write.t rename to t/05-wasi/wasi-p1/fd_write.t diff --git a/t/01-wasm/hfuncs/wasi/014-path_open.t b/t/05-wasi/wasi-p1/path_open.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/014-path_open.t rename to t/05-wasi/wasi-p1/path_open.t diff --git a/t/01-wasm/hfuncs/wasi/001-random_get.t b/t/05-wasi/wasi-p1/random_get.t similarity index 100% rename from t/01-wasm/hfuncs/wasi/001-random_get.t rename to t/05-wasi/wasi-p1/random_get.t diff --git a/t/05-others/001-socket_buffer_reuse.t b/t/06-others/001-socket_buffer_reuse.t similarity index 100% rename from t/05-others/001-socket_buffer_reuse.t rename to t/06-others/001-socket_buffer_reuse.t diff --git a/t/05-others/002-resolver_add_sanity.t b/t/06-others/002-resolver_add_sanity.t similarity index 100% rename from t/05-others/002-resolver_add_sanity.t rename to t/06-others/002-resolver_add_sanity.t diff --git a/t/05-others/010-client_connection_abort.t b/t/06-others/010-client_connection_abort.t similarity index 100% rename from t/05-others/010-client_connection_abort.t rename to t/06-others/010-client_connection_abort.t diff --git a/t/05-others/011-upstream_connection_abort.t b/t/06-others/011-upstream_connection_abort.t similarity index 100% rename from t/05-others/011-upstream_connection_abort.t rename to t/06-others/011-upstream_connection_abort.t diff --git a/t/07-metrics/001-metrics_sighup.t b/t/06-others/020-metrics_sighup.t similarity index 100% rename from t/07-metrics/001-metrics_sighup.t rename to t/06-others/020-metrics_sighup.t diff --git a/t/07-metrics/002-histograms_sighup.t b/t/06-others/021-histograms_sighup.t similarity index 100% rename from t/07-metrics/002-histograms_sighup.t rename to t/06-others/021-histograms_sighup.t diff --git a/t/06-ipc/001-ipc_block.t b/t/07-ipc/001-ipc_block.t similarity index 100% rename from t/06-ipc/001-ipc_block.t rename to t/07-ipc/001-ipc_block.t From 5e5befa37751646d6420e2b561e9df9f50504b13 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Wed, 25 Sep 2024 11:22:17 -0700 Subject: [PATCH 3/3] chore(wasi) groudwork for multiple wasi interfaces --- config | 2 +- src/wasm/wasi/ngx_wasi.h | 2 +- .../wasi/{ngx_wasi_host.c => ngx_wasi_preview1_host.c} | 4 ++-- src/wasm/wrt/ngx_wrt_v8.c | 2 +- src/wasm/wrt/ngx_wrt_wasmer.c | 2 +- src/wasm/wrt/ngx_wrt_wasmtime.c | 10 +++++----- 6 files changed, 11 insertions(+), 11 deletions(-) rename src/wasm/wasi/{ngx_wasi_host.c => ngx_wasi_preview1_host.c} (99%) diff --git a/config b/config index 386969168..fb08299c4 100644 --- a/config +++ b/config @@ -189,7 +189,7 @@ NGX_WASM_SRCS="\ $ngx_addon_dir/src/wasm/wrt/ngx_wrt_utils.c \ $ngx_addon_dir/src/wasm/vm/ngx_wavm.c \ $ngx_addon_dir/src/wasm/vm/ngx_wavm_host.c \ - $ngx_addon_dir/src/wasm/wasi/ngx_wasi_host.c" + $ngx_addon_dir/src/wasm/wasi/ngx_wasi_preview1_host.c" NGX_WASM_CORE_SRCS="\ $ngx_addon_dir/src/wasm/ngx_wasm_core_module.c \ diff --git a/src/wasm/wasi/ngx_wasi.h b/src/wasm/wasi/ngx_wasi.h index 7c83c38ed..18914bdb9 100644 --- a/src/wasm/wasi/ngx_wasi.h +++ b/src/wasm/wasi/ngx_wasi.h @@ -15,7 +15,7 @@ #define WASI_ERRNO_NOTSUP 58 -extern ngx_wavm_host_def_t ngx_wasi_host; +extern ngx_wavm_host_def_t ngx_wasip1_host; #endif /* _NGX_WASI_H_INCLUDED_ */ diff --git a/src/wasm/wasi/ngx_wasi_host.c b/src/wasm/wasi/ngx_wasi_preview1_host.c similarity index 99% rename from src/wasm/wasi/ngx_wasi_host.c rename to src/wasm/wasi/ngx_wasi_preview1_host.c index 57874b72b..ad0d799a2 100644 --- a/src/wasm/wasi/ngx_wasi_host.c +++ b/src/wasm/wasi/ngx_wasi_preview1_host.c @@ -400,7 +400,7 @@ static ngx_wavm_host_func_def_t ngx_wasi_hfuncs[] = { }; -ngx_wavm_host_def_t ngx_wasi_host = { - ngx_string("ngx_wasi"), +ngx_wavm_host_def_t ngx_wasip1_host = { + ngx_string("ngx_wasi_preview1"), ngx_wasi_hfuncs, }; diff --git a/src/wasm/wrt/ngx_wrt_v8.c b/src/wasm/wrt/ngx_wrt_v8.c index b39aa6d07..b544ef5df 100644 --- a/src/wasm/wrt/ngx_wrt_v8.c +++ b/src/wasm/wrt/ngx_wrt_v8.c @@ -333,7 +333,7 @@ ngx_v8_link_module(ngx_wrt_module_t *module, ngx_array_t *hfuncs, name.data = (u_char *) importname->data; hfunc = ngx_wavm_host_hfunc_create(module->engine->pool, - &ngx_wasi_host, &name); + &ngx_wasip1_host, &name); if (hfunc) { dd(" -> wasi resolved: \"%.*s\"", diff --git a/src/wasm/wrt/ngx_wrt_wasmer.c b/src/wasm/wrt/ngx_wrt_wasmer.c index b71bc900c..ecfe2baa4 100644 --- a/src/wasm/wrt/ngx_wrt_wasmer.c +++ b/src/wasm/wrt/ngx_wrt_wasmer.c @@ -341,7 +341,7 @@ ngx_wasmer_link_module(ngx_wrt_module_t *module, ngx_array_t *hfuncs, name.data = (u_char *) importname->data; hfunc = ngx_wavm_host_hfunc_create(module->engine->pool, - &ngx_wasi_host, &name); + &ngx_wasip1_host, &name); if (hfunc) { dd(" -> wasi resolved by host function: \"%.*s\"", diff --git a/src/wasm/wrt/ngx_wrt_wasmtime.c b/src/wasm/wrt/ngx_wrt_wasmtime.c index 651a63686..2bb2df993 100644 --- a/src/wasm/wrt/ngx_wrt_wasmtime.c +++ b/src/wasm/wrt/ngx_wrt_wasmtime.c @@ -280,17 +280,17 @@ ngx_wasmtime_init_engine(ngx_wrt_engine_t *engine, wasm_config_t *config, nwasi = 0; - for (i = 0; ngx_wasi_host.funcs[i].ptr; i++) { + for (i = 0; ngx_wasip1_host.funcs[i].ptr; i++) { nwasi++; } engine->pool = pool; engine->wasi_hfuncs = ngx_pcalloc(pool, sizeof(ngx_wavm_hfunc_t *) * nwasi); - for (i = 0; ngx_wasi_host.funcs[i].ptr; i++) { - def = &ngx_wasi_host.funcs[i]; + for (i = 0; ngx_wasip1_host.funcs[i].ptr; i++) { + def = &ngx_wasip1_host.funcs[i]; - hfunc = ngx_wavm_host_hfunc_create(pool, &ngx_wasi_host, &def->name); + hfunc = ngx_wavm_host_hfunc_create(pool, &ngx_wasip1_host, &def->name); err->res = wasmtime_linker_define_func(engine->linker, wasi_module, @@ -316,7 +316,7 @@ ngx_wasmtime_destroy_engine(ngx_wrt_engine_t *engine) { size_t i; - for (i = 0; ngx_wasi_host.funcs[i].ptr; i++) { + for (i = 0; ngx_wasip1_host.funcs[i].ptr; i++) { wasm_functype_delete(engine->wasi_hfuncs[i]->functype); }