From 36be34bb87f6292b6259172d974c211023e5ba43 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 23 Sep 2015 10:34:00 +0200 Subject: [PATCH] Test: support for stack logging for OSX malloc/leaks. --- tests/support/server.tcl | 2 ++ tests/test_helper.tcl | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/tests/support/server.tcl b/tests/support/server.tcl index e5c31af28b4..19d6c5152b6 100644 --- a/tests/support/server.tcl +++ b/tests/support/server.tcl @@ -213,6 +213,8 @@ proc start_server {options {code undefined}} { if {$::valgrind} { set pid [exec valgrind --track-origins=yes --suppressions=src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full src/redis-server $config_file > $stdout 2> $stderr &] + } elseif ($::stack_logging) { + set pid [exec /usr/bin/env MallocStackLogging=1 MallocLogFile=/tmp/malloc_log.txt src/redis-server $config_file > $stdout 2> $stderr &] } else { set pid [exec src/redis-server $config_file > $stdout 2> $stderr &] } diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index 914f6ba1ef1..1c38f9fd0a7 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -391,6 +391,7 @@ proc send_data_packet {fd status data} { proc print_help_screen {} { puts [join { "--valgrind Run the test over valgrind." + "--stack-logging Enable OSX leaks/malloc stack logging." "--accurate Run slow randomized tests for more iterations." "--quiet Don't show individual tests." "--single Just execute the specified unit (see next option)." @@ -417,6 +418,10 @@ for {set j 0} {$j < [llength $argv]} {incr j} { incr j } elseif {$opt eq {--valgrind}} { set ::valgrind 1 + } elseif {$opt eq {--stack-logging}} { + if {[string match {*Darwin*} [exec uname -a]]} { + set ::stack_logging 1 + } } elseif {$opt eq {--quiet}} { set ::quiet 1 } elseif {$opt eq {--host}} {