Skip to content

Commit 098caac

Browse files
authored
ci: add test ci (#5)
1 parent 2500907 commit 098caac

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

.github/workflows/test.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: "ubuntu-18.04"
12+
env:
13+
OPENRESTY_PREFIX: "/usr/local/openresty"
14+
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v2
18+
19+
- name: Get dependencies
20+
run: |
21+
sudo apt install -y cpanminus build-essential libncurses5-dev libreadline-dev libssl-dev perl
22+
wget https://github.com/tinygo-org/tinygo/releases/download/v0.19.0/tinygo_0.19.0_amd64.deb
23+
sudo dpkg -i tinygo_0.19.0_amd64.deb
24+
25+
- name: Before install
26+
run: |
27+
sudo cpanm --notest Test::Nginx > build.log 2>&1 || (cat build.log && exit 1)
28+
git clone https://github.com/iresty/test-nginx.git test-nginx
29+
30+
- name: Install
31+
run: |
32+
wget https://raw.githubusercontent.com/api7/apisix-build-tools/master/build-apisix-base.sh
33+
chmod +x build-apisix-base.sh
34+
OR_PREFIX=$OPENRESTY_PREFIX ./build-apisix-base.sh latest
35+
36+
- name: Script
37+
run: |
38+
make build.all.testdata
39+
export PATH=$OPENRESTY_PREFIX/nginx/sbin:$PATH
40+
prove -I. -Itest-nginx/lib -r t/

src/vm/wasmtime.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,16 @@ static void *
7272
ngx_wasm_wasmtime_load(const char *bytecode, size_t size)
7373
{
7474
size_t i;
75+
bool ok;
7576
wasm_trap_t *trap = NULL;
7677
wasmtime_module_t *module;
7778
wasmtime_store_t *store;
7879
wasmtime_context_t *context;
7980
wasi_config_t *wasi_config;
8081
wasmtime_error_t *error;
8182
ngx_wasm_wasmtime_plugin_t *plugin;
83+
wasmtime_extern_t item;
8284

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

101-
wasi_config_inherit_argv(wasi_config);
102102
wasi_config_inherit_env(wasi_config);
103103
wasi_config_inherit_stdin(wasi_config);
104104
wasi_config_inherit_stdout(wasi_config);
@@ -152,8 +152,6 @@ ngx_wasm_wasmtime_load(const char *bytecode, size_t size)
152152
goto free_linker;
153153
}
154154

155-
wasmtime_extern_t item;
156-
bool ok;
157155
ok = wasmtime_instance_export_get(context, &plugin->instance, "memory", strlen("memory"), &item);
158156
if (!ok || item.kind != WASMTIME_EXTERN_MEMORY) {
159157
ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "the wasm plugin doesn't export memory");

t/WASM.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use Cwd qw(cwd);
77
log_level('info');
88
no_long_string();
99
no_shuffle();
10+
master_on();
1011
worker_connections(128);
1112

1213

t/plugin_lifecycle.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ location /t {
151151
for i = 1, 2 do
152152
do
153153
local plugin = wasm.load("t/testdata/plugin_lifecycle/main.go.wasm")
154-
for i = 1, 2 do
154+
for j = 1, 2 do
155155
local ctx = assert(wasm.on_configure(plugin, '{"body":512}'))
156156
end
157157
end

0 commit comments

Comments
 (0)