mirror of
http://github.com/valkey-io/valkey
synced 2024-11-23 03:33:28 +00:00
print warnings in redis log when a test raises an exception (very likely to be caused by something like a failed assertion)
This commit is contained in:
parent
85ecc65edc
commit
fdfb02e7ff
2
redis.c
2
redis.c
@ -10556,7 +10556,7 @@ static void debugCommand(redisClient *c) {
|
||||
|
||||
static void _redisAssert(char *estr, char *file, int line) {
|
||||
redisLog(REDIS_WARNING,"=== ASSERTION FAILED ===");
|
||||
redisLog(REDIS_WARNING,"==> %s:%d '%s' is not true\n",file,line,estr);
|
||||
redisLog(REDIS_WARNING,"==> %s:%d '%s' is not true",file,line,estr);
|
||||
#ifdef HAVE_BACKTRACE
|
||||
redisLog(REDIS_WARNING,"(forcing SIGSEGV in order to print the stack trace)");
|
||||
*((char*)-1) = 'x';
|
||||
|
@ -7,7 +7,16 @@ proc test {name code okpattern} {
|
||||
# if {$::testnum < $::first || $::testnum > $::last} return
|
||||
puts -nonewline [format "#%03d %-68s " $::testnum $name]
|
||||
flush stdout
|
||||
set retval [uplevel 1 $code]
|
||||
if {[catch {set retval [uplevel 1 $code]} error]} {
|
||||
puts "ERROR\n\nLogged warnings:"
|
||||
foreach file [glob tests/tmp/server.[pid].*/stdout] {
|
||||
set warnings [warnings_from_file $file]
|
||||
if {[string length $warnings] > 0} {
|
||||
puts $warnings
|
||||
}
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
if {$okpattern eq $retval || [string match $okpattern $retval]} {
|
||||
puts "PASSED"
|
||||
incr ::passed
|
||||
|
@ -25,6 +25,23 @@ proc zlistAlikeSort {a b} {
|
||||
string compare [lindex $a 1] [lindex $b 1]
|
||||
}
|
||||
|
||||
# Return all log lines starting with the first line that contains a warning.
|
||||
# Generally, this will be an assertion error with a stack trace.
|
||||
proc warnings_from_file {filename} {
|
||||
set lines [split [exec cat $filename] "\n"]
|
||||
set matched 0
|
||||
set result {}
|
||||
foreach line $lines {
|
||||
if {[regexp {^\[\d+\]\s+\d+\s+\w+\s+\d{2}:\d{2}:\d{2} \#} $line]} {
|
||||
set matched 1
|
||||
}
|
||||
if {$matched} {
|
||||
lappend result $line
|
||||
}
|
||||
}
|
||||
join $result "\n"
|
||||
}
|
||||
|
||||
# Return value for INFO property
|
||||
proc status {r property} {
|
||||
if {[regexp "\r\n$property:(.*?)\r\n" [$r info] _ value]} {
|
||||
|
Loading…
Reference in New Issue
Block a user