mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-17 16:47:50 +00:00
This commit removes the checks for the Python 2 binary in the makefile and makes sure that ZDTM tests always use python3. Since support for Python 2 has been dropped, these checks are no longer needed. Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
54 lines
1.3 KiB
Python
Executable file
54 lines
1.3 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
import os
|
|
import subprocess
|
|
import tempfile
|
|
|
|
yard = "external_yard"
|
|
|
|
if sys.argv[1] == "--post-start":
|
|
'''
|
|
Create external cgroup yard to be passed to CRIU via --cgroup-yard
|
|
'''
|
|
os.mkdir(yard)
|
|
subprocess.check_call(["mount", "-t", "tmpfs", "zdtm_yard", yard])
|
|
with open("/proc/self/cgroup") as f:
|
|
for line in f:
|
|
cgr = line.split(":")[1]
|
|
|
|
if cgr == "":
|
|
cgr = "unified"
|
|
|
|
if cgr.startswith("name="):
|
|
ctrl = cgr[len("name="):]
|
|
opts = "none," + cgr
|
|
else:
|
|
ctrl = cgr
|
|
opts = cgr
|
|
|
|
os.mkdir(yard + "/" + ctrl)
|
|
if cgr == "unified":
|
|
subprocess.check_call(["mount", "-t", "cgroup2", "none", yard + "/" + ctrl])
|
|
else:
|
|
subprocess.check_call(["mount", "-t", "cgroup", "none", yard + "/" + ctrl, "-o", opts])
|
|
|
|
if sys.argv[1] in ["--pre-restore", "--clean"]:
|
|
'''
|
|
Clean up the leftover cgroups created by the test
|
|
'''
|
|
tname = tempfile.mkdtemp()
|
|
subprocess.call(["mount", "-t", "cgroup", "none", tname, "-o", "none,name=zdtmtst"])
|
|
|
|
for cg in [os.path.join(tname, "subcg00", "subsubcg"),
|
|
os.path.join(tname, "subcg00")]:
|
|
if os.access(cg, os.F_OK):
|
|
os.rmdir(cg)
|
|
|
|
subprocess.call(["umount", tname])
|
|
os.rmdir(tname)
|
|
|
|
if sys.argv[1] == "--clean":
|
|
if os.access(yard, os.F_OK):
|
|
subprocess.call(["umount", "-l", yard])
|
|
os.rmdir(yard)
|