[CRIU] [PATCH] test: zdtm -- Add zdtm-cpt2.sh script
Andrew Vagin
avagin at parallels.com
Mon Aug 19 06:13:57 EDT 2013
On Mon, Aug 19, 2013 at 01:58:13PM +0400, Cyrill Gorcunov wrote:
>
> This is pretty trivial script I use for OpenVZ -> CRIU
> converter testing (which is named cpt2, that's where
> postfix comes from).
>
> So I'm asking for it being merged for a while (carrying
> it out of tree is quite inconvenient). We can drop it
> once converter will be complete.
The next two commands do the same:
make -C test_dir test_name.pid
make -C test_dir test_name.out
If you want to have this functionality in our tree, I would like to have
it in zdtm.sh. For example your script is not able to execute test cases
in a new set of namespaces, but zdtm.sh can do that.
Thanks.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> test/zdtm-cpt2.sh | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 81 insertions(+)
> create mode 100755 test/zdtm-cpt2.sh
>
> diff --git a/test/zdtm-cpt2.sh b/test/zdtm-cpt2.sh
> new file mode 100755
> index 0000000..56827ea
> --- /dev/null
> +++ b/test/zdtm-cpt2.sh
> @@ -0,0 +1,81 @@
> +#!/bin/sh
> +
> +#
> +# A trivial script to start/stop tests used in CRIU zdtm engine.
> +# I used it for converter but might be worth for testing if test
> +# passes start/stop cycle but fails in CRIU itself.
> +
> +basedir="test/zdtm/live"
> +
> +error_nopid()
> +{
> + echo "No $1.pid found"
> + exit 1
> +}
> +
> +start_test()
> +{
> + local testname=$1
> + local filename=`basename $testname`
> + local directory=`dirname $testname`
> + local pid=-1
> +
> + #
> + # drop any running instance
> + killall -9 $filename > /dev/null 2>&1
> +
> + #
> + # cleanup previous data
> + make -s -C $basedir/$directory $filename.cleanout
> +
> + #
> + # finally run it
> + make -s -C $basedir/$directory $filename.pid
> + pid=`cat $basedir/$testname.pid` || error_nopid $testname
> +
> + echo "test '$testname' running with pid '$pid'"
> +}
> +
> +stop_test()
> +{
> + local testname=$1
> + local filename=`basename $testname`
> + local directory=`dirname $testname`
> + local pid=-1
> +
> + #
> + # get running pid
> + pid=`cat $basedir/$testname.pid` || error_nopid $testname
> +
> + #
> + # finalize it and read results
> + kill $pid > /dev/null 2>&1
> + sltime=1
> + for i in `seq 10`; do
> + test -f $basedir/$testname.out && break
> + echo Waiting...
> + sleep 0.$sltime
> + [ $sltime -lt 9 ] && sltime=$((sltime+1))
> + done
> + cat $basedir/$testname.out
> +}
> +
> +if [ $# -ge 2 ]; then
> + case $1 in
> + start)
> + shift
> + for i in $@; do
> + start_test $i
> + done
> + ;;
> + stop)
> + shift
> + for i in $@; do
> + stop_test $i
> + done
> + ;;
> + *)
> + echo "(start|stop) test-name"
> + ;;
> + esac
> +fi
More information about the CRIU
mailing list