[CRIU] [PATCH 2/2] zdtm/cgroup01: create more than one empty cgroups

Andrew Vagin avagin at openvz.org
Fri Aug 15 05:24:25 PDT 2014


We found a bug, when a second cgroup is restored incorrectly,
so let's create one more empty cgroup.

Signed-off-by: Andrew Vagin <avagin at openvz.org>
---
 test/zdtm/live/static/cgroup.hook |  3 ++-
 test/zdtm/live/static/cgroup01.c  | 31 ++++++++++++++++++++-----------
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/test/zdtm/live/static/cgroup.hook b/test/zdtm/live/static/cgroup.hook
index 908d78c..f1a3158 100755
--- a/test/zdtm/live/static/cgroup.hook
+++ b/test/zdtm/live/static/cgroup.hook
@@ -9,7 +9,8 @@ echo "Cleaning $tname"
 
 set +e
 rmdir "$tname/subcg/subsubcg/"
-rmdir "$tname/subcg/empty/"
+rmdir "$tname/subcg/empty.0/"
+rmdir "$tname/subcg/empty.1/"
 rmdir "$tname/subcg/"
 set -e
 
diff --git a/test/zdtm/live/static/cgroup01.c b/test/zdtm/live/static/cgroup01.c
index a715cd8..10de6fc 100644
--- a/test/zdtm/live/static/cgroup01.c
+++ b/test/zdtm/live/static/cgroup01.c
@@ -17,7 +17,7 @@ static const char *empty = "empty";
 
 int main(int argc, char **argv)
 {
-	int cgfd, l, ret = 1;
+	int cgfd, l, ret = 1, i;
 	char aux[1024], paux[1024];
 	FILE *cgf;
 	struct stat st;
@@ -55,8 +55,13 @@ int main(int argc, char **argv)
 		goto out_rs;
 	}
 
-	sprintf(paux, "%s/%s/%s", dirname, subname, empty);
-	mkdir(paux, 0600);
+	for (i = 0; i < 2; i++) {
+		sprintf(paux, "%s/%s/%s.%d", dirname, subname, empty, i);
+		if (mkdir(paux, 0600)) {
+			err("mkdir %s", paux);
+			return 1;
+		}
+	}
 
 	test_daemon();
 	test_waitsig();
@@ -71,10 +76,14 @@ int main(int argc, char **argv)
 		char *s;
 
 		s = strstr(paux, cgname);
-		if (s) {
-			sscanf(paux, "%*d %*d %*d:%*d %*s %s", aux);
-			test_msg("found cgroup at %s\n", aux);
-			sprintf(paux, "%s/%s/%s", aux, subname, empty);
+		if (!s)
+			continue;
+
+		sscanf(paux, "%*d %*d %*d:%*d %*s %s", aux);
+		test_msg("found cgroup at %s\n", aux);
+
+		for (i = 0; i < 2; i++) {
+			sprintf(paux, "%s/%s/%s.%d", aux, subname, empty, i);
 			if (stat(paux, &st)) {
 				fail("couldn't stat %s\n", paux);
 				ret = -1;
@@ -86,11 +95,11 @@ int main(int argc, char **argv)
 				ret = -1;
 				goto out_close;
 			}
-
-			pass();
-			ret = 0;
-			goto out_close;
 		}
+
+		pass();
+		ret = 0;
+		goto out_close;
 	}
 
 	fail("empty cgroup not found!\n");
-- 
1.9.3



More information about the CRIU mailing list