]> git.ipfire.org Git - thirdparty/libcgroup.git/log
thirdparty/libcgroup.git
4 years agoftests: Skip test 032 due to Github Issue #50
Tom Hromatka [Wed, 2 Jun 2021 19:46:48 +0000 (19:46 +0000)] 
ftests: Skip test 032 due to Github Issue #50

On full cgroup v2 systems, skip 032-lscgroup-multiple_g_flags.py
due to Github Issue #50.  Currently lscgroup is doing path matching
on the mounts that have the same path as the cgroup rather than
reading cgroup.controllers for that particular cgroup.  I'm afraid
fixing it could involve a non-trivial rewrite of lscgroup since it
doesn't use any of the common structures used elsewhere in libcgroup.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Skip test 031 due to Github Issue #50
Tom Hromatka [Wed, 2 Jun 2021 20:37:21 +0000 (20:37 +0000)] 
ftests: Skip test 031 due to Github Issue #50

On full cgroup v2 systems, skip 031-lscgroup-g_flag.py
due to Github Issue #50.  Currently lscgroup is doing path matching
on the mounts that have the same path as the cgroup rather than
reading cgroup.controllers for that particular cgroup.  I'm afraid
fixing it could involve a non-trivial rewrite of lscgroup since it
doesn't use any of the common structures used elsewhere in libcgroup.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Modify functional test 030 to support cgroup v2
Tom Hromatka [Wed, 2 Jun 2021 20:11:01 +0000 (20:11 +0000)] 
ftests: Modify functional test 030 to support cgroup v2

Add cgroup v2 support to the 030-lssubsys-lssubsys_all.py
functional test.  It continues to support cgroup v1 as well.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Modify functional test 014 to support cgroup v2
Tom Hromatka [Wed, 2 Jun 2021 13:34:33 +0000 (13:34 +0000)] 
ftests: Modify functional test 014 to support cgroup v2

Add support for a full cgroup v2 system to the 014-cgget-a_flag.py
functional test.  It continues to support cgroup v1 as well.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Modify functional test 013 to support cgroup v2
Tom Hromatka [Wed, 2 Jun 2021 20:38:42 +0000 (20:38 +0000)] 
ftests: Modify functional test 013 to support cgroup v2

Add cgroup v2 support to the 013-cgget-multiple_g_flags.py
functional test.  It continues to support cgroup v1 as well.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agocgroup.py: Fix bug in delete with multiple controllers
Tom Hromatka [Wed, 2 Jun 2021 13:33:14 +0000 (13:33 +0000)] 
cgroup.py: Fix bug in delete with multiple controllers

When multiple controllers are passed into Cgroup.delete()
via a list, delete() was erroneously joining them without
a comma separator.  Add the comma separator.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Modify functional test 012 to support cgroup v2
Tom Hromatka [Wed, 2 Jun 2021 13:48:51 +0000 (13:48 +0000)] 
ftests: Modify functional test 012 to support cgroup v2

Add cgroup v2 support to the 012-cgget-multiple_r_flags2.py
functional test.  It continues to support cgroup v1 as well.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Modify functional test 011 to support cgroup v2
Tom Hromatka [Wed, 2 Jun 2021 14:33:06 +0000 (14:33 +0000)] 
ftests: Modify functional test 011 to support cgroup v2

Add cgroup v2 support to the 011-cgget-r_flag_two_cgroups.py
functional test.  It continues to support cgroup v1 as well.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Modify functional test 010 to support cgroup v2
Tom Hromatka [Wed, 2 Jun 2021 13:10:02 +0000 (13:10 +0000)] 
ftests: Modify functional test 010 to support cgroup v2

Add cgroup v2 support to the 010-cgget-g_flag_controller_and_cgroup.py
functional test.  It continues to support cgroup v1 as well.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Modify functional test 009 to support cgroup v2
Tom Hromatka [Wed, 2 Jun 2021 19:58:24 +0000 (19:58 +0000)] 
ftests: Modify functional test 009 to support cgroup v2

Add cgroup v2 support to the 009-cgget-g_flag_controller_only.py
functional test.  It continues to support cgroup v1 as well.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Modify functional test 008 to support cgroup v2
Tom Hromatka [Tue, 1 Jun 2021 22:10:12 +0000 (22:10 +0000)] 
ftests: Modify functional test 008 to support cgroup v2

