From ee59dc1b5cdcc631438aba3904d6d3b520354c80 Mon Sep 17 00:00:00 2001 From: Yang Bodong Date: Wed, 23 Dec 2020 22:28:17 +0800 Subject: [PATCH] Tests: fix the problem that Darwin memory leak detection may fail (#8213) Apparently the "leaks" took reports a different error string about process that's not found in each version of MacOS. This cause the test suite to fail on some OS versions, since some tests terminate the process before looking for leaks. Instead of looking at the error string, we now look at the (documented) exit code. --- tests/support/server.tcl | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/support/server.tcl b/tests/support/server.tcl index 1cddb7068..77ba31d84 100644 --- a/tests/support/server.tcl +++ b/tests/support/server.tcl @@ -50,11 +50,17 @@ proc kill_server config { tags {"leaks"} { test "Check for memory leaks (pid $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" + catch {exec leaks $pid} output option + # In a few tests we kill the server process, so leaks will not find it. + # It'll exits with exit code >1 on error, so we ignore these. + if {[dict exists $option -errorcode]} { + set details [dict get $option -errorcode] + if {[lindex $details 0] eq "CHILDSTATUS"} { + set status [lindex $details 2] + if {$status > 1} { + set output "0 leaks" + } + } } set output } {*0 leaks*}