[CRIU] [PATCH] zdtm: check one end of socketpair with data
Andrey Vagin
avagin at openvz.org
Wed Jul 29 13:06:37 PDT 2015
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
test/zdtm.sh | 1 +
test/zdtm/live/static/Makefile | 1 +
test/zdtm/live/static/socket_close_data.c | 43 +++++++++++++++++++++++++++++++
3 files changed, 45 insertions(+)
create mode 100644 test/zdtm/live/static/socket_close_data.c
diff --git a/test/zdtm.sh b/test/zdtm.sh
index 130ef01..e57fb70 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -88,6 +88,7 @@ generate_test_list()
static/sock_filter
static/socket6_udp
static/socket_udplite
+ static/socket_close_data
static/selfexe00
static/link10
static/unlink_fstat00
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index fe636d6..7575f7d 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -33,6 +33,7 @@ TST_NOFILE = \
socket6_udp \
socket_udplite \
socket_aio \
+ socket_close_data \
packet_sock \
packet_sock_mmap \
sock_filter \
diff --git a/test/zdtm/live/static/socket_close_data.c b/test/zdtm/live/static/socket_close_data.c
new file mode 100644
index 0000000..e8aeb45
--- /dev/null
+++ b/test/zdtm/live/static/socket_close_data.c
@@ -0,0 +1,43 @@
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Check one end of socketpair with data";
+const char *test_author = "Andrew Vagin <avagin at openvz.org";
+
+#define MSG "hello"
+int main(int argc, char **argv)
+{
+ int sks[2], ret;
+ char buf[1024];
+
+ test_init(argc, argv);
+
+ if (socketpair(PF_UNIX, SOCK_DGRAM, 0, sks) < 0) {
+ err("socketpair");
+ return 1;
+ }
+
+ if (write(sks[1], MSG, sizeof(MSG)) != sizeof(MSG)) {
+ err("write");
+ return 1;
+ }
+ close(sks[1]);
+
+ test_daemon();
+ test_waitsig();
+
+ ret = read(sks[0], buf, sizeof(MSG));
+ buf[ret > 0 ? ret : 0] = 0;
+ if (ret != sizeof(MSG)) {
+ fail("%d: %s", ret, buf);
+ return 1;
+ }
+
+ pass();
+ return 0;
+}
--
2.1.0
More information about the CRIU
mailing list