From 8897a0fb2598ccf59164c35dfcf9bb89b118c550 Mon Sep 17 00:00:00 2001 From: Pavel Tikhomirov Date: Wed, 14 Dec 2022 14:51:02 +0300 Subject: [PATCH] zdtm: add scm10 test for scm sent unix sk with closed sender Signed-off-by: Pavel Tikhomirov (cherry picked from commit a9b546c74f6c1e817b0790bd9621cc137bb719f3) Signed-off-by: Ahmed Elaidy Reviewed-by: Alexander Mikhalitsyn --- test/zdtm/static/Makefile | 2 ++ test/zdtm/static/scm07.c | 13 +++++++++++-- test/zdtm/static/scm10.c | 1 + test/zdtm/static/scm10.desc | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) create mode 120000 test/zdtm/static/scm10.c create mode 120000 test/zdtm/static/scm10.desc diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile index 82eeec415..39326c729 100644 --- a/test/zdtm/static/Makefile +++ b/test/zdtm/static/Makefile @@ -234,6 +234,7 @@ TST_NOFILE := \ scm07 \ scm08 \ scm09 \ + scm10 \ aio00 \ aio01 \ fd \ @@ -677,6 +678,7 @@ scm02: CFLAGS += -DSEND_BOTH scm04: CFLAGS += -DSEPARATE scm08: CFLAGS += -DSEND_ANOTHER_FD scm09: CFLAGS += -DCLOSE_SENDER_FD +scm10: CFLAGS += -DCLOSE_SENDER_FD mntns_link_remap: CFLAGS += -DZDTM_LINK_REMAP mntns_shared_bind02: CFLAGS += -DSHARED_BIND02 mntns_root_bind02: CFLAGS += -DROOT_BIND02 diff --git a/test/zdtm/static/scm07.c b/test/zdtm/static/scm07.c index e2c0fab66..a96f0509d 100644 --- a/test/zdtm/static/scm07.c +++ b/test/zdtm/static/scm07.c @@ -108,12 +108,14 @@ next_msg: return fdp ? *fdp : -4; } +#define MSG "HELLO" + int main(int argc, char **argv) { int sk[2] = { -1, -1 }, p[2] = { -1, -1 }, rfd, ret = 1; - -#define MSG "HELLO" +#ifndef CLOSE_SENDER_FD char buf[8]; /* bigger than the MSG to check boundaries */ +#endif test_init(argc, argv); @@ -174,6 +176,11 @@ int main(int argc, char **argv) /* we sent this side of socketpair */ close(p[1]); +#ifdef CLOSE_SENDER_FD + close(p[0]); + p[0] = -1; +#endif + test_daemon(); test_waitsig(); @@ -183,6 +190,7 @@ int main(int argc, char **argv) goto out; } +#ifndef CLOSE_SENDER_FD if (write(p[0], MSG, sizeof(MSG)) != sizeof(MSG)) { fail("Socket write-broken"); goto out; @@ -198,6 +206,7 @@ int main(int argc, char **argv) fail("Socket read-broken (%s)", buf); goto out; } +#endif pass(); ret = 0; diff --git a/test/zdtm/static/scm10.c b/test/zdtm/static/scm10.c new file mode 120000 index 000000000..11df4e3d7 --- /dev/null +++ b/test/zdtm/static/scm10.c @@ -0,0 +1 @@ +scm07.c \ No newline at end of file diff --git a/test/zdtm/static/scm10.desc b/test/zdtm/static/scm10.desc new file mode 120000 index 000000000..6e2a849cf --- /dev/null +++ b/test/zdtm/static/scm10.desc @@ -0,0 +1 @@ +scm07.desc \ No newline at end of file