Internal change.

PiperOrigin-RevId: 481202690
This commit is contained in:
Derek Mauro
2022-10-14 12:11:32 -07:00
committed by gVisor bot
parent 0444ca8c9f
commit bf8062b8db
13 changed files with 60 additions and 45 deletions
+3 -1
View File
@@ -24,6 +24,8 @@
#include <sys/uio.h>
#include <unistd.h>
#include <memory>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/strings/str_format.h"
@@ -261,7 +263,7 @@ void FuseTest::ServerFuseLoop() {
void FuseTest::SetUpFuseServer(const struct fuse_init_out* payload) {
ASSERT_THAT(socketpair(AF_UNIX, SOCK_STREAM, 0, sock_), SyscallSucceeds());
fuse_server_ = absl::make_unique<ScopedThread>([this, payload]() {
fuse_server_ = std::make_unique<ScopedThread>([this, payload]() {
// Begin child thread, i.e. the FUSE server.
ServerCompleteWith(ServerConsumeFuseInit(payload).ok());
ServerFuseLoop();
+3 -1
View File
@@ -19,6 +19,8 @@
#include <syscall.h>
#include <unistd.h>
#include <memory>
#include "gtest/gtest.h"
#include "absl/memory/memory.h"
#include "absl/time/clock.h"
@@ -51,7 +53,7 @@ void BasePollTest::SetTimer(absl::Duration duration) {
ClearTimer();
// Create a new timer thread.
timer_ = absl::make_unique<TimerThread>(absl::Now() + duration, tgid, tid);
timer_ = std::make_unique<TimerThread>(absl::Now() + duration, tgid, tid);
}
bool BasePollTest::TimerFired() const { return timer_fired; }
+3 -1
View File
@@ -16,6 +16,8 @@
#include <sys/resource.h>
#include <unistd.h>
#include <memory>
#include "gtest/gtest.h"
#include "absl/memory/memory.h"
#include "test/util/eventfd_util.h"
@@ -125,7 +127,7 @@ TEST(DupTest, Rlimit) {
if (new_fd == -1) {
break;
}
auto f = absl::make_unique<FileDescriptor>(new_fd);
auto f = std::make_unique<FileDescriptor>(new_fd);
EXPECT_LT(new_fd, kFDLimit);
EXPECT_GT(new_fd, prev_fd);
// Check that all fds in (prev_fd, new_fd) are used.
+4 -4
View File
@@ -270,7 +270,7 @@ TEST_P(PrivateAndSharedFutexTest, WakeAll) {
std::vector<std::unique_ptr<ScopedThread>> threads;
threads.reserve(kThreads);
for (int i = 0; i < kThreads; i++) {
threads.push_back(absl::make_unique<ScopedThread>([&] {
threads.push_back(std::make_unique<ScopedThread>([&] {
EXPECT_THAT(futex_wait(IsPrivate(), &a, kInitialValue),
SyscallSucceeds());
}));
@@ -302,7 +302,7 @@ TEST_P(PrivateAndSharedFutexTest, WakeSome) {
errs.push_back(0);
}
for (int i = 0; i < kThreads; i++) {
threads.push_back(absl::make_unique<ScopedThread>([&, i] {
threads.push_back(std::make_unique<ScopedThread>([&, i] {
rets[i] =
futex_wait(IsPrivate(), &a, kInitialValue, kIneffectiveWakeTimeout);
errs[i] = errno;
@@ -669,7 +669,7 @@ TEST_P(PrivateAndSharedFutexTest, PIConcurrency) {
std::unique_ptr<ScopedThread> threads[100];
for (size_t i = 0; i < ABSL_ARRAYSIZE(threads); ++i) {
threads[i] = absl::make_unique<ScopedThread>([is_priv, &a] {
threads[i] = std::make_unique<ScopedThread>([is_priv, &a] {
for (size_t j = 0; j < 10; ++j) {
ASSERT_THAT(futex_lock_pi(is_priv, &a), SyscallSucceeds());
EXPECT_EQ(a.load() & FUTEX_TID_MASK, gettid());
@@ -725,7 +725,7 @@ TEST_P(PrivateAndSharedFutexTest, PITryLockConcurrency) {
std::unique_ptr<ScopedThread> threads[10];
for (size_t i = 0; i < ABSL_ARRAYSIZE(threads); ++i) {
threads[i] = absl::make_unique<ScopedThread>([is_priv, &a] {
threads[i] = std::make_unique<ScopedThread>([is_priv, &a] {
for (size_t j = 0; j < 10;) {
if (futex_trylock_pi(is_priv, &a) == 0) {
++j;
+3 -1
View File
@@ -15,6 +15,8 @@
#include <errno.h>
#include <sys/syscall.h>
#include <memory>
#include "gtest/gtest.h"
#include "absl/memory/memory.h"
#include "test/util/cleanup.h"
@@ -198,7 +200,7 @@ TEST(MempolicyTest, QueryAvailableNodes) {
TEST(MempolicyTest, GetMempolicyQueryNodeForAddress) {
uint64_t dummy_stack_address;
auto dummy_heap_address = absl::make_unique<uint64_t>();
auto dummy_heap_address = std::make_unique<uint64_t>();
int mode;
for (auto ptr : {&dummy_stack_address, dummy_heap_address.get()}) {
+3 -1
View File
@@ -19,6 +19,8 @@
#include <sys/types.h>
#include <unistd.h>
#include <memory>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/memory/memory.h"
@@ -325,7 +327,7 @@ TEST_F(OpenTest, AppendConcurrentWrite) {
// Start kThreadCount threads which will write concurrently into the same
// file.
for (int i = 0; i < kThreadCount; i++) {
threads[i] = absl::make_unique<ScopedThread>([filename]() {
threads[i] = std::make_unique<ScopedThread>([filename]() {
const FileDescriptor fd =
ASSERT_NO_ERRNO_AND_VALUE(Open(filename, O_RDWR | O_APPEND));
+6 -5
View File
@@ -17,6 +17,7 @@
#include <sys/types.h>
#include <sys/uio.h>
#include <memory>
#include <string>
#include <vector>
@@ -199,7 +200,7 @@ TEST(Preadv2Test, TestInvalidOffset) {
const FileDescriptor fd =
ASSERT_NO_ERRNO_AND_VALUE(Open(file.path(), O_RDONLY | O_DIRECT));
auto iov = absl::make_unique<struct iovec[]>(1);
auto iov = std::make_unique<struct iovec[]>(1);
iov[0].iov_base = nullptr;
iov[0].iov_len = 0;
@@ -217,7 +218,7 @@ TEST(Preadv2Test, TestUnreadableFile) {
const FileDescriptor fd =
ASSERT_NO_ERRNO_AND_VALUE(Open(file.path(), O_WRONLY));
auto iov = absl::make_unique<struct iovec[]>(1);
auto iov = std::make_unique<struct iovec[]>(1);
iov[0].iov_base = nullptr;
iov[0].iov_len = 0;
@@ -234,7 +235,7 @@ TEST(Preadv2Test, Preadv2WithOpath) {
const FileDescriptor fd =
ASSERT_NO_ERRNO_AND_VALUE(Open(file.path(), O_PATH));
auto iov = absl::make_unique<struct iovec[]>(1);
auto iov = std::make_unique<struct iovec[]>(1);
iov[0].iov_base = nullptr;
iov[0].iov_len = 0;
@@ -252,7 +253,7 @@ TEST(Preadv2Test, TestUnseekableFileInvalid) {
ASSERT_THAT(pipe(pipe_fds), SyscallSucceeds());
auto iov = absl::make_unique<struct iovec[]>(1);
auto iov = std::make_unique<struct iovec[]>(1);
iov[0].iov_base = nullptr;
iov[0].iov_len = 0;
@@ -277,7 +278,7 @@ TEST(Preadv2Test, TestUnseekableFileValid) {
SyscallSucceedsWithValue(content.size()));
std::vector<char> buf(content.size());
auto iov = absl::make_unique<struct iovec[]>(1);
auto iov = std::make_unique<struct iovec[]>(1);
iov[0].iov_base = buf.data();
iov[0].iov_len = buf.size();
+4 -3
View File
@@ -20,6 +20,7 @@
#include <atomic>
#include <cerrno>
#include <ctime>
#include <memory>
#include <set>
#include "gmock/gmock.h"
@@ -371,7 +372,7 @@ TEST(SemaphoreTest, SemOpRandom) {
// These threads will wait in a loop.
std::unique_ptr<ScopedThread> decs[5];
for (auto& dec : decs) {
dec = absl::make_unique<ScopedThread>([&sem, &mutex, &count, &seed, &done] {
dec = std::make_unique<ScopedThread>([&sem, &mutex, &count, &seed, &done] {
for (size_t i = 0; i < 500; ++i) {
int16_t val;
{
@@ -393,7 +394,7 @@ TEST(SemaphoreTest, SemOpRandom) {
// These threads will wait for zero in a loop.
std::unique_ptr<ScopedThread> zeros[5];
for (auto& zero : zeros) {
zero = absl::make_unique<ScopedThread>([&sem, &mutex, &done] {
zero = std::make_unique<ScopedThread>([&sem, &mutex, &done] {
for (size_t i = 0; i < 500; ++i) {
{
absl::MutexLock l(&mutex);
@@ -412,7 +413,7 @@ TEST(SemaphoreTest, SemOpRandom) {
// These threads will signal in a loop.
std::unique_ptr<ScopedThread> incs[5];
for (auto& inc : incs) {
inc = absl::make_unique<ScopedThread>([&sem, &mutex, &count, &seed] {
inc = std::make_unique<ScopedThread>([&sem, &mutex, &count, &seed] {
for (size_t i = 0; i < 500; ++i) {
int16_t val;
{
@@ -139,7 +139,7 @@ TEST_P(BindToDeviceDistributionTest, Tcp) {
listener_fds.size());
for (size_t i = 0; i < listener_fds.size(); i++) {
listen_threads[i] = absl::make_unique<ScopedThread>(
listen_threads[i] = std::make_unique<ScopedThread>(
[&listener_fds, &accept_counts, &connects_received, i,
kConnectAttempts]() {
do {
@@ -262,7 +262,7 @@ TEST_P(BindToDeviceDistributionTest, Udp) {
listener_fds.size());
for (size_t i = 0; i < listener_fds.size(); i++) {
receiver_threads[i] = absl::make_unique<ScopedThread>(
receiver_threads[i] = std::make_unique<ScopedThread>(
[&listener_fds, &packets_per_socket, &packets_received, i]() {
do {
struct sockaddr_storage addr = {};
+2 -2
View File
@@ -1420,7 +1420,7 @@ TEST_P(SocketInetReusePortTest, TcpPortReuseMultiThread) {
DisableSave ds;
for (int i = 0; i < kThreadCount; i++) {
listen_thread[i] = absl::make_unique<ScopedThread>(
listen_thread[i] = std::make_unique<ScopedThread>(
[&listener_fds, &accept_counts, i, &connects_received]() {
do {
auto fd = Accept(listener_fds[i].get(), nullptr, nullptr);
@@ -1527,7 +1527,7 @@ TEST_P(SocketInetReusePortTest, UdpPortReuseMultiThread) {
DisableSave ds; // Too expensive.
for (int i = 0; i < kThreadCount; i++) {
receiver_thread[i] = absl::make_unique<ScopedThread>(
receiver_thread[i] = std::make_unique<ScopedThread>(
[&listener_fds, &packets_per_socket, i, &packets_received]() {
do {
struct sockaddr_storage addr = {};
+3 -1
View File
@@ -1119,6 +1119,8 @@ TEST_P(TCPSocketPairTest, SpliceToPipe) {
#include <sys/sendfile.h>
#include <memory>
TEST_P(TCPSocketPairTest, SendfileFromRegularFileSucceeds) {
auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair());
const TempPath in_file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile());
@@ -1214,7 +1216,7 @@ TEST_P(TCPSocketPairTest, TCPResetDuringClose) {
constexpr int kThreadCount = 100;
std::unique_ptr<ScopedThread> instances[kThreadCount];
for (int i = 0; i < kThreadCount; i++) {
instances[i] = absl::make_unique<ScopedThread>([&]() {
instances[i] = std::make_unique<ScopedThread>([&]() {
auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair());
ScopedThread t([&]() {
@@ -20,6 +20,7 @@
#include <sys/un.h>
#include <cstdio>
#include <memory>
#include "gtest/gtest.h"
#include "absl/memory/memory.h"
@@ -1014,10 +1015,10 @@ TEST_P(IPv4UDPUnboundSocketTest, TestTwoSocketsJoinSameMulticastGroup) {
// and both will receive data on it.
TEST_P(IPv4UDPUnboundSocketTest, TestMcastReceptionOnTwoSockets) {
std::unique_ptr<SocketPair> socket_pairs[2] = {
absl::make_unique<FDSocketPair>(ASSERT_NO_ERRNO_AND_VALUE(NewSocket()),
ASSERT_NO_ERRNO_AND_VALUE(NewSocket())),
absl::make_unique<FDSocketPair>(ASSERT_NO_ERRNO_AND_VALUE(NewSocket()),
ASSERT_NO_ERRNO_AND_VALUE(NewSocket()))};
std::make_unique<FDSocketPair>(ASSERT_NO_ERRNO_AND_VALUE(NewSocket()),
ASSERT_NO_ERRNO_AND_VALUE(NewSocket())),
std::make_unique<FDSocketPair>(ASSERT_NO_ERRNO_AND_VALUE(NewSocket()),
ASSERT_NO_ERRNO_AND_VALUE(NewSocket()))};
ip_mreq iface = {}, group = {};
iface.imr_interface.s_addr = htonl(INADDR_LOOPBACK);
@@ -1087,10 +1088,10 @@ TEST_P(IPv4UDPUnboundSocketTest, TestMcastReceptionOnTwoSockets) {
// both memberships have been dropped.
TEST_P(IPv4UDPUnboundSocketTest, TestMcastReceptionWhenDroppingMemberships) {
std::unique_ptr<SocketPair> socket_pairs[2] = {
absl::make_unique<FDSocketPair>(ASSERT_NO_ERRNO_AND_VALUE(NewSocket()),
ASSERT_NO_ERRNO_AND_VALUE(NewSocket())),
absl::make_unique<FDSocketPair>(ASSERT_NO_ERRNO_AND_VALUE(NewSocket()),
ASSERT_NO_ERRNO_AND_VALUE(NewSocket()))};
std::make_unique<FDSocketPair>(ASSERT_NO_ERRNO_AND_VALUE(NewSocket()),
ASSERT_NO_ERRNO_AND_VALUE(NewSocket())),
std::make_unique<FDSocketPair>(ASSERT_NO_ERRNO_AND_VALUE(NewSocket()),
ASSERT_NO_ERRNO_AND_VALUE(NewSocket()))};
ip_mreq iface = {}, group = {};
iface.imr_interface.s_addr = htonl(INADDR_LOOPBACK);
+15 -15
View File
@@ -43,8 +43,8 @@ Creator<SocketPair> SyscallSocketPairCreator(int domain, int type,
int pair[2];
RETURN_ERROR_IF_SYSCALL_FAIL(socketpair(domain, type, protocol, pair));
MaybeSave(); // Save on successful creation.
return absl::make_unique<FDSocketPair>(FileDescriptor(pair[0]),
FileDescriptor(pair[1]));
return std::make_unique<FDSocketPair>(FileDescriptor(pair[0]),
FileDescriptor(pair[1]));
};
}
@@ -54,7 +54,7 @@ Creator<FileDescriptor> SyscallSocketCreator(int domain, int type,
int fd = 0;
RETURN_ERROR_IF_SYSCALL_FAIL(fd = socket(domain, type, protocol));
MaybeSave(); // Save on successful creation.
return absl::make_unique<FileDescriptor>(fd);
return std::make_unique<FileDescriptor>(fd);
};
}
@@ -128,7 +128,7 @@ Creator<SocketPair> AcceptBindSocketPairCreator(bool abstract, int domain,
// accepted is before connected to destruct connected before accepted.
// Destructors for nonstatic member objects are called in the reverse order
// in which they appear in the class declaration.
return absl::make_unique<AddrFDSocketPair>(
return std::make_unique<AddrFDSocketPair>(
std::move(accepted), std::move(connected), bind_addr, extra_addr);
};
}
@@ -188,7 +188,7 @@ Creator<SocketPair> BidirectionalBindSocketPairCreator(bool abstract,
MaybeSave(); // Successful unlink.
}
return absl::make_unique<FDSocketPair>(std::move(sock1), std::move(sock2));
return std::make_unique<FDSocketPair>(std::move(sock1), std::move(sock2));
};
}
@@ -242,7 +242,7 @@ Creator<SocketPair> SocketpairGoferSocketPairCreator(int domain, int type,
RETURN_ERROR_IF_SYSCALL_FAIL(close(sock));
}
return absl::make_unique<FDSocketPair>(std::move(sock1), std::move(sock2));
return std::make_unique<FDSocketPair>(std::move(sock1), std::move(sock2));
};
}
@@ -268,7 +268,7 @@ Creator<SocketPair> SocketpairGoferFileSocketPairCreator(int flags) {
sock2.reset(sock2_fd);
}
return absl::make_unique<FDSocketPair>(std::move(sock1), std::move(sock2));
return std::make_unique<FDSocketPair>(std::move(sock1), std::move(sock2));
};
}
@@ -284,8 +284,8 @@ Creator<SocketPair> UnboundSocketPairCreator(bool abstract, int domain,
MaybeSave(); // Successful socket creation.
ASSIGN_OR_RETURN_ERRNO(auto sock2, Socket(domain, type, protocol));
MaybeSave(); // Successful socket creation.
return absl::make_unique<AddrFDSocketPair>(std::move(sock1),
std::move(sock2), addr1, addr2);
return std::make_unique<AddrFDSocketPair>(std::move(sock1),
std::move(sock2), addr1, addr2);
};
}
@@ -382,7 +382,7 @@ CreateTCPConnectAcceptSocketPair(int bound, FileDescriptor connected, int type,
T extra_addr = {};
LocalhostAddr(&extra_addr, dual_stack);
return absl::make_unique<AddrFDSocketPair>(
return std::make_unique<AddrFDSocketPair>(
std::move(connected), std::move(accepted), bind_addr, extra_addr);
}
@@ -485,8 +485,8 @@ PosixErrorOr<std::unique_ptr<AddrFDSocketPair>> CreateUDPBoundSocketPair(
ASSIGN_OR_RETURN_ERRNO(T addr1, BindIP<T>(sock1.get(), dual_stack));
ASSIGN_OR_RETURN_ERRNO(T addr2, BindIP<T>(sock2.get(), dual_stack));
return absl::make_unique<AddrFDSocketPair>(std::move(sock1), std::move(sock2),
addr1, addr2);
return std::make_unique<AddrFDSocketPair>(std::move(sock1), std::move(sock2),
addr1, addr2);
}
template <typename T>
@@ -538,7 +538,7 @@ Creator<SocketPair> UDPUnboundSocketPairCreator(int domain, int type,
ASSIGN_OR_RETURN_ERRNO(auto sock2, Socket(domain, type, protocol));
MaybeSave(); // Successful socket creation.
return absl::make_unique<FDSocketPair>(std::move(sock1), std::move(sock2));
return std::make_unique<FDSocketPair>(std::move(sock1), std::move(sock2));
};
}
@@ -549,7 +549,7 @@ SocketPairKind Reversed(SocketPairKind const& base) {
base.protocol,
[creator]() -> PosixErrorOr<std::unique_ptr<ReversedSocketPair>> {
ASSIGN_OR_RETURN_ERRNO(auto creator_value, creator());
return absl::make_unique<ReversedSocketPair>(std::move(creator_value));
return std::make_unique<ReversedSocketPair>(std::move(creator_value));
}};
}
@@ -560,7 +560,7 @@ Creator<FileDescriptor> UnboundSocketCreator(int domain, int type,
RETURN_ERROR_IF_SYSCALL_FAIL(sock = socket(domain, type, protocol));
MaybeSave(); // Successful socket creation.
return absl::make_unique<FileDescriptor>(sock);
return std::make_unique<FileDescriptor>(sock);
};
}