Add cgroup v2 support to the 008-cgget-multiple_r_flags.py
functional test.  It continues to support cgroup v1 as well.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Modify functional test 005 to support cgroup v2
Tom Hromatka [Wed, 2 Jun 2021 13:58:53 +0000 (13:58 +0000)] 
ftests: Modify functional test 005 to support cgroup v2

Add support for a full cgroup v2 system to the
005-cgsnapshot-basic_snapshot_v2.py functional test. It
continues to support cgroup v1 systems and mixed systems
as well.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agorun.py: Ignore LXD cgroup v2 warning
Tom Hromatka [Tue, 1 Jun 2021 22:08:13 +0000 (22:08 +0000)] 
run.py: Ignore LXD cgroup v2 warning

On full cgroup v2 systems, LXD raises the following warning:
WARNING: cgroup v2 is not fully supported yet

Add logic to run.py to ignore this warning.  A non-zero return
code or other strings in stderr should still cause a RunError
exception to be raised.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #23 from drakenclimber/issues/delete-cgclear
Tom Hromatka [Tue, 1 Jun 2021 13:44:48 +0000 (07:44 -0600)] 
Merge pull request #23 from drakenclimber/issues/delete-cgclear

ftests: Delete the cgclear functional test

4 years agoMerge pull request #22 from drakenclimber/issues/cgexec-test
Tom Hromatka [Mon, 24 May 2021 15:41:02 +0000 (09:41 -0600)] 
Merge pull request #22 from drakenclimber/issues/cgexec-test

Add a cgexec functional test

4 years agoftests: Delete the cgclear functional test
Tom Hromatka [Tue, 18 May 2021 18:33:14 +0000 (18:33 +0000)] 
ftests: Delete the cgclear functional test

Delete the cgclear functional test.  cgclear has been
removed from libcgroup.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add a cgexec test
Tom Hromatka [Mon, 17 May 2021 14:22:48 +0000 (14:22 +0000)] 
ftests: Add a cgexec test

Add a basic cgexec test

-----------------------------------------------------------------
Test Results:
        Run Date:                          May 03 19:56:02
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                        11.87
        034-cgexec-basic_cgexec.py                    2.55
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                               14.42

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agocgroup.py: Add method to get pids in a cgroup
Tom Hromatka [Mon, 17 May 2021 14:15:59 +0000 (14:15 +0000)] 
cgroup.py: Add method to get pids in a cgroup

Add a method, get_pids_in_cgroup(), that will return
the pids in a given cgroup.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoprocess.py: Add support for cgexec'ing a new process
Tom Hromatka [Mon, 17 May 2021 14:12:37 +0000 (14:12 +0000)] 
process.py: Add support for cgexec'ing a new process

Add support for cgexec to create_process_in_cgroup().
cgclassify still remains as the default process assignment
mechanism.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agocgroup.py: Add support for cgexec
Tom Hromatka [Mon, 17 May 2021 14:04:37 +0000 (14:04 +0000)] 
cgroup.py: Add support for cgexec

Add support for cgexec to the Cgroup class.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #21 from drakenclimber/issues/skip-tests
Tom Hromatka [Wed, 5 May 2021 15:24:00 +0000 (09:24 -0600)] 
Merge pull request #21 from drakenclimber/issues/skip-tests

ftests.py: Allow for skipping of multiple tests

4 years agoftests.py: Allow for skipping of multiple tests
Tom Hromatka [Wed, 5 May 2021 15:19:17 +0000 (11:19 -0400)] 
ftests.py: Allow for skipping of multiple tests

In anticipation of some tests not running nicely on some
distros, make the ftests.py --skip/-S option smarter so that
it can accept a single test or multiple tests separated by a
comma.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #20 from drakenclimber/issues/fix-warnings
Tom Hromatka [Fri, 30 Apr 2021 13:39:03 +0000 (07:39 -0600)] 
Merge pull request #20 from drakenclimber/issues/fix-warnings

Fix warnings in libcgroup-tests repo

4 years agogunit: Fix an snprintf() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 17:21:27 +0000 (17:21 +0000)] 
gunit: Fix an snprintf() truncation warning

