From: Tom Hromatka Date: Wed, 8 Mar 2023 19:44:56 +0000 (-0700) Subject: ftests: Add ability to enable/disable controllers in the subtree control file X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eee3ebbd7039f7f379e92f79f1a537dd749ac105;p=thirdparty%2Flibcgroup.git ftests: Add ability to enable/disable controllers in the subtree control file Add a method to the functional tests that can enable/disable controllers in the cgroup.subtree_control file. Signed-off-by: Tom Hromatka Reviewed-by: Kamalesh Babulal (cherry picked from commit 5a331e5f20a05ae4bf0c95bc68f62670612546f8) --- diff --git a/tests/ftests/cgroup.py b/tests/ftests/cgroup.py index 948eedbb..557db831 100644 --- a/tests/ftests/cgroup.py +++ b/tests/ftests/cgroup.py @@ -1113,6 +1113,25 @@ class Cgroup(object): return True + # Method to enable or disable controllers in the subtree control file + @staticmethod + def subtree_control(config, cgname, controllers, enable=True, ignore_systemd=False): + if isinstance(controllers, str): + controllers = [controllers] + elif isinstance(controllers, list): + pass + else: + raise ValueError('Unsupported controller value') + + if enable: + enable_char = '+' + else: + enable_char = '-' + + for ctrl in controllers: + Cgroup.set(config, cgname, 'cgroup.subtree_control', + '{}{}'.format(enable_char, ctrl), ignore_systemd=ignore_systemd) + class CgroupError(Exception): def __init__(self, message):