Skip to content

Commit d3bc591

Browse files
enjoy-binbinallenss-amazon
authored andcommitted
Make ./runtest --dump-logs dump logs on valgrind / sanitizer errors (valkey-io#2427)
Sometimes we want to print server logs even if valgrind or sanitizer errors occur, which might help troubleshoot the problem. Signed-off-by: Binbin <[email protected]>
1 parent 854ba89 commit d3bc591

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

tests/support/server.tcl

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,23 @@ proc start_server_error {executable config_file error} {
1212
send_data_packet $::test_server_fd err $err
1313
}
1414

15-
proc check_valgrind_errors stderr {
16-
set res [find_valgrind_errors $stderr true]
15+
proc check_valgrind_errors srv {
16+
set res [find_valgrind_errors [dict get $srv stderr] true]
1717
if {$res != ""} {
1818
send_data_packet $::test_server_fd err "Valgrind error: $res\n"
19+
if {$::dump_logs} {
20+
dump_server_log $srv
21+
}
1922
}
2023
}
2124

22-
proc check_sanitizer_errors stderr {
23-
set res [sanitizer_errors_from_file $stderr]
25+
proc check_sanitizer_errors srv {
26+
set res [sanitizer_errors_from_file [dict get $srv stderr]]
2427
if {$res != ""} {
2528
send_data_packet $::test_server_fd err "Sanitizer error: $res\n"
29+
if {$::dump_logs} {
30+
dump_server_log $srv
31+
}
2632
}
2733
}
2834

@@ -42,6 +48,7 @@ proc clean_persistence config {
4248
catch {exec rm -rf $rdb}
4349
}
4450

51+
# config is actually a srv
4552
proc kill_server config {
4653
# nothing to kill when running against external server
4754
if {$::external} return
@@ -56,10 +63,10 @@ proc kill_server config {
5663
if {![is_alive $pid]} {
5764
# Check valgrind errors if needed
5865
if {$::valgrind} {
59-
check_valgrind_errors [dict get $config stderr]
66+
check_valgrind_errors $config
6067
}
6168

62-
check_sanitizer_errors [dict get $config stderr]
69+
check_sanitizer_errors $config
6370

6471
# Remove this pid from the set of active pids in the test server.
6572
send_data_packet $::test_server_fd server-killed $pid
@@ -120,10 +127,10 @@ proc kill_server config {
120127

121128
# Check valgrind errors if needed
122129
if {$::valgrind} {
123-
check_valgrind_errors [dict get $config stderr]
130+
check_valgrind_errors $config
124131
}
125132

126-
check_sanitizer_errors [dict get $config stderr]
133+
check_sanitizer_errors $config
127134

128135
# Remove this pid from the set of active pids in the test server.
129136
send_data_packet $::test_server_fd server-killed $pid

0 commit comments

Comments
 (0)