Fix the following snprintf() string truncation warning:

013-cgroup_build_tasks_procs_path.cpp:65:22: warning: ‘%s’ directive output may be truncated writing up
to 820799 bytes into a region of size 4081 [-Wformat-truncation=]
   65 |      "/sys/fs/cgroup/%s", cg_mount_table[i].name);
      |                      ^~
In file included from /usr/include/stdio.h:867,
                 from /usr/include/c++/9/cstdio:42,
                 from /usr/include/c++/9/ext/string_conversions.h:43,
                 from /usr/include/c++/9/bits/basic_string.h:6493,
                 from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from ../../googletest/googletest/include/gtest/gtest.h:55,
                 from 013-cgroup_build_tasks_procs_path.cpp:22:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 16 an
d 820815 bytes into a destination of size 4096
   67 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |        __bos (__s), __fmt, __va_arg_pack ());
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agogunit: Fix an snprintf() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 17:19:40 +0000 (17:19 +0000)] 
gunit: Fix an snprintf() truncation warning

Fix the following snprintf() string truncation warning:

001-path.cpp: In member function ‘virtual void BuildPathV1Test::SetUp()’:
001-path.cpp:70:22: warning: ‘%s’ directive output may be truncated writing up to 820799 bytes into a re
gion of size 4081 [-Wformat-truncation=]
   70 |      "/sys/fs/cgroup/%s", cg_mount_table[i].name);
      |                      ^~
In file included from /usr/include/stdio.h:867,
                 from /usr/include/c++/9/cstdio:42,
                 from /usr/include/c++/9/ext/string_conversions.h:43,
                 from /usr/include/c++/9/bits/basic_string.h:6493,
                 from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from ../../googletest/googletest/include/gtest/gtest.h:55,
                 from 001-path.cpp:22:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin___snprintf_chk’ output between 16 an
d 820815 bytes into a destination of size 4096
   67 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |        __bos (__s), __fmt, __va_arg_pack ());
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMakefile.am/tests: Do not compile the old tests
Tom Hromatka [Tue, 27 Apr 2021 17:12:15 +0000 (17:12 +0000)] 
Makefile.am/tests: Do not compile the old tests

For historical reasons, the old tests remain in the testing
directory but are not being run or installed.

Due to compiler warnings from newer versions of GCC, do not
compile these tests.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMakefile.am: Remove default.conf
Tom Hromatka [Mon, 26 Apr 2021 19:44:12 +0000 (19:44 +0000)] 
Makefile.am: Remove default.conf

