mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Merge pull request #1492 from majek:err_typo_in_netstack_tests
PiperOrigin-RevId: 290840370
This commit is contained in:
@@ -164,7 +164,7 @@ func main() {
|
||||
// Create TCP endpoint.
|
||||
var wq waiter.Queue
|
||||
ep, e := s.NewEndpoint(tcp.ProtocolNumber, ipv4.ProtocolNumber, &wq)
|
||||
if err != nil {
|
||||
if e != nil {
|
||||
log.Fatal(e)
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ func main() {
|
||||
// Create TCP endpoint, bind it, then start listening.
|
||||
var wq waiter.Queue
|
||||
ep, e := s.NewEndpoint(tcp.ProtocolNumber, proto, &wq)
|
||||
if err != nil {
|
||||
if e != nil {
|
||||
log.Fatal(e)
|
||||
}
|
||||
|
||||
|
||||
@@ -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_t>(&cb));
|
||||
EXPECT_EQ(events[0].obj, reinterpret_cast<uint64>(&cb));
|
||||
EXPECT_LT(events[0].res, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
#include "test/util/test_util.h"
|
||||
#include "test/util/thread_util.h"
|
||||
|
||||
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");
|
||||
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");
|
||||
|
||||
namespace gvisor {
|
||||
namespace testing {
|
||||
|
||||
@@ -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_t>(foo_map), SyscallSucceeds());
|
||||
ASSERT_THAT(reinterpret_cast<int64>(foo_map), SyscallSucceeds());
|
||||
|
||||
// Always unmap.
|
||||
auto cleanup_map = Cleanup(
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace testing {
|
||||
|
||||
namespace {
|
||||
|
||||
int64_t clock_gettime_nsecs(clockid_t id) {
|
||||
int64 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_t 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_t ns) {
|
||||
int64_t start = clock_gettime_nsecs(CLOCK_THREAD_CPUTIME_ID);
|
||||
int64_t end = start + ns;
|
||||
void spin_ns(int64 ns) {
|
||||
int64 start = clock_gettime_nsecs(CLOCK_THREAD_CPUTIME_ID);
|
||||
int64 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_t start = clock_gettime_nsecs(CLOCK_PROCESS_CPUTIME_ID);
|
||||
int64 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_t end = clock_gettime_nsecs(CLOCK_PROCESS_CPUTIME_ID);
|
||||
int64 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.
|
||||
|
||||
@@ -37,7 +37,7 @@ TEST(EventfdTest, Nonblock) {
|
||||
FileDescriptor efd =
|
||||
ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, EFD_NONBLOCK | EFD_SEMAPHORE));
|
||||
|
||||
uint64_t l;
|
||||
uint64 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_t l;
|
||||
uint64 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_t l = 1;
|
||||
uint64 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_t l = 16;
|
||||
uint64 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_t l = 1;
|
||||
uint64 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_t big[16];
|
||||
uint64 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_t l = 1;
|
||||
uint64 l = 1;
|
||||
ASSERT_THAT(write(efd.get(), &l, sizeof(l)), SyscallSucceeds());
|
||||
|
||||
uint64_t big[16];
|
||||
uint64 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_t l[16];
|
||||
uint64 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_t val = 0;
|
||||
uint64 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_t val = 1;
|
||||
uint64 val = 1;
|
||||
EXPECT_THAT(write(efd.get(), &val, sizeof(val)),
|
||||
SyscallSucceedsWithValue(sizeof(val)));
|
||||
});
|
||||
|
||||
@@ -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_t kX87ControlWordDefault = 0x37f;
|
||||
constexpr uint16 kX87ControlWordDefault = 0x37f;
|
||||
|
||||
// Mask for the divide-by-zero exception.
|
||||
constexpr uint16_t kX87ControlWordDiv0Mask = 1 << 2;
|
||||
constexpr uint16 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_t kMXCSRDefault = 0x1f80;
|
||||
constexpr uint32 kMXCSRDefault = 0x1f80;
|
||||
|
||||
// Mask for the divide-by-zero exception.
|
||||
constexpr uint32_t kMXCSRDiv0Mask = 1 << 9;
|
||||
constexpr uint32 kMXCSRDiv0Mask = 1 << 9;
|
||||
|
||||
// Flag for a pending divide-by-zero exception.
|
||||
constexpr uint32_t kMXCSRDiv0Flag = 1 << 2;
|
||||
constexpr uint32 kMXCSRDiv0Flag = 1 << 2;
|
||||
|
||||
void inline Halt() { asm("hlt\r\n"); }
|
||||
|
||||
@@ -112,10 +112,10 @@ TEST(ExceptionTest, DivideByZero) {
|
||||
|
||||
EXPECT_EXIT(
|
||||
{
|
||||
uint32_t remainder;
|
||||
uint32_t quotient;
|
||||
uint32_t divisor = 0;
|
||||
uint64_t value = 1;
|
||||
uint32 remainder;
|
||||
uint32 quotient;
|
||||
uint32 divisor = 0;
|
||||
uint64 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_t quotient;
|
||||
int32_t value = 1;
|
||||
int32_t divisor = 0;
|
||||
int32 quotient;
|
||||
int32 value = 1;
|
||||
int32 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_t kControlWord =
|
||||
constexpr uint16 kControlWord =
|
||||
kX87ControlWordDefault & ~kX87ControlWordDiv0Mask;
|
||||
|
||||
int32_t quotient;
|
||||
int32_t value = 1;
|
||||
int32_t divisor = 0;
|
||||
int32 quotient;
|
||||
int32 value = 1;
|
||||
int32 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_t kControlWord =
|
||||
constexpr uint16 kControlWord =
|
||||
kX87ControlWordDefault & ~kX87ControlWordDiv0Mask;
|
||||
|
||||
int32_t quotient;
|
||||
int32_t value = 1;
|
||||
int32_t divisor = 0;
|
||||
int32 quotient;
|
||||
int32 value = 1;
|
||||
int32 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_t status;
|
||||
int32_t quotient;
|
||||
int32_t value = 1;
|
||||
int32_t divisor = 0;
|
||||
uint32 status;
|
||||
int32 quotient;
|
||||
int32 value = 1;
|
||||
int32 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_t kMXCSR = kMXCSRDefault & ~kMXCSRDiv0Mask;
|
||||
constexpr uint32 kMXCSR = kMXCSRDefault & ~kMXCSRDiv0Mask;
|
||||
|
||||
int32_t quotient;
|
||||
int32_t value = 1;
|
||||
int32_t divisor = 0;
|
||||
int32 quotient;
|
||||
int32 value = 1;
|
||||
int32 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_t mxcsr;
|
||||
int32_t quotient;
|
||||
int32_t value = 1;
|
||||
int32_t divisor = 0;
|
||||
uint32 mxcsr;
|
||||
int32 quotient;
|
||||
int32 value = 1;
|
||||
int32 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_t* ptr = reinterpret_cast<uint64_t*>(&array[i]);
|
||||
uint64* ptr = reinterpret_cast<uint64*>(&array[i]);
|
||||
asm("mov %0, 0(%0)\r\n" : : "r"(ptr) : "ax");
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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_t> dirfd,
|
||||
void CheckExecHelper(const absl::optional<int32> 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_t> 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_t>(), filename, argv, envv,
|
||||
CheckExecHelper(/*dirfd=*/absl::optional<int32>(), filename, argv, envv,
|
||||
/*flags=*/0, expect_status, expect_stderr);
|
||||
}
|
||||
|
||||
void CheckExecveat(const int32_t dirfd, const std::string& pathname,
|
||||
void CheckExecveat(const int32 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_t>(dirfd), pathname, argv, envv, flags,
|
||||
CheckExecHelper(absl::optional<int32>(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_t badFD = -1;
|
||||
const int32 badFD = -1;
|
||||
CheckExecveat(badFD, path, {path}, {}, ArgEnvExitStatus(0, 0), 0,
|
||||
absl::StrCat(path, "\n"));
|
||||
}
|
||||
|
||||
@@ -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_t offset = elf.phdrs[1].p_offset;
|
||||
const uint64 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, ®s), SyscallSucceeds());
|
||||
|
||||
const uint64_t load_addr = regs.rip & ~(kPageSize - 1);
|
||||
const uint64 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, ®s), SyscallSucceeds());
|
||||
|
||||
const uint64_t load_addr = regs.rip & ~(kPageSize - 1);
|
||||
const uint64 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_t const offset = interpreter.phdrs[1].p_offset;
|
||||
uint64 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, ®s), SyscallSucceeds());
|
||||
|
||||
const uint64_t interp_load_addr = regs.rip & ~(kPageSize - 1);
|
||||
const uint64 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_t const offset = interpreter.phdrs[1].p_offset;
|
||||
uint64 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, ®s), SyscallSucceeds());
|
||||
|
||||
const uint64_t interp_load_addr = regs.rip & ~(kPageSize - 1);
|
||||
const uint64 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_t const offset = interpreter.phdrs[1].p_offset;
|
||||
uint64 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_t const offset = interpreter.phdrs[1].p_offset;
|
||||
uint64 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;
|
||||
|
||||
@@ -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_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,
|
||||
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,
|
||||
"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_t GetSubprocessFcntlTimeInUsec() {
|
||||
int64_t ret = 0;
|
||||
int64 GetSubprocessFcntlTimeInUsec() {
|
||||
int64 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_t kMinBlockTimeUsec = absl::ToInt64Microseconds(absl::Seconds(1));
|
||||
const int64 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_t subprocess_blocked_time_usec = GetSubprocessFcntlTimeInUsec();
|
||||
int64 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_t kMinBlockTimeUsec = absl::ToInt64Microseconds(absl::Seconds(1));
|
||||
const int64 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_t subprocess_blocked_time_usec = GetSubprocessFcntlTimeInUsec();
|
||||
int64 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_t kMinBlockTimeUsec = absl::ToInt64Microseconds(absl::Seconds(1));
|
||||
const int64 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_t subprocess_blocked_time_usec = GetSubprocessFcntlTimeInUsec();
|
||||
int64 subprocess_blocked_time_usec = GetSubprocessFcntlTimeInUsec();
|
||||
|
||||
// We must have been waiting at least kMinBlockTime.
|
||||
EXPECT_GT(subprocess_blocked_time_usec, kMinBlockTimeUsec);
|
||||
|
||||
@@ -270,7 +270,7 @@ TEST_F(ForkTest, Alarm) {
|
||||
|
||||
// Child cannot affect parent private memory.
|
||||
TEST_F(ForkTest, PrivateMemory) {
|
||||
std::atomic<uint32_t> local(0);
|
||||
std::atomic<uint32> local(0);
|
||||
|
||||
pid_t child1 = Fork();
|
||||
if (child1 == 0) {
|
||||
|
||||
@@ -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_t sub_op) {
|
||||
int nwake1, int nwake2, uint32 sub_op) {
|
||||
int op = FUTEX_WAKE_OP;
|
||||
if (priv) {
|
||||
op |= FUTEX_PRIVATE_FLAG;
|
||||
|
||||
@@ -48,26 +48,26 @@ constexpr int kBufSize = 1024;
|
||||
|
||||
// C++-friendly version of struct inotify_event.
|
||||
struct Event {
|
||||
int32_t wd;
|
||||
uint32_t mask;
|
||||
uint32_t cookie;
|
||||
uint32_t len;
|
||||
int32 wd;
|
||||
uint32 mask;
|
||||
uint32 cookie;
|
||||
uint32 len;
|
||||
std::string name;
|
||||
|
||||
Event(uint32_t mask, int32_t wd, absl::string_view name, uint32_t cookie)
|
||||
Event(uint32 mask, int32 wd, absl::string_view name, uint32 cookie)
|
||||
: wd(wd),
|
||||
mask(mask),
|
||||
cookie(cookie),
|
||||
len(name.size()),
|
||||
name(std::string(name)) {}
|
||||
Event(uint32_t mask, int32_t wd, absl::string_view name)
|
||||
Event(uint32 mask, int32 wd, absl::string_view name)
|
||||
: Event(mask, wd, name, 0) {}
|
||||
Event(uint32_t mask, int32_t wd) : Event(mask, wd, "", 0) {}
|
||||
Event(uint32 mask, int32 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_t flags) {
|
||||
std::string FlagString(uint32 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_t mask) {
|
||||
uint32 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_t last_cookie = events[0].cookie;
|
||||
uint32 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_t seed = time(nullptr);
|
||||
uint32 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_t event_mask;
|
||||
uint32 event_mask;
|
||||
memcpy(&event_mask, buf.data() + offsetof(struct inotify_event, mask),
|
||||
sizeof(event_mask));
|
||||
EXPECT_EQ(event_mask, IN_ACCESS);
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
namespace gvisor {
|
||||
namespace testing {
|
||||
|
||||
uint32_t IPFromInetSockaddr(const struct sockaddr* addr) {
|
||||
uint32 IPFromInetSockaddr(const struct sockaddr* addr) {
|
||||
auto* in_addr = reinterpret_cast<const struct sockaddr_in*>(addr);
|
||||
return in_addr->sin_addr.s_addr;
|
||||
}
|
||||
|
||||
uint16_t PortFromInetSockaddr(const struct sockaddr* addr) {
|
||||
uint16 PortFromInetSockaddr(const struct sockaddr* addr) {
|
||||
auto* in_addr = reinterpret_cast<const struct sockaddr_in*>(addr);
|
||||
return ntohs(in_addr->sin_port);
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ namespace gvisor {
|
||||
namespace testing {
|
||||
|
||||
// Extracts the IP address from an inet sockaddr in network byte order.
|
||||
uint32_t IPFromInetSockaddr(const struct sockaddr* addr);
|
||||
uint32 IPFromInetSockaddr(const struct sockaddr* addr);
|
||||
|
||||
// Extracts the port from an inet sockaddr in host byte order.
|
||||
uint16_t PortFromInetSockaddr(const struct sockaddr* addr);
|
||||
uint16 PortFromInetSockaddr(const struct sockaddr* addr);
|
||||
|
||||
// InterfaceIndex returns the index of the named interface.
|
||||
PosixErrorOr<int> InterfaceIndex(std::string name);
|
||||
|
||||
@@ -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_t>(th1.Join()));
|
||||
result.worker_samples.push_back(reinterpret_cast<int64_t>(th2.Join()));
|
||||
result.worker_samples.push_back(reinterpret_cast<int64>(th1.Join()));
|
||||
result.worker_samples.push_back(reinterpret_cast<int64>(th2.Join()));
|
||||
cleanup_itimer.Release()();
|
||||
result.expected_total = (Now(main_clock) - start) / kPeriod;
|
||||
result.main_thread_samples = signal_test_num_samples.load();
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
#include "test/util/test_util.h"
|
||||
#include "test/util/thread_util.h"
|
||||
|
||||
ABSL_FLAG(int32_t, scratch_uid, 65534, "scratch UID");
|
||||
ABSL_FLAG(int32_t, scratch_gid, 65534, "scratch GID");
|
||||
ABSL_FLAG(int32, scratch_uid, 65534, "scratch UID");
|
||||
ABSL_FLAG(int32, scratch_gid, 65534, "scratch GID");
|
||||
|
||||
using ::testing::Ge;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "test/util/test_util.h"
|
||||
#include "test/util/thread_util.h"
|
||||
|
||||
ABSL_FLAG(int32_t, scratch_uid, 65534, "scratch UID");
|
||||
ABSL_FLAG(int32, scratch_uid, 65534, "scratch UID");
|
||||
|
||||
namespace gvisor {
|
||||
namespace testing {
|
||||
@@ -55,7 +55,7 @@ TEST(LinkTest, CanCreateLinkFile) {
|
||||
const std::string newname = NewTempAbsPath();
|
||||
|
||||
// Get the initial link count.
|
||||
uint64_t initial_link_count = ASSERT_NO_ERRNO_AND_VALUE(Links(oldfile.path()));
|
||||
uint64 initial_link_count = ASSERT_NO_ERRNO_AND_VALUE(Links(oldfile.path()));
|
||||
|
||||
EXPECT_THAT(link(oldfile.path().c_str(), newname.c_str()), SyscallSucceeds());
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ int memfd_create(const std::string& name, unsigned int flags) {
|
||||
}
|
||||
|
||||
PosixErrorOr<FileDescriptor> MemfdCreate(const std::string& name,
|
||||
uint32_t flags) {
|
||||
uint32 flags) {
|
||||
int fd = memfd_create(name, flags);
|
||||
if (fd < 0) {
|
||||
return PosixError(
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user