[CRIU] [PATCH 1/2] zdtm.py: Add optional dependency support
Laurent Dufour
ldufour at linux.vnet.ibm.com
Fri Jan 15 00:33:42 PST 2016
Depending on the distribution, binaries or shared libraries a test is
dependent of may not be stored at the same place.
This patch introduces the ability to define option in the dependency
list, by separating the optional target names by a '|' character.
For instance the dependency of test may be described this way:
{'flavor': 'ns', 'deps': [ '/bin/foo|/usr/bin/foo' ], 'flags': 'suid'}
Note, there shouldn't be any spaces around the '|'.
If none of the optional dependency is satisfied, an error is raised.
Signed-off-by: Laurent Dufour <ldufour at linux.vnet.ibm.com>
---
test/zdtm.py | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/test/zdtm.py b/test/zdtm.py
index 90d600a8bed7..80c51c0b9156 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -116,9 +116,6 @@ class ns_flavor:
self.root_mounted = False
def __copy_one(self, fname):
- if not os.access(fname, os.F_OK):
- raise test_fail_exc("Deps check (%s doesn't exist)" % fname)
-
tfname = self.root + fname
if not os.access(tfname, os.F_OK):
# Copying should be atomic as tests can be
@@ -145,6 +142,8 @@ class ns_flavor:
ldd.wait()
for lib in libs:
+ if not os.access(lib, os.F_OK):
+ raise test_fail_exc("Can't find lib %s required by %s" % (lib, binary))
self.__copy_one(lib)
def __mknod(self, name, rdev = None):
@@ -173,6 +172,14 @@ class ns_flavor:
self.__mknod("net/tun")
self.__mknod("rtc")
+ def __copy_deps(self, deps):
+ for d in deps.split('|'):
+ if os.access(d, os.F_OK):
+ self.__copy_one(d)
+ self.__copy_libs(d)
+ return
+ raise test_fail_exc("Deps check %s failed" % deps)
+
def init(self, l_bins, x_bins):
subprocess.check_call(["mount", "--make-slave", "--bind", ".", self.root])
self.root_mounted = True
@@ -188,8 +195,7 @@ class ns_flavor:
for b in l_bins:
self.__copy_libs(b)
for b in x_bins:
- self.__copy_one(b)
- self.__copy_libs(b)
+ self.__copy_deps(b)
def fini(self):
if self.root_mounted:
--
1.9.1
More information about the CRIU
mailing list