From: Tom Hromatka Date: Thu, 16 Dec 2021 15:06:10 +0000 (-0700) Subject: ftests: Add a test for the python bindings to library_version() X-Git-Tag: v3.1.0~308^2~2^2~105^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a3e23387bca54f7e21d544ede865fbbe14f7c97;p=thirdparty%2Flibcgroup.git ftests: Add a test for the python bindings to library_version() Add a functional test that exercises the library_version() python bindings. ----------------------------------------------------------------- Test Results: Run Date: Oct 27 15:53:49 Passed: 1 test(s) Skipped: 0 test(s) Failed: 0 test(s) ----------------------------------------------------------------- Timing Results: Test Time (sec) --------------------------------------------------------- setup 0.00 040-pybindings-library_version.py 0.00 teardown 0.00 --------------------------------------------------------- Total Run Time 0.00 Signed-off-by: Tom Hromatka --- diff --git a/ftests/041-pybindings-library_version.py b/ftests/041-pybindings-library_version.py new file mode 100755 index 00000000..8248f539 --- /dev/null +++ b/ftests/041-pybindings-library_version.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 +# +# get the library version using the python bindings +# +# Copyright (c) 2021-2022 Oracle and/or its affiliates. +# Author: Tom Hromatka +# + +# +# 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 . +# + +from libcgroup import Cgroup +import consts +import ftests +import os +import sys + +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 + + [major, minor, release] = Cgroup.library_version() + + if not isinstance(major, int): + result = consts.TEST_FAILED + cause = "Major version failed. Received {}".format(major) + return result, cause + + if not isinstance(minor, int): + result = consts.TEST_FAILED + cause = "Minor version failed. Received {}".format(minor) + return result, cause + + if not isinstance(release, int): + result = consts.TEST_FAILED + cause = "Release version failed. Received {}".format(release) + return result, cause + + return result, cause + +def teardown(config): + pass + +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))