diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-04-24 19:01:29 -0300 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-04-24 19:02:13 -0300 |
commit | 78edb35ab4f4227485cb9ec816b43c37e0d5e62a (patch) | |
tree | 20d78b824f47ce62a790c448799c471d4db9900e /src/test/test-cgroup-util.c | |
parent | e10375f2c0f5dd0dc8508f3ca165eb8aa63c64fb (diff) |
cgroup: always validate cgroup controller names
Let's better be safe than sorry.
Diffstat (limited to 'src/test/test-cgroup-util.c')
-rw-r--r-- | src/test/test-cgroup-util.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c index 95cede7a22..6726f8fb13 100644 --- a/src/test/test-cgroup-util.c +++ b/src/test/test-cgroup-util.c @@ -153,6 +153,19 @@ static void test_escape(void) { test_escape_one("_foobar", "__foobar"); } +static void test_controller_is_valid(void) { + assert_se(cg_controller_is_valid("foobar", false)); + assert_se(cg_controller_is_valid("foo_bar", false)); + assert_se(cg_controller_is_valid("name=foo", true)); + assert_se(!cg_controller_is_valid("", false)); + assert_se(!cg_controller_is_valid("name=", true)); + assert_se(!cg_controller_is_valid("=", false)); + assert_se(!cg_controller_is_valid("cpu,cpuacct", false)); + assert_se(!cg_controller_is_valid("_", false)); + assert_se(!cg_controller_is_valid("_foobar", false)); + assert_se(!cg_controller_is_valid("tatü", false)); +} + int main(void) { test_path_decode_unit(); test_path_get_unit(); @@ -160,6 +173,7 @@ int main(void) { test_get_paths(); test_proc(); test_escape(); + test_controller_is_valid(); return 0; } |