From 0752ab653e3fe94f24894c095ca5ea82191b03be Mon Sep 17 00:00:00 2001 From: Kevin Krakauer Date: Thu, 21 Nov 2024 11:51:54 -0800 Subject: [PATCH] testing: increase some timeouts in packet tests These are unnecessarily short, and can cause flakes. Startblock: cl/698155239 is submitted PiperOrigin-RevId: 698863623 --- test/syscalls/linux/packet_socket_dgram.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/test/syscalls/linux/packet_socket_dgram.cc b/test/syscalls/linux/packet_socket_dgram.cc index 19a9e395f..7ef377349 100644 --- a/test/syscalls/linux/packet_socket_dgram.cc +++ b/test/syscalls/linux/packet_socket_dgram.cc @@ -69,6 +69,7 @@ using ::testing::Eq; constexpr char kMessage[] = "soweoneul malhaebwa"; constexpr in_port_t kPort = 0x409c; // htons(40000) +constexpr int kTimeoutMS = 60 * 1000; // // "Cooked" tests. Cooked AF_PACKET sockets do not contain link layer @@ -107,7 +108,8 @@ TEST(BasicCookedPacketTest, WrongType) { struct pollfd pfd = {}; pfd.fd = sock.get(); pfd.events = POLLIN; - EXPECT_THAT(RetryEINTR(poll)(&pfd, 1, 1000), SyscallSucceedsWithValue(0)); + EXPECT_THAT(RetryEINTR(poll)(&pfd, 1, kTimeoutMS), + SyscallSucceedsWithValue(0)); } // Tests for "cooked" (SOCK_DGRAM) packet(7) sockets. @@ -171,7 +173,8 @@ void ReceiveMessage(int sock, int ifindex) { struct pollfd pfd = {}; pfd.fd = sock; pfd.events = POLLIN; - EXPECT_THAT(RetryEINTR(poll)(&pfd, 1, 2000), SyscallSucceedsWithValue(1)); + EXPECT_THAT(RetryEINTR(poll)(&pfd, 1, kTimeoutMS), + SyscallSucceedsWithValue(1)); // Read and verify the data. constexpr size_t packet_size = @@ -300,10 +303,12 @@ TEST_P(CookedPacketTest, Send) { struct pollfd pfd = {}; pfd.fd = udp_sock.get(); pfd.events = POLLIN; - ASSERT_THAT(RetryEINTR(poll)(&pfd, 1, 5000), SyscallSucceedsWithValue(1)); + ASSERT_THAT(RetryEINTR(poll)(&pfd, 1, kTimeoutMS), + SyscallSucceedsWithValue(1)); pfd.fd = socket_; pfd.events = POLLIN; - ASSERT_THAT(RetryEINTR(poll)(&pfd, 1, 5000), SyscallSucceedsWithValue(1)); + ASSERT_THAT(RetryEINTR(poll)(&pfd, 1, kTimeoutMS), + SyscallSucceedsWithValue(1)); // Receive on the packet socket. char recv_buf[sizeof(send_buf)]; @@ -418,7 +423,8 @@ TEST_P(CookedPacketTest, BindDrop) { struct pollfd pfd = {}; pfd.fd = socket_; pfd.events = POLLIN; - EXPECT_THAT(RetryEINTR(poll)(&pfd, 1, 1000), SyscallSucceedsWithValue(0)); + EXPECT_THAT(RetryEINTR(poll)(&pfd, 1, kTimeoutMS), + SyscallSucceedsWithValue(0)); } // Verify that we receive outbound packets. This test requires at least one @@ -488,7 +494,8 @@ TEST_P(CookedPacketTest, ReceiveOutbound) { struct pollfd pfd = {}; pfd.fd = socket_; pfd.events = POLLIN; - EXPECT_THAT(RetryEINTR(poll)(&pfd, 1, 1000), SyscallSucceedsWithValue(1)); + EXPECT_THAT(RetryEINTR(poll)(&pfd, 1, kTimeoutMS), + SyscallSucceedsWithValue(1)); // Now read and check that the packet is the one we just sent. // Read and verify the data.