From abf6b15c14a84f141e04a4344cf37b38e91c352a Mon Sep 17 00:00:00 2001 From: Bui Quang Minh Date: Mon, 20 Sep 2021 20:57:03 +0700 Subject: [PATCH] zdtm: Dumping/restoring with --tcp-close on TCP_CLOSE socket Signed-off-by: Bui Quang Minh --- test/zdtm/static/Makefile | 1 + test/zdtm/static/socket-tcp-close2.c | 67 +++++++++++++++++++++++++ test/zdtm/static/socket-tcp-close2.desc | 1 + 3 files changed, 69 insertions(+) create mode 100644 test/zdtm/static/socket-tcp-close2.c create mode 100644 test/zdtm/static/socket-tcp-close2.desc diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile index c9e6589f0..b6aa621c7 100644 --- a/test/zdtm/static/Makefile +++ b/test/zdtm/static/Makefile @@ -107,6 +107,7 @@ TST_NOFILE := \ socket-tcp4v6-closed \ socket-tcp-close0 \ socket-tcp-close1 \ + socket-tcp-close2 \ socket-dump-tcp-close \ socket-tcp-unconn \ socket-tcp6-unconn \ diff --git a/test/zdtm/static/socket-tcp-close2.c b/test/zdtm/static/socket-tcp-close2.c new file mode 100644 index 000000000..697c99f39 --- /dev/null +++ b/test/zdtm/static/socket-tcp-close2.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include + +#include "zdtmtst.h" + +const char *test_doc = "Check both dump and restore with tcp_close on TCP_CLOSE sockets"; +const char *test_author = "Bui Quang Minh "; + +static int port = 8880; + +int main(int argc, char **argv) +{ + int fd_s, fd, client; + char c; + + test_init(argc, argv); + signal(SIGPIPE, SIG_IGN); + + fd_s = tcp_init_server(AF_INET, &port); + if (fd_s < 0) { + pr_err("Server initializations failed\n"); + return 1; + } + + client = tcp_init_client(AF_INET, "localhost", port); + if (client < 0) { + pr_err("Client initializations failed\n"); + return 1; + } + + fd = tcp_accept_server(fd_s); + if (fd < 0) { + pr_err("Can't accept client\n"); + return 1; + } + close(fd_s); + + shutdown(client, SHUT_WR); + shutdown(fd, SHUT_WR); + + test_daemon(); + test_waitsig(); + + if (read(fd, &c, 1) != 0) { + fail("read server"); + return 1; + } + if (read(client, &c, 1) != 0) { + fail("read client"); + return 1; + } + if (write(client, &c, 1) != -1) { + fail("write client"); + return 1; + } + if (write(fd, &c, 1) != -1) { + fail("write server"); + return 1; + } + + pass(); + return 0; +} diff --git a/test/zdtm/static/socket-tcp-close2.desc b/test/zdtm/static/socket-tcp-close2.desc new file mode 100644 index 000000000..c53a1f315 --- /dev/null +++ b/test/zdtm/static/socket-tcp-close2.desc @@ -0,0 +1 @@ +{'opts': '--tcp-close', 'flags': 'reqrst '}