Remove the reference in EXTRA_DIST to default.conf.
default.conf was deleted in e326a57222e8 ("ftests: Remove
unused config files").

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #19 from drakenclimber/issues/38
Tom Hromatka [Mon, 19 Apr 2021 14:33:39 +0000 (08:33 -0600)] 
Merge pull request #19 from drakenclimber/issues/38

ftests: Add cgget test with no flags

4 years agoMerge pull request #18 from drakenclimber/issues/fixtest004
Tom Hromatka [Thu, 15 Apr 2021 20:23:53 +0000 (14:23 -0600)] 
Merge pull request #18 from drakenclimber/issues/fixtest004

ftests: Allow test 004 to run on systems w/ or w/o swap

4 years agoftests: Allow test 004 to run on systems w/ or w/o swap
Tom Hromatka [Thu, 25 Mar 2021 20:03:35 +0000 (20:03 +0000)] 
ftests: Allow test 004 to run on systems w/ or w/o swap

Add smarts to test 004 so that it can be run on systems with
or without swap.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #17 from drakenclimber/issues/lscgroup
Tom Hromatka [Thu, 15 Apr 2021 19:57:21 +0000 (13:57 -0600)] 
Merge pull request #17 from drakenclimber/issues/lscgroup

Add support and tests for lscgroup

4 years agoftests: Add cgget test with no flags
Tom Hromatka [Wed, 14 Apr 2021 17:06:25 +0000 (11:06 -0600)] 
ftests: Add cgget test with no flags

Add a cgget test that exercises the following format:
cgget CgroupName

-----------------------------------------------------------------
Test Results:
        Run Date:                          Apr 14 10:57:44
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                         0.00
        033-cgget-no_flags.py                         0.11
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                                0.11

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add an lscgroup test with multiple '-g' flags
Tom Hromatka [Thu, 25 Mar 2021 16:35:32 +0000 (16:35 +0000)] 
ftests: Add an lscgroup test with multiple '-g' flags

Add an lscgroup test with multiple '-g' flags.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Mar 25 16:35:47
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                        14.12
        032-lscgroup-multiple_g_flags.py              4.63
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                               18.75

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add an lscgroup test with a single '-g' flag
Tom Hromatka [Thu, 25 Mar 2021 16:34:47 +0000 (16:34 +0000)] 
ftests: Add an lscgroup test with a single '-g' flag

Add a test that invokes lscgroup with a single '-g' flag.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Mar 25 16:34:25
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                        18.41
        031-lscgroup-g_flag.py                        0.58
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                               18.98

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agocgroup.py: Add support for lscgroup
Tom Hromatka [Thu, 25 Mar 2021 16:33:38 +0000 (16:33 +0000)] 
cgroup.py: Add support for lscgroup

Add support for lscgroup to the Cgroup class.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #16 from drakenclimber/issues/lssubsys
Tom Hromatka [Thu, 8 Apr 2021 16:38:59 +0000 (10:38 -0600)] 
Merge pull request #16 from drakenclimber/issues/lssubsys

Add functional tests for lssubsys

4 years agoftests: Add an lssubsys -a functional test
Tom Hromatka [Wed, 24 Mar 2021 19:12:44 +0000 (19:12 +0000)] 
ftests: Add an lssubsys -a functional test

Add a functional test that exercises 'lssubsys -a'

-----------------------------------------------------------------
Test Results:
        Run Date:                          Mar 24 19:12:33
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                        20.06
        030-lssubsys-lssubsys_all.py                  0.18
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                               20.23

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add basic lssubsys test
Tom Hromatka [Wed, 24 Mar 2021 19:09:24 +0000 (19:09 +0000)] 
ftests: Add basic lssubsys test

Add a functional test that exercises lssubsys with no flags.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Mar 24 19:09:14
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                        23.47
        029-lssubsys-basic_lssubsys.py                0.15
        teardown                                      0.00
        --------------------------------------------------

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agocgroup.py: Add method to parse /proc/mounts for cgroup mounts
Tom Hromatka [Wed, 24 Mar 2021 19:43:42 +0000 (19:43 +0000)] 
cgroup.py: Add method to parse /proc/mounts for cgroup mounts

Add a method - Cgroup.get_cgroup_mounts() - that can parse
/proc/mounts and return a list of CgroupMount instances.
This method will be useful for validating results from lssubsys.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agocgroup.py: Add support for lssubsys
Tom Hromatka [Wed, 24 Mar 2021 18:56:23 +0000 (18:56 +0000)] 
cgroup.py: Add support for lssubsys

Add support for lssubsys to the Cgroup class.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #15 from drakenclimber/issues/fixcgset
Tom Hromatka [Mon, 5 Apr 2021 15:12:14 +0000 (09:12 -0600)] 
Merge pull request #15 from drakenclimber/issues/fixcgset

gtest: Add unit test for cgset's parse_r_flag()

4 years agogtest: Add unit test for cgset's parse_r_flag()
Tom Hromatka [Wed, 31 Mar 2021 16:58:48 +0000 (16:58 +0000)] 
gtest: Add unit test for cgset's parse_r_flag()

Add a unit test for parse_r_flag() in cgset.c.

[----------] 1 test from CgsetParseRFlagTest
[ RUN      ] CgsetParseRFlagTest.EqualCharInValue
[       OK ] CgsetParseRFlagTest.EqualCharInValue (0 ms)
[----------] 1 test from CgsetParseRFlagTest (0 ms total)

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #14 from drakenclimber/issues/cgclear
Tom Hromatka [Fri, 2 Apr 2021 17:22:12 +0000 (11:22 -0600)] 
Merge pull request #14 from drakenclimber/issues/cgclear

Add cgclear tests

4 years agogunit: Ignore systemd hierarchies in test 007
Tom Hromatka [Mon, 29 Mar 2021 17:54:09 +0000 (17:54 +0000)] 
gunit: Ignore systemd hierarchies in test 007

Now that systemd hierarchies are being ignored via the
OPAQUE_HIERARCHY setting, update unit test 007 to ensure
that systemd hierachies are not added to the mount table.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #13 from drakenclimber/issues/cgset-tests2
Tom Hromatka [Mon, 29 Mar 2021 14:05:17 +0000 (08:05 -0600)] 
Merge pull request #13 from drakenclimber/issues/cgset-tests2

Add extensive cgset tests

4 years agoftests: Add a simple cgclear functional test
Tom Hromatka [Tue, 23 Mar 2021 16:12:13 +0000 (16:12 +0000)] 
ftests: Add a simple cgclear functional test

Add a test that invokes cgclear.  Note that this test is especially
destructive and is skipped by default.  Github Actions invokes it
separately as the final step.

-----------------------------------------------------------------
Test Results:
Run Date:                          Mar 23 16:07:55
Passed:                                  1 test(s)
Skipped:                                 0 test(s)
Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
Test                                    Time (sec)
---------------------------------------------------------
setup                                         0.00
028-cgclear-basic_cgclear.py                  1.80
teardown                                      0.00
---------------------------------------------------------
Total Run Time                                1.80

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests/consts: Add parser option to skip a test
Tom Hromatka [Tue, 23 Mar 2021 16:09:29 +0000 (16:09 +0000)] 
ftests/consts: Add parser option to skip a test

Add a flag, '-S' or '--skip', to allow a test number
to be skipped.  This will be used to skip the cgclear test
by default since it's so destructive.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agocgroup.py: Add support for cgclear
Tom Hromatka [Tue, 23 Mar 2021 16:08:26 +0000 (16:08 +0000)] 
cgroup.py: Add support for cgclear

Add support for cgclear to the Cgroup class.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add pydoc documentation to Cgroup.set()
Tom Hromatka [Wed, 10 Mar 2021 18:54:29 +0000 (18:54 +0000)] 
ftests: Add pydoc documentation to Cgroup.set()

Add pydoc documentation for the Cgroup.set() method and reference
the automated tests that exercise various cgset commands.

The pydoc for Cgroup.set() is available by running:
$ python -c "from cgroup import Cgroup;help(Cgroup.set)"

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add cgset invalid options test
Tom Hromatka [Wed, 10 Mar 2021 18:51:45 +0000 (18:51 +0000)] 
ftests: Add cgset invalid options test

Add a test that tests various invalid flag combinations to cgset.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Mar 08 17:39:20
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                        18.15
        027-cgset-invalid_options.py                  0.94
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                               19.09

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add a cgset test with multiple '-r' flags and cgroups
Tom Hromatka [Wed, 10 Mar 2021 18:48:04 +0000 (18:48 +0000)] 
ftests: Add a cgset test with multiple '-r' flags and cgroups

Add a cgset test that provides multiple '-r' flags to multiple
cgroups.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Mar 08 19:30:43
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                        15.33
        026-cgset-multiple_r_multiple_cgroup.py       5.14
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                               20.47

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add multiple cgroup cgset set
Tom Hromatka [Wed, 10 Mar 2021 18:47:03 +0000 (18:47 +0000)] 
ftests: Add multiple cgroup cgset set

Add a test that passes in multiple cgroups to cgset.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Mar 08 19:14:20
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                        19.85
        025-cgset-multiple_cgroups.py                 0.85
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                               20.69

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add cgset --copy-from test
Tom Hromatka [Wed, 10 Mar 2021 17:36:28 +0000 (17:36 +0000)] 
ftests: Add cgset --copy-from test

Add a test that utilizes the cgset --copy-from flag.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Mar 02 20:24:45
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                        22.79
        023-cgset-copy_from.py                        1.13
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                               23.93

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add multiple -r flag cgset test
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>
4 years agocgroup.py: Add -h support to Cgroup.set()
Tom Hromatka [Wed, 10 Mar 2021 17:22:52 +0000 (17:22 +0000)] 
cgroup.py: Add -h support to Cgroup.set()

Add support for the '-h' flag to Cgroup.set()

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agocgroup.py: Allow for multiple cgroup names to be passed to cgset
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>
4 years agocgroup.py: Add support for cgset --copy-from flag
Tom Hromatka [Wed, 10 Mar 2021 17:15:19 +0000 (17:15 +0000)] 
cgroup.py: Add support for cgset --copy-from flag

Add support for cgset's --copy-from flag to Cgroup.set().

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agogunit: Update test 009 to match cgroup_set_values_recursive()
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>
4 years agoMerge pull request #12 from drakenclimber/issues/cgconfig-tests2
Tom Hromatka [Mon, 22 Mar 2021 17:11:54 +0000 (11:11 -0600)] 
Merge pull request #12 from drakenclimber/issues/cgconfig-tests2

Add functional tests for cgconfigparser

4 years agocgroup.py: Add pydoc documentation to Cgroup.configparser()
Tom Hromatka [Wed, 10 Mar 2021 14:29:22 +0000 (14:29 +0000)] 
cgroup.py: Add pydoc documentation to Cgroup.configparser()

Add pydoc documentation for the Cgroup.configparser() method and
reference the automated tests that exercise various cgconfigparser
commands.

The pydoc for Cgroup.configparser() is available by running:
$ python -c "from cgroup import Cgroup;help(Cgroup.configparser)"

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add invalid parameter test for cgconfigparser
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>
4 years agoftests: Add a cgconfigparser test that sets tasks owner/permissions
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>
4 years agoftests: Add a cgconfigparser owner, fperm, and dperm test
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>
4 years agoutils.py: Add functions to get permissions, users, and groups
Tom Hromatka [Tue, 9 Mar 2021 22:12:39 +0000 (22:12 +0000)] 
utils.py: Add functions to get permissions, users, and groups

Add a few functions to utils.py to get file permissions, owners,
and convert usernames to uids and group names to gids.

Functions added:
get_file_owner_uid()
get_file_owner_username()
get_file_owner_gid()
get_file_owner_group_name()
get_file_permissions()

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add a cgconfigparser test that loads a directory
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>
4 years agoftests: Add a simple cgconfigparser test
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>
4 years agocgroup.py: Add method to get a controller's mount point
Tom Hromatka [Wed, 10 Mar 2021 02:09:18 +0000 (02:09 +0000)] 
cgroup.py: Add method to get a controller's mount point

Add a static method to the Cgroup class to get a controller's
mount point.  Works with both cgroup v1 and cgroup v2.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agocgroup.py: Add support for cgconfigparser
Tom Hromatka [Tue, 9 Mar 2021 19:16:56 +0000 (19:16 +0000)] 
cgroup.py: Add support for cgconfigparser

Add support for running cgconfigparser in the functional
tests.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #10 from drakenclimber/issues/cgget-tests2
Tom Hromatka [Mon, 1 Mar 2021 17:28:46 +0000 (10:28 -0700)] 
Merge pull request #10 from drakenclimber/issues/cgget-tests2

Add extensive cgget functional tests

4 years agoftests: Add pydoc documentation to Cgroup.get()
Tom Hromatka [Thu, 11 Feb 2021 20:22:51 +0000 (20:22 +0000)] 
ftests: Add pydoc documentation to Cgroup.get()

Add pydoc documentation for the Cgroup.get() method and reference
the automated test that exercise various cgget commands.

The pydoc for Cgroup.get() is available by running:
$ python -c "from cgroup import Cgroup;help(Cgroup.get)"

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add cgget invalid parameter test
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>
4 years agoftests: Add cgget '-a' test
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>
4 years agoftests: Add multiline cgget test
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>
4 years agoftests: Add cgget test with multiple '-g' flags
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>
4 years agoftests: Add cgget test with multiple '-r' flags and multiple cgroups
Tom Hromatka [Tue, 9 Feb 2021 21:39:14 +0000 (21:39 +0000)] 
ftests: Add cgget test with multiple '-r' flags and multiple cgroups

Add a test that exercises multiple '-r' flags and multiple
cgroups in cgget.  This test verifies the following cgget
operation:

$ cgget -r memory.limit_in_bytes -r memory.soft_limit_in_bytes \
  012cgget1 012cgget2

-----------------------------------------------------------------
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>
4 years agoftests: Add cgget test with '-r' flag and two cgroups
Tom Hromatka [Tue, 9 Feb 2021 21:22:28 +0000 (21:22 +0000)] 
ftests: Add cgget test with '-r' flag and two cgroups

Add a test that exercises the '-r' <name> <cgroup1> <cgroup2>
option in cgget.  This test verifies the following cgget
operation:

$ cgget -r memory.limit_in_bytes 011cgget1 011cgget2

-----------------------------------------------------------------
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>
4 years agoftests: Add cgget test with '-g' <controller>:<cgroup> flag
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>
4 years agoftests: Add cgget test with '-g' <controller> flag
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>
4 years agoftests: Add cgget test with multiple '-r' flags
Tom Hromatka [Tue, 9 Feb 2021 20:06:25 +0000 (20:06 +0000)] 
ftests: Add cgget test with multiple '-r' flags

Add a test that exercises multiple '-r' flags passed
into cgget.  This test verifies the following cgget
operation:

$ cgget -r memory.limit_in_bytes -r memory.soft_limit_in_bytes \
  008cgget
008cgget:
memory.limit_in_bytes: 1048576
memory.soft_limit_in_bytes: 1024000

-----------------------------------------------------------------
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>
4 years agoftests: Add support for getting cgget help string
Tom Hromatka [Wed, 10 Feb 2021 23:46:34 +0000 (23:46 +0000)] 
ftests: Add support for getting cgget help string

Add support for getting cgget help string

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Throw an exception if len(stderr) > 0
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>
4 years agoftests: Clean up handling of bytes vs string
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>
4 years agoMerge pull request #9 from drakenclimber/issues/cgrules5
Tom Hromatka [Mon, 1 Mar 2021 17:13:18 +0000 (10:13 -0700)] 
Merge pull request #9 from drakenclimber/issues/cgrules5

Add cgrules functional tests

4 years agoftests: Add cgroup v2 cgrules test
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>
4 years agoftests: Add cgroup v1 cgrules test
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

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit eeb176b289b5ac704d27ca52996423b1887c6c3e)

