Skip to content

Commit

Permalink
Remove a test that no longer makes sense.
Browse files Browse the repository at this point in the history
This test passed with default TCMalloc, but only because of
implementation details of how TCMalloc worked, and it failed on ASAN
and Windows.

The reserve-single API no longer uses the free-list (unlike previous
revisions of this PR), and unused slices are no longer stored in
OwnedImpl as empty slices (unlike the code before this PR).

Therefore, there are no guarantees about which specific slice memory
is used between un-committed reservations; the result is determined by
the malloc implementation, and there is no good reason to write a test
for what that behavior may be.

Signed-off-by: Greg Greenway <ggreenway@apple.com>
  • Loading branch information
ggreenway committed Jan 27, 2021
1 parent 97bd65b commit 7b94c6f
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions test/common/buffer/owned_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -907,53 +907,6 @@ TEST_F(OwnedImplTest, ReserveCommitReuse) {
expectSlices({{8001, 4287, 12288}}, buffer);
}

TEST_F(OwnedImplTest, ReserveReuse) {
Buffer::OwnedImpl buffer;

// Test a zero-length reservation and commit.
{
auto reservation = buffer.reserveSingleSlice(0);
reservation.commit(0);
}

// Reserve some space and leave it uncommitted.
const void* first_slice;
{
auto reservation = buffer.reserveSingleSlice(8200);
first_slice = reservation.slice().mem_;
}

// Reserve more space and verify that it is not the same slice from the last reservation.
// That one was for a different size and was not committed.
const void* second_slice;
{
auto reservation = buffer.reserveSingleSlice(Slice::default_slice_size_);
EXPECT_NE(first_slice, reservation.slice().mem_);
second_slice = reservation.slice().mem_;
}

// Repeat the last reservation and verify that it yields the same slices. Both slices
// are for the default size, so the previous one should get re-used.
{
auto reservation = buffer.reserveSingleSlice(Slice::default_slice_size_);
EXPECT_EQ(second_slice, reservation.slice().mem_);

// Commit the most recent reservation and verify the representation.
reservation.commit(Slice::default_slice_size_);
expectSlices({{16384, 0, 16384}}, buffer);
}

// Do another reservation.
{
auto reservation = buffer.reserveSingleSlice(Slice::default_slice_size_);
expectSlices({{16384, 0, 16384}}, buffer);

// And commit.
reservation.commit(Slice::default_slice_size_);
expectSlices({{16384, 0, 16384}, {16384, 0, 16384}}, buffer);
}
}

// Test behavior when the size to commit() is larger than the reservation.
TEST_F(OwnedImplTest, ReserveOverCommit) {
Buffer::OwnedImpl buffer;
Expand Down

0 comments on commit 7b94c6f

Please sign in to comment.