summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorZach Koopmans <zkoopmans@google.com>2020-08-17 14:01:38 -0700
committergVisor bot <gvisor-bot@google.com>2020-08-17 14:04:20 -0700
commit988ab27058829fd2ccb550560a7651511d7b872a (patch)
treec2c2794965ddbef70530f89cefc8476e4633f9a5 /test
parente3e1b36896750e9c4d07ecb6eaf1a738b08cd876 (diff)
Fix AllSocketPairTest for open source.
Setting timeouts for sockets on GCP images (debian) for usecs only respects multiples of 4K. Set the test with a multiple of 4K with a comment. PiperOrigin-RevId: 327093848
Diffstat (limited to 'test')
-rw-r--r--test/syscalls/linux/socket_generic.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/test/syscalls/linux/socket_generic.cc b/test/syscalls/linux/socket_generic.cc
index f7d6139f1..a6182f0ac 100644
--- a/test/syscalls/linux/socket_generic.cc
+++ b/test/syscalls/linux/socket_generic.cc
@@ -462,6 +462,7 @@ TEST_P(AllSocketPairTest, SendTimeoutDefault) {
TEST_P(AllSocketPairTest, SetGetSendTimeout) {
auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair());
+ // tv_usec should be a multiple of 4000 to work on most systems.
timeval tv = {.tv_sec = 89, .tv_usec = 42000};
EXPECT_THAT(
setsockopt(sockets->first_fd(), SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)),
@@ -472,8 +473,8 @@ TEST_P(AllSocketPairTest, SetGetSendTimeout) {
EXPECT_THAT(getsockopt(sockets->first_fd(), SOL_SOCKET, SO_SNDTIMEO,
&actual_tv, &len),
SyscallSucceeds());
- EXPECT_EQ(actual_tv.tv_sec, 89);
- EXPECT_EQ(actual_tv.tv_usec, 42000);
+ EXPECT_EQ(actual_tv.tv_sec, tv.tv_sec);
+ EXPECT_EQ(actual_tv.tv_usec, tv.tv_usec);
}
TEST_P(AllSocketPairTest, SetGetSendTimeoutLargerArg) {
@@ -484,8 +485,9 @@ TEST_P(AllSocketPairTest, SetGetSendTimeoutLargerArg) {
int64_t extra_data;
} ABSL_ATTRIBUTE_PACKED;
+ // tv_usec should be a multiple of 4000 to work on most systems.
timeval_with_extra tv_extra = {
- .tv = {.tv_sec = 0, .tv_usec = 123000},
+ .tv = {.tv_sec = 0, .tv_usec = 124000},
};
EXPECT_THAT(setsockopt(sockets->first_fd(), SOL_SOCKET, SO_SNDTIMEO,
@@ -497,8 +499,8 @@ TEST_P(AllSocketPairTest, SetGetSendTimeoutLargerArg) {
EXPECT_THAT(getsockopt(sockets->first_fd(), SOL_SOCKET, SO_SNDTIMEO,
&actual_tv, &len),
SyscallSucceeds());
- EXPECT_EQ(actual_tv.tv.tv_sec, 0);
- EXPECT_EQ(actual_tv.tv.tv_usec, 123000);
+ EXPECT_EQ(actual_tv.tv.tv_sec, tv_extra.tv.tv_sec);
+ EXPECT_EQ(actual_tv.tv.tv_usec, tv_extra.tv.tv_usec);
}
TEST_P(AllSocketPairTest, SendTimeoutAllowsWrite) {