]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
test-037: make it PEP8 compliant
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 15 Feb 2022 07:28:27 +0000 (12:58 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 16 Feb 2022 19:09:18 +0000 (12:09 -0700)
Make test 037-cgxget-cpu_settings.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ftests/037-cgxget-cpu_settings.py

index 167d45ce79f942c3501571125e2feb8a1b03eb47..5a927a8c2b48a7ac7e4167404c32c261f0eb3f56 100755 (executable)
 from cgroup import Cgroup, CgroupVersion
 import consts
 import ftests
-import os
 import sys
+import os
 
 CONTROLLER = 'cpu'
 CGNAME = '037cgxget'
 
+CGRP_VER_V1 = CgroupVersion.CGROUP_V1
+CGRP_VER_V2 = CgroupVersion.CGROUP_V2
+
 TABLE = [
     # writesetting, writeval, writever, readsetting, readval, readver
-    ['cpu.shares', '512', CgroupVersion.CGROUP_V1, 'cpu.shares', '512', CgroupVersion.CGROUP_V1],
-    ['cpu.shares', '512', CgroupVersion.CGROUP_V1, 'cpu.weight', '50', CgroupVersion.CGROUP_V2],
-
-    ['cpu.weight', '200', CgroupVersion.CGROUP_V2, 'cpu.shares', '2048', CgroupVersion.CGROUP_V1],
-    ['cpu.weight', '200', CgroupVersion.CGROUP_V2, 'cpu.weight', '200', CgroupVersion.CGROUP_V2],
-
-    ['cpu.cfs_quota_us', '10000', CgroupVersion.CGROUP_V1, 'cpu.cfs_quota_us', '10000', CgroupVersion.CGROUP_V1],
-    ['cpu.cfs_period_us', '100000', CgroupVersion.CGROUP_V1, 'cpu.cfs_period_us', '100000', CgroupVersion.CGROUP_V1],
-    ['cpu.cfs_period_us', '50000', CgroupVersion.CGROUP_V1, 'cpu.max', '10000 50000', CgroupVersion.CGROUP_V2],
-
-    ['cpu.cfs_quota_us', '-1', CgroupVersion.CGROUP_V1, 'cpu.cfs_quota_us', '-1', CgroupVersion.CGROUP_V1],
-    ['cpu.cfs_period_us', '100000', CgroupVersion.CGROUP_V1, 'cpu.max', 'max 100000', CgroupVersion.CGROUP_V2],
-
-    ['cpu.max', '5000 25000', CgroupVersion.CGROUP_V2, 'cpu.max', '5000 25000', CgroupVersion.CGROUP_V2],
-    ['cpu.max', '6000 26000', CgroupVersion.CGROUP_V2, 'cpu.cfs_quota_us', '6000', CgroupVersion.CGROUP_V1],
-    ['cpu.max', '7000 27000', CgroupVersion.CGROUP_V2, 'cpu.cfs_period_us', '27000', CgroupVersion.CGROUP_V1],
-
-    ['cpu.max', 'max 40000', CgroupVersion.CGROUP_V2, 'cpu.max', 'max 40000', CgroupVersion.CGROUP_V2],
-    ['cpu.max', 'max 41000', CgroupVersion.CGROUP_V2, 'cpu.cfs_quota_us', '-1', CgroupVersion.CGROUP_V1],
+    ['cpu.shares', '512', CGRP_VER_V1, 'cpu.shares', '512', CGRP_VER_V1],
+    ['cpu.shares', '512', CGRP_VER_V1, 'cpu.weight', '50',  CGRP_VER_V2],
+
+    ['cpu.weight', '200', CGRP_VER_V2, 'cpu.shares', '2048', CGRP_VER_V1],
+    ['cpu.weight', '200', CGRP_VER_V2, 'cpu.weight', '200',  CGRP_VER_V2],
+
+    ['cpu.cfs_quota_us',  '10000',       CGRP_VER_V1,
+     'cpu.cfs_quota_us',  '10000',       CGRP_VER_V1],
+    ['cpu.cfs_period_us', '100000',      CGRP_VER_V1,
+     'cpu.cfs_period_us', '100000',      CGRP_VER_V1],
+    ['cpu.cfs_period_us', '50000',       CGRP_VER_V1,
+     'cpu.max',           '10000 50000', CGRP_VER_V2],
+
+    ['cpu.cfs_quota_us',  '-1',         CGRP_VER_V1,
+     'cpu.cfs_quota_us',  '-1',         CGRP_VER_V1],
+    ['cpu.cfs_period_us', '100000',     CGRP_VER_V1,
+     'cpu.max',           'max 100000', CGRP_VER_V2],
+
+    ['cpu.max',           '5000 25000', CGRP_VER_V2,
+     'cpu.max',           '5000 25000', CGRP_VER_V2],
+    ['cpu.max',           '6000 26000', CGRP_VER_V2,
+     'cpu.cfs_quota_us',  '6000',       CGRP_VER_V1],
+    ['cpu.max',           '7000 27000', CGRP_VER_V2,
+     'cpu.cfs_period_us', '27000',      CGRP_VER_V1],
+
+    ['cpu.max',          'max 40000', CGRP_VER_V2,
+     'cpu.max',          'max 40000', CGRP_VER_V2],
+    ['cpu.max',          'max 41000', CGRP_VER_V2,
+     'cpu.cfs_quota_us', '-1',        CGRP_VER_V1],
 ]
 
+
 def prereqs(config):
     result = consts.TEST_PASSED
     cause = None
 
     return result, cause
 
+
 def setup(config):
     Cgroup.create(config, CONTROLLER, CGNAME)
 
+
 def test(config):
     result = consts.TEST_PASSED
     cause = None
@@ -74,15 +90,20 @@ def test(config):
                           print_headers=False)
         if out != entry[4]:
             result = consts.TEST_FAILED
-            cause = "After setting {}={}, expected {}={}, but received {}={}".format(
-                    entry[0], entry[1], entry[3], entry[4], entry[3], out)
+            cause = (
+                    'After setting {}={}, expected {}={}, but received '
+                    '{}={}'.format(entry[0], entry[1], entry[3], entry[4],
+                                   entry[3], out)
+                    )
             return result, cause
 
     return result, cause
 
+
 def teardown(config):
     Cgroup.delete(config, CONTROLLER, CGNAME)
 
+
 def main(config):
     [result, cause] = prereqs(config)
     if result != consts.TEST_PASSED:
@@ -94,6 +115,7 @@ def main(config):
 
     return [result, cause]
 
+
 if __name__ == '__main__':
     config = ftests.parse_args()
     # this test was invoked directly.  run only it