Commit f22fa959 authored by bodong.ybd's avatar bodong.ybd
Browse files

Tests: Some fixes for macOS

1) cur_test: when restart_server, "no such variable" error occurs
  ./runtest --single integration/rdb
  test {client freed during loading}
      SET ::cur_test
      restart_server
        kill_server
          test "Check for memory leaks (pid $pid)"
          SET ::cur_test
          UNSET ::cur_test
      UNSET ::cur_test // This global variable has been unset.

2) `ps --ppid` not available on macOS platform, can be replaced with
`pgrep -P pid`.
parent b491d477
...@@ -190,5 +190,4 @@ proc test {name code {okpattern undefined} {options undefined}} { ...@@ -190,5 +190,4 @@ proc test {name code {okpattern undefined} {options undefined}} {
send_data_packet $::test_server_fd err "Detected a memory leak in test '$name': $output" send_data_packet $::test_server_fd err "Detected a memory leak in test '$name': $output"
} }
} }
unset ::cur_test
} }
...@@ -508,8 +508,13 @@ proc populate {num prefix size} { ...@@ -508,8 +508,13 @@ proc populate {num prefix size} {
proc get_child_pid {idx} { proc get_child_pid {idx} {
set pid [srv $idx pid] set pid [srv $idx pid]
if {[string match {*Darwin*} [exec uname -a]]} {
set fd [open "|pgrep -P $pid" "r"]
set child_pid [string trim [lindex [split [read $fd] \n] 0]]
} else {
set fd [open "|ps --ppid $pid -o pid" "r"] set fd [open "|ps --ppid $pid -o pid" "r"]
set child_pid [string trim [lindex [split [read $fd] \n] 1]] set child_pid [string trim [lindex [split [read $fd] \n] 1]]
}
close $fd close $fd
return $child_pid return $child_pid
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment