[CRIU] [PATCH]v2 zdtm: test semi-closed unix stream connection for data loss
Ruslan Kuprieiev
kupruser at gmail.com
Mon Aug 26 13:27:27 EDT 2013
Hi!
Added test for data loss in semi-closed stream unix connection.
-------------- next part --------------
Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index f76e61b..68c147e 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -48,6 +48,7 @@ TST_NOFILE = \
pstree \
sockets01 \
sockets02 \
+ sockets03 \
sockets_spair \
socket_queues \
socket_queues02 \
diff --git a/test/zdtm/live/static/sockets03.c b/test/zdtm/live/static/sockets03.c
new file mode 100644
index 0000000..82d67db
--- /dev/null
+++ b/test/zdtm/live/static/sockets03.c
@@ -0,0 +1,52 @@
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <sys/un.h>
+#include <sys/stat.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <time.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Test semi-closed unix stream connection "
+ "for data loss\n";
+const char *test_author = "Ruslan Kuprieiev <kupruser at gmail.com>\n";
+
+int main(int argc, char *argv[])
+{
+ int ssk_pair[2], ret;
+ char wdata, rdata;
+
+ srandom(time(NULL));
+ wdata = (char)random();
+
+ test_init(argc, argv);
+
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, ssk_pair) == -1) {
+ fail("socketpair\n");
+ exit(1);
+ }
+
+ write(ssk_pair[1], &wdata, sizeof(wdata));
+ close(ssk_pair[1]);
+
+ test_daemon();
+ test_waitsig();
+
+ ret = read(ssk_pair[0], &rdata, sizeof(rdata));
+ if (rdata != wdata || ret != sizeof(rdata)) {
+ fail("Data loss (write %d/read %d)", wdata, rdata);
+ return 0;
+ }
+
+ pass();
+ return 0;
+}
More information about the CRIU
mailing list