From cdca0fba3a4510d2933a484ba76f964e391fa10f Mon Sep 17 00:00:00 2001 From: Hao Zheng Date: Tue, 30 Apr 2024 17:53:43 -0700 Subject: [PATCH] enable errno tests for posix socket rev and send b/321999529 --- .../posix_socket_receive_test.cc | 6 ++--- .../posix_socket_recvfrom_test.cc | 6 ++--- .../posix_socket_send_test.cc | 22 ++++++++++--------- .../posix_socket_sendto_test.cc | 22 ++++++++++--------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/starboard/nplb/posix_compliance/posix_socket_receive_test.cc b/starboard/nplb/posix_compliance/posix_socket_receive_test.cc index 9ca368c31bb8..f8480612cb87 100644 --- a/starboard/nplb/posix_compliance/posix_socket_receive_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_receive_test.cc @@ -37,8 +37,7 @@ int Transfer(int receive_socket_fd, size - send_total, kSendFlags); if (bytes_sent < 0) { if (errno != EINPROGRESS) { - // TODO: b/321999529, need errno - // return -1; + return -1; } bytes_sent = 0; } @@ -51,8 +50,7 @@ int Transfer(int receive_socket_fd, if (bytes_received < 0) { if (errno != EINPROGRESS) { - // TODO: b/321999529, need errno - // return -1; + return -1; } bytes_received = 0; } diff --git a/starboard/nplb/posix_compliance/posix_socket_recvfrom_test.cc b/starboard/nplb/posix_compliance/posix_socket_recvfrom_test.cc index c14192951e53..eb4f1be4fc5a 100644 --- a/starboard/nplb/posix_compliance/posix_socket_recvfrom_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_recvfrom_test.cc @@ -37,8 +37,7 @@ int Transfer(int receive_socket_fd, size - send_total, kSendFlags, NULL, 0); if (bytes_sent < 0) { if (errno != EINPROGRESS) { - // TODO: b/321999529, need errno - // return -1; + return -1; } bytes_sent = 0; } @@ -51,8 +50,7 @@ int Transfer(int receive_socket_fd, if (bytes_received < 0) { if (errno != EINPROGRESS) { - // TODO: b/321999529, need errno - // return -1; + return -1; } bytes_received = 0; } diff --git a/starboard/nplb/posix_compliance/posix_socket_send_test.cc b/starboard/nplb/posix_compliance/posix_socket_send_test.cc index 668fbd239832..c86a326bb019 100644 --- a/starboard/nplb/posix_compliance/posix_socket_send_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_send_test.cc @@ -76,8 +76,9 @@ TEST(PosixSocketSendTest, RainyDayUnconnectedSocket) { ssize_t bytes_written = send(socket_fd, buf, sizeof(buf), kSendFlags); EXPECT_FALSE(bytes_written >= 0); - // TODO: check errno: EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || - // errno == EPIPE); + EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || errno == EPIPE || + errno == ENOTCONN); + SB_DLOG(INFO) << "Failed to send, errno = " << errno; EXPECT_TRUE(close(socket_fd) == 0); } @@ -109,8 +110,10 @@ TEST(PosixSocketSendTest, RainyDaySendToClosedSocket) { void* thread_result; EXPECT_TRUE(pthread_join(send_thread, &thread_result) == 0); - // TODO: errno: EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || errno - // == EPIPE); + EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || errno == EPIPE || + errno == ENOTCONN // errno on Windows + || errno == EINPROGRESS // errno on Evergreen); + SB_DLOG(INFO) << "Failed to send, errno = " << errno; // Clean up the server socket. EXPECT_TRUE(close(server_socket_fd) == 0); @@ -143,9 +146,9 @@ TEST(PosixSocketSendTest, RainyDaySendToSocketUntilBlocking) { if (result < 0) { // If we didn't get a socket, it should be pending. - // TODO: export errno - // EXPECT_TRUE(errno == EINPROGRESS || errno == EAGAIN || errno == - // EWOULDBLOCK); + EXPECT_TRUE(errno == EINPROGRESS || errno == EAGAIN || + errno == EWOULDBLOCK); + SB_DLOG(INFO) << "Failed to send, errno = " << errno; break; } @@ -195,9 +198,8 @@ TEST(PosixSocketSendTest, RainyDaySendToSocketConnectionReset) { result = send(client_socket_fd, buff, sizeof(buff), kSendFlags); if (result < 0) { - // TODO: errno: - // EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || errno == - // EPIPE); + EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || errno == EPIPE || + errno == ECONNABORTED); SB_DLOG(INFO) << "Failed to send, errno = " << errno; break; } diff --git a/starboard/nplb/posix_compliance/posix_socket_sendto_test.cc b/starboard/nplb/posix_compliance/posix_socket_sendto_test.cc index 5405e5e0e281..376acce46bad 100644 --- a/starboard/nplb/posix_compliance/posix_socket_sendto_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_sendto_test.cc @@ -79,8 +79,9 @@ TEST(PosixSocketSendtoTest, RainyDayUnconnectedSocket) { sendto(socket_fd, buf, sizeof(buf), kSendFlags, NULL, 0); EXPECT_FALSE(bytes_written >= 0); - // TODO: check errno: EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || - // errno == EPIPE); + EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || errno == EPIPE || + errno == ENOTCONN); + SB_DLOG(INFO) << "Failed to send, errno = " << errno; EXPECT_TRUE(close(socket_fd) == 0); } @@ -112,8 +113,10 @@ TEST(PosixSocketSendtoTest, RainyDaySendToClosedSocket) { void* thread_result; EXPECT_TRUE(pthread_join(send_thread, &thread_result) == 0); - // TODO: errno: EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || errno - // == EPIPE); + EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || errno == EPIPE || + errno == ENOTCONN // errno on Windows + || errno == EINPROGRESS // errno on Evergreen); + SB_DLOG(INFO) << "Failed to send, errno = " << errno; // Clean up the server socket. EXPECT_TRUE(close(server_socket_fd) == 0); @@ -146,9 +149,9 @@ TEST(PosixSocketSendtoTest, RainyDaySendToSocketUntilBlocking) { if (result < 0) { // If we didn't get a socket, it should be pending. - // TODO: export errno - // EXPECT_TRUE(errno == EINPROGRESS || errno == EAGAIN || errno == - // EWOULDBLOCK); + EXPECT_TRUE(errno == EINPROGRESS || errno == EAGAIN || + errno == EWOULDBLOCK); + SB_DLOG(INFO) << "Failed to send, errno = " << errno; break; } @@ -194,9 +197,8 @@ TEST(PosixSocketSendtoTest, RainyDaySendToSocketConnectionReset) { result = sendto(client_socket_fd, buff, sizeof(buff), kSendFlags, NULL, 0); if (result < 0) { - // TODO: errno: - // EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || errno == - // EPIPE); + EXPECT_TRUE(errno == ECONNRESET || errno == ENETRESET || errno == EPIPE || + errno == ECONNABORTED); SB_DLOG(INFO) << "Failed to send, errno = " << errno; break; }