From 40293e5466cfa3f6900d83e642c2847b1b32ebe2 Mon Sep 17 00:00:00 2001 From: Tom Hromatka Date: Tue, 18 Oct 2022 19:29:52 +0000 Subject: [PATCH] ftests: Add test for cgroup_setup_mode() 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 Reviewed-by: Kamalesh Babulal --- .../ftests/048-pybindings-get_cgroup_mode.py | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 tests/ftests/048-pybindings-get_cgroup_mode.py diff --git a/tests/ftests/048-pybindings-get_cgroup_mode.py b/tests/ftests/048-pybindings-get_cgroup_mode.py new file mode 100755 index 00000000..024cf58d --- /dev/null +++ b/tests/ftests/048-pybindings-get_cgroup_mode.py @@ -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 +# + +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: -- 2.47.2