Tom Hromatka [Wed, 10 Mar 2021 17:32:18 +0000 (17:32 +0000)]
ftests: Add multiple -r flag cgset test
Add a test that provides multiple -r flags to cgset
-----------------------------------------------------------------
Test Results:
Run Date: Mar 02 19:04:36
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 14.53
022-cgset-multiple_r_flag.py 0.72
teardown 0.00
---------------------------------------------------------
Total Run Time 15.25
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 10 Mar 2021 17:16:30 +0000 (17:16 +0000)]
cgroup.py: Allow for multiple cgroup names to be passed to cgset
Add support for multiple cgroup names - or no cgroup names -
to be passed into Cgroup.set(). cgset allows multiple cgroup
names to be supplied with either the '-r' flag or the '--copy-from'
option. No cgroup needs to be provided when '-h' is invoked.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 10 Mar 2021 18:21:25 +0000 (18:21 +0000)]
gunit: Update test 009 to match cgroup_set_values_recursive()
cgroup_set_values_recursive() had a parameter added to ignore
the dirty flag on write failures. This is needed by
cgroup_modify_cgroup() as some writes may be expected to fail.
Update test 009 to utilize this new flag. Note that
cgroup_set_values_recursive() is now being heavily tested by
the functional tests, so this unit test is no longer the primary
means of testing this function.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 10 Mar 2021 02:15:51 +0000 (02:15 +0000)]
ftests: Add invalid parameter test for cgconfigparser
Add a test that provides invalid parameters into cgconfigparser.
-----------------------------------------------------------------
Test Results:
Run Date: Mar 10 02:15:56
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 13.46
021-cgconfig-invalid_options.py 0.31
teardown 0.00
---------------------------------------------------------
Total Run Time 13.77
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 10 Mar 2021 00:18:02 +0000 (00:18 +0000)]
ftests: Add a cgconfigparser test that sets tasks owner/permissions
Add a cgconfigparser test that sets the owner, group, and
permissions on the tasks file. This test runs on cgroup v1
only.
-----------------------------------------------------------------
Test Results:
Run Date: Mar 10 00:18:10
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 14.47
020-cgconfig-tasks_perms_owner.py 7.14
teardown 0.00
---------------------------------------------------------
Total Run Time 21.61
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Tue, 9 Mar 2021 22:30:33 +0000 (22:30 +0000)]
ftests: Add a cgconfigparser owner, fperm, and dperm test
Add a cgconfigparser test that verifies that the owner,
group, file permissions, and directory permissions are
properly set.
-----------------------------------------------------------------
Test Results:
Run Date: Mar 09 22:29:07
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 20.58
019-cgconfig-uidgid_dperm_fperm.py 2.51
teardown 0.00
---------------------------------------------------------
Total Run Time 23.10
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Tue, 9 Mar 2021 19:50:11 +0000 (19:50 +0000)]
ftests: Add a cgconfigparser test that loads a directory
Add a cgconfigparser test that loads its configuration files
from a specified directory.
-----------------------------------------------------------------
Test Results:
Run Date: Mar 09 19:49:49
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 21.22
018-cgconfig-load_dir.py 0.94
teardown 0.00
---------------------------------------------------------
Total Run Time 22.16
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Tue, 9 Mar 2021 19:17:49 +0000 (19:17 +0000)]
ftests: Add a simple cgconfigparser test
Add a simple cgconfigparser test that operates on a
single configuration file.
-----------------------------------------------------------------
Test Results:
Run Date: Mar 09 19:19:17
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 17.78
017-cgconfig-load_file.py 0.70
teardown 0.00
---------------------------------------------------------
Total Run Time 18.48
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Tue, 9 Feb 2021 23:23:10 +0000 (23:23 +0000)]
ftests: Add cgget invalid parameter test
Add a cgget test that passes in various invalid parameter
combinations.
-----------------------------------------------------------------
Test Results:
Run Date: Feb 09 23:24:14
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 18.89
016-cgget-invalid_options.py 0.93
teardown 0.00
---------------------------------------------------------
Total Run Time 19.82
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 11 Feb 2021 19:28:18 +0000 (19:28 +0000)]
ftests: Add cgget '-a' test
Add a cgget test that utilizes the '-a' flag.
-----------------------------------------------------------------
Test Results:
Run Date: Feb 11 19:27:39
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 20.61
014-cgget-a_flag.py 1.01
teardown 0.00
---------------------------------------------------------
Total Run Time 21.62
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 11 Feb 2021 00:00:48 +0000 (00:00 +0000)]
ftests: Add multiline cgget test
Add a cgget test that receives a multiline setting.
-----------------------------------------------------------------
Test Results:
Run Date: Feb 11 00:00:16
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 16.49
015-cgget-multiline_r_flag.py 0.63
teardown 0.00
---------------------------------------------------------
Total Run Time 17.12
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Tue, 9 Feb 2021 22:35:05 +0000 (22:35 +0000)]
ftests: Add cgget test with multiple '-g' flags
Add cgget test with multiple '-g' flags. This test verifies
the following cgget operation:
$ cgget -g freezer -g cpu 013cgget
-----------------------------------------------------------------
Test Results:
Run Date: Feb 09 22:35:21
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 22.29
013-cgget-multiple_g_flags.py 1.18
teardown 0.00
---------------------------------------------------------
Total Run Time 23.47
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
-----------------------------------------------------------------
Test Results:
Run Date: Feb 09 21:39:23
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 16.92
012-cgget-multiple_r_flags2.py 1.83
teardown 0.00
---------------------------------------------------------
Total Run Time 18.75
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
-----------------------------------------------------------------
Test Results:
Run Date: Feb 09 21:24:10
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 17.28
011-cgget-r_flag_two_cgroups.py 1.47
teardown 0.00
---------------------------------------------------------
Total Run Time 18.76
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Tue, 9 Feb 2021 21:04:21 +0000 (21:04 +0000)]
ftests: Add cgget test with '-g' <controller>:<cgroup> flag
Add a test that exercises the '-g' <controller>:<cgroup> option
in cgget. This test verifies the following cgget operation:
$ cgget -g cpu:010cgget
-----------------------------------------------------------------
Test Results:
Run Date: Feb 09 21:04:46
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 20.73
010-cgget-g_flag_controller_and_cgroup.py 0.60
teardown 0.00
---------------------------------------------------------
Total Run Time 21.33
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Tue, 9 Feb 2021 20:49:43 +0000 (20:49 +0000)]
ftests: Add cgget test with '-g' <controller> flag
Add a test that exercises the '-g' <controller> option
in cgget. This test verifies the following cgget operation:
$ cgget -g cpu 009cgget
-----------------------------------------------------------------
Test Results:
Run Date: Feb 09 20:49:33
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 21.28
009-cgget-g_flag_controller_only.py 0.57
teardown 0.00
---------------------------------------------------------
Total Run Time 21.85
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
-----------------------------------------------------------------
Test Results:
Run Date: Feb 09 20:48:45
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 18.71
008-cgget-multiple_r_flags.py 0.78
teardown 0.00
---------------------------------------------------------
Total Run Time 19.49
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 10 Feb 2021 20:29:13 +0000 (20:29 +0000)]
ftests: Throw an exception if len(stderr) > 0
To better facilitate error handling, throw a RunError
if the stderr has been populated.
cgclassify currently prints warnings to stderr if a
setting isn't in the allow or deny list; ignore these
warnings for now. Also, non-containerized Github
Actions runs complain about missing coverage files for
cgget; ignore those errors.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 10 Feb 2021 20:25:22 +0000 (20:25 +0000)]
ftests: Clean up handling of bytes vs string
The conversion of bytes to string was being done
piecemeal within the functional tests. Consolidate
these conversions all into one location within the
run() method.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Mon, 1 Mar 2021 16:38:58 +0000 (16:38 +0000)]
ftests: Add cgroup v2 cgrules test
Add a simple cgrulesengd tests. Note that it cannot run within
a container.
-----------------------------------------------------------------
Test Results:
Run Date: Mar 01 16:56:22
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 0.00
007-cgrules-basic_cgrules_v2.py 7.13
teardown 0.00
---------------------------------------------------------
Total Run Time 7.13
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Mon, 1 Mar 2021 16:38:03 +0000 (16:38 +0000)]
ftests: Add cgroup v1 cgrules test
Add a simple cgrulesengd tests. Note that it cannot run within
a container.
-----------------------------------------------------------------
Test Results:
Run Date: Mar 01 16:43:17
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 0.00
006-cgrules-basic_cgrules_v1.py 5.21
teardown 0.00
---------------------------------------------------------
Total Run Time 5.21
Tom Hromatka [Mon, 1 Mar 2021 16:37:38 +0000 (16:37 +0000)]
ftests: Clean up a few exceptions
In the ftests and process files, two exceptions were
erroneously throwing ValueException rather than
ValueError. Fix this.
In CgroupVersion.get_version(), it returned CGROUP_UNK
if it couldn't determine the version. Make this method
more pythonic by raising a ValueError exception.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Tue, 23 Feb 2021 20:55:40 +0000 (13:55 -0700)]
gunit: Update test 009 to better test dirty flag
When the dirty flag is set, cgroup_set_values_recursive()
was erroneously failing the recursive setting of values.
There were two problems in the unit test that caused this to
be missed:
1. The dirty flag wasn't being set
2. If fgets() returned a NULL ptr, the contents of the
settings file weren't being checked
Reported-by: Bharani viswas <bharani.viswas@gmail.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 3 Feb 2021 17:32:14 +0000 (10:32 -0700)]
ftests: Make the Process() class instantiable
Make the process class instantiable so that it can
better manage its list of children processes. This
helps ensure that individual tests don't collide with
each other.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 3 Feb 2021 17:07:36 +0000 (10:07 -0700)]
ftests: Ensure the deny list file exists
It's possible that the libcgroup tests are being run
on a system that doesn't have libcgroup installed.
Ensure that the deny list file (currently named
cgsnapshot_blacklist.conf but slated to be renamed)
exists.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 3 Feb 2021 17:00:52 +0000 (10:00 -0700)]
ftests: Use sudo for many cgroup commands when not in a container
When not running in a container, prepend 'sudo' to the
front of cgcreate, cgdelete, cgset, and cgclassify.
It would be advantageous to properly utilize permissions
within Linux so that we don't need to 'sudo' these
commands, but that's more of a kernel/sysfs/cgroups
issue than a libcgroup issue. (Yes, libcgroup does allow
for setting owners and permissions, so someday we should
test this, but that's not a high priority at present.)
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 3 Feb 2021 16:54:55 +0000 (09:54 -0700)]
ftests: Test 004 must be run within a container
Test 004-cgsnapshot-basic_snapshot_v1.py must be
run within a container because the cgsnapshot
data will vary slightly when inside/outside of a
container. Add a check to its prereqs function
to enforce this.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 3 Feb 2021 16:42:44 +0000 (09:42 -0700)]
ftests: Add --container and --no-container flags
In preparation of running the tests outside of a
container, add two flags to ftests.py: --container
and --no-container. As the names imply, these flags
are used to specify whether the tests should be
containerized or not.
Note1: Some tests (cgrulesengd) will only work
in a non-containerized environment.
Note2: Running the tests in a non-containerized
environment could be destructive to a
system as cgroup changes could be made that
adversely affect the entire system.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 24 Dec 2020 21:13:40 +0000 (21:13 +0000)]
ftests: Fix failure cause when multiple tests don't pass
When multiple tests don't pass, the last failure_cause
recorded was the one being displayed. Append the
failure_cause to the failed_tests[] and skipped_tests[]
arrays, so that each failure is properly saved and
reported.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 17 Dec 2020 22:14:54 +0000 (15:14 -0700)]
ftests: Add cgroup v2 cgsnapshot test
Add a cgroup v2 cgsnapshot test.
-----------------------------------------------------------------
Test Results:
Run Date: Dec 17 22:18:33
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 16.83
005-cgsnapshot-basic_snapshot_v2.py 1.13
teardown 0.00
---------------------------------------------------------
Total Run Time 17.96
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 17 Dec 2020 20:48:35 +0000 (13:48 -0700)]
ftests: Add cgroup v1 cgsnapshot test
Add a cgroup v1 cgsnapshot test.
-----------------------------------------------------------------
Test Results:
Run Date: Dec 17 22:13:22
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 18.66
004-cgsnapshot-basic_snapshot_v1.py 0.47
teardown 0.00
---------------------------------------------------------
Total Run Time 19.14
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 17 Dec 2020 20:38:43 +0000 (13:38 -0700)]
ftests: Add support for cgsnapshot
Add functional test support for cgsnapshot to the
Cgroup class. The method, snapshot(), invokes libcgroup's
cgsnapshot and returns a dictionary of Cgroup class
instantiations (which are analogous to struct cgroup
within libcgroup.)
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 17 Dec 2020 21:54:13 +0000 (14:54 -0700)]
ftests: Make the Cgroup class instantiable
Add logic to the functional test's Cgroup class to
make it analogous to libcgroup's struct cgroup.
By adding __init__(), __str__(), and __eq__() methods,
the cgroup class can very closely mirror struct cgroup.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 17 Dec 2020 19:47:48 +0000 (12:47 -0700)]
ftests: Add a cgroup controller class
Add a controller class that mirrors libcgroup's
struct cgroup_controller. The controller class
contains a dictionary that represents the array
of struct control_values. To simplify the usability
within the functional tests, the __str__() and
__eq__() methods have been overridden.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 17 Dec 2020 19:02:06 +0000 (12:02 -0700)]
ftests: Move cgroup version enums to their own class
In preparation for adding non-static functionality to
the Cgroup class, move the cgroup version enumerations
to their own class. (Enums and __init__() can collide
in strange ways.)
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 17 Dec 2020 14:59:52 +0000 (07:59 -0700)]
ftests: Invoke ftests.sh in Makefile.am
Invoke a wrapper script, ftests.sh, in the TESTS target
within Makefile.am. This provides two advantages:
1. When new tests are added, Makefile.am does not need
to be updated
2. This adds verbose logging to the continuous integration
suite
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Tue, 3 Nov 2020 15:04:20 +0000 (08:04 -0700)]
ftests: Add a cgroup v2 basic cgget test
Add a test - 003-cgget-basic_cgget_v2.py - that tests
cgget on a cgroup v2 system.
-----------------------------------------------------------------
Test Results:
Run Date: Nov 03 17:49:35
Passed: 1 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 3.76
003-cgget-basic_cgget_v2.py 0.70
teardown 0.00
---------------------------------------------------------
Total Run Time 4.46
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 28 Oct 2020 15:34:13 +0000 (15:34 +0000)]
ftests: Fix config typo in test 001
Test 001 erroneously set the test number in the wrong place -
config.test_num. This caused all the tests to run when only
test 001 was invoked. The correct setting is config.args.num
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 28 Oct 2020 14:43:19 +0000 (14:43 +0000)]
ftests: Run a cgv1 process in the recursive cgdelete test
For cgroup v1, run a process in the child cgroup during
the recursive cgdelete tests - 002-cgdelete-recursive_delete.py.
In cgroup v1, cgdelete should migrate the process to its
parent cgroup.
If the test is being run on a cgroup v2 system, don't
create the process. Cgroup v2 doesn't support processes
running in a non-leaf cgroup, so cgdelete's recursive
command doesn't really make sense.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 28 Oct 2020 14:08:59 +0000 (14:08 +0000)]
ftests: Add support for shell commands in containers
Add support for shell commands to Container.run() method.
The parameter, shell_bool, is passed directly to Run.run()
and is ultimately sent on to subprocess.Popen(). As the
name implies, when shell_bool is set to true, the requested
command will be executed through the shell.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Tue, 27 Oct 2020 18:18:57 +0000 (18:18 +0000)]
ftests: Add symlink to sed
LXC on Ubuntu 20.04 placed at /bin/sed rather than
/usr/bin/sed like the cgtools scripts expect. Create
a symlink at /usr/bin/sed so that the cgroup tools can
run like usual.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Fri, 16 Oct 2020 14:58:12 +0000 (14:58 +0000)]
ftests: Add recursive cgdelete functional test
Add a test that creates a cgroup hierarchy and then invokes
cgdelete on the parent cgroup with the recursive flag set.
-----------------------------------------------------------------
Test Results:
Run Date: Oct 16 14:54:20
Passed: 2 test(s)
Skipped: 0 test(s)
Failed: 0 test(s)
-----------------------------------------------------------------
Timing Results:
Test Time (sec)
---------------------------------------------------------
setup 15.11
001-cgget-basic_cgget.py 0.53
002-cgdelete-recursive_delete.py 0.26
teardown 0.00
---------------------------------------------------------
Total Run Time 15.90
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 23 Sep 2020 16:49:12 +0000 (10:49 -0600)]
gunit: Add unit tests for cgroupv2_controller_enabled()
This commit adds unit tests for cgroupv2_controller_enabled()
[----------] 4 tests from CgroupV2ControllerEnabled
[ RUN ] CgroupV2ControllerEnabled.CgroupV1Controller
[ OK ] CgroupV2ControllerEnabled.CgroupV1Controller (0 ms)
[ RUN ] CgroupV2ControllerEnabled.RootCgroup
[ OK ] CgroupV2ControllerEnabled.RootCgroup (1 ms)
[ RUN ] CgroupV2ControllerEnabled.ControllerEnabled
[ OK ] CgroupV2ControllerEnabled.ControllerEnabled (0 ms)
[ RUN ] CgroupV2ControllerEnabled.ControllerDisabled
[ OK ] CgroupV2ControllerEnabled.ControllerDisabled (0 ms)
[----------] 4 tests from CgroupV2ControllerEnabled (1 ms total)
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 23 Sep 2020 16:48:34 +0000 (10:48 -0600)]
gunit: Add unit tests for cgroupv2_get_subtree_control()
This commit adds unit tests for cgroupv2_get_subtree_control()
[----------] 6 tests from GetSubtreeControlTest
[ RUN ] GetSubtreeControlTest.SingleControllerEnabled
[ OK ] GetSubtreeControlTest.SingleControllerEnabled (0 ms)
[ RUN ] GetSubtreeControlTest.SingleControllerNoMatch
[ OK ] GetSubtreeControlTest.SingleControllerNoMatch (0 ms)
[ RUN ] GetSubtreeControlTest.SingleControllerNoMatch2
[ OK ] GetSubtreeControlTest.SingleControllerNoMatch2 (0 ms)
[ RUN ] GetSubtreeControlTest.MultipleControllersEnabled
[ OK ] GetSubtreeControlTest.MultipleControllersEnabled (0 ms)
[ RUN ] GetSubtreeControlTest.MultipleControllersEnabled2
[ OK ] GetSubtreeControlTest.MultipleControllersEnabled2 (0 ms)
[ RUN ] GetSubtreeControlTest.MultipleControllersNoMatch
[ OK ] GetSubtreeControlTest.MultipleControllersNoMatch (0 ms)
[----------] 6 tests from GetSubtreeControlTest (0 ms total)
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 23 Sep 2020 16:47:32 +0000 (10:47 -0600)]
gunit: Add unit tests for cgroup_build_tasks_procs_path()
This commit adds unit tests for cgroup_build_tasks_procs_path()
[----------] 6 tests from BuildTasksProcPathTest
[ RUN ] BuildTasksProcPathTest.BuildTasksProcPathTest_ControllerNotFound
[ OK ] BuildTasksProcPathTest.BuildTasksProcPathTest_ControllerNotFound (0 ms)
[ RUN ] BuildTasksProcPathTest.BuildTasksProcPathTest_UnknownCgVersion
[ OK ] BuildTasksProcPathTest.BuildTasksProcPathTest_UnknownCgVersion (0 ms)
[ RUN ] BuildTasksProcPathTest.BuildTasksProcPathTest_CgV1
[ OK ] BuildTasksProcPathTest.BuildTasksProcPathTest_CgV1 (0 ms)
[ RUN ] BuildTasksProcPathTest.BuildTasksProcPathTest_CgV2
[ OK ] BuildTasksProcPathTest.BuildTasksProcPathTest_CgV2 (1 ms)
[ RUN ] BuildTasksProcPathTest.BuildTasksProcPathTest_CgV1WithNs
[ OK ] BuildTasksProcPathTest.BuildTasksProcPathTest_CgV1WithNs (0 ms)
[ RUN ] BuildTasksProcPathTest.BuildTasksProcPathTest_CgV2WithNs
[ OK ] BuildTasksProcPathTest.BuildTasksProcPathTest_CgV2WithNs (0 ms)
[----------] 6 tests from BuildTasksProcPathTest (1 ms total)
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 16 Jul 2020 20:55:33 +0000 (14:55 -0600)]
gunit: Add unit tests for cgroup_create_cgroup()
This commit adds unit tests for cgroup_create_cgroup().
[----------] 3 tests from CgroupCreateCgroupTest
[ RUN ] CgroupCreateCgroupTest.CgroupCreateCgroupV1
[ OK ] CgroupCreateCgroupTest.CgroupCreateCgroupV1 (1 ms)
[ RUN ] CgroupCreateCgroupTest.CgroupCreateCgroupV2
[ OK ] CgroupCreateCgroupTest.CgroupCreateCgroupV2 (0 ms)
[ RUN ] CgroupCreateCgroupTest.CgroupCreateCgroupV1AndV2
[ OK ] CgroupCreateCgroupTest.CgroupCreateCgroupV1AndV2 (1 ms)
[----------] 3 tests from CgroupCreateCgroupTest (2 ms total)
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 16 Jul 2020 20:34:55 +0000 (14:34 -0600)]
gunit: Add unit tests for cgroupv2_subtree_control()
This commit adds unit tests for cgroupv2_subtree_control().
[----------] 2 tests from SubtreeControlTest
[ RUN ] SubtreeControlTest.AddController
[ OK ] SubtreeControlTest.AddController (0 ms)
[ RUN ] SubtreeControlTest.RemoveController
[ OK ] SubtreeControlTest.RemoveController (0 ms)
[----------] 2 tests from SubtreeControlTest (0 ms total)
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 16 Jul 2020 19:57:49 +0000 (13:57 -0600)]
tests: Set cgroup version in test 006
This commit explicitly sets the cgroup version in the
fictitious mount table in test 006. With the introduction
of the CGROUP_UNK enumeration value, this test fails without
explicitly setting the version to CGROUP_V1.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 15 Jul 2020 18:36:07 +0000 (12:36 -0600)]
gunit: Add unit tests for cgroup_chown_chmod_tasks()
This commit adds unit tests for cgroup_chown_chmod_tasks().
[----------] 1 test from ChownChmodTasksTest
[ RUN ] ChownChmodTasksTest.SuccessfulChownChmod
[ OK ] ChownChmodTasksTest.SuccessfulChownChmod (0 ms)
[----------] 1 test from ChownChmodTasksTest (0 ms total)
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 15 Jul 2020 18:15:14 +0000 (12:15 -0600)]
gunit: Add unit tests for cgroup_set_values_recursive()
This commit adds unit tests for cgroup_set_values_recursive().
[----------] 1 test from SetValuesRecursiveTest
[ RUN ] SetValuesRecursiveTest.SuccessfulSetValues
[ OK ] SetValuesRecursiveTest.SuccessfulSetValues (1 ms)
[----------] 1 test from SetValuesRecursiveTest (1 ms total)
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 7 May 2020 20:19:01 +0000 (20:19 +0000)]
gunit: Add unit tests for cgroup_process_v2_mnt()
This commit adds unit tests for cgroup_process_v2_mnt().
[----------] 3 tests from CgroupProcessV2MntTest
[ RUN ] CgroupProcessV2MntTest.AddV2Mount
[ OK ] CgroupProcessV2MntTest.AddV2Mount (1 ms)
[ RUN ] CgroupProcessV2MntTest.AddV2Mount_Duplicate
[ OK ] CgroupProcessV2MntTest.AddV2Mount_Duplicate (0 ms)
[ RUN ] CgroupProcessV2MntTest.EmptyControllersFile
[ OK ] CgroupProcessV2MntTest.EmptyControllersFile (1 ms)
[----------] 3 tests from CgroupProcessV2MntTest (2 ms total)
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 7 May 2020 20:15:24 +0000 (20:15 +0000)]
gunit: Add unit tests for cgroup_process_v1_mnt()
This commit adds unit tests for cgroup_process_v1_mnt(). Note
that the compiler flag -Wno-write-strings was also added because
C++ throws a warning due to how the controllers[] array is
utilized.
[----------] 4 tests from CgroupProcessV1MntTest
[ RUN ] CgroupProcessV1MntTest.AddV1Mount
[ OK ] CgroupProcessV1MntTest.AddV1Mount (0 ms)
[ RUN ] CgroupProcessV1MntTest.AddV1Mount_Duplicate
[ OK ] CgroupProcessV1MntTest.AddV1Mount_Duplicate (0 ms)
[ RUN ] CgroupProcessV1MntTest.AddV1NamedMount
[ OK ] CgroupProcessV1MntTest.AddV1NamedMount (0 ms)
[ RUN ] CgroupProcessV1MntTest.AddV1NamedMount_Duplicate
[ OK ] CgroupProcessV1MntTest.AddV1NamedMount_Duplicate (0 ms)
[----------] 4 tests from CgroupProcessV1MntTest (0 ms total)
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Mon, 20 Apr 2020 17:37:52 +0000 (11:37 -0600)]
tests: Add unit tests for cgroup_get_cgroup()
This commit adds a unit test for cgroup_get_cgroup(). To
facilitate this, it creates a pseudo-cgroup sysfs in the
working directory and updates the test's cg_mount_table[]
to point at this temporary directory.
[----------] 2 tests from CgroupGetCgroupTest
[ RUN ] CgroupGetCgroupTest.CgroupGetCgroup1
[ OK ] CgroupGetCgroupTest.CgroupGetCgroup1 (3 ms)
[ RUN ] CgroupGetCgroupTest.CgroupGetCgroup_NoTasksFile
[ OK ] CgroupGetCgroupTest.CgroupGetCgroup_NoTasksFile (2 ms)
[----------] 2 tests from CgroupGetCgroupTest (6 ms total)
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Nikola Forró [Thu, 16 Jan 2020 17:43:54 +0000 (18:43 +0100)]
Increase maximal size of controller values
Maximal length of a controller value is determined by CG_VALUE_MAX,
which is equal to 100. That is not sufficient in some cases.
Add new constant CG_CONTROL_VALUE_MAX (to prevent breaking current API)
and set it to 4096, which is usually equal to the amount of bytes that
can be written to a sysctl file directly.
Add warning message about exceeding the limit while parsing
configuration file.
Signed-off-by: Nikola Forró <nforro@redhat.com> Reviewed-by: Tom Hromatka <tom.hromatka@oracle.com>
Nikola Forró [Thu, 16 Jan 2020 17:43:51 +0000 (18:43 +0100)]
api.c: Preserve dirty flag when copying controller values
When setting cgroup parameters with cgset fails, no error is reported.
This is caused by the fact that cgroup_copy_controller_values is not
preserving dirty flags of the values, so it's making all errors
considered non-fatal.
Signed-off-by: Nikola Forró <nforro@redhat.com> Reviewed-by: Tom Hromatka <tom.hromatka@oracle.com>
Nikola Forró [Thu, 16 Jan 2020 17:43:50 +0000 (18:43 +0100)]
api.c: Fix potential buffer overflow
It is assumed that arguments read from /proc/<pid>/cmdline don't exceed
buf_pname buffer size, which is FILENAME_MAX - 1 characters, but that's
not always the case.
Add check to prevent buffer overflow and discard the excessive part of
an argument.
Signed-off-by: Nikola Forró <nforro@redhat.com> Reviewed-by: Tom Hromatka <tom.hromatka@oracle.com>
Nikola Forró [Thu, 16 Jan 2020 17:43:49 +0000 (18:43 +0100)]
api.c: Fix order of memory subsystem parameters generated by cgsnapshot
Order of parameters usually doesn't matter, but that's not the case with
memory.limit_in_bytes and memory.memsw.limit_in_bytes. When the latter
is first in the list of parameters, the resulting configuration is not
loadable with cgconfigparser.
This happens because when a cgroup is created, both memory.limit_in_bytes
and memory.memsw.limit_in_bytes parameters are initialized to highest
value possible (RESOURCE_MAX). And because memory.memsw.limit_in_bytes
must be always higher or equal to memory.limit_in_bytes, it's impossible
to change its value first.
Make sure that after constructing parameter list of memory subsystem,
the mentioned parameters are in correct order.
Signed-off-by: Nikola Forró <nforro@redhat.com> Reviewed-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Mon, 13 Jan 2020 23:34:56 +0000 (23:34 +0000)]
tests: Fix test failure on Fedora 30
Unit test 004-cgroup_compare_ignore_rule.cpp segfaults on
test CgroupCompareIgnoreRuleTest.CombinedControllers(). This
is due to rule.procname being uninitialized. This commit
initializes the entire rule structure to zero.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Mon, 13 Jan 2020 23:31:20 +0000 (23:31 +0000)]
autotools: gtest: Distribute the googletest *.so files
googletest strongly recommends that their library is
rebuilt on each platform, but this runs counter to a
tagged release of code that utilizes gtest. This commit
enables `make dist` to bundle the googletest *.so files
into the resultant zip file.
Note that these googletest *.so files are dependent upon
a certain version of glibc (and other libraries) and may
not work on distros with very old versions of those
tools.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Fri, 10 Jan 2020 22:46:26 +0000 (22:46 +0000)]
gtest: Cleanup gtest make targets
Prior to this commit the unit test map file was being
included in the source directory. It has now been moved
to the tests/gunit directory. This commit also properly
connects the tests/gunit Makefile to the googletest *.la
so that a recompile of googletest is not required.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com> Reviewed-by: Dhaval Giani <dhaval.giani@oracle.com>