[CRIU] [PATCH 3/3] zdtm: add a test with a lot of file descriptors

Andrey Vagin avagin at openvz.org
Mon Apr 4 09:58:08 PDT 2016


From: Andrew Vagin <avagin at virtuozzo.com>

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 test/zdtm/static/Makefile |  1 +
 test/zdtm/static/fds.c    | 43 +++++++++++++++++++++++++++++++++++++++++++
 test/zdtm/static/fds.desc |  1 +
 3 files changed, 45 insertions(+)
 create mode 100644 test/zdtm/static/fds.c
 create mode 100644 test/zdtm/static/fds.desc

diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index 8706e59..02dbdf1 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -149,6 +149,7 @@ TST_NOFILE	=				\
 		oom_score_adj			\
 		loginuid			\
 		cgroupns			\
+		fds				\
 #		jobctl00			\
 
 TST_FILE	=				\
diff --git a/test/zdtm/static/fds.c b/test/zdtm/static/fds.c
new file mode 100644
index 0000000..c31e293
--- /dev/null
+++ b/test/zdtm/static/fds.c
@@ -0,0 +1,43 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+
+#include "zdtmtst.h"
+
+const char *test_doc	= "Use non-default limit for file descriptors";
+const char *test_author	= "Andrew Vagin <avagin at parallels.com>";
+
+int main(int argc, char **argv)
+{
+	struct rlimit rlim = {102400, 102400};
+	int i;
+
+	test_init(argc, argv);
+
+	setrlimit(RLIMIT_NOFILE, &rlim);
+
+	for (i = 0; i < 2048; i++) {
+		if (dup(0) == -1) {
+			pr_perror("dup");
+			return 1;
+		}
+	}
+
+	for (i = 0; i < 2048; i++)
+		fcntl(i, F_SETFD, i % 3 ? FD_CLOEXEC : 0);
+
+	test_daemon();
+	test_waitsig();
+
+	for (i = 0; i < 2048; i++)
+		if (fcntl(i, F_GETFD) != (i % 3 ? FD_CLOEXEC : 0)) {
+			fail();
+			return 1;
+		}
+
+	pass();
+
+	return 0;
+}
diff --git a/test/zdtm/static/fds.desc b/test/zdtm/static/fds.desc
new file mode 100644
index 0000000..2eac7e6
--- /dev/null
+++ b/test/zdtm/static/fds.desc
@@ -0,0 +1 @@
+{'flags': 'suid'}
-- 
2.5.0



More information about the CRIU mailing list