[CRIU] [PATCH 1/2] zdtm.sh: don't allow anyone to print on stdout

Andrew Vagin avagin at parallels.com
Thu Jan 29 03:37:21 PST 2015


On Wed, Jan 28, 2015 at 10:38:00AM -0500, Christopher Covington wrote:
> There's not commit message to explain why you want this. Why do you want this?

Sorry, I forgot to explain this.

We use zdtm.sh -l in test/Makefile and we expect that this command
prints a test list on stdout and nothing else.

Before this patch the "criu check" command printed the "Looks good."
message on sdtout too. It was unexpected behaviour.

"""
+ make -C test -j 4 'ZDTM_ARGS=-C -x '\''\(maps04\|mountpoints\|inotify_irmap\)'\''' zdtm
Error (cr-check.c:669): AIO remap doesn't work properly
Error (cr-check.c:669): AIO remap doesn't work properly
Error (cr-check.c:669): AIO remap doesn't work properly
make: Entering directory `/mnt/btrfs/workspace/test'
Makefile:63: target `Looks' given more than once in the same rule.
Makefile:63: target `good.' given more than once in the same rule.
Makefile:63: target `Looks' given more than once in the same rule.
Makefile:63: target `good.' given more than once in the same rule.
Makefile:63: target `Looks' given more than once in the same rule.
Makefile:63: target `good.' given more than once in the same rule.
"""

It was the main reason. Actually I thinkg it's a standard technique
for applications. Stdout output is moderated and stderr output can
contain anything.

Now if you want to print something on stdout, you need to print this
into the third descriptor.

Thanks,
Andrew

> 
> Thanks,
> Chris
> 
> On 01/22/2015 04:07 PM, Andrey Vagin wrote:
> > Signed-off-by: Andrey Vagin <avagin at openvz.org>
> > ---
> >  test/zdtm.sh | 15 +++++++++++++--
> >  1 file changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/test/zdtm.sh b/test/zdtm.sh
> > index 01bcbec..fa6b4bc 100755
> > --- a/test/zdtm.sh
> > +++ b/test/zdtm.sh
> > @@ -1,5 +1,10 @@
> >  #!/bin/bash
> >  
> > +# duplicate stdout into 3
> > +exec 3<&1
> > +# duplicate stderr into stdout
> > +exec 1>&2
> > +
> >  ARCH=`uname -m | sed			\
> >  		-e s/i.86/i386/		\
> >  		-e s/sun4u/sparc64/	\
> > @@ -541,7 +546,13 @@ start_test()
> >  		rm -f $ZDTM_PIDFILE
> >  	fi
> >  
> > -	if ! make -C $tdir $tname.pid; then
> > +	(
> > +		# Here is no way to set FD_CLOEXEC on 3
> > +		exec 3>&-
> > +		make -C $tdir $tname.pid
> > +	)
> > +
> > +	if [ $? -ne 0 ]; then
> >  		echo ERROR: fail to start $test
> >  		return 1
> >  	fi
> > @@ -1025,7 +1036,7 @@ while :; do
> >  		shift
> >  		;;
> >  	  -l)
> > -		echo $TEST_LIST | tr ' ' '\n'
> > +		echo $TEST_LIST | tr ' ' '\n' >&3
> >  		exit 0
> >  		;;
> >  	  -v)
> > 
> 
> 
> -- 
> 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