[CRIU] [PATCH] test: auto-dedup on restore

Andrew Vagin avagin at parallels.com
Tue Feb 4 07:09:22 PST 2014


On Tue, Feb 04, 2014 at 09:59:15AM +0400, Tikhomirov Pavel wrote:
> Use maps04, on tmpfs, check if size of pages image is zero in the end

I think you need to add pre-dump in this test case.

And I recomend you to use maps007 instead of maps04.

Why do you not want to integrate this in zdtm.sh?

> 
> Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
> ---
>  test/mem-snap/run-snap-maps04.sh | 72 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 72 insertions(+)
>  create mode 100755 test/mem-snap/run-snap-maps04.sh
> 
> diff --git a/test/mem-snap/run-snap-maps04.sh b/test/mem-snap/run-snap-maps04.sh
> new file mode 100755
> index 0000000..33b9213
> --- /dev/null
> +++ b/test/mem-snap/run-snap-maps04.sh
> @@ -0,0 +1,72 @@
> +#!/bin/bash
> +
> +source ../env.sh || exit 1
> +
> +USEPS=0
> +
> +if [ "$1" = "-s" ]; then
> +	echo "Will test via page-server"
> +	USEPS=1
> +	shift
> +fi
> +
> +NRSNAP=1
> +SPAUSE=${2:-4}
> +PORT=12345
> +
> +function fail {
> +	echo "$@"
> +	exit 1
> +}
> +set -x
> +
> +IMGDIR="dump"
> +CURDIR=${pwd}
> +if ! mount | fgrep "$CURDIR/$IMGDIR" ; then
> +	rm -rf "$IMGDIR"
> +	mkdir "$IMGDIR"
> +
> +	mount -t tmpfs -o size=1500M,nr_inodes=10k,mode=700 tmpfs $IMGDIR
> +fi
> +rm -rf "$IMGDIR/*"
> +
> +echo "Launching test"
> +cd ../zdtm/live/static/

Pls, don't change the current dir.

make -C ../zdtm/live/static/ cleanout

> +make cleanout
> +make maps04

make maps04.pid &&

> +make maps04.pid || fail "Can't start test"
> +PID=$(cat maps04.pid)
> +kill -0 $PID || fail "Test haven't started"
> +cd -
> +
> +sleep $SPAUSE
> +mkdir "$IMGDIR/$NRSNAP/"
> +
> +if [ $USEPS -eq 1 ] ; then
> +	${CRIU} page-server -D "${IMGDIR}/$NRSNAP/" -o ps.log --port ${PORT} -v4 &
> +	PS_PID=$!
> +	ps_args="--page-server --address 127.0.0.1 --port=${PORT}"
> +else
> +	ps_args=""
> +fi
> +
> +${CRIU} dump -D "${IMGDIR}/$NRSNAP/" -o dump.log -t ${PID} -v4 $ps_args || fail "Fail to dump"
> +if [ $USEPS -eq 1 ] ; then
> +	wait $PS_PID
> +fi
> +
> +echo "Restoring"
> +${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log --auto-dedup -d -v4 || fail "Fail to restore server"
> +
> +cd ../zdtm/live/static/
> +make maps04.out
> +sleep 1

I don't like unconditional sleeps in test scripts

> +cat "maps04.out" | fgrep PASS || fail "Test failed"
> +
> +cd -
> +size=$(du -sh -BK  dump/1/pages-*.img | grep -Eo '[0-9]+' | head -1)
> +if [ $size -ne 0 ] ; then

$ if [ $size -ne 0 ] ; then echo FAIL; fi
bash: [: -ne: unary operator expected

if [ "$size" -ne 0 ]; then

> +	fail "Size not null"
> +fi
> +
> +echo "Test PASSED"
> -- 
> 1.8.3.2
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list