]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests/061: Fix the expected line in cpu controller
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 28 May 2024 09:50:35 +0000 (15:20 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 30 May 2024 20:30:38 +0000 (14:30 -0600)
Cgroup cpu controller output might be less than 10 lines in older
Kernel version <= 5.4, fix it by adjusting the expected outline count
after reading the current kernel's version.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tests/ftests/061-sudo-g_flag_controller_only_systemd-v1.py

index 5e1818f395764ec7036542be622e20b58aa2367b..d6c16eb32e1063cae794a902e3be9393b3e99f83 100755 (executable)
@@ -12,6 +12,7 @@ from systemd import Systemd
 from run import RunError
 import consts
 import ftests
+import utils
 import sys
 import os
 
@@ -77,8 +78,13 @@ def test(config):
     result = consts.TEST_PASSED
     cause = None
 
+    expected_out_len = 10
+    kernel_ver = utils.get_kernel_version(config)
+    if int(kernel_ver[0]) <= 5 and int(kernel_ver[1]) <= 4:
+        expected_out_len = 8
+
     out = Cgroup.get(config, controller=CONTROLLER, cgname=SYSTEMD_CGNAME)
-    if len(out.splitlines()) < 10:
+    if len(out.splitlines()) < expected_out_len:
         # This cgget command gets all of the settings/values within the cgroup.
         # We don't care about the exact data, but there should be at least 10
         # lines of settings/values
@@ -89,7 +95,7 @@ def test(config):
                 )
 
     out = Cgroup.get(config, controller=CONTROLLER, cgname=OTHER_CGNAME, ignore_systemd=True)
-    if len(out.splitlines()) < 10:
+    if len(out.splitlines()) < expected_out_len:
         result = consts.TEST_FAILED
         tmp_cause = (
                         'cgget failed to read at least 10 lines from '