Skip to content

Commit

Permalink
Fix a few warnings (signed/unsigned comparison in gtest, and missing …
Browse files Browse the repository at this point in the history
…field initializers)
  • Loading branch information
dwblaikie committed Oct 17, 2021
1 parent 40b9c39 commit 6176fda
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
42 changes: 21 additions & 21 deletions compiler-rt/lib/gwp_asan/tests/alignment.cpp
Expand Up @@ -34,81 +34,81 @@ class AlignmentTestGPA : public gwp_asan::GuardedPoolAllocator {
// numerics of the testing.
TEST(AlignmentTest, LeftAlignedAllocs) {
// Alignment < Page Size.
EXPECT_EQ(0x4000, AlignmentTestGPA::alignUp(
EXPECT_EQ(0x4000u, AlignmentTestGPA::alignUp(
/* Ptr */ 0x4000, /* Alignment */ 0x1));
// Alignment == Page Size.
EXPECT_EQ(0x4000, AlignmentTestGPA::alignUp(
EXPECT_EQ(0x4000u, AlignmentTestGPA::alignUp(
/* Ptr */ 0x4000, /* Alignment */ 0x1000));
// Alignment > Page Size.
EXPECT_EQ(0x4000, AlignmentTestGPA::alignUp(
EXPECT_EQ(0x4000u, AlignmentTestGPA::alignUp(
/* Ptr */ 0x4000, /* Alignment */ 0x4000));
}

TEST(AlignmentTest, SingleByteAllocs) {
// Alignment < Page Size.
EXPECT_EQ(0x1,
EXPECT_EQ(0x1u,
AlignmentTestGPA::getRequiredBackingSize(
/* Size */ 0x1, /* Alignment */ 0x1, /* PageSize */ 0x1000));
EXPECT_EQ(0x7fff, AlignmentTestGPA::alignDown(
EXPECT_EQ(0x7fffu, AlignmentTestGPA::alignDown(
/* Ptr */ 0x8000 - 0x1, /* Alignment */ 0x1));

// Alignment == Page Size.
EXPECT_EQ(0x1,
EXPECT_EQ(0x1u,
AlignmentTestGPA::getRequiredBackingSize(
/* Size */ 0x1, /* Alignment */ 0x1000, /* PageSize */ 0x1000));
EXPECT_EQ(0x7000, AlignmentTestGPA::alignDown(
EXPECT_EQ(0x7000u, AlignmentTestGPA::alignDown(
/* Ptr */ 0x8000 - 0x1, /* Alignment */ 0x1000));

// Alignment > Page Size.
EXPECT_EQ(0x3001,
EXPECT_EQ(0x3001u,
AlignmentTestGPA::getRequiredBackingSize(
/* Size */ 0x1, /* Alignment */ 0x4000, /* PageSize */ 0x1000));
EXPECT_EQ(0x4000, AlignmentTestGPA::alignDown(
EXPECT_EQ(0x4000u, AlignmentTestGPA::alignDown(
/* Ptr */ 0x8000 - 0x1, /* Alignment */ 0x4000));
}

TEST(AlignmentTest, PageSizedAllocs) {
// Alignment < Page Size.
EXPECT_EQ(0x1000,
EXPECT_EQ(0x1000u,
AlignmentTestGPA::getRequiredBackingSize(
/* Size */ 0x1000, /* Alignment */ 0x1, /* PageSize */ 0x1000));
EXPECT_EQ(0x7000, AlignmentTestGPA::alignDown(
EXPECT_EQ(0x7000u, AlignmentTestGPA::alignDown(
/* Ptr */ 0x8000 - 0x1000, /* Alignment */ 0x1));

// Alignment == Page Size.
EXPECT_EQ(0x1000, AlignmentTestGPA::getRequiredBackingSize(
EXPECT_EQ(0x1000u, AlignmentTestGPA::getRequiredBackingSize(
/* Size */ 0x1000, /* Alignment */ 0x1000,
/* PageSize */ 0x1000));
EXPECT_EQ(0x7000, AlignmentTestGPA::alignDown(
EXPECT_EQ(0x7000u, AlignmentTestGPA::alignDown(
/* Ptr */ 0x8000 - 0x1000, /* Alignment */ 0x1000));

// Alignment > Page Size.
EXPECT_EQ(0x4000, AlignmentTestGPA::getRequiredBackingSize(
EXPECT_EQ(0x4000u, AlignmentTestGPA::getRequiredBackingSize(
/* Size */ 0x1000, /* Alignment */ 0x4000,
/* PageSize */ 0x1000));
EXPECT_EQ(0x4000, AlignmentTestGPA::alignDown(
EXPECT_EQ(0x4000u, AlignmentTestGPA::alignDown(
/* Ptr */ 0x8000 - 0x1000, /* Alignment */ 0x4000));
}

TEST(AlignmentTest, MoreThanPageAllocs) {
// Alignment < Page Size.
EXPECT_EQ(0x2fff,
EXPECT_EQ(0x2fffu,
AlignmentTestGPA::getRequiredBackingSize(
/* Size */ 0x2fff, /* Alignment */ 0x1, /* PageSize */ 0x1000));
EXPECT_EQ(0x5001, AlignmentTestGPA::alignDown(
EXPECT_EQ(0x5001u, AlignmentTestGPA::alignDown(
/* Ptr */ 0x8000 - 0x2fff, /* Alignment */ 0x1));

// Alignment == Page Size.
EXPECT_EQ(0x2fff, AlignmentTestGPA::getRequiredBackingSize(
EXPECT_EQ(0x2fffu, AlignmentTestGPA::getRequiredBackingSize(
/* Size */ 0x2fff, /* Alignment */ 0x1000,
/* PageSize */ 0x1000));
EXPECT_EQ(0x5000, AlignmentTestGPA::alignDown(
EXPECT_EQ(0x5000u, AlignmentTestGPA::alignDown(
/* Ptr */ 0x8000 - 0x2fff, /* Alignment */ 0x1000));

// Alignment > Page Size.
EXPECT_EQ(0x5fff, AlignmentTestGPA::getRequiredBackingSize(
EXPECT_EQ(0x5fffu, AlignmentTestGPA::getRequiredBackingSize(
/* Size */ 0x2fff, /* Alignment */ 0x4000,
/* PageSize */ 0x1000));
EXPECT_EQ(0x4000, AlignmentTestGPA::alignDown(
EXPECT_EQ(0x4000u, AlignmentTestGPA::alignDown(
/* Ptr */ 0x8000 - 0x2fff, /* Alignment */ 0x4000));
}
Expand Up @@ -130,22 +130,22 @@ static struct StackDepotBenchmarkParams {
bool UseCount;
} params[] = {
// All traces are unique, very unusual.
{10000000, 1, 1},
{8000000, 1, 4},
{8000000, 1, 16},
{10000000, 1, 1, false, false},
{8000000, 1, 4, false, false},
{8000000, 1, 16, false, false},
// Probably most realistic sets.
{3000000, 10, 1},
{3000000, 10, 4},
{3000000, 10, 16},
{3000000, 10, 1, false, false},
{3000000, 10, 4, false, false},
{3000000, 10, 16, false, false},
// Update use count as msan/dfsan.
{3000000, 10, 1, false, true},
{3000000, 10, 4, false, true},
{3000000, 10, 16, false, true},
// Unrealistic, as above, but traces are unique inside of thread.
{4000000, 1, 4, true},
{2000000, 1, 16, true},
{2000000, 10, 4, true},
{500000, 10, 16, true},
{4000000, 1, 4, true, false},
{2000000, 1, 16, true, false},
{2000000, 10, 4, true, false},
{500000, 10, 16, true, false},
{1500000, 10, 4, true, true},
{800000, 10, 16, true, true},
};
Expand Down

0 comments on commit 6176fda

Please sign in to comment.