Skip to content

Commit

Permalink
Cherry pick PR #3123: enable errno tests for posix socket rev and send (
Browse files Browse the repository at this point in the history
#3400)

Refer to the original PR: #3123

b/321999529

Test-On-Device: true

Co-authored-by: Hao <[email protected]>
  • Loading branch information
1 parent 7d99be1 commit 92ded59
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
23 changes: 13 additions & 10 deletions starboard/nplb/posix_compliance/posix_socket_send_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -109,8 +110,11 @@ 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);
Expand Down Expand Up @@ -143,9 +147,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;
}

Expand Down Expand Up @@ -195,9 +199,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;
}
Expand Down
23 changes: 13 additions & 10 deletions starboard/nplb/posix_compliance/posix_socket_sendto_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -112,8 +113,11 @@ 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);
Expand Down Expand Up @@ -146,9 +150,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;
}

Expand Down Expand Up @@ -194,9 +198,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;
}
Expand Down

0 comments on commit 92ded59

Please sign in to comment.