[CRIU] [PATCH cr 2/2] zdtm: add a stream test case for TCP
connections
Andrey Vagin
avagin at openvz.org
Mon Sep 17 05:25:20 EDT 2012
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
test/zdtm/live/static/socket-tcp.c | 37 ++++++++++++++++++++++++++++++++-
test/zdtm/live/streaming/Makefile | 2 +
test/zdtm/live/streaming/socket-tcp.c | 1 +
3 files changed, 39 insertions(+), 1 deletions(-)
create mode 120000 test/zdtm/live/streaming/socket-tcp.c
diff --git a/test/zdtm/live/static/socket-tcp.c b/test/zdtm/live/static/socket-tcp.c
index b9a2d33..747e9f0 100644
--- a/test/zdtm/live/static/socket-tcp.c
+++ b/test/zdtm/live/static/socket-tcp.c
@@ -9,6 +9,7 @@ const char *test_author = "Andrey Vagin <avagin at parallels.com";
#include <string.h>
#include <errno.h>
#include <stdlib.h>
+#include <signal.h>
static int port = 8880;
@@ -73,6 +74,22 @@ int main(int argc, char **argv)
if (fd < 0)
return 1;
+#ifdef STREAM
+ while (1) {
+ if (read_data(fd, buf, BUF_SIZE)) {
+ err("read less then have to");
+ return 1;
+ }
+ if (datachk(buf, BUF_SIZE, &crc))
+ return 2;
+
+ datagen(buf, BUF_SIZE, &crc);
+ if (write_data(fd, buf, BUF_SIZE)) {
+ err("can't write");
+ return 1;
+ }
+ }
+#else
if (read_data(fd, buf, BUF_SIZE)) {
err("read less then have to");
return 1;
@@ -85,6 +102,7 @@ int main(int argc, char **argv)
err("can't write");
return 1;
}
+#endif
return 0;
}
@@ -112,6 +130,23 @@ int main(int argc, char **argv)
}
test_daemon();
+#ifdef STREAM
+ while (test_go()) {
+ datagen(buf, BUF_SIZE, &crc);
+ if (write_data(fd, buf, BUF_SIZE)) {
+ err("can't write");
+ return 1;
+ }
+
+ if (read_data(fd, buf, BUF_SIZE)) {
+ err("read less then have to");
+ return 1;
+ }
+ if (datachk(buf, BUF_SIZE, &crc))
+ return 2;
+ }
+ kill(extpid, SIGKILL);
+#else
test_waitsig();
datagen(buf, BUF_SIZE, &crc);
@@ -126,7 +161,7 @@ int main(int argc, char **argv)
}
if (datachk(buf, BUF_SIZE, &crc))
return 2;
-
+#endif
pass();
return 0;
}
diff --git a/test/zdtm/live/streaming/Makefile b/test/zdtm/live/streaming/Makefile
index e62ee75..b9a9f84 100644
--- a/test/zdtm/live/streaming/Makefile
+++ b/test/zdtm/live/streaming/Makefile
@@ -9,6 +9,7 @@ TST_NOFILE = \
socket_loop00 \
netlink00 \
file_aio \
+ socket-tcp \
TST_FILE = \
unix_sock \
@@ -58,6 +59,7 @@ wait_stop:
$(TST): $(LIB)
file_aio: override LDLIBS += -lrt -pthread
+socket-tcp: override CFLAGS += -D STREAM
$(LIB): force
$(MAKE) -C $(LIBDIR)
diff --git a/test/zdtm/live/streaming/socket-tcp.c b/test/zdtm/live/streaming/socket-tcp.c
new file mode 120000
index 0000000..772a5dd
--- /dev/null
+++ b/test/zdtm/live/streaming/socket-tcp.c
@@ -0,0 +1 @@
+../static/socket-tcp.c
\ No newline at end of file
--
1.7.1
More information about the CRIU
mailing list