diff options
author | Gleb Smirnoff <glebius@FreeBSD.org> | 2024-02-28 22:32:47 +0000 |
---|---|---|
committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2024-02-28 22:32:47 +0000 |
commit | 253d8a1f8a247fc363ab6bad6ed0fa9c7cc25060 (patch) | |
tree | 0465c3599b3c3fe712d35441c7a2c8532d045666 | |
parent | 3bc122d27064957911570c1037e6b644b7303c17 (diff) | |
download | src-253d8a1f8a247fc363ab6bad6ed0fa9c7cc25060.tar.gz src-253d8a1f8a247fc363ab6bad6ed0fa9c7cc25060.zip |
tests/unix_seqpacket: test that implied connect doesn't work
Applies both to SOCK_STREAM and SOCK_SEQPACKET. Put the test in this file
as it is most advanced one.
Reviewed by: tuexen
Differential Revision: https://reviews.freebsd.org/D43854
-rw-r--r-- | tests/sys/kern/unix_seqpacket_test.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/sys/kern/unix_seqpacket_test.c b/tests/sys/kern/unix_seqpacket_test.c index cde427401970..e93bdfe7e0b1 100644 --- a/tests/sys/kern/unix_seqpacket_test.c +++ b/tests/sys/kern/unix_seqpacket_test.c @@ -527,6 +527,23 @@ ATF_TC_BODY(send_before_accept, tc) close(a); } +/* Implied connect is unix/dgram only feature. Fails on stream or seqpacket. */ +ATF_TC_WITHOUT_HEAD(implied_connect); +ATF_TC_BODY(implied_connect, tc) +{ + const struct sockaddr_un *sun; + int l, s; + + sun = mk_listening_socket(&l); + + ATF_REQUIRE((s = socket(PF_LOCAL, SOCK_SEQPACKET, 0)) > 0); + ATF_REQUIRE(sendto(s, &s, sizeof(s), 0, (struct sockaddr *)sun, + sizeof(*sun)) == -1); + ATF_REQUIRE(errno == ENOTCONN); + close(l); + close(s); +} + /* accept(2) can receive a connection */ ATF_TC_WITHOUT_HEAD(accept); ATF_TC_BODY(accept, tc) @@ -1099,6 +1116,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, send_recv_with_connect); ATF_TP_ADD_TC(tp, sendto_recvfrom); ATF_TP_ADD_TC(tp, send_before_accept); + ATF_TP_ADD_TC(tp, implied_connect); ATF_TP_ADD_TC(tp, shutdown_send); ATF_TP_ADD_TC(tp, shutdown_send_sigpipe); ATF_TP_ADD_TC(tp, eagain_8k_8k); |