Skip to content

Commit

Permalink
chore(tests) add --- backtraces block
Browse files Browse the repository at this point in the history
When set it will add `backtraces on;` to wasm context in nginx.conf
  • Loading branch information
casimiro committed Aug 11, 2023
1 parent 9ad9c05 commit 515ef56
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/wasm/wrt/ngx_wrt_wasmer.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ ngx_wasmer_init_conf(ngx_wavm_conf_t *conf, ngx_log_t *log)
char *auto_compiler = NULL;
wasm_config_t *config;

ngx_wasm_assert(conf->backtraces != NGX_CONF_UNSET);

if (conf->backtraces) {
setenv("RUST_BACKTRACE", "FULL", 1);

} else {
setenv("RUST_BACKTRACE", "0", 1);
}

config = wasm_config_new();
if (config == NULL) {
goto error;
Expand Down
2 changes: 2 additions & 0 deletions src/wasm/wrt/ngx_wrt_wasmtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ ngx_wasmtime_init_conf(ngx_wavm_conf_t *conf, ngx_log_t *log)

if (conf->backtraces) {
setenv("WASMTIME_BACKTRACE_DETAILS", "1", 1);
setenv("RUST_BACKTRACE", "FULL", 1);

} else {
setenv("WASMTIME_BACKTRACE_DETAILS", "0", 1);
setenv("RUST_BACKTRACE", "0", 1);
}

config = wasm_config_new();
Expand Down
12 changes: 6 additions & 6 deletions t/TestWasm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,8 @@ add_block_preprocessor(sub {
$block->set_value("request", "GET /t");
}

# --- env variables

my $main_config = $block->main_config || '';

$block->set_value("main_config",
"env WASMTIME_BACKTRACE_DETAILS=1;\n"
. $main_config);

# --- load_nginx_modules: ngx_http_echo_module

my @arr;
Expand Down Expand Up @@ -149,6 +143,7 @@ add_block_preprocessor(sub {
# --- wasm_modules: on_phases

my $wasm_modules = $block->wasm_modules;
my $backtraces = $block->backtraces;
if (defined $wasm_modules) {
@arr = split /\s+/, $wasm_modules;
if (@arr) {
Expand All @@ -162,6 +157,11 @@ add_block_preprocessor(sub {
" compiler " . $compiler . ";\n";
}

if (defined $backtraces) {
$wasm_config = $wasm_config .
" backtraces on;\n";
}

my $tls_skip_verify = $block->tls_skip_verify;
my $tls_skip_host_check = $block->tls_skip_host_check;
my $tls_trusted_certificate = $block->tls_trusted_certificate;
Expand Down

0 comments on commit 515ef56

Please sign in to comment.