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

tests: cgroup02 should use --cgroup-root on dump

To mimic the environment that systemd is in when it causes the problem, we
preserve a prefix cgroup path across checkpoint and restore which the tasks
live below, and then we open a fd to this path. Without
--cgroup-root /prefix on dump, this test fails:

(00.030429)     32: Error (criu/files-reg.c:1487): File home/ubuntu/criu/test/zdtm/static/cgroup02.test/zdtmtst/prefix has bad mode 040600 (expect 040777)
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 1ede31b7
......@@ -17,7 +17,7 @@ static const char *cgname = "zdtmtst";
static const char *subname = "oldroot";
static const char *cgname2 = "zdtmtst.defaultroot";
int mount_and_add(const char *controller, const char *path)
int mount_and_add(const char *controller, const char *prefix, const char *path)
{
char aux[1024], paux[1024], subdir[1024];
int cgfd, l;
......@@ -39,11 +39,14 @@ int mount_and_add(const char *controller, const char *path)
goto err_rd;
}
sprintf(paux, "%s/%s", subdir, path);
sprintf(paux, "%s/%s", subdir, prefix);
mkdir(paux, 0600);
sprintf(paux, "%s/%s/%s", subdir, prefix, path);
mkdir(paux, 0600);
l = sprintf(aux, "%d", getpid());
sprintf(paux, "%s/%s/tasks", subdir, path);
sprintf(paux, "%s/%s/%s/tasks", subdir, prefix, path);
cgfd = open(paux, O_WRONLY);
if (cgfd < 0) {
......@@ -93,21 +96,37 @@ int main(int argc, char **argv)
bool found_zdtmtstroot = false, found_newroot = false;
char paux[1024];
int ret = -1;
int fd;
test_init(argc, argv);
if (mount_and_add(cgname, subname))
if (mount_and_add(cgname, "prefix", subname))
goto out;
if (mount_and_add(cgname2, subname)) {
if (mount_and_add(cgname2, "prefix", subname)) {
sprintf(paux, "%s/%s", dirname, cgname);
umount(paux);
rmdir(paux);
goto out;
}
sprintf(paux, "%s/%s/prefix", dirname, cgname);
fd = open(paux, O_DIRECTORY);
if (fd < 0)
goto out_umount;
if (fchmod(fd, 0777) < 0) {
fail("fchmod");
goto out_umount;
}
test_daemon();
test_waitsig();
if (close(fd) < 0) {
fail("fd didn't survive");
goto out_umount;
}
cgf = fopen("/proc/self/mountinfo", "r");
if (cgf == NULL) {
fail("No mountinfo file");
......@@ -118,7 +137,7 @@ int main(int argc, char **argv)
char *s;
s = strstr(paux, cgname);
if (s && test_exists(paux, "zdtmtstroot")) {
if (s && test_exists(paux, "prefix")) {
found_zdtmtstroot = true;
}
......
{'flavor': 'h', 'flags': 'suid', 'ropts': '--manage-cgroups --cgroup-root /newroot --cgroup-root name=zdtmtst:/zdtmtstroot'}
{'flavor': 'h', 'flags': 'suid', 'dopts': '--manage-cgroups --cgroup-root name=zdtmtst:/prefix', 'ropts': '--manage-cgroups --cgroup-root /newroot --cgroup-root name=zdtmtst:/prefix'}
......@@ -9,7 +9,7 @@ rmroots() {
mount -t cgroup none $tname -o "$1"
for d in "$tname/oldroot" "$tname/newroot" "$tname/zdtmtstroot"; do
for d in "$tname/prefix" "$tname/newroot"; do
test -d "$d" || continue
# sort by line length
for i in `find $d -type d | awk '{print length, $0}' | sort -rn | cut -d " " -f2-`; do
......
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