Commit 986fa1ab authored by Andrey Vagin's avatar Andrey Vagin Committed by Cyrill Gorcunov

zdtm.sh: detect leaked descriptors

Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 3116e3e9
...@@ -49,6 +49,21 @@ CRTOOLS=`pwd`/`dirname $0`/../crtools ...@@ -49,6 +49,21 @@ CRTOOLS=`pwd`/`dirname $0`/../crtools
test -x $CRTOOLS || exit 1 test -x $CRTOOLS || exit 1
ARGS="" ARGS=""
save_fds()
{
ls -l /proc/$1/fd | sed 's/\(-> \(pipe\|socket\)\):.*/\1/' > $2
}
diff_fds()
{
if ! diff -up $1 $2; then
echo ERROR: Sets of descriptors are differ:
echo $1
echo $2
return 1
fi
}
run_test() run_test()
{ {
local test=$ZP/$1 local test=$ZP/$1
...@@ -67,12 +82,14 @@ run_test() ...@@ -67,12 +82,14 @@ run_test()
echo Dump $pid echo Dump $pid
mkdir -p $ddump mkdir -p $ddump
save_fds $pid $ddump/dump.fd
setsid $CRTOOLS dump -D $ddump -o dump.log -t $pid $args $ARGS || { setsid $CRTOOLS dump -D $ddump -o dump.log -t $pid $args $ARGS || {
echo WARNING: process $tname is left running for your debugging needs echo WARNING: process $tname is left running for your debugging needs
return 1 return 1
} }
if expr " $ARGS" : ' -s'; then if expr " $ARGS" : ' -s'; then
save_fds $pid $ddump/dump.fd.after
diff_fds $ddump/dump.fd $ddump/dump.fd.after || return 1
killall -CONT $tname killall -CONT $tname
else else
while :; do while :; do
...@@ -83,6 +100,9 @@ run_test() ...@@ -83,6 +100,9 @@ run_test()
echo Restore $pid echo Restore $pid
setsid $CRTOOLS restore -D $ddump -o restore.log -d -t $pid $args || return 2 setsid $CRTOOLS restore -D $ddump -o restore.log -d -t $pid $args || return 2
save_fds $pid $ddump/restore.fd
diff_fds $ddump/dump.fd $ddump/restore.fd || return 2
fi fi
echo Check results $pid echo Check results $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