]> git.ipfire.org Git - thirdparty/libcgroup.git/log
thirdparty/libcgroup.git
4 years agogithub: Always display test logs
Tom Hromatka [Wed, 23 Dec 2020 18:12:39 +0000 (11:12 -0700)] 
github: Always display test logs

Always display the test logs in the github actions
GUI.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #19 from drakenclimber/issues/cgsnapshot2
Tom Hromatka [Wed, 23 Dec 2020 15:23:17 +0000 (08:23 -0700)] 
Merge pull request #19 from drakenclimber/issues/cgsnapshot2

Add support for cgroup v2 cgsnapshot

4 years agoMerge pull request #6 from drakenclimber/issues/cgsnapshot2
Tom Hromatka [Wed, 23 Dec 2020 15:17:37 +0000 (08:17 -0700)] 
Merge pull request #6 from drakenclimber/issues/cgsnapshot2

Add tests for cgroup v1 and cgroup v2 cgsnapshot

4 years agocgsnapshot: Replace hardcoded "tasks" file 19/head
Tom Hromatka [Thu, 17 Dec 2020 18:39:11 +0000 (11:39 -0700)] 
cgsnapshot: Replace hardcoded "tasks" file

Replace the hardcoded building of the tasks path in
cgsnapshot with a call to cgroup_build_tasks_procs_path().
By calling cgroup_build_tasks_procs_path(), cgsnapshot
now supports both cgroup v1 and cgroup v2.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Dhaval Giani <dhaval.giani@oracle.com>
4 years agoapi.c: Export cgroup_build_tasks_procs_path()
Tom Hromatka [Thu, 17 Dec 2020 18:38:52 +0000 (11:38 -0700)] 
api.c: Export cgroup_build_tasks_procs_path()

Make cgroup_build_tasks_procs_path() available to
libcgroup.la library users (i.e. the libcgroup tools).

This change will be used in the next commit so that
cgsnapshot can properly read the tasks/procs file.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Dhaval Giani <dhaval.giani@oracle.com>
4 years agoftests: Add cgroup v2 cgsnapshot test
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>
4 years agoftests: Add cgroup v1 cgsnapshot test
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>
4 years agoftests: Add support for cgsnapshot
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>
4 years agoftests: Make the Cgroup class instantiable
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>
4 years agoftests: Add a cgroup controller class
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>
4 years agoftests: Add a utilities file and an indent() function
Tom Hromatka [Thu, 17 Dec 2020 19:43:26 +0000 (12:43 -0700)] 
ftests: Add a utilities file and an indent() function

Add a new file to hold generic utilities for the
functional tests.  As part of this change, a function
that can indent a block of text has been added.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Move cgroup version enums to their own class
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>
4 years agogithub: Display ftests.sh.log in the CI GUI
Tom Hromatka [Thu, 17 Dec 2020 18:24:13 +0000 (11:24 -0700)] 
github: Display ftests.sh.log in the CI GUI

Now that we invoke ftests.sh in the functional tests'
Makefile.am, test-suite.log isn't that useful.  Display
ftests.sh.log in the Github Actions GUI since
ftests.sh.log contains pass/fail info for each test.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #18 from drakenclimber/issues/betterlogs
Tom Hromatka [Thu, 17 Dec 2020 15:50:12 +0000 (08:50 -0700)] 
Merge pull request #18 from drakenclimber/issues/betterlogs

github: Improve logging and reporting

4 years agoMerge pull request #5 from drakenclimber/issues/betterlogs
Tom Hromatka [Thu, 17 Dec 2020 15:45:15 +0000 (08:45 -0700)] 
Merge pull request #5 from drakenclimber/issues/betterlogs

ftests: Invoke ftests.sh in Makefile.am

4 years agogithub: Improve logging and reporting 18/head
Tom Hromatka [Thu, 17 Dec 2020 15:03:32 +0000 (08:03 -0700)] 
github: Improve logging and reporting

