Commit 00468aa8 authored by Pavel Emelyanov's avatar Pavel Emelyanov

zdtm: Test descriptor sent over unix and kept open

Reviewed-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent f084b246
......@@ -154,6 +154,7 @@ TST_NOFILE := \
remap_dead_pid \
remap_dead_pid_root \
scm00 \
scm01 \
aio00 \
aio01 \
fd \
......@@ -439,6 +440,7 @@ socket-tcp-closed-last-ack: CFLAGS += -D ZDTM_TCP_LAST_ACK
mnt_ext_manual: CFLAGS += -D ZDTM_EXTMAP_MANUAL
sigpending: LDLIBS += -lrt
vdso01: LDLIBS += -lrt
scm01: CFLAGS += -DKEEP_SENT_FD
mntns_link_remap: CFLAGS += -DZDTM_LINK_REMAP
mntns_shared_bind02: CFLAGS += -DSHARED_BIND02
mntns_root_bind02: CFLAGS += -DROOT_BIND02
......
......@@ -68,7 +68,7 @@ static int recv_fd(int via)
int main(int argc, char **argv)
{
int sk[2], p[2];
int sk[2], p[2], rfd;
#define MSG "HELLO"
char buf[8]; /* bigger than the MSG to check boundaries */
......@@ -89,6 +89,7 @@ int main(int argc, char **argv)
exit(1);
}
#ifndef KEEP_SENT_FD
close(p[0]);
/* Swap pipe ends to make scm recv put pipe into different place */
......@@ -96,22 +97,29 @@ int main(int argc, char **argv)
close(p[1]);
p[1] = p[0];
p[0] = -1;
#endif
test_daemon();
test_waitsig();
p[0] = recv_fd(sk[1]);
if (p[0] < 0) {
rfd = recv_fd(sk[1]);
if (rfd < 0) {
fail("Can't recv pipe back (%d)", p[0]);
goto out;
}
#ifdef KEEP_SENT_FD
if (rfd == p[0]) {
fail("Original descriptor not kept");
goto out;
}
again:
#endif
if (write(p[1], MSG, sizeof(MSG)) != sizeof(MSG)) {
fail("Pipe write-broken");
goto out;
}
if (read(p[0], buf, sizeof(buf)) != sizeof(MSG)) {
if (read(rfd, buf, sizeof(buf)) != sizeof(MSG)) {
fail("Pipe read-broken");
goto out;
}
......@@ -122,6 +130,14 @@ int main(int argc, char **argv)
goto out;
}
#ifdef KEEP_SENT_FD
if (rfd != p[0]) {
test_msg("Check kept\n");
rfd = p[0];
goto again;
}
#endif
pass();
out:
return 0;
......
scm00.c
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment