redict/tests/integration/logging.tcl
Binbin b947049f85
Fix timing issue in logging.tcl with FreeBSD (#9910)
A test failure was reported in Daily CI.
`Crash report generated on SIGABRT` with FreeBSD.

```
*** [err]: Crash report generated on SIGABRT in tests/integration/logging.tcl
Expected [string match *crashed by signal* ### Starting...(logs) in tests/integration/logging.tcl]
```

It look like `tail -1000` was executed too early, before it
printed out all the crash logs. We can give it a few more
chances by using `wait_for_log_messages`.

Other changes:
1. In `Server is able to generate a stack trace on selected systems`,
use `wait_for_log_messages`to reduce the lines of code. And if it
fails, there are more detailed logs that can be printed.

2. In `Crash report generated on DEBUG SEGFAULT`, we also use
`wait_for_log_messages` to avoid possible timing issues.
2021-12-07 12:02:58 +02:00

59 lines
1.8 KiB
Tcl

tags {"external:skip"} {
set system_name [string tolower [exec uname -s]]
set backtrace_supported 0
# We only support darwin or Linux with glibc
if {$system_name eq {darwin}} {
set backtrace_supported 1
} elseif {$system_name eq {linux}} {
# Avoid the test on libmusl, which does not support backtrace
set ldd [exec ldd src/redis-server]
if {![string match {*libc.musl*} $ldd]} {
set backtrace_supported 1
}
}
if {$backtrace_supported} {
set server_path [tmpdir server.log]
start_server [list overrides [list dir $server_path]] {
test "Server is able to generate a stack trace on selected systems" {
r config set watchdog-period 200
r debug sleep 1
set pattern "*debugCommand*"
set res [wait_for_log_messages 0 \"$pattern\" 0 100 100]
if {$::verbose} { puts $res }
}
}
}
# Valgrind will complain that the process terminated by a signal, skip it.
if {!$::valgrind} {
if {$backtrace_supported} {
set crash_pattern "*STACK TRACE*"
} else {
set crash_pattern "*crashed by signal*"
}
set server_path [tmpdir server1.log]
start_server [list overrides [list dir $server_path]] {
test "Crash report generated on SIGABRT" {
set pid [s process_id]
exec kill -SIGABRT $pid
set res [wait_for_log_messages 0 \"$crash_pattern\" 0 50 100]
if {$::verbose} { puts $res }
}
}
set server_path [tmpdir server2.log]
start_server [list overrides [list dir $server_path]] {
test "Crash report generated on DEBUG SEGFAULT" {
catch {r debug segfault}
set res [wait_for_log_messages 0 \"$crash_pattern\" 0 50 100]
if {$::verbose} { puts $res }
}
}
}
}