diff --git a/test/mounts/mounts.py b/test/mounts/mounts.py new file mode 100755 index 000000000..7f11d7dc0 --- /dev/null +++ b/test/mounts/mounts.py @@ -0,0 +1,31 @@ +import os +import tempfile, random + +def mount(src, dst, shared, private, slave): + cmd = "mount" + if shared: + cmd += " --make-shared" + if private: + cmd += " --make-private" + if slave: + cmd += " --make-slave" + if src: + cmd += " --bind '%s' '%s'" % (src, dst) + else: + cmd += " -t tmpfs none '%s'" % (dst) + + print cmd + ret = os.system(cmd) + if ret: + print "failed" + +root = tempfile.mkdtemp(prefix = "root.mount", dir = "/tmp") +mount(None, root, 1, 0, 0) +mounts = [root] + +for i in xrange(10): + dstdir = random.choice(mounts) + dst = tempfile.mkdtemp(prefix = "mount", dir = dstdir) + src = random.choice(mounts + [None]) + mount(src, dst, random.randint(0,100) > 50, random.randint(0,100) > 90, random.randint(0,100) > 50) + mounts.append(dst) diff --git a/test/mounts/mounts.sh b/test/mounts/mounts.sh new file mode 100755 index 000000000..19116d0cf --- /dev/null +++ b/test/mounts/mounts.sh @@ -0,0 +1,27 @@ +[ -z "$INMNTNS" ] && { + export INMNTNS=`pwd` + export INMNTNS_PID=$$ + unshare -m -- setsid bash -x "$0" "$@" < /dev/null &> mounts.log & + echo $! > mounts.pid + while :; do + sleep 1 + done +} + +cd $INMNTNS + +mount --make-rprivate / + +for i in `cat /proc/self/mounts | awk '{ print $2 }'`; do + [ '/' = "$i" ] && continue + [ '/proc' = "$i" ] && continue + [ '/dev' = "$i" ] && continue + echo $i + umount -l $i +done + +python mounts.py +kill $INMNTNS_PID +while :; do + sleep 10 +done diff --git a/test/mounts/run.sh b/test/mounts/run.sh new file mode 100755 index 000000000..23d05e5a3 --- /dev/null +++ b/test/mounts/run.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +CRIU=../../criu +set -x + +mkdir -p dump + +./mounts.sh +pid=`cat mounts.pid` +kill -0 $pid || exit + +cat /proc/$pid/mountinfo | sort -k 4 +echo "Suspend server" +${CRIU} dump -D dump -o dump.log -t $pid -v4 || { + cat dump/dump.log | grep Error + exit 1 +} +echo "Resume server" +${CRIU} restore -d -D dump -o restore.log -v4 || { + cat dump/dump.log | grep Error + exit 1 +} +cat /proc/$pid/mountinfo | sort -k 4 +kill $pid