Change to standard types.

PiperOrigin-RevId: 290846481
This commit is contained in:
Adin Scannell
2020-01-21 17:28:57 -08:00
committed by gVisor bot
parent 0693fb05d1
commit 2296b47344
72 changed files with 483 additions and 480 deletions
+1 -1
View File
@@ -183,7 +183,7 @@ TEST_F(AIOTest, BadWrite) {
// Verify that it fails with the right error code.
EXPECT_EQ(events[0].data, 0x123);
EXPECT_EQ(events[0].obj, reinterpret_cast<uint64>(&cb));
EXPECT_EQ(events[0].obj, reinterpret_cast<uint64_t>(&cb));
EXPECT_LT(events[0].res, 0);
}
+3 -3
View File
@@ -31,9 +31,9 @@
#include "test/util/test_util.h"
#include "test/util/thread_util.h"
ABSL_FLAG(int32, scratch_uid1, 65534, "first scratch UID");
ABSL_FLAG(int32, scratch_uid2, 65533, "second scratch UID");
ABSL_FLAG(int32, scratch_gid, 65534, "first scratch GID");
ABSL_FLAG(int32_t, scratch_uid1, 65534, "first scratch UID");
ABSL_FLAG(int32_t, scratch_uid2, 65533, "second scratch UID");
ABSL_FLAG(int32_t, scratch_gid, 65534, "first scratch GID");
namespace gvisor {
namespace testing {
+1 -1
View File
@@ -253,7 +253,7 @@ TEST(ChrootTest, ProcMemSelfMapsNoEscapeProcOpen) {
// Mmap the newly created file.
void* foo_map = mmap(nullptr, kPageSize, PROT_READ | PROT_WRITE, MAP_PRIVATE,
foo.get(), 0);
ASSERT_THAT(reinterpret_cast<int64>(foo_map), SyscallSucceeds());
ASSERT_THAT(reinterpret_cast<int64_t>(foo_map), SyscallSucceeds());
// Always unmap.
auto cleanup_map = Cleanup(
+6 -6
View File
@@ -34,7 +34,7 @@ namespace testing {
namespace {
int64 clock_gettime_nsecs(clockid_t id) {
int64_t clock_gettime_nsecs(clockid_t id) {
struct timespec ts;
TEST_PCHECK(clock_gettime(id, &ts) == 0);
return (ts.tv_sec * 1000000000 + ts.tv_nsec);
@@ -42,9 +42,9 @@ int64 clock_gettime_nsecs(clockid_t id) {
// Spin on the CPU for at least ns nanoseconds, based on
// CLOCK_THREAD_CPUTIME_ID.
void spin_ns(int64 ns) {
int64 start = clock_gettime_nsecs(CLOCK_THREAD_CPUTIME_ID);
int64 end = start + ns;
void spin_ns(int64_t ns) {
int64_t start = clock_gettime_nsecs(CLOCK_THREAD_CPUTIME_ID);
int64_t end = start + ns;
do {
constexpr int kLoopCount = 1000000; // large and arbitrary
@@ -64,7 +64,7 @@ TEST(ClockGettime, CputimeId) {
// the workers. Note that we test CLOCK_PROCESS_CPUTIME_ID by having the
// workers execute in parallel and verifying that CLOCK_PROCESS_CPUTIME_ID
// accumulates the runtime of all threads.
int64 start = clock_gettime_nsecs(CLOCK_PROCESS_CPUTIME_ID);
int64_t start = clock_gettime_nsecs(CLOCK_PROCESS_CPUTIME_ID);
// Create a kNumThreads threads.
std::list<ScopedThread> threads;
@@ -76,7 +76,7 @@ TEST(ClockGettime, CputimeId) {
t.Join();
}
int64 end = clock_gettime_nsecs(CLOCK_PROCESS_CPUTIME_ID);
int64_t end = clock_gettime_nsecs(CLOCK_PROCESS_CPUTIME_ID);
// The aggregate time spent in the worker threads must be at least
// 'kNumThreads' times the time each thread spun.
+11 -11
View File
@@ -37,7 +37,7 @@ TEST(EventfdTest, Nonblock) {
FileDescriptor efd =
ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, EFD_NONBLOCK | EFD_SEMAPHORE));
uint64 l;
uint64_t l;
ASSERT_THAT(read(efd.get(), &l, sizeof(l)), SyscallFailsWithErrno(EAGAIN));
l = 1;
@@ -52,7 +52,7 @@ TEST(EventfdTest, Nonblock) {
void* read_three_times(void* arg) {
int efd = *reinterpret_cast<int*>(arg);
uint64 l;
uint64_t l;
EXPECT_THAT(read(efd, &l, sizeof(l)), SyscallSucceedsWithValue(sizeof(l)));
EXPECT_THAT(read(efd, &l, sizeof(l)), SyscallSucceedsWithValue(sizeof(l)));
EXPECT_THAT(read(efd, &l, sizeof(l)), SyscallSucceedsWithValue(sizeof(l)));
@@ -68,7 +68,7 @@ TEST(EventfdTest, BlockingWrite) {
reinterpret_cast<void*>(&efd)),
SyscallSucceeds());
uint64 l = 1;
uint64_t l = 1;
ASSERT_THAT(write(efd, &l, sizeof(l)), SyscallSucceeds());
EXPECT_EQ(l, 1);
@@ -85,7 +85,7 @@ TEST(EventfdTest, SmallWrite) {
FileDescriptor efd =
ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, EFD_NONBLOCK | EFD_SEMAPHORE));
uint64 l = 16;
uint64_t l = 16;
ASSERT_THAT(write(efd.get(), &l, 4), SyscallFailsWithErrno(EINVAL));
}
@@ -93,7 +93,7 @@ TEST(EventfdTest, SmallRead) {
FileDescriptor efd =
ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, EFD_NONBLOCK | EFD_SEMAPHORE));
uint64 l = 1;
uint64_t l = 1;
ASSERT_THAT(write(efd.get(), &l, sizeof(l)), SyscallSucceeds());
l = 0;
@@ -104,7 +104,7 @@ TEST(EventfdTest, BigWrite) {
FileDescriptor efd =
ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, EFD_NONBLOCK | EFD_SEMAPHORE));
uint64 big[16];
uint64_t big[16];
big[0] = 16;
ASSERT_THAT(write(efd.get(), big, sizeof(big)), SyscallSucceeds());
}
@@ -113,10 +113,10 @@ TEST(EventfdTest, BigRead) {
FileDescriptor efd =
ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, EFD_NONBLOCK | EFD_SEMAPHORE));
uint64 l = 1;
uint64_t l = 1;
ASSERT_THAT(write(efd.get(), &l, sizeof(l)), SyscallSucceeds());
uint64 big[16];
uint64_t big[16];
ASSERT_THAT(read(efd.get(), big, sizeof(big)), SyscallSucceeds());
EXPECT_EQ(big[0], 1);
}
@@ -125,7 +125,7 @@ TEST(EventfdTest, BigWriteBigRead) {
FileDescriptor efd =
ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, EFD_NONBLOCK | EFD_SEMAPHORE));
uint64 l[16];
uint64_t l[16];
l[0] = 16;
ASSERT_THAT(write(efd.get(), l, sizeof(l)), SyscallSucceeds());
ASSERT_THAT(read(efd.get(), l, sizeof(l)), SyscallSucceeds());
@@ -150,7 +150,7 @@ TEST(EventfdTest, NotifyNonZero_NoRandomSave) {
int wait_out = epoll_wait(epollfd.get(), &out_ev, 1, kEpollTimeoutMs);
EXPECT_EQ(wait_out, 1);
EXPECT_EQ(efd.get(), out_ev.data.fd);
uint64 val = 0;
uint64_t val = 0;
ASSERT_THAT(read(efd.get(), &val, sizeof(val)), SyscallSucceeds());
EXPECT_EQ(val, 1);
@@ -159,7 +159,7 @@ TEST(EventfdTest, NotifyNonZero_NoRandomSave) {
// epoll_wait times out.
ScopedThread t([&efd] {
sleep(5);
uint64 val = 1;
uint64_t val = 1;
EXPECT_THAT(write(efd.get(), &val, sizeof(val)),
SyscallSucceedsWithValue(sizeof(val)));
});
+33 -33
View File
@@ -24,20 +24,20 @@ namespace testing {
// Default value for the x87 FPU control word. See Intel SDM Vol 1, Ch 8.1.5
// "x87 FPU Control Word".
constexpr uint16 kX87ControlWordDefault = 0x37f;
constexpr uint16_t kX87ControlWordDefault = 0x37f;
// Mask for the divide-by-zero exception.
constexpr uint16 kX87ControlWordDiv0Mask = 1 << 2;
constexpr uint16_t kX87ControlWordDiv0Mask = 1 << 2;
// Default value for the SSE control register (MXCSR). See Intel SDM Vol 1, Ch
// 11.6.4 "Initialization of SSE/SSE3 Extensions".
constexpr uint32 kMXCSRDefault = 0x1f80;
constexpr uint32_t kMXCSRDefault = 0x1f80;
// Mask for the divide-by-zero exception.
constexpr uint32 kMXCSRDiv0Mask = 1 << 9;
constexpr uint32_t kMXCSRDiv0Mask = 1 << 9;
// Flag for a pending divide-by-zero exception.
constexpr uint32 kMXCSRDiv0Flag = 1 << 2;
constexpr uint32_t kMXCSRDiv0Flag = 1 << 2;
void inline Halt() { asm("hlt\r\n"); }
@@ -112,10 +112,10 @@ TEST(ExceptionTest, DivideByZero) {
EXPECT_EXIT(
{
uint32 remainder;
uint32 quotient;
uint32 divisor = 0;
uint64 value = 1;
uint32_t remainder;
uint32_t quotient;
uint32_t divisor = 0;
uint64_t value = 1;
asm("divl 0(%2)\r\n"
: "=d"(remainder), "=a"(quotient)
: "r"(&divisor), "d"(value >> 32), "a"(value));
@@ -126,9 +126,9 @@ TEST(ExceptionTest, DivideByZero) {
// By default, x87 exceptions are masked and simply return a default value.
TEST(ExceptionTest, X87DivideByZeroMasked) {
int32 quotient;
int32 value = 1;
int32 divisor = 0;
int32_t quotient;
int32_t value = 1;
int32_t divisor = 0;
asm("fildl %[value]\r\n"
"fidivl %[divisor]\r\n"
"fistpl %[quotient]\r\n"
@@ -148,12 +148,12 @@ TEST(ExceptionTest, X87DivideByZeroUnmasked) {
EXPECT_EXIT(
{
// Clear the divide by zero exception mask.
constexpr uint16 kControlWord =
constexpr uint16_t kControlWord =
kX87ControlWordDefault & ~kX87ControlWordDiv0Mask;
int32 quotient;
int32 value = 1;
int32 divisor = 0;
int32_t quotient;
int32_t value = 1;
int32_t divisor = 0;
asm volatile(
"fldcw %[cw]\r\n"
"fildl %[value]\r\n"
@@ -176,12 +176,12 @@ TEST(ExceptionTest, X87StatusClobber) {
EXPECT_EXIT(
{
// Clear the divide by zero exception mask.
constexpr uint16 kControlWord =
constexpr uint16_t kControlWord =
kX87ControlWordDefault & ~kX87ControlWordDiv0Mask;
int32 quotient;
int32 value = 1;
int32 divisor = 0;
int32_t quotient;
int32_t value = 1;
int32_t divisor = 0;
asm volatile(
"fildl %[value]\r\n"
"fidivl %[divisor]\r\n"
@@ -208,10 +208,10 @@ TEST(ExceptionTest, X87StatusClobber) {
// By default, SSE exceptions are masked and simply return a default value.
TEST(ExceptionTest, SSEDivideByZeroMasked) {
uint32 status;
int32 quotient;
int32 value = 1;
int32 divisor = 0;
uint32_t status;
int32_t quotient;
int32_t value = 1;
int32_t divisor = 0;
asm("cvtsi2ssl %[value], %%xmm0\r\n"
"cvtsi2ssl %[divisor], %%xmm1\r\n"
"divss %%xmm1, %%xmm0\r\n"
@@ -233,11 +233,11 @@ TEST(ExceptionTest, SSEDivideByZeroUnmasked) {
EXPECT_EXIT(
{
// Clear the divide by zero exception mask.
constexpr uint32 kMXCSR = kMXCSRDefault & ~kMXCSRDiv0Mask;
constexpr uint32_t kMXCSR = kMXCSRDefault & ~kMXCSRDiv0Mask;
int32 quotient;
int32 value = 1;
int32 divisor = 0;
int32_t quotient;
int32_t value = 1;
int32_t divisor = 0;
asm volatile(
"ldmxcsr %[mxcsr]\r\n"
"cvtsi2ssl %[value], %%xmm0\r\n"
@@ -254,10 +254,10 @@ TEST(ExceptionTest, SSEDivideByZeroUnmasked) {
// Pending exceptions in the SSE status register are not clobbered by syscalls.
TEST(ExceptionTest, SSEStatusClobber) {
uint32 mxcsr;
int32 quotient;
int32 value = 1;
int32 divisor = 0;
uint32_t mxcsr;
int32_t quotient;
int32_t value = 1;
int32_t divisor = 0;
asm("cvtsi2ssl %[value], %%xmm0\r\n"
"cvtsi2ssl %[divisor], %%xmm1\r\n"
"divss %%xmm1, %%xmm0\r\n"
@@ -336,7 +336,7 @@ TEST(ExceptionTest, AlignmentCheck) {
SetAlignmentCheck();
for (int i = 0; i < 8; i++) {
// At least 7/8 offsets will be unaligned here.
uint64* ptr = reinterpret_cast<uint64*>(&array[i]);
uint64_t* ptr = reinterpret_cast<uint64_t*>(&array[i]);
asm("mov %0, 0(%0)\r\n" : : "r"(ptr) : "ax");
}
},
+5 -5
View File
@@ -62,7 +62,7 @@ constexpr char kExecFromThread[] = "--exec_exec_from_thread";
// Runs file specified by dirfd and pathname with argv and checks that the exit
// status is expect_status and that stderr contains expect_stderr.
void CheckExecHelper(const absl::optional<int32> dirfd,
void CheckExecHelper(const absl::optional<int32_t> dirfd,
const std::string& pathname, const ExecveArray& argv,
const ExecveArray& envv, const int flags,
int expect_status, const std::string& expect_stderr) {
@@ -143,15 +143,15 @@ void CheckExecHelper(const absl::optional<int32> dirfd,
void CheckExec(const std::string& filename, const ExecveArray& argv,
const ExecveArray& envv, int expect_status,
const std::string& expect_stderr) {
CheckExecHelper(/*dirfd=*/absl::optional<int32>(), filename, argv, envv,
CheckExecHelper(/*dirfd=*/absl::optional<int32_t>(), filename, argv, envv,
/*flags=*/0, expect_status, expect_stderr);
}
void CheckExecveat(const int32 dirfd, const std::string& pathname,
void CheckExecveat(const int32_t dirfd, const std::string& pathname,
const ExecveArray& argv, const ExecveArray& envv,
const int flags, int expect_status,
const std::string& expect_stderr) {
CheckExecHelper(absl::optional<int32>(dirfd), pathname, argv, envv, flags,
CheckExecHelper(absl::optional<int32_t>(dirfd), pathname, argv, envv, flags,
expect_status, expect_stderr);
}
@@ -603,7 +603,7 @@ TEST(ExecveatTest, AbsolutePathWithFDCWD) {
TEST(ExecveatTest, AbsolutePath) {
std::string path = RunfilePath(kBasicWorkload);
// File descriptor should be ignored when an absolute path is given.
const int32 badFD = -1;
const int32_t badFD = -1;
CheckExecveat(badFD, path, {path}, {}, ArgEnvExitStatus(0, 0), 0,
absl::StrCat(path, "\n"));
}
+9 -9
View File
@@ -700,7 +700,7 @@ TEST(ElfTest, PIE) {
// The first segment really needs to start at 0 for a normal PIE binary, and
// thus includes the headers.
const uint64 offset = elf.phdrs[1].p_offset;
const uint64_t offset = elf.phdrs[1].p_offset;
elf.phdrs[1].p_offset = 0x0;
elf.phdrs[1].p_vaddr = 0x0;
elf.phdrs[1].p_filesz += offset;
@@ -720,7 +720,7 @@ TEST(ElfTest, PIE) {
struct user_regs_struct regs;
ASSERT_THAT(ptrace(PTRACE_GETREGS, child, 0, &regs), SyscallSucceeds());
const uint64 load_addr = regs.rip & ~(kPageSize - 1);
const uint64_t load_addr = regs.rip & ~(kPageSize - 1);
EXPECT_THAT(child, ContainsMappings(std::vector<ProcMapsEntry>({
// text page.
@@ -789,7 +789,7 @@ TEST(ElfTest, PIENonZeroStart) {
struct user_regs_struct regs;
ASSERT_THAT(ptrace(PTRACE_GETREGS, child, 0, &regs), SyscallSucceeds());
const uint64 load_addr = regs.rip & ~(kPageSize - 1);
const uint64_t load_addr = regs.rip & ~(kPageSize - 1);
// The ELF is loaded at an arbitrary address, not the first PT_LOAD vaddr.
//
@@ -859,7 +859,7 @@ TEST(ElfTest, ELFInterpreter) {
// The first segment really needs to start at 0 for a normal PIE binary, and
// thus includes the headers.
uint64 const offset = interpreter.phdrs[1].p_offset;
uint64_t const offset = interpreter.phdrs[1].p_offset;
// N.B. Since Linux 4.10 (0036d1f7eb95b "binfmt_elf: fix calculations for bss
// padding"), Linux unconditionally zeroes the remainder of the highest mapped
// page in an interpreter, failing if the protections don't allow write. Thus
@@ -912,7 +912,7 @@ TEST(ElfTest, ELFInterpreter) {
struct user_regs_struct regs;
ASSERT_THAT(ptrace(PTRACE_GETREGS, child, 0, &regs), SyscallSucceeds());
const uint64 interp_load_addr = regs.rip & ~(kPageSize - 1);
const uint64_t interp_load_addr = regs.rip & ~(kPageSize - 1);
EXPECT_THAT(
child, ContainsMappings(std::vector<ProcMapsEntry>({
@@ -1047,7 +1047,7 @@ TEST(ElfTest, ELFInterpreterRelative) {
// The first segment really needs to start at 0 for a normal PIE binary, and
// thus includes the headers.
uint64 const offset = interpreter.phdrs[1].p_offset;
uint64_t const offset = interpreter.phdrs[1].p_offset;
// See comment in ElfTest.ELFInterpreter.
interpreter.phdrs[1].p_flags = PF_R | PF_W | PF_X;
interpreter.phdrs[1].p_offset = 0x0;
@@ -1086,7 +1086,7 @@ TEST(ElfTest, ELFInterpreterRelative) {
struct user_regs_struct regs;
ASSERT_THAT(ptrace(PTRACE_GETREGS, child, 0, &regs), SyscallSucceeds());
const uint64 interp_load_addr = regs.rip & ~(kPageSize - 1);
const uint64_t interp_load_addr = regs.rip & ~(kPageSize - 1);
EXPECT_THAT(
child, ContainsMappings(std::vector<ProcMapsEntry>({
@@ -1109,7 +1109,7 @@ TEST(ElfTest, ELFInterpreterWrongArch) {
// The first segment really needs to start at 0 for a normal PIE binary, and
// thus includes the headers.
uint64 const offset = interpreter.phdrs[1].p_offset;
uint64_t const offset = interpreter.phdrs[1].p_offset;
// See comment in ElfTest.ELFInterpreter.
interpreter.phdrs[1].p_flags = PF_R | PF_W | PF_X;
interpreter.phdrs[1].p_offset = 0x0;
@@ -1190,7 +1190,7 @@ TEST(ElfTest, ElfInterpreterNoExecute) {
// The first segment really needs to start at 0 for a normal PIE binary, and
// thus includes the headers.
uint64 const offset = interpreter.phdrs[1].p_offset;
uint64_t const offset = interpreter.phdrs[1].p_offset;
// See comment in ElfTest.ELFInterpreter.
interpreter.phdrs[1].p_flags = PF_R | PF_W | PF_X;
interpreter.phdrs[1].p_offset = 0x0;
+11 -11
View File
@@ -46,9 +46,9 @@ ABSL_FLAG(bool, blocking, false,
"Whether to set a blocking lock (otherwise non-blocking).");
ABSL_FLAG(bool, retry_eintr, false,
"Whether to retry in the subprocess on EINTR.");
ABSL_FLAG(uint64, child_setlock_start, 0, "The value of struct flock start");
ABSL_FLAG(uint64, child_setlock_len, 0, "The value of struct flock len");
ABSL_FLAG(int32, socket_fd, -1,
ABSL_FLAG(uint64_t, child_setlock_start, 0, "The value of struct flock start");
ABSL_FLAG(uint64_t, child_setlock_len, 0, "The value of struct flock len");
ABSL_FLAG(int32_t, socket_fd, -1,
"A socket to use for communicating more state back "
"to the parent.");
@@ -71,8 +71,8 @@ class FcntlLockTest : public ::testing::Test {
EXPECT_THAT(close(fds_[1]), SyscallSucceeds());
}
int64 GetSubprocessFcntlTimeInUsec() {
int64 ret = 0;
int64_t GetSubprocessFcntlTimeInUsec() {
int64_t ret = 0;
EXPECT_THAT(ReadFd(fds_[0], reinterpret_cast<void*>(&ret), sizeof(ret)),
SyscallSucceedsWithValue(sizeof(ret)));
return ret;
@@ -676,7 +676,7 @@ TEST_F(FcntlLockTest, SetWriteLockThenBlockingWriteLock) {
// We will wait kHoldLockForSec before we release our lock allowing the
// subprocess to obtain it.
constexpr absl::Duration kHoldLockFor = absl::Seconds(5);
const int64 kMinBlockTimeUsec = absl::ToInt64Microseconds(absl::Seconds(1));
const int64_t kMinBlockTimeUsec = absl::ToInt64Microseconds(absl::Seconds(1));
absl::SleepFor(kHoldLockFor);
@@ -685,7 +685,7 @@ TEST_F(FcntlLockTest, SetWriteLockThenBlockingWriteLock) {
ASSERT_THAT(fcntl(fd.get(), F_SETLKW, &fl), SyscallSucceeds());
// Read the blocked time from the subprocess socket.
int64 subprocess_blocked_time_usec = GetSubprocessFcntlTimeInUsec();
int64_t subprocess_blocked_time_usec = GetSubprocessFcntlTimeInUsec();
// We must have been waiting at least kMinBlockTime.
EXPECT_GT(subprocess_blocked_time_usec, kMinBlockTimeUsec);
@@ -729,7 +729,7 @@ TEST_F(FcntlLockTest, SetReadLockThenBlockingWriteLock) {
// subprocess to obtain it.
constexpr absl::Duration kHoldLockFor = absl::Seconds(5);
const int64 kMinBlockTimeUsec = absl::ToInt64Microseconds(absl::Seconds(1));
const int64_t kMinBlockTimeUsec = absl::ToInt64Microseconds(absl::Seconds(1));
absl::SleepFor(kHoldLockFor);
@@ -738,7 +738,7 @@ TEST_F(FcntlLockTest, SetReadLockThenBlockingWriteLock) {
ASSERT_THAT(fcntl(fd.get(), F_SETLKW, &fl), SyscallSucceeds());
// Read the blocked time from the subprocess socket.
int64 subprocess_blocked_time_usec = GetSubprocessFcntlTimeInUsec();
int64_t subprocess_blocked_time_usec = GetSubprocessFcntlTimeInUsec();
// We must have been waiting at least kMinBlockTime.
EXPECT_GT(subprocess_blocked_time_usec, kMinBlockTimeUsec);
@@ -782,7 +782,7 @@ TEST_F(FcntlLockTest, SetWriteLockThenBlockingReadLock) {
// subprocess to obtain it.
constexpr absl::Duration kHoldLockFor = absl::Seconds(5);
const int64 kMinBlockTimeUsec = absl::ToInt64Microseconds(absl::Seconds(1));
const int64_t kMinBlockTimeUsec = absl::ToInt64Microseconds(absl::Seconds(1));
absl::SleepFor(kHoldLockFor);
@@ -791,7 +791,7 @@ TEST_F(FcntlLockTest, SetWriteLockThenBlockingReadLock) {
ASSERT_THAT(fcntl(fd.get(), F_SETLKW, &fl), SyscallSucceeds());
// Read the blocked time from the subprocess socket.
int64 subprocess_blocked_time_usec = GetSubprocessFcntlTimeInUsec();
int64_t subprocess_blocked_time_usec = GetSubprocessFcntlTimeInUsec();
// We must have been waiting at least kMinBlockTime.
EXPECT_GT(subprocess_blocked_time_usec, kMinBlockTimeUsec);
+1 -1
View File
@@ -270,7 +270,7 @@ TEST_F(ForkTest, Alarm) {
// Child cannot affect parent private memory.
TEST_F(ForkTest, PrivateMemory) {
std::atomic<uint32> local(0);
std::atomic<uint32_t> local(0);
pid_t child1 = Fork();
if (child1 == 0) {
+1 -1
View File
@@ -112,7 +112,7 @@ int futex_wake_bitset(bool priv, std::atomic<int>* uaddr, int count,
}
int futex_wake_op(bool priv, std::atomic<int>* uaddr1, std::atomic<int>* uaddr2,
int nwake1, int nwake2, uint32 sub_op) {
int nwake1, int nwake2, uint32_t sub_op) {
int op = FUTEX_WAKE_OP;
if (priv) {
op |= FUTEX_PRIVATE_FLAG;
+12 -12
View File
@@ -48,26 +48,26 @@ constexpr int kBufSize = 1024;
// C++-friendly version of struct inotify_event.
struct Event {
int32 wd;
uint32 mask;
uint32 cookie;
uint32 len;
int32_t wd;
uint32_t mask;
uint32_t cookie;
uint32_t len;
std::string name;
Event(uint32 mask, int32 wd, absl::string_view name, uint32 cookie)
Event(uint32_t mask, int32_t wd, absl::string_view name, uint32_t cookie)
: wd(wd),
mask(mask),
cookie(cookie),
len(name.size()),
name(std::string(name)) {}
Event(uint32 mask, int32 wd, absl::string_view name)
Event(uint32_t mask, int32_t wd, absl::string_view name)
: Event(mask, wd, name, 0) {}
Event(uint32 mask, int32 wd) : Event(mask, wd, "", 0) {}
Event(uint32_t mask, int32_t wd) : Event(mask, wd, "", 0) {}
Event() : Event(0, 0, "", 0) {}
};
// Prints the symbolic name for a struct inotify_event's 'mask' field.
std::string FlagString(uint32 flags) {
std::string FlagString(uint32_t flags) {
std::vector<std::string> names;
#define EMIT(target) \
@@ -320,7 +320,7 @@ PosixErrorOr<FileDescriptor> InotifyInit1(int flags) {
}
PosixErrorOr<int> InotifyAddWatch(int fd, const std::string& path,
uint32 mask) {
uint32_t mask) {
int wd;
EXPECT_THAT(wd = inotify_add_watch(fd, path.c_str(), mask),
SyscallSucceeds());
@@ -647,7 +647,7 @@ TEST(Inotify, MoveGeneratesEvents) {
Event(IN_MOVED_TO, root_wd, Basename(newpath), events[1].cookie)}));
EXPECT_NE(events[0].cookie, 0);
EXPECT_EQ(events[0].cookie, events[1].cookie);
uint32 last_cookie = events[0].cookie;
uint32_t last_cookie = events[0].cookie;
// Test move from root -> root/dir1.
newpath = NewTempAbsPathInDir(dir1.path());
@@ -841,7 +841,7 @@ TEST(Inotify, ConcurrentThreadsGeneratingEvents) {
}
auto test_thread = [&files]() {
uint32 seed = time(nullptr);
uint32_t seed = time(nullptr);
for (int i = 0; i < 20; i++) {
const TempPath& file = files[rand_r(&seed) % files.size()];
const FileDescriptor file_fd =
@@ -960,7 +960,7 @@ TEST(Inotify, BlockingReadOnInotifyFd) {
t.Join();
// Make sure the event we got back is sane.
uint32 event_mask;
uint32_t event_mask;
memcpy(&event_mask, buf.data() + offsetof(struct inotify_event, mask),
sizeof(event_mask));
EXPECT_EQ(event_mask, IN_ACCESS);
+2 -2
View File
@@ -24,12 +24,12 @@
namespace gvisor {
namespace testing {
uint32 IPFromInetSockaddr(const struct sockaddr* addr) {
uint32_t IPFromInetSockaddr(const struct sockaddr* addr) {
auto* in_addr = reinterpret_cast<const struct sockaddr_in*>(addr);
return in_addr->sin_addr.s_addr;
}
uint16 PortFromInetSockaddr(const struct sockaddr* addr) {
uint16_t PortFromInetSockaddr(const struct sockaddr* addr) {
auto* in_addr = reinterpret_cast<const struct sockaddr_in*>(addr);
return ntohs(in_addr->sin_port);
}
+2 -2
View File
@@ -27,10 +27,10 @@ namespace gvisor {
namespace testing {
// Extracts the IP address from an inet sockaddr in network byte order.
uint32 IPFromInetSockaddr(const struct sockaddr* addr);
uint32_t IPFromInetSockaddr(const struct sockaddr* addr);
// Extracts the port from an inet sockaddr in host byte order.
uint16 PortFromInetSockaddr(const struct sockaddr* addr);
uint16_t PortFromInetSockaddr(const struct sockaddr* addr);
// InterfaceIndex returns the index of the named interface.
PosixErrorOr<int> InterfaceIndex(std::string name);
+2 -2
View File
@@ -177,8 +177,8 @@ SignalTestResult ItimerSignalTest(int id, clock_t main_clock,
SignalTestResult result;
// Wait for the workers to be done and collect their sample counts.
result.worker_samples.push_back(reinterpret_cast<int64>(th1.Join()));
result.worker_samples.push_back(reinterpret_cast<int64>(th2.Join()));
result.worker_samples.push_back(reinterpret_cast<int64_t>(th1.Join()));
result.worker_samples.push_back(reinterpret_cast<int64_t>(th2.Join()));
cleanup_itimer.Release()();
result.expected_total = (Now(main_clock) - start) / kPeriod;
result.main_thread_samples = signal_test_num_samples.load();
+2 -2
View File
@@ -32,8 +32,8 @@
#include "test/util/test_util.h"
#include "test/util/thread_util.h"
ABSL_FLAG(int32, scratch_uid, 65534, "scratch UID");
ABSL_FLAG(int32, scratch_gid, 65534, "scratch GID");
ABSL_FLAG(int32_t, scratch_uid, 65534, "scratch UID");
ABSL_FLAG(int32_t, scratch_gid, 65534, "scratch GID");
using ::testing::Ge;
+3 -2
View File
@@ -32,7 +32,7 @@
#include "test/util/test_util.h"
#include "test/util/thread_util.h"
ABSL_FLAG(int32, scratch_uid, 65534, "scratch UID");
ABSL_FLAG(int32_t, scratch_uid, 65534, "scratch UID");
namespace gvisor {
namespace testing {
@@ -55,7 +55,8 @@ TEST(LinkTest, CanCreateLinkFile) {
const std::string newname = NewTempAbsPath();
// Get the initial link count.
uint64 initial_link_count = ASSERT_NO_ERRNO_AND_VALUE(Links(oldfile.path()));
uint64_t initial_link_count =
ASSERT_NO_ERRNO_AND_VALUE(Links(oldfile.path()));
EXPECT_THAT(link(oldfile.path().c_str(), newname.c_str()), SyscallSucceeds());
+1 -1
View File
@@ -61,7 +61,7 @@ int memfd_create(const std::string& name, unsigned int flags) {
}
PosixErrorOr<FileDescriptor> MemfdCreate(const std::string& name,
uint32 flags) {
uint32_t flags) {
int fd = memfd_create(name, flags);
if (fd < 0) {
return PosixError(
+7 -7
View File
@@ -33,7 +33,7 @@ using ::absl::StrFormat;
// AnonUsageFromMeminfo scrapes the current anonymous memory usage from
// /proc/meminfo and returns it in bytes.
PosixErrorOr<uint64> AnonUsageFromMeminfo() {
PosixErrorOr<uint64_t> AnonUsageFromMeminfo() {
ASSIGN_OR_RETURN_ERRNO(auto meminfo, GetContents("/proc/meminfo"));
std::vector<std::string> lines(absl::StrSplit(meminfo, '\n'));
@@ -47,7 +47,7 @@ PosixErrorOr<uint64> AnonUsageFromMeminfo() {
absl::StrSplit(line, ' ', absl::SkipEmpty()));
if (parts.size() == 3) {
// The size is the second field, let's try to parse it as a number.
ASSIGN_OR_RETURN_ERRNO(auto anon_kb, Atoi<uint64>(parts[1]));
ASSIGN_OR_RETURN_ERRNO(auto anon_kb, Atoi<uint64_t>(parts[1]));
return anon_kb * 1024;
}
@@ -65,10 +65,10 @@ TEST(MemoryAccounting, AnonAccountingPreservedOnSaveRestore) {
// the test.
SKIP_IF(!IsRunningOnGvisor());
uint64 anon_initial = ASSERT_NO_ERRNO_AND_VALUE(AnonUsageFromMeminfo());
uint64_t anon_initial = ASSERT_NO_ERRNO_AND_VALUE(AnonUsageFromMeminfo());
// Cause some anonymous memory usage.
uint64 map_bytes = Megabytes(512);
uint64_t map_bytes = Megabytes(512);
char* mem =
static_cast<char*>(mmap(nullptr, map_bytes, PROT_READ | PROT_WRITE,
MAP_POPULATE | MAP_ANON | MAP_PRIVATE, -1, 0));
@@ -77,11 +77,11 @@ TEST(MemoryAccounting, AnonAccountingPreservedOnSaveRestore) {
// Write something to each page to prevent them from being decommited on
// S/R. Zero pages are dropped on save.
for (uint64 i = 0; i < map_bytes; i += kPageSize) {
for (uint64_t i = 0; i < map_bytes; i += kPageSize) {
mem[i] = 'a';
}
uint64 anon_after_alloc = ASSERT_NO_ERRNO_AND_VALUE(AnonUsageFromMeminfo());
uint64_t anon_after_alloc = ASSERT_NO_ERRNO_AND_VALUE(AnonUsageFromMeminfo());
EXPECT_THAT(anon_after_alloc,
EquivalentWithin(anon_initial + map_bytes, 0.03));
@@ -90,7 +90,7 @@ TEST(MemoryAccounting, AnonAccountingPreservedOnSaveRestore) {
MaybeSave();
// Usage should remain the same across S/R.
uint64 anon_after_sr = ASSERT_NO_ERRNO_AND_VALUE(AnonUsageFromMeminfo());
uint64_t anon_after_sr = ASSERT_NO_ERRNO_AND_VALUE(AnonUsageFromMeminfo());
EXPECT_THAT(anon_after_sr, EquivalentWithin(anon_after_alloc, 0.03));
}
+14 -14
View File
@@ -43,12 +43,12 @@ namespace {
#define MPOL_MF_MOVE (1 << 1)
#define MPOL_MF_MOVE_ALL (1 << 2)
int get_mempolicy(int *policy, uint64 *nmask, uint64 maxnode, void *addr,
int get_mempolicy(int *policy, uint64_t *nmask, uint64_t maxnode, void *addr,
int flags) {
return syscall(SYS_get_mempolicy, policy, nmask, maxnode, addr, flags);
}
int set_mempolicy(int mode, uint64 *nmask, uint64 maxnode) {
int set_mempolicy(int mode, uint64_t *nmask, uint64_t maxnode) {
return syscall(SYS_set_mempolicy, mode, nmask, maxnode);
}
@@ -68,8 +68,8 @@ Cleanup ScopedMempolicy() {
// Temporarily change the memory policy for the calling thread within the
// caller's scope.
PosixErrorOr<Cleanup> ScopedSetMempolicy(int mode, uint64 *nmask,
uint64 maxnode) {
PosixErrorOr<Cleanup> ScopedSetMempolicy(int mode, uint64_t *nmask,
uint64_t maxnode) {
if (set_mempolicy(mode, nmask, maxnode)) {
return PosixError(errno, "set_mempolicy");
}
@@ -78,7 +78,7 @@ PosixErrorOr<Cleanup> ScopedSetMempolicy(int mode, uint64 *nmask,
TEST(MempolicyTest, CheckDefaultPolicy) {
int mode = 0;
uint64 nodemask = 0;
uint64_t nodemask = 0;
ASSERT_THAT(get_mempolicy(&mode, &nodemask, sizeof(nodemask) * BITS_PER_BYTE,
nullptr, 0),
SyscallSucceeds());
@@ -88,12 +88,12 @@ TEST(MempolicyTest, CheckDefaultPolicy) {
}
TEST(MempolicyTest, PolicyPreservedAfterSetMempolicy) {
uint64 nodemask = 0x1;
uint64_t nodemask = 0x1;
auto cleanup = ASSERT_NO_ERRNO_AND_VALUE(ScopedSetMempolicy(
MPOL_BIND, &nodemask, sizeof(nodemask) * BITS_PER_BYTE));
int mode = 0;
uint64 nodemask_after = 0x0;
uint64_t nodemask_after = 0x0;
ASSERT_THAT(get_mempolicy(&mode, &nodemask_after,
sizeof(nodemask_after) * BITS_PER_BYTE, nullptr, 0),
SyscallSucceeds());
@@ -118,7 +118,7 @@ TEST(MempolicyTest, PolicyPreservedAfterSetMempolicy) {
TEST(MempolicyTest, SetMempolicyRejectsInvalidInputs) {
auto cleanup = ScopedMempolicy();
uint64 nodemask;
uint64_t nodemask;
if (IsRunningOnGvisor()) {
// Invalid nodemask, we only support a single node on gvisor.
@@ -165,7 +165,7 @@ TEST(MempolicyTest, EmptyNodemaskOnSet) {
SyscallFailsWithErrno(EINVAL));
EXPECT_THAT(set_mempolicy(MPOL_PREFERRED, nullptr, 1), SyscallSucceeds());
uint64 nodemask = 0x1;
uint64_t nodemask = 0x1;
EXPECT_THAT(set_mempolicy(MPOL_DEFAULT, &nodemask, 0),
SyscallFailsWithErrno(EINVAL));
EXPECT_THAT(set_mempolicy(MPOL_BIND, &nodemask, 0),
@@ -175,7 +175,7 @@ TEST(MempolicyTest, EmptyNodemaskOnSet) {
}
TEST(MempolicyTest, QueryAvailableNodes) {
uint64 nodemask = 0;
uint64_t nodemask = 0;
ASSERT_THAT(
get_mempolicy(nullptr, &nodemask, sizeof(nodemask) * BITS_PER_BYTE,
nullptr, MPOL_F_MEMS_ALLOWED),
@@ -197,8 +197,8 @@ TEST(MempolicyTest, QueryAvailableNodes) {
}
TEST(MempolicyTest, GetMempolicyQueryNodeForAddress) {
uint64 dummy_stack_address;
auto dummy_heap_address = absl::make_unique<uint64>();
uint64_t dummy_stack_address;
auto dummy_heap_address = absl::make_unique<uint64_t>();
int mode;
for (auto ptr : {&dummy_stack_address, dummy_heap_address.get()}) {
@@ -228,7 +228,7 @@ TEST(MempolicyTest, GetMempolicyQueryNodeForAddress) {
TEST(MempolicyTest, GetMempolicyCanOmitPointers) {
int mode;
uint64 nodemask;
uint64_t nodemask;
// Omit nodemask pointer.
ASSERT_THAT(get_mempolicy(&mode, nullptr, 0, nullptr, 0), SyscallSucceeds());
@@ -249,7 +249,7 @@ TEST(MempolicyTest, GetMempolicyNextInterleaveNode) {
SyscallFailsWithErrno(EINVAL));
// Set default policy for thread to MPOL_INTERLEAVE.
uint64 nodemask = 0x1;
uint64_t nodemask = 0x1;
auto cleanup = ASSERT_NO_ERRNO_AND_VALUE(ScopedSetMempolicy(
MPOL_INTERLEAVE, &nodemask, sizeof(nodemask) * BITS_PER_BYTE));

Some files were not shown because too many files have changed in this diff Show More