From 3d5c7d71ea500de4117abc6bf6dc95ac8fd875f1 Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Sun, 20 Aug 2023 11:12:47 +0530 Subject: [PATCH] ftests: update test to check for ctrl name in scope name Update the test case to check for controller names in the scope name. ----------------------------------------------------------------- Test Results: Run Date: Aug 18 07:57:32 Passed: 1 test(s) Skipped: 0 test(s) Failed: 0 test(s) ----------------------------------------------------------------- Timing Results: Test Time (sec) ------------------------------------------------- setup 0.00 078-sudo-cgcreate_systemd_scope.py 5.28 teardown 0.00 ------------------------------------------------- Total Run Time 5.28 Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- .../ftests/078-sudo-cgcreate_systemd_scope.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/ftests/078-sudo-cgcreate_systemd_scope.py b/tests/ftests/078-sudo-cgcreate_systemd_scope.py index 48897d56..5fc4df3f 100755 --- a/tests/ftests/078-sudo-cgcreate_systemd_scope.py +++ b/tests/ftests/078-sudo-cgcreate_systemd_scope.py @@ -22,6 +22,7 @@ SLICE = 'libcgroup.slice' CGNAME = os.path.join(SLICE, '078cgcreate.scope') IN_SCOPE_CHILD_CGNAME = os.path.join(CGNAME, 'in_scope_childcg') OUT_OF_SCOPE_CHILD_CGNAME = '078outofscopechild' +INVAL_CGNAME = os.path.join(SLICE, 'cpu.scope') def prereqs(config): @@ -66,6 +67,15 @@ def test(config): Cgroup.create_and_validate(config, None, IN_SCOPE_CHILD_CGNAME) Cgroup.create_and_validate(config, None, OUT_OF_SCOPE_CHILD_CGNAME) + try: + Cgroup.create_and_validate(config, CONTROLLERS, INVAL_CGNAME, create_scope=True) + except RunError as re: + if 'Invalid scope name, using controller name cpu' not in str(re): + raise re + else: + result = consts.TEST_FAILED + cause = 'Erroneously succeeded in creating scope {}', format(INVAL_CGNAME) + return result, cause @@ -77,6 +87,14 @@ def teardown(config): print_headers=False, values_only=True, ignore_systemd=True)) Process.kill(config, pid) + # try deleting INVAL_CGNAME for the cases, where it was erroneously created. + try: + pid = int(Cgroup.get(config, None, INVAL_CGNAME, setting='cgroup.procs', + print_headers=False, values_only=True, ignore_systemd=True)) + Process.kill(config, pid) + except RunError: + pass + # systemd will automatically remove the cgroup once there are no more pids in # the cgroup, so we don't need to delete CGNAME. But let's try to remove the # slice -- 2.47.2