summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorEyal Soha <eyalsoha@google.com>2020-02-05 17:56:00 -0800
committergVisor bot <gvisor-bot@google.com>2020-02-05 17:56:42 -0800
commitf3d95607036b8a502c65aa7b3e8145227274dbbc (patch)
treef077cba6b93e226535d0bb87567af9915651801e /test
parentf2d3efca1deded31a2929ea77c0eecf476764660 (diff)
recv() on a closed TCP socket returns ENOTCONN
From RFC 793 s3.9 p58 Event Processing: If RECEIVE Call arrives in CLOSED state and the user has access to such a connection, the return should be "error: connection does not exist" Fixes #1598 PiperOrigin-RevId: 293494287
Diffstat (limited to 'test')
-rw-r--r--test/syscalls/linux/tcp_socket.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/syscalls/linux/tcp_socket.cc b/test/syscalls/linux/tcp_socket.cc
index 525ccbd88..8a8b68e75 100644
--- a/test/syscalls/linux/tcp_socket.cc
+++ b/test/syscalls/linux/tcp_socket.cc
@@ -1339,6 +1339,15 @@ TEST_P(SimpleTcpSocketTest, SetTCPDeferAcceptGreaterThanZero) {
EXPECT_EQ(get, kTCPDeferAccept);
}
+TEST_P(SimpleTcpSocketTest, RecvOnClosedSocket) {
+ auto s =
+ ASSERT_NO_ERRNO_AND_VALUE(Socket(GetParam(), SOCK_STREAM, IPPROTO_TCP));
+ char buf[1];
+ EXPECT_THAT(recv(s.get(), buf, 0, 0), SyscallFailsWithErrno(ENOTCONN));
+ EXPECT_THAT(recv(s.get(), buf, sizeof(buf), 0),
+ SyscallFailsWithErrno(ENOTCONN));
+}
+
INSTANTIATE_TEST_SUITE_P(AllInetTests, SimpleTcpSocketTest,
::testing::Values(AF_INET, AF_INET6));