From 1da44415982f76b618cd76b8a684fb5802d0d426 Mon Sep 17 00:00:00 2001 From: Andrey Vagin Date: Mon, 17 Sep 2012 18:23:46 +0400 Subject: [PATCH] zdtm: add a stream test case for TCP connections Signed-off-by: Andrey Vagin Signed-off-by: Pavel Emelyanov --- 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 deletion(-) 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 b9a2d33de..747e9f03b 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 #include #include +#include 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 e62ee75a9..b9a9f847f 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 000000000..772a5dd6e --- /dev/null +++ b/test/zdtm/live/streaming/socket-tcp.c @@ -0,0 +1 @@ +../static/socket-tcp.c \ No newline at end of file