Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Vagin <avagin@virtuozzo.com>2016-02-20 19:23:00 +0300
committerPavel Emelyanov <xemul@virtuozzo.com>2016-02-24 13:09:17 +0300
commit88aaae3ace1eace0399244a753895334c727c708 (patch)
tree32a9a21b4a4b91f05cd0be839e9ecfe775fc60fc /test/others/mem-snap
parenta47d2917a50273770103abdb132186f09c466b5d (diff)
tests: move non-zdtm tests to tests/others/
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Diffstat (limited to 'test/others/mem-snap')
-rw-r--r--test/others/mem-snap/Makefile2
-rwxr-xr-xtest/others/mem-snap/run-predump-2.sh66
-rwxr-xr-xtest/others/mem-snap/run-predump.sh77
-rwxr-xr-xtest/others/mem-snap/run-snap-auto-dedup.sh93
-rwxr-xr-xtest/others/mem-snap/run-snap-dedup-on-restore.sh87
-rwxr-xr-xtest/others/mem-snap/run-snap-dedup.sh99
-rwxr-xr-xtest/others/mem-snap/run-snap-maps04.sh68
-rwxr-xr-xtest/others/mem-snap/run-snap.sh74
-rwxr-xr-xtest/others/mem-snap/run.sh13
9 files changed, 579 insertions, 0 deletions
diff --git a/test/others/mem-snap/Makefile b/test/others/mem-snap/Makefile
new file mode 100644
index 000000000..7779a9903
--- /dev/null
+++ b/test/others/mem-snap/Makefile
@@ -0,0 +1,2 @@
+run:
+ ./run.sh
diff --git a/test/others/mem-snap/run-predump-2.sh b/test/others/mem-snap/run-predump-2.sh
new file mode 100755
index 000000000..809612e67
--- /dev/null
+++ b/test/others/mem-snap/run-predump-2.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+source ../../env.sh || exit 1
+
+function fail {
+ echo "$@"
+ exit 1
+}
+set -x
+
+IMGDIR="dump/"
+
+rm -rf "$IMGDIR"
+mkdir "$IMGDIR"
+
+function launch_test {
+ echo "Launching test"
+ cd ../../zdtm/live/static/
+ make cleanout
+ make maps04
+ make maps04.pid || fail "Can't start test"
+ PID=$(cat maps04.pid)
+ kill -0 $PID || fail "Test didn't start"
+ cd -
+}
+
+function stop_test {
+ wtime=1
+ cd ../../zdtm/live/static/
+ make maps04.stop
+ cat maps04.out | fgrep PASS || fail "Test failed"
+ echo "OK"
+}
+
+launch_test
+
+echo "Taking plain dump"
+
+mkdir "$IMGDIR/dump-1/"
+${CRIU} dump -D "$IMGDIR/dump-1/" -o dump.log -t ${PID} -v4 || fail "Fail to dump"
+
+sleep 1
+echo "Restore to check it works"
+${CRIU} restore -D "${IMGDIR}/dump-1/" -o restore.log -d -v4 || fail "Fail to restore server"
+
+stop_test
+
+
+launch_test
+
+echo "Taking pre and plain dumps"
+
+echo "Pre-dump"
+mkdir "$IMGDIR/dump-2/"
+mkdir "$IMGDIR/dump-2/pre/"
+${CRIU} pre-dump -D "$IMGDIR/dump-2/pre/" -o dump.log -t ${PID} -v4 || fail "Fail to pre-dump"
+
+echo "Plain dump"
+mkdir "$IMGDIR/dump-2/plain/"
+${CRIU} dump -D "$IMGDIR/dump-2/plain/" -o dump.log -t ${PID} -v4 --prev-images-dir=../pre/ --track-mem || fail "Fail to dump"
+
+sleep 1
+echo "Restore"
+${CRIU} restore -D "${IMGDIR}/dump-2/plain/" -o restore.log -d -v4 || fail "Fail to restore server"
+
+stop_test
diff --git a/test/others/mem-snap/run-predump.sh b/test/others/mem-snap/run-predump.sh
new file mode 100755
index 000000000..073784a87
--- /dev/null
+++ b/test/others/mem-snap/run-predump.sh
@@ -0,0 +1,77 @@
+#!/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:-3}
+SPAUSE=${2:-4}
+PORT=12345
+
+function fail {
+ echo "$@"
+ exit 1
+}
+set -x
+
+IMGDIR="dump/"
+
+rm -rf "$IMGDIR"
+mkdir "$IMGDIR"
+
+echo "Launching test"
+cd ../../zdtm//live/static/
+make cleanout
+make mem-touch
+make mem-touch.pid || fail "Can't start test"
+PID=$(cat mem-touch.pid)
+kill -0 $PID || fail "Test didn't start"
+cd -
+
+echo "Making $NRSNAP pre-dumps"
+
+for SNAP in $(seq 1 $NRSNAP); do
+ sleep $SPAUSE
+ mkdir "$IMGDIR/$SNAP/"
+ if [ $SNAP -eq 1 ] ; then
+ # First pre-dump
+ cmd="pre-dump"
+ args="--track-mem -R"
+ elif [ $SNAP -eq $NRSNAP ]; then
+ # Last dump
+ cmd="dump"
+ args="--prev-images-dir=../$((SNAP - 1))/ --track-mem"
+ else
+ # Other pre-dumps
+ cmd="pre-dump"
+ args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R"
+ fi
+
+ if [ $USEPS -eq 1 ]; then
+ ${CRIU} page-server -D "${IMGDIR}/$SNAP/" -o ps.log --port ${PORT} -v4 &
+ PS_PID=$!
+ ps_args="--page-server --address 127.0.0.1 --port=${PORT}"
+ else
+ ps_args=""
+ fi
+
+ ${CRIU} $cmd -D "${IMGDIR}/$SNAP/" -o dump.log -t ${PID} -v4 $args $ps_args || fail "Fail to dump"
+ if [ $USEPS -eq 1 ]; then
+ wait $PS_PID
+ fi
+done
+
+echo "Restoring"
+${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -d -v4 || fail "Fail to restore server"
+
+cd ../../zdtm//live/static/
+make mem-touch.stop
+cat mem-touch.out | fgrep PASS || fail "Test failed"
+
+echo "Test PASSED"
diff --git a/test/others/mem-snap/run-snap-auto-dedup.sh b/test/others/mem-snap/run-snap-auto-dedup.sh
new file mode 100755
index 000000000..c0d87792e
--- /dev/null
+++ b/test/others/mem-snap/run-snap-auto-dedup.sh
@@ -0,0 +1,93 @@
+#!/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:-3}
+SPAUSE=${2:-4}
+PORT=12345
+
+function fail {
+ echo "$@"
+ exit 1
+}
+set -x
+
+IMGDIR="dump/"
+
+rm -rf "$IMGDIR"
+mkdir "$IMGDIR"
+
+echo "Launching test"
+cd ../../zdtm//live/static/
+make cleanout
+make mem-touch
+make mem-touch.pid || fail "Can't start test"
+PID=$(cat mem-touch.pid)
+kill -0 $PID || fail "Test didn't start"
+cd -
+
+echo "Making $NRSNAP snapshots"
+
+for SNAP in $(seq 1 $NRSNAP); do
+ sleep $SPAUSE
+ mkdir "$IMGDIR/$SNAP/"
+ if [ $SNAP -eq 1 ] ; then
+ # First snapshot -- no parent, keep running
+ args="--track-mem -R"
+ elif [ $SNAP -eq $NRSNAP ]; then
+ # Last snapshot -- has parent, kill afterwards
+ size_first_2=$(du -sh -BK dump/2/pages-*.img | grep -Eo '[0-9]+' | head -1)
+ size_first_1=$(du -sh -BK dump/1/pages-*.img | grep -Eo '[0-9]+' | head -1)
+ args="--prev-images-dir=../$((SNAP - 1))/ --track-mem --auto-dedup"
+ else
+ # Other snapshots -- have parent, keep running
+ args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R"
+ fi
+
+ if [ $USEPS -eq 1 ]; then
+ ${CRIU} page-server -D "${IMGDIR}/$SNAP/" -o ps.log --auto-dedup --port ${PORT} -v4 &
+ PS_PID=$!
+ ps_args="--page-server --address 127.0.0.1 --port=${PORT}"
+ else
+ ps_args=""
+ fi
+
+ ${CRIU} dump -D "${IMGDIR}/$SNAP/" -o dump.log -t ${PID} -v4 $args $ps_args || fail "Fail to dump"
+ if [ $USEPS -eq 1 ]; then
+ wait $PS_PID
+ fi
+done
+
+size_last_2=$(du -sh -BK dump/2/pages-*.img | grep -Eo '[0-9]+' | head -1)
+size_last_1=$(du -sh -BK dump/1/pages-*.img | grep -Eo '[0-9]+' | head -1)
+
+dedup_ok_2=1
+if [ $size_first_2 -gt $size_last_2 ]; then
+ dedup_ok_2=0
+fi
+
+dedup_ok_1=1
+if [ $size_first_1 -gt $size_last_1 ]; then
+ dedup_ok_1=0
+fi
+
+echo "Restoring"
+${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -d -v4 || fail "Fail to restore server"
+
+cd ../../zdtm//live/static/
+make mem-touch.stop
+cat mem-touch.out | fgrep PASS || fail "Test failed"
+
+if [[ $dedup_ok_2 -ne 0 || $dedup_ok_1 -ne 0 ]]; then
+ fail "Dedup test failed"
+fi
+
+echo "Test PASSED"
diff --git a/test/others/mem-snap/run-snap-dedup-on-restore.sh b/test/others/mem-snap/run-snap-dedup-on-restore.sh
new file mode 100755
index 000000000..5821d8a68
--- /dev/null
+++ b/test/others/mem-snap/run-snap-dedup-on-restore.sh
@@ -0,0 +1,87 @@
+#!/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:-3}
+SPAUSE=${2:-4}
+PORT=12345
+
+function fail {
+ echo "$@"
+ exit 1
+}
+set -x
+
+IMGDIR="dump/"
+
+rm -rf "$IMGDIR"
+mkdir "$IMGDIR"
+
+echo "Launching test"
+cd ../../zdtm//live/static/
+make cleanout
+make mem-touch
+make mem-touch.pid || fail "Can't start test"
+PID=$(cat mem-touch.pid)
+kill -0 $PID || fail "Test didn't start"
+cd -
+
+echo "Making $NRSNAP snapshots"
+
+for SNAP in $(seq 1 $NRSNAP); do
+ sleep $SPAUSE
+ mkdir "$IMGDIR/$SNAP/"
+ if [ $SNAP -eq 1 ] ; then
+ # First snapshot -- no parent, keep running
+ args="--track-mem -R"
+ elif [ $SNAP -eq $NRSNAP ]; then
+ # Last snapshot -- has parent, kill afterwards
+ args="--prev-images-dir=../$((SNAP - 1))/ --track-mem --auto-dedup"
+ else
+ # Other snapshots -- have parent, keep running
+ args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R --auto-dedup"
+ fi
+
+ if [ $USEPS -eq 1 ]; then
+ ${CRIU} page-server -D "${IMGDIR}/$SNAP/" -o ps.log --auto-dedup --port ${PORT} -v4 &
+ PS_PID=$!
+ ps_args="--page-server --address 127.0.0.1 --port=${PORT}"
+ else
+ ps_args=""
+ fi
+
+ ${CRIU} dump -D "${IMGDIR}/$SNAP/" -o dump.log -t ${PID} -v4 $args $ps_args || fail "Fail to dump"
+ if [ $USEPS -eq 1 ]; then
+ wait $PS_PID
+ fi
+done
+
+echo "Restoring"
+${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log --auto-dedup -d -v4 || fail "Fail to restore server"
+
+size_last3=$(du -sh -BK dump/3/pages-*.img | grep -Eo '[0-9]+' | head -1)
+size_last2=$(du -sh -BK dump/2/pages-*.img | grep -Eo '[0-9]+' | head -1)
+size_last1=$(du -sh -BK dump/1/pages-*.img | grep -Eo '[0-9]+' | head -1)
+
+restore_dedup_ok=0
+if [[ $size_last1 -ne 0 || $size_last2 -ne 0 || $size_last3 -ne 0 ]]; then
+ restore_dedup_ok=1
+fi
+
+cd ../../zdtm//live/static/
+make mem-touch.stop
+cat mem-touch.out | fgrep PASS || fail "Test failed"
+
+if [ $restore_dedup_ok -ne 0 ]; then
+ fail "Dedup test failed"
+fi
+
+echo "Test PASSED"
diff --git a/test/others/mem-snap/run-snap-dedup.sh b/test/others/mem-snap/run-snap-dedup.sh
new file mode 100755
index 000000000..f59342e6e
--- /dev/null
+++ b/test/others/mem-snap/run-snap-dedup.sh
@@ -0,0 +1,99 @@
+#!/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:-3}
+SPAUSE=${2:-4}
+PORT=12345
+
+function fail {
+ echo "$@"
+ exit 1
+}
+set -x
+
+IMGDIR="dump/"
+
+rm -rf "$IMGDIR"
+mkdir "$IMGDIR"
+
+echo "Launching test"
+cd ../../zdtm/live/static/
+make cleanout
+make mem-touch
+make mem-touch.pid || fail "Can't start test"
+PID=$(cat mem-touch.pid)
+kill -0 $PID || fail "Test didn't start"
+cd -
+
+echo "Making $NRSNAP snapshots"
+
+for SNAP in $(seq 1 $NRSNAP); do
+ sleep $SPAUSE
+ mkdir "$IMGDIR/$SNAP/"
+ if [ $SNAP -eq 1 ] ; then
+ # First snapshot -- no parent, keep running
+ args="--track-mem -R"
+ elif [ $SNAP -eq $NRSNAP ]; then
+ # Last snapshot -- has parent, kill afterwards
+ args="--prev-images-dir=../$((SNAP - 1))/ --track-mem"
+ else
+ # Other snapshots -- have parent, keep running
+ args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R"
+ fi
+
+ if [ $USEPS -eq 1 ]; then
+ ${CRIU} page-server -D "${IMGDIR}/$SNAP/" -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}/$SNAP/" -o dump.log -t ${PID} -v4 $args $ps_args || fail "Fail to dump"
+ if [ $USEPS -eq 1 ]; then
+ wait $PS_PID
+ fi
+done
+
+echo "Dedup test"
+
+size_first_2=$(du -sh -BK dump/2/pages-*.img | grep -Eo '[0-9]+' | head -1)
+size_first_1=$(du -sh -BK dump/1/pages-*.img | grep -Eo '[0-9]+' | head -1)
+
+${CRIU} dedup -D "${IMGDIR}/$NRSNAP/"
+
+size_last_2=$(du -sh -BK dump/2/pages-*.img | grep -Eo '[0-9]+' | head -1)
+size_last_1=$(du -sh -BK dump/1/pages-*.img | grep -Eo '[0-9]+' | head -1)
+
+dedup_ok_2=1
+dedup_ok_1=1
+
+if [ $size_first_2 -gt $size_last_2 ]; then
+ dedup_ok_2=0
+fi
+
+if [ $size_first_1 -gt $size_last_1 ]; then
+ dedup_ok_1=0
+fi
+
+echo "Restoring"
+${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -d -v4 || fail "Fail to restore server"
+
+cd ../../zdtm/live/static/
+make mem-touch.stop
+cat mem-touch.out | fgrep PASS || fail "Test failed"
+
+if [[ $dedup_ok_2 -ne 0 || $dedup_ok_1 -ne 0 ]]; then
+ fail "Dedup test failed"
+fi
+
+echo "Test PASSED"
diff --git a/test/others/mem-snap/run-snap-maps04.sh b/test/others/mem-snap/run-snap-maps04.sh
new file mode 100755
index 000000000..97c493958
--- /dev/null
+++ b/test/others/mem-snap/run-snap-maps04.sh
@@ -0,0 +1,68 @@
+#!/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"
+make -C ../../zdtm//live/static/ cleanout
+make -C ../../zdtm//live/static/ maps04
+make -C ../../zdtm//live/static/ maps04.pid || fail "Can't start test"
+PID=$(cat ../../zdtm//live/static/maps04.pid)
+kill -0 $PID || fail "Test haven't started"
+
+mkdir "$IMGDIR/$NRSNAP/"
+
+if [ $USEPS -eq 1 ] ; then
+ ${CRIU} page-server -D "${IMGDIR}/$NRSNAP/" -o ps.log --port ${PORT} -d -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"
+
+make -C ../../zdtm//live/static/ maps04.stop
+sleep 1
+
+cat "../zdtm/live/static/maps04.out" | fgrep PASS || fail "Test failed"
+
+size=$(du -sh -BK dump/1/pages-*.img | grep -Eo '[0-9]+' | head -1)
+if [ $size -ne 0 ] ; then
+ fail "Size not null"
+fi
+
+echo "Test PASSED"
diff --git a/test/others/mem-snap/run-snap.sh b/test/others/mem-snap/run-snap.sh
new file mode 100755
index 000000000..6aca4d971
--- /dev/null
+++ b/test/others/mem-snap/run-snap.sh
@@ -0,0 +1,74 @@
+#!/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:-3}
+SPAUSE=${2:-4}
+PORT=12345
+
+function fail {
+ echo "$@"
+ exit 1
+}
+set -x
+
+IMGDIR="dump/"
+
+rm -rf "$IMGDIR"
+mkdir "$IMGDIR"
+
+echo "Launching test"
+cd ../../zdtm/live/static/
+make cleanout
+make mem-touch
+make mem-touch.pid || fail "Can't start test"
+PID=$(cat mem-touch.pid)
+kill -0 $PID || fail "Test didn't start"
+cd -
+
+echo "Making $NRSNAP snapshots"
+
+for SNAP in $(seq 1 $NRSNAP); do
+ sleep $SPAUSE
+ mkdir "$IMGDIR/$SNAP/"
+ if [ $SNAP -eq 1 ] ; then
+ # First snapshot -- no parent, keep running
+ args="--track-mem -R"
+ elif [ $SNAP -eq $NRSNAP ]; then
+ # Last snapshot -- has parent, kill afterwards
+ args="--prev-images-dir=../$((SNAP - 1))/ --track-mem"
+ else
+ # Other snapshots -- have parent, keep running
+ args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R"
+ fi
+
+ if [ $USEPS -eq 1 ]; then
+ ${CRIU} page-server -D "${IMGDIR}/$SNAP/" -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}/$SNAP/" -o dump.log -t ${PID} -v4 $args $ps_args || fail "Fail to dump"
+ if [ $USEPS -eq 1 ]; then
+ wait $PS_PID
+ fi
+done
+
+echo "Restoring"
+${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -d -v4 || fail "Fail to restore server"
+
+cd ../../zdtm/live/static/
+make mem-touch.stop
+cat mem-touch.out | fgrep PASS || fail "Test failed"
+
+echo "Test PASSED"
diff --git a/test/others/mem-snap/run.sh b/test/others/mem-snap/run.sh
new file mode 100755
index 000000000..b3995ecf0
--- /dev/null
+++ b/test/others/mem-snap/run.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Don't execute tests, which use maps04, they are executed by zdtm
+
+set -e
+
+#./run-predump-2.sh
+./run-predump.sh
+./run-snap-auto-dedup.sh
+./run-snap-dedup-on-restore.sh
+./run-snap-dedup.sh
+#./run-snap-maps04.sh
+./run-snap.sh