Display the high-level log, test-suite.log, in
the github work for all jobs.  Also, archive the
functional test logs to facilitate debugging a
failed run.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Invoke ftests.sh in Makefile.am
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>
4 years agoREADME.md: Update the coveralls badge
Tom Hromatka [Tue, 15 Dec 2020 22:11:01 +0000 (15:11 -0700)] 
README.md: Update the coveralls badge

The coveralls.io badge wasn't consistently updating
after a successful run.  Remove the "?branch=master"
parameter and switch to using a png rather than an
svg.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #17 from drakenclimber/issues/github_actions
Tom Hromatka [Tue, 15 Dec 2020 21:01:14 +0000 (14:01 -0700)] 
Merge pull request #17 from drakenclimber/issues/github_actions

Transition from Travis CI to Github Actions

4 years agoREADME.md: Transition from Travis CI to Github Actions 17/head
Tom Hromatka [Tue, 15 Dec 2020 20:46:58 +0000 (13:46 -0700)] 
README.md: Transition from Travis CI to Github Actions

Travis CI has now been disabled.  Delete the Travis CI
badge and display the Github Actions continuous integration
workflow badge.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agogithub: Add continuous integration Github workflow
Tom Hromatka [Tue, 15 Dec 2020 20:46:21 +0000 (13:46 -0700)] 
github: Add continuous integration Github workflow

Add a Github Actions continuous integration workflow.  This
workflow runs the unit tests, the cgroup v1 functional tests,
and the cgroup v2 functional tests.  The code coverage results
from all of the runs are collated at coveralls.io.

Like Travis CI, Github Actions currently does not provide a
distro that natively runs cgroup v2.  (And it also doesn't
expose the kernel boot command line.)  So, like our previous
Travis CI solution, unmount the cpuset controller and enable
it in cgroup v2.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agogithub: Add a Github Action to setup the libcgroup directory
Tom Hromatka [Tue, 15 Dec 2020 20:45:46 +0000 (13:45 -0700)] 
github: Add a Github Action to setup the libcgroup directory

Add a Github Action to setup the libcgroup directory.
This action installs the required dependencies, run
bootstrap.sh, runs configure, and invokes make.

