[CRIU] [PATCH] zdtm: improve checking file descriptors and memory regions

Andrew Vagin avagin at parallels.com
Tue Oct 28 02:35:11 PDT 2014


On Tue, Oct 28, 2014 at 12:19:28PM +0400, Pavel Emelyanov wrote:
> On 10/28/2014 01:12 PM, Andrey Vagin wrote:
> > Now we check them for all test processes
> 
> Why do we need it at all? There's a test in zdtm suit
> already, that checks for no extra files after restore.

static/fd is very simple. You don't know which code doesn't close a file
descriptor. For example when we are restoring a socket pair, we may
forget to close a file descriptor, which belongs to another process.
static/fd can't to catch this bug, because it doesn't create unix
sockets.

> 
> > Signed-off-by: Andrey Vagin <avagin at openvz.org>
> > ---
> >  test/Makefile |  2 +-
> >  test/zdtm.sh  | 30 +++++++++++++++++++-----------
> >  2 files changed, 20 insertions(+), 12 deletions(-)
> > 
> > diff --git a/test/Makefile b/test/Makefile
> > index 9ab8f3d..aa27f53 100644
> > --- a/test/Makefile
> > +++ b/test/Makefile
> > @@ -61,5 +61,5 @@ mount_cgroups: .FORCE
> >  
> >  $(TST): zdtm_ct mount_cgroups .FORCE
> >  	./zdtm.sh --ct ${ZDTM_ARGS} $(@) &> $(subst /,_,$@).log; \
> > -	{ ret=$$?; flock Makefile cat $(subst /,_,$@).log; exit $$ret; }
> > +	{ ret=$$?; fname=$(subst /,_,$@).log; flock Makefile cat $$fname; unlink $$fname; exit $$ret; }
> >  .PHONY: zdtm_ns
> > diff --git a/test/zdtm.sh b/test/zdtm.sh
> > index 191acdf..0f7609a 100755
> > --- a/test/zdtm.sh
> > +++ b/test/zdtm.sh
> > @@ -451,17 +451,29 @@ stop_test()
> >  
> >  save_fds()
> >  {
> > -	test -n "$PIDNS" && return 0
> > -	ls -l /proc/$1/fd | sed 's/\(-> \(pipe\|socket\)\):.*/\1/' | sed -e 's/\/.nfs[0-9a-zA-Z]*/.nfs-silly-rename/' | awk '{ print $9,$10,$11; }' > $2
> > +	test -z "$PIDNS" && return 0
> > +	truncate --size 0 $2
> > +	for p in `ls /proc/$1/root/proc/ | grep "^[0-9]*$"`; do
> > +		ls -l /proc/$1/root/proc/$p/fd |
> > +			sed 's/\(-> \(pipe\|socket\)\):.*/\1/' |
> > +			sed -e 's/\/.nfs[0-9a-zA-Z]*/.nfs-silly-rename/' |
> > +			sed 's/net:\[[0-9].*\]/net/' |
> > +			awk '{ print $9,$10,$11; }' | sort >> $2
> > +	done
> >  }
> >  
> >  save_maps()
> >  {
> > -	cat /proc/$1/maps | python maps.py > $2
> > +	test -z "$PIDNS" && return 0
> > +	truncate --size 0 $2
> > +	for p in `ls /proc/$1/root/proc/ | grep "^[0-9]*$"`; do
> > +		cat /proc/$1/root/proc/$p/maps | python maps.py >> $2
> > +	done
> >  }
> >  
> >  diff_maps()
> >  {
> > +	test -z "$PIDNS" && return 0
> >  	if ! diff -up $1 $2; then
> >  		echo ERROR: Sets of mappings differ:
> >  		echo $1
> > @@ -472,7 +484,7 @@ diff_maps()
> >  
> >  diff_fds()
> >  {
> > -	test -n "$PIDNS" && return 0
> > +	test -z "$PIDNS" && return 0
> >  	if ! diff -up $1 $2; then
> >  		echo ERROR: Sets of descriptors differ:
> >  		echo $1
> > @@ -511,7 +523,6 @@ run_test()
> >  	echo "Execute $test"
> >  
> >  	start_test $tdir $tname || return 1
> > -	read
> >  
> >  	if [ $START_ONLY -eq 1 ]; then
> >  		echo "Test is started"
> > @@ -653,12 +664,9 @@ EOF
> >  			cat $ddump/restore.log* | grep Error
> >  
> >  			[ -n "$PIDNS" ] && PID=`cat $TPID`
> > -			for i in `seq 5`; do
> > -				save_fds $PID  $ddump/restore.fd
> > -				diff_fds $ddump/dump.fd $ddump/restore.fd && break
> > -				sleep 0.2
> > -			done
> > -			[ $i -eq 5 ] && return 2
> > +
> > +			save_fds $PID  $ddump/restore.fd
> > +			diff_fds $ddump/dump.fd $ddump/restore.fd || return 2
> >  
> >  			save_maps $PID $ddump/restore.maps
> >  			expr $tname : "static" > /dev/null && {
> > 
> 


More information about the CRIU mailing list