Commit 32452b21 authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

zdtm.py: umount root only if it was mounted

We get the stack trace if a test failed:

Test output: ================================
09:11:34.584:     4: PASS

 <<< ================================
Traceback (most recent call last):
  File "zdtm.py", line 922, in <module>
    do_run_test(tinfo[0], tinfo[1], tinfo[2], tinfo[3])
  File "zdtm.py", line 696, in do_run_test
    t.kill()
  File "zdtm.py", line 302, in kill
    self.__flavor.fini()
  File "zdtm.py", line 168, in fini
    subprocess.check_call(["mount", "--make-private", self.root])
  File "/usr/lib64/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['mount', '--make-private', '/tmp/criu-root-YN1t3X']' returned non-zero exit status 32
umount: /tmp/criu-root-YN1t3X: not mounted

Cc: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Acked-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 6cc31661
......@@ -108,6 +108,7 @@ class ns_flavor:
self.ns = True
self.uns = False
self.root = make_tests_root()
self.root_mounted = False
def __copy_one(self, fname):
if not os.access(fname, os.F_OK):
......@@ -143,6 +144,7 @@ class ns_flavor:
def init(self, test_bin, deps):
subprocess.check_call(["mount", "--make-private", "--bind", ".", self.root])
self.root_mounted = True
if not os.access(self.root + "/.constructed", os.F_OK):
with open(os.path.abspath(__file__)) as o:
......@@ -165,8 +167,10 @@ class ns_flavor:
self.__copy_libs(dep)
def fini(self):
subprocess.check_call(["mount", "--make-private", self.root])
subprocess.check_call(["umount", "-l", self.root])
if self.root_mounted:
subprocess.check_call(["mount", "--make-private", self.root])
subprocess.check_call(["umount", "-l", self.root])
self.root_mounted = False
class userns_flavor(ns_flavor):
def __init__(self, opts):
......
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