criu/test/others/mounts/mounts.py
Andrew Vagin 88aaae3ace tests: move non-zdtm tests to tests/others/
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-02-24 13:09:17 +03:00

31 lines
740 B
Python
Executable file

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)