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

Christopher Covington cov at codeaurora.org
Tue Oct 28 08:54:16 PDT 2014


Hi Andrey,

On 10/28/2014 05:12 AM, Andrey Vagin wrote:
> Now we check them for all test processes
> 
> 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

Busybox doesn't have truncate. Can you use `echo -n > $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

Same.

> +	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 && {
> 

Thanks,
Chris

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


More information about the CRIU mailing list