summaryrefslogtreecommitdiff
path: root/tests/integration/logging.tcl
blob: 4f8639be0deb492a0a5cca3a26b9b7fa7b36d7f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
    # and on static binaries (ldd exit code 1) where we can't detect libmusl
    catch {
        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 crash-memcheck-enabled no]] {
        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 crash-memcheck-enabled no]] {
        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 }
        }
    }
}

}