diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile index 7627828ef..16ea0f042 100644 --- a/test/zdtm/static/Makefile +++ b/test/zdtm/static/Makefile @@ -28,6 +28,7 @@ TST_NOFILE := \ socket_listen6 \ socket_listen4v6 \ socket_udp \ + socket_udp-corked \ socket6_udp \ socket_udp_shutdown \ sk-freebind \ diff --git a/test/zdtm/static/socket_udp-corked.c b/test/zdtm/static/socket_udp-corked.c new file mode 100644 index 000000000..30cfac5ec --- /dev/null +++ b/test/zdtm/static/socket_udp-corked.c @@ -0,0 +1,76 @@ +#include "zdtmtst.h" + +const char *test_doc = "static test for UDP socket\n"; +const char *test_author = "Pavel Emelyanov \n"; + +/* Description: + * Create two tcp socket, server send asynchronous request on + * read data and clietn write data after migration + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* for sockaddr_in and inet_ntoa() */ +#include +#include + +static int port = 8880; + +#define MSG1 "msg1" + +int main(int argc, char **argv) +{ + int ret, sk1; + socklen_t len = sizeof(struct sockaddr_in); + struct sockaddr_in addr1; + int opt; + + test_init(argc, argv); + + sk1 = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (sk1 < 0) { + pr_perror("Can't create socket"); + return 1; + } + + memset(&addr1, 0, sizeof(addr1)); + addr1.sin_family = AF_INET; + addr1.sin_addr.s_addr = inet_addr("127.0.0.1"); + addr1.sin_port = htons(port); + + ret = bind(sk1, (struct sockaddr *)&addr1, len); + if (ret < 0) { + pr_perror("Can't bind socket"); + return 1; + } + ret = connect(sk1, (struct sockaddr *)&addr1, len); + if (ret < 0) { + pr_perror("Can't connect"); + return 1; + } + + opt = 1; + if (setsockopt(sk1, SOL_UDP, UDP_CORK, &opt, sizeof(opt))) { + pr_perror("Unable to set UDP_CORK"); + return 1; + } + + if (write(sk1, MSG1, sizeof(MSG1)) != sizeof(MSG1)) { + pr_perror("write"); + return 1; + } + + test_daemon(); + test_waitsig(); + + + pass(); + return 0; +} diff --git a/test/zdtm/static/socket_udp-corked.desc b/test/zdtm/static/socket_udp-corked.desc new file mode 100644 index 000000000..ded89879a --- /dev/null +++ b/test/zdtm/static/socket_udp-corked.desc @@ -0,0 +1 @@ +{'flags': 'crfail'}