Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Beyad <abeyad@google.com>
  • Loading branch information
abeyad committed Aug 23, 2024
1 parent c7deb81 commit 792f9c0
Showing 1 changed file with 40 additions and 23 deletions.
63 changes: 40 additions & 23 deletions test/extensions/filters/udp/udp_proxy/udp_proxy_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,29 +116,46 @@ class UdpProxyFilterTest : public UdpProxyFilterBase {
EXPECT_CALL(*socket_->io_handle_, connect(_)).Times(0);
}
if (!connect_sys_errno) {
EXPECT_CALL(*socket_->io_handle_, isConnected()).WillOnce(Return(false));
EXPECT_CALL(*socket_->io_handle_, sendmsg(_, 1, 0, _, _))
.WillOnce(Invoke(
[this, data, local_ip, sys_errno](
const Buffer::RawSlice* slices, uint64_t, int,
const Network::Address::Ip* self_ip,
const Network::Address::Instance& peer_address) -> Api::IoCallUint64Result {
EXPECT_EQ(data, absl::string_view(static_cast<const char*>(slices[0].mem_),
slices[0].len_));
EXPECT_EQ(peer_address, *upstream_address_);
if (local_ip == nullptr) {
EXPECT_EQ(nullptr, self_ip);
} else {
EXPECT_EQ(self_ip->addressAsString(), local_ip->addressAsString());
}
// For suppression of clang-tidy NewDeleteLeaks rule, don't use the ternary
// operator.
if (sys_errno == 0) {
return makeNoError(data.size());
} else {
return makeError(sys_errno);
}
}));
if (expect_connect) {
EXPECT_CALL(*socket_->io_handle_, isConnected()).WillOnce(Return(true));
EXPECT_CALL(*socket_->io_handle_, writev(_, 1))
.WillOnce(Invoke([data, sys_errno](const Buffer::RawSlice* slices,
uint64_t) -> Api::IoCallUint64Result {
EXPECT_EQ(data, absl::string_view(static_cast<const char*>(slices[0].mem_),
slices[0].len_));
// For suppression of clang-tidy NewDeleteLeaks rule, don't use the ternary
// operator.
if (sys_errno == 0) {
return makeNoError(data.size());
} else {
return makeError(sys_errno);
}
}));
} else {
EXPECT_CALL(*socket_->io_handle_, isConnected()).WillOnce(Return(false));
EXPECT_CALL(*socket_->io_handle_, sendmsg(_, 1, 0, _, _))
.WillOnce(Invoke(
[this, data, local_ip, sys_errno](
const Buffer::RawSlice* slices, uint64_t, int,
const Network::Address::Ip* self_ip,
const Network::Address::Instance& peer_address) -> Api::IoCallUint64Result {
EXPECT_EQ(data, absl::string_view(static_cast<const char*>(slices[0].mem_),
slices[0].len_));
EXPECT_EQ(peer_address, *upstream_address_);
if (local_ip == nullptr) {
EXPECT_EQ(nullptr, self_ip);
} else {
EXPECT_EQ(self_ip->addressAsString(), local_ip->addressAsString());
}
// For suppression of clang-tidy NewDeleteLeaks rule, don't use the ternary
// operator.
if (sys_errno == 0) {
return makeNoError(data.size());
} else {
return makeError(sys_errno);
}
}));
}
}
}

Expand Down

0 comments on commit 792f9c0

Please sign in to comment.