[CRIU] [PATCH 1/2] test: check a pipe with a custom size
Andrei Vagin
avagin at openvz.org
Sat Dec 2 00:05:49 MSK 2017
From: Andrei Vagin <avagin at virtuozzo.com>
CRIU doesn't handle correctly pipes with sizes which are bigger than a
default one.
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
test/zdtm/static/Makefile | 1 +
test/zdtm/static/pipe03.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
create mode 100644 test/zdtm/static/pipe03.c
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index 289edd721..7627828ef 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -205,6 +205,7 @@ TST_NOFILE := \
pidns02 \
pidns03 \
config_inotify_irmap \
+ pipe03 \
# jobctl00 \
include ../Makefile.inc
diff --git a/test/zdtm/static/pipe03.c b/test/zdtm/static/pipe03.c
new file mode 100644
index 000000000..a8721e934
--- /dev/null
+++ b/test/zdtm/static/pipe03.c
@@ -0,0 +1,54 @@
+#include <fcntl.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Check that pipes with a non-default size can be c/r-ed";
+const char *test_author = "Andrei Vagin <avagin at gmail.com>";
+
+#define DATA_SIZE (1 << 20)
+#define BUF_SIZE (4096)
+
+int main(int argc, char **argv)
+{
+ int p[2], i;
+ uint8_t buf[BUF_SIZE];
+ uint32_t crc;
+
+ test_init(argc, argv);
+
+ if (pipe2(p, O_NONBLOCK)) {
+ pr_perror("pipe");
+ return 1;
+ }
+
+ if (fcntl(p[1], F_SETPIPE_SZ, DATA_SIZE) == -1) {
+ pr_perror("Unable to change a pipe size");
+ return 1;
+ }
+
+ crc = ~0;
+ datagen(buf, BUF_SIZE, &crc);
+
+ for (i = 0; i < DATA_SIZE / BUF_SIZE; i++) {
+ if (write(p[1], buf, BUF_SIZE) != BUF_SIZE) {
+ pr_perror("write");
+ return 1;
+ }
+ }
+
+ test_daemon();
+ test_waitsig();
+
+ for (i = 0; i < DATA_SIZE / BUF_SIZE; i++) {
+ if (read(p[0], buf, BUF_SIZE) != BUF_SIZE) {
+ pr_perror("read");
+ return 1;
+ }
+ }
+
+ pass();
+ return 0;
+}
--
2.13.6
More information about the CRIU
mailing list