]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests: Add test for cgroup_setup_mode()
authorTom Hromatka <tom.hromatka@oracle.com>
Tue, 25 Oct 2022 21:20:21 +0000 (15:20 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Tue, 25 Oct 2022 21:20:56 +0000 (15:20 -0600)
Add a python bindings test for cgroup_setup_mode()

-----------------------------------------------------------------
Test Results:
        Run Date:                          Oct 18 19:28:31
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                  Time (sec)
        ------------------------------------------------
        setup                                       0.00
        048-pybindings-get_cgroup_mode.py           0.00
        teardown                                    0.00
        ------------------------------------------------
        Total Run Time                              0.00

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 40293e5466cfa3f6900d83e642c2847b1b32ebe2)

tests/ftests/048-pybindings-get_cgroup_mode.py [new file with mode: 0755]

diff --git a/tests/ftests/048-pybindings-get_cgroup_mode.py b/tests/ftests/048-pybindings-get_cgroup_mode.py
new file mode 100755 (executable)
index 0000000..024cf58
--- /dev/null
@@ -0,0 +1,62 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: LGPL-2.1-only
+#
+# Test to get the cgroup mode
+#
+# Copyright (c) 2022 Oracle and/or its affiliates.
+# Author: Tom Hromatka <tom.hromatka@oracle.com>
+#
+
+from cgroup import Cgroup as CgroupCli
+from libcgroup import Cgroup
+import consts
+import ftests
+import sys
+import os
+
+
+def prereqs(config):
+    return consts.TEST_PASSED, None
+
+
+def setup(config):
+    return consts.TEST_PASSED, None
+
+
+def test(config):
+    result = consts.TEST_PASSED
+    cause = None
+
+    mode1 = Cgroup.cgroup_mode()
+    mode2 = CgroupCli.get_cgroup_mode(config)
+
+    if mode1 != mode2:
+        result = consts.TEST_FAILED
+        cause = 'mode mismatch: libcgroup mode: {}, tests mode: {}'.format(mode1, mode2)
+
+    return result, cause
+
+
+def teardown(config):
+    return consts.TEST_PASSED, None
+
+
+def main(config):
+    [result, cause] = prereqs(config)
+    if result != consts.TEST_PASSED:
+        return [result, cause]
+
+    setup(config)
+    [result, cause] = test(config)
+    teardown(config)
+
+    return [result, cause]
+
+
+if __name__ == '__main__':
+    config = ftests.parse_args()
+    # this test was invoked directly.  run only it
+    config.args.num = int(os.path.basename(__file__).split('-')[0])
+    sys.exit(ftests.main(config))
+
+# vim: set et ts=4 sw=4: