From 5a331e5f20a05ae4bf0c95bc68f62670612546f8 Mon Sep 17 00:00:00 2001 From: Tom Hromatka Date: Wed, 8 Mar 2023 12:44:56 -0700 Subject: [PATCH] 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 --- tests/ftests/cgroup.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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): -- 2.47.2