Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request google#1492 from majek:err_typo_in_netstack_tests
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 290840370
  • Loading branch information
gvisor-bot committed Jan 22, 2020
2 parents b3405a7 + 200cf24 commit 45a8edb
Show file tree
Hide file tree
Showing 74 changed files with 473 additions and 473 deletions.
2 changes: 1 addition & 1 deletion pkg/tcpip/sample/tun_tcp_connect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/tcpip/sample/tun_tcp_echo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion test/syscalls/linux/aio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions test/syscalls/linux/chown.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/syscalls/linux/chroot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 6 additions & 6 deletions test/syscalls/linux/clock_gettime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ 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);
}

// 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
Expand All @@ -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;
Expand All @@ -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.
Expand Down
22 changes: 11 additions & 11 deletions test/syscalls/linux/eventfd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)));
Expand All @@ -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);

Expand All @@ -85,15 +85,15 @@ 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));
}

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;
Expand All @@ -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());
}
Expand All @@ -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);
}
Expand All @@ -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());
Expand All @@ -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);

Expand All @@ -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)));
});
Expand Down
66 changes: 33 additions & 33 deletions test/syscalls/linux/exceptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"); }

Expand Down Expand Up @@ -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));
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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");
}
},
Expand Down
10 changes: 5 additions & 5 deletions test/syscalls/linux/exec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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"));
}
Expand Down
Loading

0 comments on commit 45a8edb

Please sign in to comment.