Add a functional test that exercises the cpu v1/v2 mappings. ----------------------------------------------------------------- Test Results: Run Date: Apr 19 18:39:16 Passed: 1 test(s) Skipped: 0 test(s) Failed: 0 test(s) ----------------------------------------------------------------- Timing Results: Test Time (sec) --------------------------------------------------------- setup 0.00 035-cgxget-cpu_settings.py 0.50 teardown 0.00 --------------------------------------------------------- Total Run Time 0.50
Signed-off-by: Tom Hromatka <tom.hroma...@oracle.com> --- ftests/035-cgxget-cpu_settings.py | 86 +++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 ftests/035-cgxget-cpu_settings.py diff --git a/ftests/035-cgxget-cpu_settings.py b/ftests/035-cgxget-cpu_settings.py new file mode 100755 index 000000000000..ecbba22abbb7 --- /dev/null +++ b/ftests/035-cgxget-cpu_settings.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 +# +# cgxget functionality test - various cpu settings +# +# Copyright (c) 2021 Oracle and/or its affiliates. +# Author: Tom Hromatka <tom.hroma...@oracle.com> +# + +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of version 2.1 of the GNU Lesser General Public License as +# published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License +# for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, see <http://www.gnu.org/licenses>. +# + +from cgroup import Cgroup, CgroupVersion +import consts +import ftests +import os +import sys + +CONTROLLER = 'cpu' +CGNAME = '035cgxget' + +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], +] + +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 + + for entry in TABLE: + Cgroup.xset(config, cgname=CGNAME, setting=entry[0], value=entry[1], + version=entry[2]) + + out = Cgroup.xget(config, cgname=CGNAME, setting=entry[3], + version=entry[5], values_only=True, + 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) + 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: + 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)) -- 2.25.1 _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel