From: Kamalesh Babulal Date: Wed, 1 Nov 2023 10:43:33 +0000 (+0530) Subject: ftests/081: add support for cgroup hybrid mode X-Git-Tag: v3.2.0~131 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca72882b1ddcadfaac8aa4a6432ed5e8f2b3c9f6;p=thirdparty%2Flibcgroup.git ftests/081: add support for cgroup hybrid mode 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 Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/tests/ftests/081-pybindings-cgrp_get_curr_ctrl_path-v1.py b/tests/ftests/081-pybindings-cgrp_get_curr_ctrl_path-v1.py index d4a07b73..4b0c9307 100755 --- a/tests/ftests/081-pybindings-cgrp_get_curr_ctrl_path-v1.py +++ b/tests/ftests/081-pybindings-cgrp_get_curr_ctrl_path-v1.py @@ -7,7 +7,7 @@ # Author: Kamalesh Babulal # -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.