[CRIU] [PATCH] zdtm: Make sure the root dirs are not present

Cyrill Gorcunov gorcunov at openvz.org
Mon Feb 29 06:09:20 PST 2016


When creating root for NS testing we should make
sure that directories we're about to create are
not present (created already). For this sake
use os.access helper.

With this patch I can run test on my local machine.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
Andrew, does it make sense?

 test/zdtm.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/test/zdtm.py b/test/zdtm.py
index 1ace91953667..7e93d5b977f3 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -161,8 +161,9 @@ class ns_flavor:
 
 	def __construct_root(self):
 		for dir in self.__root_dirs:
-			os.mkdir(self.root + dir)
-			os.chmod(self.root + dir, 0777)
+			if not os.access(self.root + dir, os.F_OK):
+				os.mkdir(self.root + dir)
+				os.chmod(self.root + dir, 0777)
 
 		for ldir in [ "/bin", "/sbin", "/lib", "/lib64" ]:
 			os.symlink(".." + ldir, self.root + "/usr" + ldir)
-- 
2.5.0



More information about the CRIU mailing list