mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 05:18:00 +00:00
zdtm.py: compare a set of mounts before and after c/r
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
36216c3c1b
commit
4986d1b51e
39
test/zdtm.py
39
test/zdtm.py
@ -17,6 +17,7 @@ import string
|
|||||||
import imp
|
import imp
|
||||||
import socket
|
import socket
|
||||||
import fcntl
|
import fcntl
|
||||||
|
import errno
|
||||||
|
|
||||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
@ -751,43 +752,41 @@ def cr(cr_api, test, opts):
|
|||||||
|
|
||||||
# Additional checks that can be done outside of test process
|
# Additional checks that can be done outside of test process
|
||||||
|
|
||||||
def get_maps(test):
|
def get_visible_state(test):
|
||||||
maps = []
|
maps = []
|
||||||
|
files = []
|
||||||
|
mounts = []
|
||||||
|
|
||||||
|
if not test.static() or not test.ns():
|
||||||
|
return ([], [], [])
|
||||||
|
|
||||||
r = re.compile('^[0-9]+$')
|
r = re.compile('^[0-9]+$')
|
||||||
pids = filter(lambda p: r.match(p), os.listdir("/proc/%s/root/proc/" % test.getpid()))
|
pids = filter(lambda p: r.match(p), os.listdir("/proc/%s/root/proc/" % test.getpid()))
|
||||||
for pid in pids:
|
for pid in pids:
|
||||||
|
files.append(os.listdir("/proc/%s/root/proc/%s/fd" % (test.getpid(), pid)))
|
||||||
|
|
||||||
maps.append([0, 0])
|
maps.append([0, 0])
|
||||||
last = 0
|
last = 0
|
||||||
for mp in open("/proc/%s/root/proc/%s/maps" % (test.getpid(), pid)).readlines():
|
for mp in open("/proc/%s/root/proc/%s/maps" % (test.getpid(), pid)):
|
||||||
m = map(lambda x: int('0x' + x, 0), mp.split()[0].split('-'))
|
m = map(lambda x: int('0x' + x, 0), mp.split()[0].split('-'))
|
||||||
if maps[last][1] == m[0]:
|
if maps[last][1] == m[0]:
|
||||||
maps[last][1] = m[1]
|
maps[last][1] = m[1]
|
||||||
else:
|
else:
|
||||||
maps.append(m)
|
maps.append(m)
|
||||||
last += 1
|
last += 1
|
||||||
return maps
|
|
||||||
|
|
||||||
def get_fds(test):
|
try:
|
||||||
files = []
|
r = re.compile("^\S+\s\S+\s\S+\s(\S+)\s(\S+)")
|
||||||
r = re.compile('^[0-9]+$')
|
for m in open("/proc/%s/root/proc/%s/mountinfo" % (test.getpid(), pid)):
|
||||||
pids = filter(lambda p: r.match(p), os.listdir("/proc/%s/root/proc/" % test.getpid()))
|
mounts.append(r.match(m).groups())
|
||||||
for pid in pids:
|
except IOError, e:
|
||||||
files.append(os.listdir("/proc/%s/root/proc/%s/fd" % (test.getpid(), pid)))
|
if e.errno != errno.EINVAL:
|
||||||
|
raise e
|
||||||
return files
|
return files, maps, mounts
|
||||||
|
|
||||||
def cmp_lists(m1, m2):
|
def cmp_lists(m1, m2):
|
||||||
return len(m1) != len(m2) or filter(lambda x: x[0] != x[1], zip(m1, m2))
|
return len(m1) != len(m2) or filter(lambda x: x[0] != x[1], zip(m1, m2))
|
||||||
|
|
||||||
def get_visible_state(test):
|
|
||||||
if test.static() and test.ns():
|
|
||||||
fds = get_fds(test)
|
|
||||||
maps = get_maps(test)
|
|
||||||
return (fds, maps)
|
|
||||||
else:
|
|
||||||
return ([], [])
|
|
||||||
|
|
||||||
def check_visible_state(test, state):
|
def check_visible_state(test, state):
|
||||||
new = get_visible_state(test)
|
new = get_visible_state(test)
|
||||||
if cmp_lists(new[0], state[0]):
|
if cmp_lists(new[0], state[0]):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user