]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests/081: add support for cgroup hybrid mode
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 1 Nov 2023 10:43:33 +0000 (16:13 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 17 Jan 2024 16:43:38 +0000 (09:43 -0700)
Add support for cgroup hybrid mode with controllers in cgroup v2.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Nov 01 10:40:32
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                             Time (sec)
        -----------------------------------------------------------
        setup                                                  0.00
        081-pybindings-cgrp_get_curr_ctrl_path-v1.py           2.09
        teardown                                               0.00
        -----------------------------------------------------------
        Total Run Time                                         2.09

Suggested-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tests/ftests/081-pybindings-cgrp_get_curr_ctrl_path-v1.py

index d4a07b732ab9db018b91699722294fa89642dd3a..4b0c93071a30d16d59a2d92b8ed055bdaa7a8dab 100755 (executable)
@@ -7,7 +7,7 @@
 # Author: Kamalesh Babulal <kamalesh.babulal@oracle.com>
 #
 
-from cgroup import Cgroup as CgroupCli, Mode
+from cgroup import Cgroup as CgroupCli, Mode, CgroupVersion
 from libcgroup import Cgroup, Version
 from process import Process
 import consts
@@ -64,11 +64,19 @@ def test(config):
     # Test 2 - get the relative path of cgroup, for the pid's memory controller.
     #          It's expected to fail because we not had created cgroup.
     #
-    cgrp_path = cgrp.get_current_controller_path(pid, "memory")
-    if cgrp_path == expected_path:
-        result = consts.TEST_FAILED
-        tmp_cause = 'cgroup path unexpectedly formed {}'.format(cgrp_path)
-        cause = '\n'.join(filter(None, [cause, tmp_cause]))
+    try:
+        cgrp_path = cgrp.get_current_controller_path(pid, "memory")
+        if cgrp_path == expected_path:
+            result = consts.TEST_FAILED
+            tmp_cause = 'cgroup path unexpectedly formed {}'.format(cgrp_path)
+            cause = '\n'.join(filter(None, [cause, tmp_cause]))
+    except RuntimeError as re:
+        if (Cgroup.cgroup_mode() == Mode.CGROUP_MODE_HYBRID and
+           CgroupVersion.get_version("memory") == CgroupVersion.CGROUP_V2):
+            if '50001' in str(re):
+                pass
+        else:
+            raise re
 
     #
     # Test 3 - get the relative path of cgroup, for the pid's invalid controller.