zdtm: add a stream test case for TCP connections

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrey Vagin 2012-09-17 18:23:46 +04:00 committed by Pavel Emelyanov
parent 06282f407c
commit 1da4441598
3 changed files with 39 additions and 1 deletions

View file

@ -9,6 +9,7 @@ const char *test_author = "Andrey Vagin <avagin@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;
}

View file

@ -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)

View file

@ -0,0 +1 @@
../static/socket-tcp.c