Commit 7d094517 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

tests: expand the list of cgroup devices written

Hopefully this would/will trigger more of these types of bugs; I took this
list straight from Adrian's report.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
CC: Adrian Reber <adrian@lisas.de>
Tested-by: 's avatarAdrian Reber <areber@redhat.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 0e83397d
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include <limits.h> #include <limits.h>
#include "zdtmtst.h" #include "zdtmtst.h"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
const char *test_doc = "Check that some cgroups properties in kernel controllers are preserved"; const char *test_doc = "Check that some cgroups properties in kernel controllers are preserved";
const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>";
...@@ -79,7 +81,7 @@ err_rd: ...@@ -79,7 +81,7 @@ err_rd:
bool checkval(char *path, char *val) bool checkval(char *path, char *val)
{ {
char buf[64]; char buf[1024];
int fd, n; int fd, n;
fd = open(path, O_RDONLY); fd = open(path, O_RDONLY);
...@@ -106,8 +108,22 @@ bool checkval(char *path, char *val) ...@@ -106,8 +108,22 @@ bool checkval(char *path, char *val)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret = -1; int ret = -1, i;
char path[PATH_MAX]; char buf[1024], path[PATH_MAX];
char *deny[] = {
"c *:* m",
"b *:* m",
"c 1:3 rwm",
"c 1:5 rwm",
"c 1:7 rwm",
"c 5:0 rwm",
"c 5:2 rwm",
"c 1:8 rwm",
"c 1:9 rwm",
"c 136:* rwm",
"c 10:229 rwm",
};
test_init(argc, argv); test_init(argc, argv);
...@@ -116,11 +132,10 @@ int main(int argc, char **argv) ...@@ -116,11 +132,10 @@ int main(int argc, char **argv)
/* need to allow /dev/null for restore */ /* need to allow /dev/null for restore */
sprintf(path, "%s/devices/%s/devices.allow", dirname, cgname); sprintf(path, "%s/devices/%s/devices.allow", dirname, cgname);
if (write_value(path, "c 1:3 rwm") < 0) for (i = 0; i < ARRAY_SIZE(deny); i++) {
goto out; if (write_value(path, deny[i]) < 0)
goto out;
if (write_value(path, "c 1:5 rwm") < 0) }
goto out;
if (mount_and_add("memory", cgname, "memory.limit_in_bytes", "268435456") < 0) if (mount_and_add("memory", cgname, "memory.limit_in_bytes", "268435456") < 0)
goto out; goto out;
...@@ -128,8 +143,14 @@ int main(int argc, char **argv) ...@@ -128,8 +143,14 @@ int main(int argc, char **argv)
test_daemon(); test_daemon();
test_waitsig(); test_waitsig();
buf[0] = 0;
for (i = 0; i < ARRAY_SIZE(deny); i++) {
strcat(buf, deny[i]);
strcat(buf, "\n");
}
sprintf(path, "%s/devices/%s/devices.list", dirname, cgname); sprintf(path, "%s/devices/%s/devices.list", dirname, cgname);
if (!checkval(path, "c 1:3 rwm\nc 1:5 rwm\n")) { if (!checkval(path, buf)) {
fail(); fail();
goto out; goto out;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment