Commit 6b13731d authored by Laurent Dufour's avatar Laurent Dufour Committed by Pavel Emelyanov

zdtm.py: Add optional dependency support

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: 's avatarLaurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 6853c480
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment