[v2] zdtm.py: call clean_tests_root() from one process only

Submitted by Andrei Vagin on Aug. 31, 2016, 11:20 p.m.

Details

Message ID 1472685601-27125-1-git-send-email-avagin@openvz.org
State Accepted
Series "zdtm.py: call clean_tests_root() from one process only"
Commit f6f36341596ff7beb5126f4be28520cc6dcb9c86
Headers show

Commit Message

Andrei Vagin Aug. 31, 2016, 11:20 p.m.
From: Andrei Vagin <avagin@virtuozzo.com>

An atexit hook is executed for forked processes too,
clean_tests_root() has to be called only once.

v2: fix flak8 warnings
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
---
 test/zdtm.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/test/zdtm.py b/test/zdtm.py
index abcd5ed..56ad841 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -49,16 +49,16 @@  tests_root = None
 
 def clean_tests_root():
 	global tests_root
-	if tests_root:
-		os.rmdir(tests_root)
+	if tests_root and tests_root[0] == os.getpid():
+		os.rmdir(tests_root[1])
 
 
 def make_tests_root():
 	global tests_root
 	if not tests_root:
-		tests_root = tempfile.mkdtemp("", "criu-root-", "/tmp")
+		tests_root = (os.getpid(), tempfile.mkdtemp("", "criu-root-", "/tmp"))
 		atexit.register(clean_tests_root)
-	return tests_root
+	return tests_root[1]
 
 # Report generation
 

Comments

Pavel Emelianov Sept. 1, 2016, 12:53 p.m.
Applied