[CRIU] [PATCH 2/3] zdtm: Add sockets01 test case
Cyrill Gorcunov
gorcunov at openvz.org
Thu May 31 03:38:29 EDT 2012
Code to test socketpair (extracted from
previous sockets00 test case).
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
test/zdtm.sh | 1 +
test/zdtm/live/static/Makefile | 1 +
test/zdtm/live/static/sockets01.c | 58 +++++++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 0 deletions(-)
create mode 100644 test/zdtm/live/static/sockets01.c
diff --git a/test/zdtm.sh b/test/zdtm.sh
index bf408d4..86834b1 100644
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -28,6 +28,7 @@ transition/file_read
transition/fork
static/zombie00
static/sockets00
+static/sockets01
static/socket_queues
static/pid00
static/pstree
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index 17a6e79..ce02438 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -35,6 +35,7 @@ TST_NOFILE = \
utsname \
pstree \
sockets00 \
+ sockets01 \
socket_queues \
ipc_namespace \
selfexe00 \
diff --git a/test/zdtm/live/static/sockets01.c b/test/zdtm/live/static/sockets01.c
new file mode 100644
index 0000000..f2c916f
--- /dev/null
+++ b/test/zdtm/live/static/sockets01.c
@@ -0,0 +1,58 @@
+#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 "zdtmtst.h"
+
+const char *test_doc = "Test unix stream socketpair\n";
+const char *test_author = "Cyrill Gorcunov <gorcunov at openvz.org";
+
+#define SK_DATA "packet"
+
+int main(int argc, char *argv[])
+{
+ int ssk_pair[2];
+ char buf[64];
+
+ test_init(argc, argv);
+
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, ssk_pair) == -1) {
+ fail("socketpair\n");
+ exit(1);
+ }
+
+ memset(buf, 0, sizeof(buf));
+ write(ssk_pair[0], SK_DATA, sizeof(SK_DATA));
+ read(ssk_pair[1], &buf, sizeof(buf));
+ if (strcmp(buf, SK_DATA)) {
+ fail("data corrupted\n");
+ exit(1);
+ }
+ test_msg("stream : '%s'\n", buf);
+
+ test_daemon();
+ test_waitsig();
+
+ memset(buf, 0, sizeof(buf));
+ write(ssk_pair[0], SK_DATA, sizeof(SK_DATA));
+ read(ssk_pair[1], &buf, sizeof(buf));
+ if (strcmp(buf, SK_DATA)) {
+ fail("data corrupted\n");
+ exit(1);
+ }
+ test_msg("stream : '%s'\n", buf);
+
+ pass();
+ return 0;
+}
--
1.7.7.6
More information about the CRIU
mailing list