Skip to content
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
40 changes: 40 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: "ubuntu-18.04"
env:
OPENRESTY_PREFIX: "/usr/local/openresty"

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Get dependencies
run: |
sudo apt install -y cpanminus build-essential libncurses5-dev libreadline-dev libssl-dev perl
wget https://github.com/tinygo-org/tinygo/releases/download/v0.19.0/tinygo_0.19.0_amd64.deb
sudo dpkg -i tinygo_0.19.0_amd64.deb

- name: Before install
run: |
sudo cpanm --notest Test::Nginx > build.log 2>&1 || (cat build.log && exit 1)
git clone https://github.com/iresty/test-nginx.git test-nginx

- name: Install
run: |
wget https://raw.githubusercontent.com/api7/apisix-build-tools/master/build-apisix-base.sh
chmod +x build-apisix-base.sh
OR_PREFIX=$OPENRESTY_PREFIX ./build-apisix-base.sh latest

- name: Script
run: |
make build.all.testdata
export PATH=$OPENRESTY_PREFIX/nginx/sbin:$PATH
prove -I. -Itest-nginx/lib -r t/
6 changes: 2 additions & 4 deletions src/vm/wasmtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,16 @@ static void *
ngx_wasm_wasmtime_load(const char *bytecode, size_t size)
{
size_t i;
bool ok;
wasm_trap_t *trap = NULL;
wasmtime_module_t *module;
wasmtime_store_t *store;
wasmtime_context_t *context;
wasi_config_t *wasi_config;
wasmtime_error_t *error;
ngx_wasm_wasmtime_plugin_t *plugin;
wasmtime_extern_t item;

// TODO: separate WASM compiling from the store init
error = wasmtime_module_new(vm_engine, (const uint8_t*) bytecode, size, &module);
if (module == NULL) {
return NULL;
Expand All @@ -98,7 +99,6 @@ ngx_wasm_wasmtime_load(const char *bytecode, size_t size)
goto free_store;
}

wasi_config_inherit_argv(wasi_config);
wasi_config_inherit_env(wasi_config);
wasi_config_inherit_stdin(wasi_config);
wasi_config_inherit_stdout(wasi_config);
Expand Down Expand Up @@ -152,8 +152,6 @@ ngx_wasm_wasmtime_load(const char *bytecode, size_t size)
goto free_linker;
}

wasmtime_extern_t item;
bool ok;
ok = wasmtime_instance_export_get(context, &plugin->instance, "memory", strlen("memory"), &item);
if (!ok || item.kind != WASMTIME_EXTERN_MEMORY) {
ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "the wasm plugin doesn't export memory");
Expand Down
1 change: 1 addition & 0 deletions t/WASM.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use Cwd qw(cwd);
log_level('info');
no_long_string();
no_shuffle();
master_on();
worker_connections(128);


Expand Down
2 changes: 1 addition & 1 deletion t/plugin_lifecycle.t
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ location /t {
for i = 1, 2 do
do
local plugin = wasm.load("t/testdata/plugin_lifecycle/main.go.wasm")
for i = 1, 2 do
for j = 1, 2 do
local ctx = assert(wasm.on_configure(plugin, '{"body":512}'))
end
end
Expand Down