4 years agoftests: Clean up a few exceptions
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>
4 years agoftests: Add support for getting a process' cgroups
Tom Hromatka [Mon, 1 Mar 2021 16:37:23 +0000 (16:37 +0000)] 
ftests: Add support for getting a process' cgroups

Add support to get the current cgroup(s) of a running process.
Works with both cgroup v1 and cgroup v2.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add cgrulesengd support to the Cgroup class
Tom Hromatka [Mon, 1 Mar 2021 16:37:06 +0000 (16:37 +0000)] 
ftests: Add cgrulesengd support to the Cgroup class

Add cgrulesengd support to the Cgroup class.  Add methods
to insert a rule, initialize the daemon, and start the
daemon in a separate process.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #8 from drakenclimber/issues/nocontainer
Tom Hromatka [Mon, 1 Mar 2021 15:53:22 +0000 (08:53 -0700)] 
Merge pull request #8 from drakenclimber/issues/nocontainer

Add support to run the functional tests outside of a container

4 years agoMerge pull request #7 from drakenclimber/issues/21
Tom Hromatka [Thu, 25 Feb 2021 15:13:44 +0000 (08:13 -0700)] 
Merge pull request #7 from drakenclimber/issues/21

gunit: Update test 009 to better test dirty flag

4 years agogunit: Update test 009 to better test dirty flag
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>
4 years agoftests: Add a script to run the non-containerized tests
Tom Hromatka [Wed, 3 Feb 2021 17:49:45 +0000 (10:49 -0700)] 
ftests: Add a script to run the non-containerized tests

Add a script to run the non-containerized tests and
invoke it from `make check`.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Add permissions support to cgsnapshot parsing
Tom Hromatka [Wed, 3 Feb 2021 17:46:23 +0000 (10:46 -0700)] 
ftests: Add permissions support to cgsnapshot parsing

In a container cgsnapshot doesn't report owner/group
permissions, but on a bare-metal setup, it does.  Add
support to parse the permissions fields.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoftests: Make the Process() class instantiable
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>
4 years agoftests: Ensure the deny list file exists
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>
4 years agoftests: Use sudo for many cgroup commands when not in a container
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>
4 years agoftests: Test 004 must be run within a container
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>
4 years agoftests: Add --container and --no-container flags
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>
4 years agoftests: Fix failure cause when multiple tests don't pass
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>
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