Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable errno tests for posix socket rev and send #3123

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading