mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
test: Add test for memory snapshots
Two args (optional) -- number of snaps (3 defail) and pause between them (4 defail). Uses memory toucher from zdtm/. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
53
test/mem-snap/run.sh
Executable file
53
test/mem-snap/run.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
NRSNAP=${1:-3}
|
||||
SPAUSE=${2:-4}
|
||||
|
||||
function fail {
|
||||
echo "$@"
|
||||
exit 1
|
||||
}
|
||||
set -x
|
||||
|
||||
CRTOOLS="../../crtools"
|
||||
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="--snapshot -R"
|
||||
elif [ $SNAP -eq $NRSNAP ]; then
|
||||
# Last snapshot -- has parent, kill afterwards
|
||||
args="--snapshot=../$((SNAP - 1))/"
|
||||
else
|
||||
# Other snapshots -- have parent, keep running
|
||||
args="--snapshot=../$((SNAP - 1))/ -R"
|
||||
fi
|
||||
|
||||
${CRTOOLS} dump -D "${IMGDIR}/$SNAP/" -o dump.log -t ${PID} $args || fail "Fail to dump"
|
||||
done
|
||||
|
||||
echo "Restoring"
|
||||
${CRTOOLS} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -t ${PID} -d -v 4 || fail "Fail to restore server"
|
||||
|
||||
cd ../zdtm/live/static/
|
||||
make mem-touch.out
|
||||
cat mem-touch.out | fgrep PASS || fail "Test failed"
|
||||
|
||||
echo "Test PASSED"
|
Reference in New Issue
Block a user