Avoid excessive save/restore cycles in socket_ipv4_udp_unbound tests.

PiperOrigin-RevId: 338805321
This commit is contained in:
Jamie Liu
2020-10-24 00:23:52 -07:00
committed by gVisor bot
parent 0a035a1011
commit bc814b01ab
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -2435,6 +2435,7 @@ cc_library(
"@com_google_absl//absl/memory",
gtest,
"//test/util:posix_error",
"//test/util:save_util",
"//test/util:test_util",
],
alwayslink = 1,
@@ -28,6 +28,7 @@
#include "test/syscalls/linux/ip_socket_test_util.h"
#include "test/syscalls/linux/socket_test_util.h"
#include "test/util/posix_error.h"
#include "test/util/save_util.h"
#include "test/util/test_util.h"
namespace gvisor {
@@ -2108,6 +2109,9 @@ TEST_P(IPv4UDPUnboundSocketTest, ReuseAddrReusePortDistribution) {
constexpr int kMessageSize = 10;
// Saving during each iteration of the following loop is too expensive.
DisableSave ds;
for (int i = 0; i < 100; ++i) {
// Send a new message to the REUSEADDR/REUSEPORT group. We use a new socket
// each time so that a new ephemerial port will be used each time. This
@@ -2120,6 +2124,8 @@ TEST_P(IPv4UDPUnboundSocketTest, ReuseAddrReusePortDistribution) {
SyscallSucceedsWithValue(sizeof(send_buf)));
}
ds.reset();
// Check that both receivers got messages. This checks that we are using load
// balancing (REUSEPORT) instead of the most recently bound socket
// (REUSEADDR).