X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/ab72b4833d2054231437acccec36f32f07290075..4774a53b:/tests/support/util.tcl?ds=inline diff --git a/tests/support/util.tcl b/tests/support/util.tcl index 3f4a4259..36bc90d9 100644 --- a/tests/support/util.tcl +++ b/tests/support/util.tcl @@ -25,10 +25,33 @@ 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]} { + set _ $value + } +} + proc waitForBgsave r { while 1 { - set i [$r info] - if {[string match {*bgsave_in_progress:1*} $i]} { + if {[status r bgsave_in_progress] eq 1} { puts -nonewline "\nWaiting for background save to finish... " flush stdout after 1000 @@ -40,8 +63,7 @@ proc waitForBgsave r { proc waitForBgrewriteaof r { while 1 { - set i [$r info] - if {[string match {*bgrewriteaof_in_progress:1*} $i]} { + if {[status r bgrewriteaof_in_progress] eq 1} { puts -nonewline "\nWaiting for background AOF rewrite to finish... " flush stdout after 1000 @@ -51,6 +73,16 @@ proc waitForBgrewriteaof r { } } +proc wait_for_sync r { + while 1 { + if {[status r master_link_status] eq "down"} { + after 10 + } else { + break + } + } +} + proc randomInt {max} { expr {int(rand()*$max)} } @@ -156,3 +188,11 @@ proc createComplexDataset {r ops} { } } } + +proc formatCommand {args} { + set cmd "*[llength $args]\r\n" + foreach a $args { + append cmd "$[string length $a]\r\n$a\r\n" + } + set _ $cmd +}