Since the action is invoked locally (and not via Github
Action's published action mechanism), the repository must
be git cloned prior to running this action.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agotravis: Disable Travis CI
Tom Hromatka [Tue, 15 Dec 2020 20:45:16 +0000 (13:45 -0700)] 
travis: Disable Travis CI

Disable the Travis CI build by deleting the
.travis.yml file.  Subsequent commits will transition
to using Github Actions instead.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #16 from drakenclimber/issues/ftests_cgv2
Tom Hromatka [Mon, 23 Nov 2020 17:14:37 +0000 (10:14 -0700)] 
Merge pull request #16 from drakenclimber/issues/ftests_cgv2

Add cgroup v2 support to the functional tests

4 years agoMerge pull request #4 from drakenclimber/issues/ftests_cgv2
Tom Hromatka [Mon, 23 Nov 2020 16:29:40 +0000 (09:29 -0700)] 
Merge pull request #4 from drakenclimber/issues/ftests_cgv2

Add cgroup v2 support to the functional tests

4 years agoftests: Add a cgroup v2 basic cgget test
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>
4 years agoftests: Rename Test 001 to denote it is cgroup v1 only
Tom Hromatka [Tue, 3 Nov 2020 14:55:05 +0000 (07:55 -0700)] 
ftests: Rename Test 001 to denote it is cgroup v1 only

Rename test 1 from 001-cgget-basic_cgget.py to
001-cgget-basic_cgget_v1.py.  Also add logic to the test
to skip it on a v2 system.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Fix config typo in test 001
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>
4 years agoftests: Run a cgv1 process in the recursive cgdelete test
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>
4 years agoftests: Add class to create and manage child processes
Tom Hromatka [Tue, 27 Oct 2020 19:12:07 +0000 (19:12 +0000)] 
ftests: Add class to create and manage child processes

Add a class that can create and delete child processes.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add support for shell commands in containers
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>
4 years agoftests: Add support for cgclassify to Cgroup class
Tom Hromatka [Wed, 28 Oct 2020 15:30:55 +0000 (15:30 +0000)] 
ftests: Add support for cgclassify to Cgroup class

Add support for cgclassify to Cgroup class.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add a method to get a controller's cgroup version
Tom Hromatka [Mon, 26 Oct 2020 17:53:06 +0000 (11:53 -0600)] 
ftests: Add a method to get a controller's cgroup version

Add a static method to the Cgroup class to get a
controller's cgroup version.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Michal Koutný <mkoutny@suse.com>
4 years agoftests: Cleanup printing of test timing
Tom Hromatka [Mon, 26 Oct 2020 22:06:14 +0000 (16:06 -0600)] 
ftests: Cleanup printing of test timing

Combine the passed, skipped, and failed tests into a
single list when displaying the timing results of
each test.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Increase the display width for printing test results
Tom Hromatka [Mon, 26 Oct 2020 20:11:12 +0000 (14:11 -0600)] 
ftests: Increase the display width for printing test results

In the functional tests, increase the column width for
displaying the test name from 30 to 35 characters.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add symlink to sed
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>
4 years agoftests: Remove unused config files
Tom Hromatka [Wed, 28 Oct 2020 18:39:38 +0000 (12:39 -0600)] 
ftests: Remove unused config files

Remove references to default.conf and tmp.conf.  When the ftests
switched from LXC to LXD, these files became no longer needed.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agotravis: Add test job on cgroup v2 Ubuntu 20.04 16/head
Tom Hromatka [Wed, 28 Oct 2020 14:57:09 +0000 (14:57 +0000)] 
travis: Add test job on cgroup v2 Ubuntu 20.04

Add a test job on Ubuntu 20.04.  Prior to running the tests, unmount
the cpuset cgroup controller and enable it in the cgroup v2 unified
hierarchy.  Once each job is complete, it notifies coveralls via a
REST call.

Unfortunately, Travis CI doesn't provide a cgroup v2 system image
and also doesn't allow us to modify the kernel boot parameters.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agotravis: Exclude lex.l and parse.y from code coverage
Tom Hromatka [Mon, 26 Oct 2020 16:48:31 +0000 (10:48 -0600)] 
travis: Exclude lex.l and parse.y from code coverage

Exclude lex.l and parse.y from code coverage numbers.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #14 from drakenclimber/issues/cgdelete
Tom Hromatka [Thu, 22 Oct 2020 18:13:27 +0000 (12:13 -0600)] 
Merge pull request #14 from drakenclimber/issues/cgdelete

api.c: Replace hardcoded "/tasks" in delete functions

4 years agoMerge pull request #3 from drakenclimber/issues/cgdelete
Tom Hromatka [Thu, 22 Oct 2020 18:13:13 +0000 (12:13 -0600)] 
Merge pull request #3 from drakenclimber/issues/cgdelete

ftests: Add recursive cgdelete functional test

4 years agoapi.c: Replace hardcoded "/tasks" in delete functions 14/head
Tom Hromatka [Thu, 15 Oct 2020 21:58:19 +0000 (15:58 -0600)] 
api.c: Replace hardcoded "/tasks" in delete functions

Replace the hardcoded building of the tasks path in
cg_delete_cgroup_controller() and cgroup_delete_cgroup_ext()
with a call to cgroup_build_tasks_procs_path().  By calling
cgroup_build_tasks_procs_path(), both delete functions now
support cgroup v1 and v2.

cgdelete now supports cgroup v2.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add recursive cgdelete functional test
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>
4 years agoMerge pull request #13 from drakenclimber/issues/cgclassify2
Tom Hromatka [Thu, 15 Oct 2020 20:03:23 +0000 (14:03 -0600)] 
Merge pull request #13 from drakenclimber/issues/cgclassify2

Add cgroup v2 support for cgclassify and cgexec

4 years agoMerge pull request #2 from drakenclimber/issues/cgclassify
Tom Hromatka [Thu, 15 Oct 2020 20:00:05 +0000 (14:00 -0600)] 
Merge pull request #2 from drakenclimber/issues/cgclassify

Add unit tests for cgclassify and cgexec functions

4 years agoapi.c: Verify if a controller is enabled for a v2 cgroup 13/head
Tom Hromatka [Wed, 23 Sep 2020 16:41:32 +0000 (10:41 -0600)] 
api.c: Verify if a controller is enabled for a v2 cgroup

Add a function, cgroupv2_controller_enabled(), that checks if the
requested cgroup v2 controller can be used for the specified path.
Again, in cgroup v2, to use a controller, it must be added to the
parent cgroup's cgroup.subtree_control file.

This check is required to ensure that the cgexec and cgclassify
operations will succeed.  And with this commit, cgexec and cgclassify
work on both cgroup v1 and cgroup v2 hierarchies.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoapi.c: Add function to read the cgroup.subtree_control file
Tom Hromatka [Wed, 23 Sep 2020 16:41:00 +0000 (10:41 -0600)] 
api.c: Add function to read the cgroup.subtree_control file

Add a function, cgroupv2_get_subtree_control(), that verifies
if a controller is enabled in the cgroup.subtree_control file
for the requested path.

This function will be used in the next commit - "api.c: Add function
to check if a controller is enabled for a cgroup v2 cgroup" - to
determine if the requested cgroup v2 controller is enabled for a
cgroup.  This is a required check to ensure that the
cgclassify/cgexec operation will succeed.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoapi.c: Add function to build tasks/procs path
Tom Hromatka [Wed, 23 Sep 2020 16:39:33 +0000 (10:39 -0600)] 
api.c: Add function to build tasks/procs path

Replace the inline logic in multiple functions that concatenates
the path and cgroup v1 tasks file with a function -
cgroup_build_tasks_procs_path() - that works for both cgroup v1
and v2.  In the v1 case, it appends tasks, and in the v2 case, it
appends cgroup.procs.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agogunit: Add unit tests for cgroupv2_controller_enabled()
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>
4 years agogunit: Add unit tests for cgroupv2_get_subtree_control()
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>
4 years agogunit: Add unit tests for cgroup_build_tasks_procs_path()
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>
4 years agoRevert "DO NOT COMMIT"
Tom Hromatka [Wed, 9 Sep 2020 16:23:45 +0000 (10:23 -0600)] 
Revert "DO NOT COMMIT"

This reverts commit 83d6205fc7711818bd2e4bf1890d7d157756182e.

4 years agoMerge pull request #11 from drakenclimber/issues/cgcreate
Tom Hromatka [Wed, 9 Sep 2020 16:02:44 +0000 (10:02 -0600)] 
Merge pull request #11 from drakenclimber/issues/cgcreate

Add cgroup v2 support to cgcreate

4 years agoMerge pull request #1 from drakenclimber/issues/cgcreate
Tom Hromatka [Wed, 9 Sep 2020 16:02:05 +0000 (10:02 -0600)] 
Merge pull request #1 from drakenclimber/issues/cgcreate

Add tests for cgcreate cgroup v2 support

5 years agogunit: Add unit tests for cgroup_create_cgroup()
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>
5 years agogunit: Add unit tests for cgroupv2_subtree_control()
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>
5 years agotests: Set cgroup version in test 006
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>
5 years agogunit: Add unit tests for cgroup_chown_chmod_tasks()
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>
5 years agogunit: Add unit tests for cgroup_set_values_recursive()
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>
5 years agoapi.c: Add cgroup v2 support to cgroup_create_cgroup() 11/head
Tom Hromatka [Wed, 29 Jul 2020 16:52:49 +0000 (16:52 +0000)] 
api.c: Add cgroup v2 support to cgroup_create_cgroup()

This commit adds cgroup v2 support go cgroup_create_cgroup().
If the controller is mounted via cgroup v2, then the
subtree_control file in the parent directory will be updated
to enable the controller in children cgroups.  The tasks
file is only updated for cgroup v1 mounts.

Here's an example of creating a cgroup hierarchy in a single command:
sudo cgcreate -g io:a/b/c/d

The above cgcreate example is equivalent to:
mkdir -p {root_cg}/a/b/c/d
echo +io > {root_cg}/cgroup.subtree_control
echo +io > {root_cg}/a/cgroup.subtree_control
echo +io > {root_cg}/a/b/cgroup.subtree_control
echo +io > {root_cg}/a/b/c/cgroup.subtree_control

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agoapi.c: Add function to recursively manage the cgroup v2 subtree
Tom Hromatka [Wed, 29 Jul 2020 16:46:44 +0000 (16:46 +0000)] 
api.c: Add function to recursively manage the cgroup v2 subtree

This commit adds the function cgroupv2_subtree_control_recursive().
cgroupv2_subtree_control_recursive() creates a cgroup hierarchy with
the subtree_control enabled in each parent cgroup for the requested
cgroup controller.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agoapi.c: Add function to manage the cgroup v2 subtree_control file
Tom Hromatka [Thu, 16 Jul 2020 20:26:49 +0000 (14:26 -0600)] 
api.c: Add function to manage the cgroup v2 subtree_control file

This commit adds the function cgroupv2_subtree_control().
cgroupv2_subtree_control() can be used to enable or disable a
controller in the subtree_control file.  The equivalent command
line is:
echo +{ctrl_name} > {path}/cgroup.subtree_control
echo -{ctrl_name} > {path}/cgroup.subtree_control

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agoapi.c: Add function to get the cgroup version of a controller
Tom Hromatka [Thu, 16 Jul 2020 19:36:48 +0000 (13:36 -0600)] 
api.c: Add function to get the cgroup version of a controller

This commit adds cgroup_get_controller_version() which returns
which version (cgroup v1 or cgroup v2) of a controller is mounted.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agoapi.c: Refactor tasks file permissions code into its own function
Tom Hromatka [Wed, 15 Jul 2020 18:44:20 +0000 (12:44 -0600)] 
api.c: Refactor tasks file permissions code into its own function

Within cgroup_create_cgroup(), there was a block of code to set the
owner, group, and file permissions on the cgroup v1 tasks file.  This
commit moves that logic into its own function -
cgroup_chown_chmod_tasks().

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agoapi.c: Refactor duplicate logic in cgroup modify and create
Tom Hromatka [Wed, 15 Jul 2020 17:06:47 +0000 (11:06 -0600)] 
api.c: Refactor duplicate logic in cgroup modify and create

cgroup_modify_cgroup() and cgroup_create_cgroup() have nearly
identical logic to walk the settings beneath the controller
and update them.  This commit refactors the duplicate logic in
these two functions into one location - cgroup_set_values_recursive().

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agotravis: Show the gunit log on failure
Tom Hromatka [Wed, 15 Jul 2020 18:06:15 +0000 (12:06 -0600)] 
travis: Show the gunit log on failure

When a failure occurs in TravisCI, we currently show only the
test-suite.log from the functional tests.  This commit also displays
the googletest test-suite.log.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agoDO NOT COMMIT
Tom Hromatka [Wed, 15 Jul 2020 17:18:16 +0000 (11:18 -0600)] 
DO NOT COMMIT

This commit points the testing directory at my personal fork

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agoMerge pull request #8 from kloczek/master
Dhaval Giani [Sat, 11 Jul 2020 15:48:54 +0000 (08:48 -0700)] 
Merge pull request #8 from kloczek/master

Fix automake bug for parallel makefiles

5 years agoParalell build fix #7 8/head
Koji Builder [Sat, 11 Jul 2020 15:22:48 +0000 (16:22 +0100)] 
Paralell build fix #7

All source soce files which first needs to be generated needs to be listed in
BUILT_SOURCES.
This patch adds to that automake variable parse.c and parse.h because they are
listed below in libcgroup_la_SOURCES.

Documentetion of the BUILT_SOURCES is on:
https://www.gnu.org/software/automake/manual/html_node/Sources.html

Reported-by: Tomasz Kłoczko <kloczek@giithub.com>
Signed-off-by: Tomasz Kłoczko <kloczek@giithub.com>
5 years agoapi.c: Declare cgroup_process_v2_mnt() as STATIC
Tom Hromatka [Mon, 11 May 2020 02:23:19 +0000 (02:23 +0000)] 
api.c: Declare cgroup_process_v2_mnt() as STATIC

This commit changes cgroup_process_v2_mnt() from static to STATIC
to allow it to be unit tested.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Dhaval Giani <dhaval.giani@oracle.com>
5 years agoapi.c: Declare cgroup_process_v1_mnt() as STATIC
Tom Hromatka [Mon, 11 May 2020 02:23:06 +0000 (02:23 +0000)] 
api.c: Declare cgroup_process_v1_mnt() as STATIC

This commit changes cgroup_process_v1_mnt() from static to STATIC
to allow it to be unit tested.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Dhaval Giani <dhaval.giani@oracle.com>
5 years agoapi.c: cgget: cgset: Add cgroup v2 support
Tom Hromatka [Mon, 11 May 2020 02:09:44 +0000 (02:09 +0000)] 
api.c: cgget: cgset: Add cgroup v2 support

This commit adds cgroup v2 support to cgroup_init(). With these
changes, cgget and cgset now work on a cgroup v1 mount, a cgroup
v2 mount, or a cgroup v2 unified mount hierarchy.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agoapi.c: Add support for cgroup v2 to cg_test_mounted_fs()
Tom Hromatka [Mon, 11 May 2020 02:20:40 +0000 (02:20 +0000)] 
api.c: Add support for cgroup v2 to cg_test_mounted_fs()

This commit adds a string comparison of "cgroup2" to
cg_test_mounted_fs().  This allows cgroup v2 mounts to pass the
filesystem check and thus cgroups can be created.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Dhaval Giani <dhaval.giani@oracle.com>
5 years agoapi.c: Only stat the cgroup tasks file if it's a v1 mount
Tom Hromatka [Mon, 11 May 2020 02:16:42 +0000 (02:16 +0000)] 
api.c: Only stat the cgroup tasks file if it's a v1 mount

In cgroup_get_cgroup(), stat should only be called on the cgroup's
task file if the cgroup is a v1 mount.  v2 mounts don't have a
tasks file.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Dhaval Giani <dhaval.giani@oracle.com>
5 years agoapi.c: Add cgroup version enumeration
Tom Hromatka [Mon, 11 May 2020 02:05:55 +0000 (02:05 +0000)] 
api.c: Add cgroup version enumeration

This commit adds a cgroup version enumeration to the
cg_mount_table.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Dhaval Giani <dhaval.giani@oracle.com>
5 years agoapi.c: Refactor cgroup v1 logic in cgroup_init()
Tom Hromatka [Mon, 11 May 2020 02:00:37 +0000 (02:00 +0000)] 
api.c: Refactor cgroup v1 logic in cgroup_init()

In preparation for adding support for cgroup v2, this commit
moves the cgroup v1 mount logic out of cgroup_init() and into
its own function.  No functional changes were made.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Dhaval Giani <dhaval.giani@oracle.com>
5 years agogunit: Add unit tests for cgroup_process_v2_mnt()
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>
5 years agogunit: Add unit tests for cgroup_process_v1_mnt()
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>
5 years agoMerge remote-tracking branch 'upstream/master' into HEAD
Tom Hromatka [Wed, 22 Apr 2020 15:04:42 +0000 (09:04 -0600)] 
Merge remote-tracking branch 'upstream/master' into HEAD

5 years agoREADME: Update the code coverage badge
Tom Hromatka [Mon, 20 Apr 2020 18:48:57 +0000 (12:48 -0600)] 
README: Update the code coverage badge

Update the code coverage badge with the latest recommended
markdown from coveralls.io

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agotests: Add unit tests for cgroup_get_cgroup()
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>
5 years agobootstrap: Update bootstrap to support libcgroup-tests
Tom Hromatka [Tue, 7 Apr 2020 14:13:23 +0000 (08:13 -0600)] 
bootstrap: Update bootstrap to support libcgroup-tests

This commit updates bootstrap.sh to manage the tests folder now
that it's a git submodule copy of libcgroup-tests.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agogit: Add submodule libcgroup-tests
Tom Hromatka [Tue, 7 Apr 2020 14:11:07 +0000 (08:11 -0600)] 
git: Add submodule libcgroup-tests

This commit adds the libcgroup-tests git repo as a submodule.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agotests: Remove the tests folder from this git repo
Tom Hromatka [Tue, 7 Apr 2020 14:08:25 +0000 (08:08 -0600)] 
tests: Remove the tests folder from this git repo

The test code has been moved to a separate git repo,
libcgroup-tests.  But before that repo can be added as a
submodule, the tests directory must first be deleted from
this repo.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agogit: Moved the tests to the root directory
Tom Hromatka [Tue, 7 Apr 2020 13:59:34 +0000 (07:59 -0600)] 
git: Moved the tests to the root directory

This commit moves all of the files from tests/* to the
root of the git repository.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agogit: folder re-organization
Tom Hromatka [Tue, 7 Apr 2020 13:58:19 +0000 (07:58 -0600)] 
git: folder re-organization

In preparation of moving the tests to their own git repo, this
commit deletes every file/folder other than the test folder.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agotests: Remove the tests folder from this git repo
Tom Hromatka [Mon, 6 Apr 2020 14:43:43 +0000 (08:43 -0600)] 
tests: Remove the tests folder from this git repo

The test code has been moved to a separate git repo,
libcgroup-tests.  Before we can add that repo as a submodule,
we must first delete the tests directory.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agoMerge pull request #5 from drakenclimber/issues/fix_dist_check v0.42.1 v0.42.2
Tom Hromatka [Fri, 31 Jan 2020 21:20:05 +0000 (14:20 -0700)] 
Merge pull request #5 from drakenclimber/issues/fix_dist_check

Fix small issues with distribution zip files

5 years agoMerge pull request #6 from drakenclimber/codereviews/nforro-old-fixes2
Tom Hromatka [Fri, 31 Jan 2020 21:19:37 +0000 (14:19 -0700)] 
Merge pull request #6 from drakenclimber/codereviews/nforro-old-fixes2

Series of old fixes from Nikola Forró

5 years agoIncrease maximal size of controller values 6/head
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>
5 years agoapi.c: Fix level of failed user/group lookup warnings
Nikola Forró [Thu, 16 Jan 2020 17:43:53 +0000 (18:43 +0100)] 
api.c: Fix level of failed user/group lookup warnings

Signed-off-by: Nikola Forró <nforro@redhat.com>
Reviewed-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agoapi.c: Show warning when tasks file can not be opened
Nikola Forró [Thu, 16 Jan 2020 17:43:52 +0000 (18:43 +0100)] 
api.c: Show warning when tasks file can not be opened

Signed-off-by: Nikola Forró <nforro@redhat.com>
Reviewed-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agoapi.c: Preserve dirty flag when copying controller values
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>
5 years agoapi.c: Fix potential buffer overflow
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>
5 years agoapi.c: Fix order of memory subsystem parameters generated by cgsnapshot
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>
5 years agotests: Fix test failure on Fedora 30 5/head
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>
5 years agoautotools: gtest: Distribute the googletest *.so files
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>
5 years agoRelease v0.42 v0.42
Dhaval Giani [Fri, 10 Jan 2020 23:20:39 +0000 (15:20 -0800)] 
Release v0.42

5 years agoMerge pull request #4 from drakenclimber/issues/fixdistzip
Dhaval Giani [Fri, 10 Jan 2020 23:16:53 +0000 (15:16 -0800)] 
Merge pull request #4 from drakenclimber/issues/fixdistzip

Fix a few issues with the test Makefile.ams

5 years agotests: Ship the functional test files 4/head
Tom Hromatka [Fri, 10 Jan 2020 22:48:03 +0000 (22:48 +0000)] 
tests: Ship the functional test files

This commit adds the *.py files to the dist zip so that
the functional tests can be run in the dist zip.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Dhaval Giani <dhaval.giani@oracle.com>