[CRIU] [PATCH 3/4] zdtm: add a test with a lot of file descriptors (v2)
Andrey Vagin
avagin at openvz.org
Tue Apr 5 12:29:39 PDT 2016
From: Andrew Vagin <avagin at virtuozzo.com>
v2: increase a file limit
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
test/zdtm.py | 1 +
test/zdtm/static/Makefile | 1 +
test/zdtm/static/fds.c | 43 +++++++++++++++++++++++++++++++++++++++++++
test/zdtm/static/fds.desc | 1 +
4 files changed, 46 insertions(+)
create mode 100644 test/zdtm/static/fds.c
create mode 100644 test/zdtm/static/fds.desc
diff --git a/test/zdtm.py b/test/zdtm.py
index 082d201..e766afd 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -20,6 +20,7 @@ import fcntl
import errno
import datetime
import yaml
+import resource
os.chdir(os.path.dirname(os.path.abspath(__file__)))
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..abb8c90
--- /dev/null
+++ b/test/zdtm/static/fds.desc
@@ -0,0 +1 @@
+{'flags': 'suid', "init" : resource.setrlimit(resource.RLIMIT_NOFILE, (10240, 10240))}
--
2.5.0
More information about the CRIU
mailing list