]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests: Modify functional test 014 to support cgroup v2
authorTom Hromatka <tom.hromatka@oracle.com>
Wed, 2 Jun 2021 13:34:33 +0000 (13:34 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Tue, 8 Jun 2021 18:16:32 +0000 (18:16 +0000)
Add support for a full cgroup v2 system to the 014-cgget-a_flag.py
functional test.  It continues to support cgroup v1 as well.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ftests/014-cgget-a_flag.py

index ff4dd6297ccb9ae2a47cfd5082e86b2c23ad3cbb..4d2f49cb8c7f4c6f9e977624f51825f54b73925f 100755 (executable)
@@ -37,8 +37,17 @@ def prereqs(config):
     return result, cause
 
 def setup(config):
-    Cgroup.create(config, CONTROLLER1, CGNAME)
-    Cgroup.create(config, CONTROLLER2, CGNAME)
+    ver1 = CgroupVersion.get_version(CONTROLLER1)
+    ver2 = CgroupVersion.get_version(CONTROLLER2)
+
+    if ver1 == CgroupVersion.CGROUP_V2 and \
+       ver2 == CgroupVersion.CGROUP_V2:
+        # If both controllers are cgroup v2, then we only need to make
+        # one cgroup.  The path will be the same for both
+        Cgroup.create(config, [CONTROLLER1, CONTROLLER2], CGNAME)
+    else:
+        Cgroup.create(config, CONTROLLER1, CGNAME)
+        Cgroup.create(config, CONTROLLER2, CGNAME)
 
 def test(config):
     result = consts.TEST_PASSED
@@ -69,8 +78,17 @@ def test(config):
     return result, cause
 
 def teardown(config):
-    Cgroup.delete(config, CONTROLLER1, CGNAME)
-    Cgroup.delete(config, CONTROLLER2, CGNAME)
+    ver1 = CgroupVersion.get_version(CONTROLLER1)
+    ver2 = CgroupVersion.get_version(CONTROLLER2)
+
+    if ver1 == CgroupVersion.CGROUP_V2 and \
+       ver2 == CgroupVersion.CGROUP_V2:
+        # If both controllers are cgroup v2, then we only need to make
+        # one cgroup.  The path will be the same for both
+        Cgroup.delete(config, [CONTROLLER1, CONTROLLER2], CGNAME)
+    else:
+        Cgroup.delete(config, CONTROLLER1, CGNAME)
+        Cgroup.delete(config, CONTROLLER2, CGNAME)
 
 def main(config):
     [result, cause] = prereqs(config)