Skip to content

Commit

Permalink
enable errno tests for posix socket rev and send
Browse files Browse the repository at this point in the history
b/321999529
  • Loading branch information
haozheng-cobalt committed May 1, 2024
1 parent ad53292 commit cdca0fb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
6 changes: 2 additions & 4 deletions starboard/nplb/posix_compliance/posix_socket_receive_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
6 changes: 2 additions & 4 deletions starboard/nplb/posix_compliance/posix_socket_recvfrom_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
22 changes: 12 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,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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down
22 changes: 12 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,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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit cdca0fb

Please sign in to comment.