]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
tests: Add unit tests for cgroup_compare_ignore_rule()
authorTom Hromatka <tom.hromatka@oracle.com>
Mon, 4 Nov 2019 23:20:01 +0000 (23:20 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 12 Dec 2019 22:10:28 +0000 (15:10 -0700)
commitce5f317baa860ac69a9e60186add034dde92aafb
treeeac40c8eb055d46cbc7946690cdfd9a87d4f7891
parentae76f3a8c9c90ac05feb046714f4f6566b24cd3c
tests: Add unit tests for cgroup_compare_ignore_rule()

The following tests are in this commit:

NotAnIgnore() - Test that non-ignore rules are not processed

SimpleMatch() - Test that an ignore rule with a matching cgroup
    and controller match

CgroupsDontMatch() - Test that cgroups with similar but not matching
    names do not match

ControllersDontMatch() - Test that controllers with non-matching
    names do not match

CombinedControllers() - Test that controllers that have been mounted
    on the same path, e.g. cpu,cpuacct, can be matched by a rule

MatchChildFolder() - Compares a rule with a single-level hierarchy
    with a rule that matches that hierarchy

MatchGrandchildFolder() - Compares a rule with a multi-level hierarchy
    with a process that matches that hierachy

MatchSimilarChildFolder() - Compares a child folder that is similar
    to the rule.  This mimics a misconfiguration that a user could
    make

RealWorldMatch() - Test that a realistic cgroup proc file matches
    a new process

RealWorldNoMatch() - Test that a realistic cgroup proc file will
    not match a new process

SimilarFolderNoMatch() - Compares a rule with a folder name that
   is similar to the process' cgroup, but not a match

RootDestinationMatch() - Compares a rule with the root as the
   destination and a process also running in the root cgroup

RootDestinationNoMatch() - Compares a rule with the root as the
   destination and a process in another cgroup folder

The results from googletest are reported below:

[----------] 13 tests from CgroupCompareIgnoreRuleTest
[ RUN      ] CgroupCompareIgnoreRuleTest.NotAnIgnore
[       OK ] CgroupCompareIgnoreRuleTest.NotAnIgnore (0 ms)
[ RUN      ] CgroupCompareIgnoreRuleTest.SimpleMatch
[       OK ] CgroupCompareIgnoreRuleTest.SimpleMatch (0 ms)
[ RUN      ] CgroupCompareIgnoreRuleTest.CgroupsDontMatch
[       OK ] CgroupCompareIgnoreRuleTest.CgroupsDontMatch (0 ms)
[ RUN      ] CgroupCompareIgnoreRuleTest.ControllersDontMatch
[       OK ] CgroupCompareIgnoreRuleTest.ControllersDontMatch (0 ms)
[ RUN      ] CgroupCompareIgnoreRuleTest.CombinedControllers
[       OK ] CgroupCompareIgnoreRuleTest.CombinedControllers (0 ms)
[ RUN      ] CgroupCompareIgnoreRuleTest.MatchChildFolder
[       OK ] CgroupCompareIgnoreRuleTest.MatchChildFolder (0 ms)
[ RUN      ] CgroupCompareIgnoreRuleTest.MatchGrandchildFolder
[       OK ] CgroupCompareIgnoreRuleTest.MatchGrandchildFolder (0 ms)
[ RUN      ] CgroupCompareIgnoreRuleTest.MatchSimilarChildFolder
[       OK ] CgroupCompareIgnoreRuleTest.MatchSimilarChildFolder (0 ms)
[ RUN      ] CgroupCompareIgnoreRuleTest.RealWorldMatch
[       OK ] CgroupCompareIgnoreRuleTest.RealWorldMatch (0 ms)
[ RUN      ] CgroupCompareIgnoreRuleTest.RealWorldNoMatch
[       OK ] CgroupCompareIgnoreRuleTest.RealWorldNoMatch (1 ms)
[ RUN      ] CgroupCompareIgnoreRuleTest.SimilarFolderNoMatch
[       OK ] CgroupCompareIgnoreRuleTest.SimilarFolderNoMatch (0 ms)
[ RUN      ] CgroupCompareIgnoreRuleTest.RootDestinationMatch
[       OK ] CgroupCompareIgnoreRuleTest.RootDestinationMatch (0 ms)
[ RUN      ] CgroupCompareIgnoreRuleTest.RootDestinationNoMatch
[       OK ] CgroupCompareIgnoreRuleTest.RootDestinationNoMatch (0 ms)
[----------] 13 tests from CgroupCompareIgnoreRuleTest (3 ms total)

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/api.c
src/libcgroup-internal.h
tests/gunit/004-cgroup_compare_ignore_rule.cpp [new file with mode: 0644]
tests/gunit/Makefile.am