[CRIU] [PATCH] zdtm.py: collect fds and maps for all test processes
Andrey Vagin
avagin at openvz.org
Mon Dec 14 13:36:22 PST 2015
From: Andrew Vagin <avagin at virtuozzo.com>
It works for tests which are executed in a separate pidns
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
test/zdtm.py | 37 +++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/test/zdtm.py b/test/zdtm.py
index e8e344a..08d752b 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -379,6 +379,9 @@ class zdtm_test:
def static(self):
return self.__name.split('/')[2] == 'static'
+ def ns(self):
+ return self.__flavor.ns
+
def blocking(self):
return test_flag(self.__desc, 'crfail')
@@ -726,26 +729,36 @@ def cr(cr_api, test, opts):
# Additional checks that can be done outside of test process
def get_maps(test):
- maps = [[0,0]]
- last = 0
- for mp in open("/proc/%s/maps" % test.getpid()).readlines():
- m = map(lambda x: int('0x' + x, 0), mp.split()[0].split('-'))
- if maps[last][1] == m[0]:
- maps[last][1] = m[1]
- else:
- maps.append(m)
- last += 1
- maps.pop(0)
+ maps = []
+
+ r = re.compile('^[0-9]+$')
+ pids = filter(lambda p: r.match(p), os.listdir("/proc/%s/root/proc/" % test.getpid()))
+ for pid in pids:
+ maps.append([0, 0])
+ last = 0
+ for mp in open("/proc/%s/root/proc/%s/maps" % (test.getpid(), pid)).readlines():
+ m = map(lambda x: int('0x' + x, 0), mp.split()[0].split('-'))
+ if maps[last][1] == m[0]:
+ maps[last][1] = m[1]
+ else:
+ maps.append(m)
+ last += 1
return maps
def get_fds(test):
- return map(lambda x: int(x), os.listdir("/proc/%s/fdinfo" % test.getpid()))
+ files = []
+ r = re.compile('^[0-9]+$')
+ pids = filter(lambda p: r.match(p), os.listdir("/proc/%s/root/proc/" % test.getpid()))
+ for pid in pids:
+ files.append(os.listdir("/proc/%s/root/proc/%s/fd" % (test.getpid(), pid)))
+
+ return files
def cmp_lists(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():
+ if test.static() and test.ns():
fds = get_fds(test)
maps = get_maps(test)
return (fds, maps)
--
2.4.3
More information about the CRIU
mailing list