Skip to content

Commit

Permalink
chore(tests) update trap regexes for new format
Browse files Browse the repository at this point in the history
The complete backtrace is tested in 006-backtraces_directives.t. All
other traps only test `[crit]` and the trap message, which are now in 2
different lines. This update makes trap testing across the tests much
more resilient to future changes.
  • Loading branch information
thibaultcha committed Aug 3, 2023
1 parent eaa5506 commit 88723c3
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 65 deletions.
40 changes: 24 additions & 16 deletions t/01-wasm/directives/006-backtraces_directive.t
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ qq{
--- error_log eval
[
qr/\[info\] .*? \[wasm\] using wasmtime with compiler: "auto" \(backtraces: 0\)/,
qr/\[crit\] .*? panicked at 'trap'/,
qr/\[crit\] .*? panicked at/,
qr/custom trap/,
qr/\[error\] .*? \[wasm\] error while executing at wasm backtrace:/,
qr# 0: 0x[0-9a-f]+ - <unknown>!__rust_start_panic#,
qr# 1: 0x[0-9a-f]+ - <unknown>!rust_panic#,
Expand All @@ -72,7 +73,7 @@ qq{
]
--- no_access_log eval
my @checks;
for my $i (20..$::n) {
for my $i (21..$::n) {
push(@checks, "stub$i\n");
}
[@checks]
Expand Down Expand Up @@ -100,7 +101,8 @@ qq{
--- error_log eval
[
qr/\[info\] .*? \[wasm\] using wasmtime with compiler: "cranelift" \(backtraces: 1\)/,
qr/\[crit\] .*? panicked at 'trap'/,
qr/\[crit\] .*? panicked at/,
qr/custom trap/,
qr/\[error\] .*? \[wasm\] error while executing at wasm backtrace:/,
qr# 0: 0x[0-9a-f]+ - .*?abort#,
qr# at /rustc/[0-9a-f]+/library/panic_abort/src/lib.rs:[0-9]+:[0-9]+ *- __rust_start_panic#,
Expand All @@ -122,7 +124,7 @@ qq{
]
--- no_error_log eval
my @checks;
for my $i (23..$::n) {
for my $i (24..$::n) {
push(@checks, "stub$i\n");
}
[@checks]
Expand Down Expand Up @@ -150,7 +152,8 @@ qq{
--- error_log eval
[
qr/\[info\] .*? \[wasm\] using wasmer with compiler: "auto" \(backtraces: 0\)/,
qr/\[crit\] .*? panicked at 'trap'/,
qr/\[crit\] .*? panicked at/,
qr/custom trap/,
qr/\[error\] .*? \[wasm\] unreachable/,
qr/Backtrace:/,
qr# 0: func [0-9]+ @ 0x[0-9a-f]+#,
Expand All @@ -166,7 +169,7 @@ qq{
]
--- no_error_log eval
my @checks;
for my $i (17..$::n) {
for my $i (18..$::n) {
push(@checks, "stub$i\n");
}
[@checks]
Expand Down Expand Up @@ -195,7 +198,8 @@ qr/500 Internal Server Error/
--- error_log eval
[
qr/\[info\] .*? \[wasm\] using wasmer with compiler: "cranelift" \(backtraces: 1\)/,
qr/\[crit\] .*? panicked at 'trap'/,
qr/\[crit\] .*? panicked at/,
qr/custom trap/,
qr/\[error\] .*? \[wasm\] unreachable/,
qr/Backtrace:/,
qr# 0: __rust_start_panic @ 0x[0-9a-f]+#,
Expand All @@ -210,7 +214,7 @@ qr/500 Internal Server Error/
]
--- no_error_log eval
my @checks;
for my $i (16..$::n) {
for my $i (17..$::n) {
push(@checks, "stub$i\n");
}
[@checks]
Expand Down Expand Up @@ -238,7 +242,8 @@ qq{
--- error_log eval
[
qr/\[info\] .*? \[wasm\] using wasmer with compiler: "singlepass" \(backtraces: 1\)/,
qr/\[crit\] .*? panicked at 'trap'/,
qr/\[crit\] .*? panicked at/,
qr/custom trap/,
qr/\[error\] .*? \[wasm\] unreachable/,
qr/Backtrace:/,
qr# 0: __rust_start_panic @ 0x[0-9a-f]+#,
Expand All @@ -254,7 +259,7 @@ qq{
]
--- no_error_log eval
my @checks;
for my $i (17..$::n) {
for my $i (18..$::n) {
push(@checks, "stub$i\n");
}
[@checks]
Expand Down Expand Up @@ -283,7 +288,8 @@ qq{
--- error_log eval
[
qr/\[info\] .*? \[wasm\] using wasmer with compiler: "llvm" \(backtraces: 1\)/,
qr/\[crit\] .*? panicked at 'trap'/,
qr/\[crit\] .*? panicked at/,
qr/custom trap/,
qr/\[error\] .*? \[wasm\] unreachable/,
qr/Backtrace:/,
qr# 0: __rust_start_panic @ 0x[0-9a-f]+#,
Expand All @@ -299,7 +305,7 @@ qq{
]
--- no_error_log eval
my @checks;
for my $i (17..$::n) {
for my $i (18..$::n) {
push(@checks, "stub$i\n");
}
[@checks]
Expand Down Expand Up @@ -328,7 +334,8 @@ qr/500 Internal Server Error/
--- error_log eval
[
qr/\[info\] .*? \[wasm\] using v8 with compiler: "auto" \(backtraces: 0\)/,
qr/\[crit\] .*? panicked at 'trap'/,
qr/\[crit\] .*? panicked at/,
qr/custom trap/,
qr/\[error\] .*? \[wasm\] Uncaught RuntimeError: unreachable/,
qr/Backtrace:/,
qr# 0: func [0-9]+ @ 0x[0-9a-f]+#,
Expand All @@ -344,7 +351,7 @@ qr/500 Internal Server Error/
]
--- no_error_log eval
my @checks;
for my $i (17..$::n) {
for my $i (18..$::n) {
push(@checks, "stub$i\n");
}
[@checks]
Expand Down Expand Up @@ -373,7 +380,8 @@ qr/500 Internal Server Error/
--- error_log eval
[
qr/\[info\] .*? \[wasm\] using v8 with compiler: "auto" \(backtraces: 1\)/,
qr/\[crit\] .*? panicked at 'trap'/,
qr/\[crit\] .*? panicked at/,
qr/custom trap/,
qr/\[error\] .*? \[wasm\] Uncaught RuntimeError: unreachable/,
qr/Backtrace:/,
qr# 0: __rust_start_panic @ 0x[0-9a-f]+#,
Expand All @@ -389,7 +397,7 @@ qr/500 Internal Server Error/
]
--- no_error_log eval
my @checks;
for my $i (17..$::n) {
for my $i (18..$::n) {
push(@checks, "stub$i\n");
}
[@checks]
8 changes: 4 additions & 4 deletions t/03-proxy_wasm/002-on_root_phases_failures.t
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ qq{
}
--- error_log eval
[
qr/\[crit\] .*? panicked at 'trap on_vm_start'/,
qr/(\[error\] .*?(Uncaught RuntimeError: )?unreachable|wasm trap: wasm `unreachable` instruction executed)/,
qr/\[crit\] .*? panicked at/,
qr/trap on_vm_start/,
qr/\[emerg\] .*? failed initializing "hostcalls" filter \(initialization failed\)/,
]
--- must_die: 2
Expand Down Expand Up @@ -84,8 +84,8 @@ qq{
}
--- error_log eval
[
qr/\[crit\] .*? panicked at 'trap on_configure'/,
qr/(\[error\] .*?(Uncaught RuntimeError: )?unreachable|wasm trap: wasm `unreachable` instruction executed)/,
qr/\[crit\] .*? panicked at/,
qr/trap on_configure/,
qr/\[emerg\] .*? failed initializing "hostcalls" filter \(initialization failed\)/,
]
--- must_die: 2
Expand Down
4 changes: 2 additions & 2 deletions t/03-proxy_wasm/005-on_http_phases_failures.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ __DATA__
--- response_body
--- error_log eval
[
qr/\[crit\] .*? panicked at 'trap'/,
qr/(\[error\] .*?(Uncaught RuntimeError: )?unreachable|wasm trap: wasm `unreachable` instruction executed)/
qr/\[crit\] .*? panicked at/,
qr/custom trap/,
]
--- no_error_log
[emerg]
4 changes: 2 additions & 2 deletions t/03-proxy_wasm/hfuncs/100-proxy_log.t
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ C
--- error_log eval
[
qr/\[alert\] .*? NYI - proxy_log bad log_level: 100/,
qr/\[crit\] .*? panicked at 'unexpected status: 2'/,
qr/(\[error\] .*?(Uncaught RuntimeError: )?unreachable|wasm trap: wasm `unreachable` instruction executed)/,
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 2/,
]
--- no_error_log
[emerg]
Expand Down
4 changes: 2 additions & 2 deletions t/03-proxy_wasm/hfuncs/102-proxy_send_local_response.t
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ should produce error page content from a panic, not from echo
--- response_body_like: 500 Internal Server Error
--- error_log eval
[
qr/\[crit\] .*? panicked at 'unexpected status: 2'/,
qr/(\[error\] .*?unreachable|wasm trap: wasm `unreachable` instruction executed).*/
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 2/,
]
--- no_error_log
[alert]
Expand Down
5 changes: 2 additions & 3 deletions t/03-proxy_wasm/hfuncs/115-proxy_get_http_response_body.t
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ Hello world
--- error_log eval
[
qr/on_response_body, 12 bytes, eof: false/,
qr/\[crit\] .*? panicked at 'unexpected status: 10'/
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 10/
]
--- no_error_log
[alert]
4 changes: 2 additions & 2 deletions t/03-proxy_wasm/hfuncs/119-proxy_properties_get_ngx.t
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,6 @@ is global (single instance for root/request).
[
qr/\[info\] .*? \[hostcalls\] on_tick/,
qr/\[error\] .*? cannot get ngx properties outside of a request/,
qr/\[crit\] .*? panicked at 'unexpected status: 10'/,
qr/(.*?(Uncaught RuntimeError: )?unreachable|wasm trap: wasm `unreachable` instruction executed).*/
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 10/,
]
8 changes: 4 additions & 4 deletions t/03-proxy_wasm/hfuncs/120-proxy_properties_get_host.t
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ is global (single instance for root/request).
[
qr/\[info\] .*? \[hostcalls\] on_tick/,
qr/\[error\] .*? cannot get host properties outside of a request/,
qr/\[crit\] .*? panicked at 'unexpected status: 10'/,
qr/(.*?(Uncaught RuntimeError: )?unreachable|wasm trap: wasm `unreachable` instruction executed).*/,
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 10/,
]
--- no_error_log
[emerg]
Expand Down Expand Up @@ -178,6 +178,6 @@ HTTP 200 since the root and request instances are different.
[
qr/\[info\] .*? \[hostcalls\] on_tick/,
qr/\[error\] .*? cannot get host properties outside of a request/,
qr/\[crit\] .*? panicked at 'unexpected status: 10'/,
qr/(.*?(Uncaught RuntimeError: )?unreachable|wasm trap: wasm `unreachable` instruction executed).*/,
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 10/,
]
11 changes: 6 additions & 5 deletions t/03-proxy_wasm/hfuncs/121-proxy_properties_set.t
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ qq{
--- error_log eval
[
qr/\[error\] .*? variable "request_uri" is not changeable/,
qr/\[crit\] .*? panicked at 'unexpected status: 10'/,
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 10/,
]
--- no_error_log
[emerg]
Expand All @@ -56,7 +55,9 @@ forward the NotFound status back to the caller.
--- error_code: 500
--- response_body_like eval: qr/500 Internal Server Error/
--- error_log eval
qr/\[crit\] .*? panicked at 'unexpected status: 1'/
[
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 1/
]
--- no_error_log
[emerg]
[alert]
8 changes: 4 additions & 4 deletions t/03-proxy_wasm/hfuncs/122-proxy_properties_set_host.t
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ isolation is global (single instance for root/request).
[
qr/\[info\] .*? \[hostcalls\] on_tick/,
qr/\[error\] .*? cannot set host properties outside of a request/,
qr/\[crit\] .*? panicked at 'unexpected status: 10'/,
qr/(.*?(Uncaught RuntimeError: )?unreachable|wasm trap: wasm `unreachable` instruction executed).*/,
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 10/,
]
--- no_error_log
[emerg]
Expand Down Expand Up @@ -199,8 +199,8 @@ ngx_http_* calls.
[
qr/\[info\] .*? \[hostcalls\] on_tick/,
qr/\[error\] .*? cannot set host properties outside of a request/,
qr/\[crit\] .*? panicked at 'unexpected status: 10'/,
qr/(.*?(Uncaught RuntimeError: )?unreachable|wasm trap: wasm `unreachable` instruction executed).*/,
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 10/,
]
--- no_error_log
[emerg]
19 changes: 10 additions & 9 deletions t/03-proxy_wasm/hfuncs/123-proxy_properties_set_ngx.t
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ GET /t?hello=world
--- error_log eval
[
qr/\[error\] .*? variable "query_string" is not changeable/,
qr/\[crit\] .*? panicked at 'unexpected status: 10'/,
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 10/,
]
--- no_error_log
[emerg]
Expand All @@ -181,10 +180,12 @@ forward the NotFound status back to the caller.
--- error_code: 500
--- response_body_like eval: qr/500 Internal Server Error/
--- error_log eval
qr/\[crit\] .*? panicked at 'unexpected status: 1'/
[
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 1/
]
--- no_error_log
[emerg]
[alert]
Expand Down Expand Up @@ -216,8 +217,8 @@ request, and isolation is global (single instance for root/request)
[
qr/\[info\] .*? \[hostcalls\] on_tick/,
qr/\[error\] .*? cannot set ngx properties outside of a request/,
qr/\[crit\] .*? panicked at 'unexpected status: 10'/,
qr/(.*?(Uncaught RuntimeError: )?unreachable|wasm trap: wasm `unreachable` instruction executed).*/
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 10/,
]
Expand Down Expand Up @@ -250,6 +251,6 @@ HTTP 200 since the root and request instances are different.
[
qr/\[info\] .*? \[hostcalls\] on_tick/,
qr/\[error\] .*? cannot set ngx properties outside of a request/,
qr/\[crit\] .*? panicked at 'unexpected status: 10'/,
qr/(.*?(Uncaught RuntimeError: )?unreachable|wasm trap: wasm `unreachable` instruction executed).*/
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 10/,
]
4 changes: 2 additions & 2 deletions t/03-proxy_wasm/hfuncs/130-proxy_dispatch_http.t
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,8 @@ tcp socket trying to receive data (max: 1017)
--- response_body_like: 500 Internal Server Error
--- error_log eval
[
qr/panicked at 'trap!'/,
qr/(\[error\]|Uncaught RuntimeError|\s+).*?unreachable/
qr/\[crit\] .*? panicked at/,
qr/trap!/,
]
Expand Down
14 changes: 9 additions & 5 deletions t/03-proxy_wasm/hfuncs/200-buffers_and_maps_bad_args.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use strict;
use lib '.';
use t::TestWasm;

plan tests => repeat_each() * (blocks() * 4);
plan tests => repeat_each() * (blocks() * 5);

run_tests();

Expand All @@ -23,7 +23,8 @@ __DATA__
--- error_log eval
[
qr/\[alert\] .*? NYI - set_buffer bad buf_type: 100/,
qr/\[crit\] .*? panicked at 'unexpected status: 2'/,
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 2/,
]
Expand All @@ -41,7 +42,8 @@ __DATA__
--- error_log eval
[
qr/\[alert\] .*? NYI - get_buffer bad buf_type: 100/,
qr/\[crit\] .*? panicked at 'unexpected status: 2'/,
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 2/,
]
Expand All @@ -59,7 +61,8 @@ __DATA__
--- error_log eval
[
qr/\[alert\] .*? NYI - set_map bad map_type: 100/,
qr/\[crit\] .*? panicked at 'unexpected status: 2'/,
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 2/,
]
Expand All @@ -77,5 +80,6 @@ __DATA__
--- error_log eval
[
qr/\[alert\] .*? NYI - get_map bad map_type: 100/,
qr/\[crit\] .*? panicked at 'unexpected status: 2'/,
qr/\[crit\] .*? panicked at/,
qr/unexpected status: 2/,
]
Loading

0 comments on commit 88723c3

Please sign in to comment.