summaryrefslogtreecommitdiff
path: root/tests/instances.tcl
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-01-02 13:14:23 +0100
committerantirez <antirez@gmail.com>2016-01-02 13:14:23 +0100
commit8b3aa734c9d62271a931b65b28f2e1b7eba1e42b (patch)
treedd2f560a389a940dba7d59040530365e2f569e41 /tests/instances.tcl
parent190babe2df31556500bda417a93eb2d560009d08 (diff)
downloadredis-8b3aa734c9d62271a931b65b28f2e1b7eba1e42b.tar.gz
Cluster test: do leaks detection with OSX leaks utility.
Diffstat (limited to 'tests/instances.tcl')
-rw-r--r--tests/instances.tcl32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/instances.tcl b/tests/instances.tcl
index 5251ffa38..766e820e9 100644
--- a/tests/instances.tcl
+++ b/tests/instances.tcl
@@ -249,6 +249,37 @@ proc test {descr code} {
}
}
+# Check memory leaks when running on OSX using the "leaks" utility.
+proc check_leaks instance_types {
+ if {[string match {*Darwin*} [exec uname -a]]} {
+ puts -nonewline "Testing for memory leaks..."; flush stdout
+ foreach type $instance_types {
+ foreach_instance_id [set ::${type}_instances] id {
+ if {[instance_is_killed $type $id]} continue
+ set pid [get_instance_attrib $type $id pid]
+ set output {0 leaks}
+ catch {exec leaks $pid} output
+ if {[string match {*process does not exist*} $output] ||
+ [string match {*cannot examine*} $output]} {
+ # In a few tests we kill the server process.
+ set output "0 leaks"
+ } else {
+ puts -nonewline "$type/$pid "
+ flush stdout
+ }
+ if {![string match {*0 leaks*} $output]} {
+ puts [colorstr red "=== MEMORY LEAK DETECTED ==="]
+ puts "Instance type $type, ID $id:"
+ puts $output
+ puts "==="
+ incr ::failed
+ }
+ }
+ }
+ puts ""
+ }
+}
+
# Execute all the units inside the 'tests' directory.
proc run_tests {} {
set tests [lsort [glob ../tests/*]]
@@ -259,6 +290,7 @@ proc run_tests {} {
if {[file isdirectory $test]} continue
puts [colorstr yellow "Testing unit: [lindex [file split $test] end]"]
source $test
+ check_leaks {redis sentinel}
}
}