MCPcopy Create free account
hub / github.com/facebook/CacheLib / TEST_F

Function TEST_F

cachelib/allocator/memory/tests/MemoryPoolTest.cpp:41–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39constexpr size_t SerializationBufferSize = 100 * 1024;
40
41TEST_F(MemoryPoolTest, Create) {
42 auto slabAlloc = createSlabAllocator(10);
43 auto usable = slabAlloc->getNumUsableSlabs();
44 size_t poolSize = usable * Slab::kSize;
45
46 // random alloc sizes.
47 auto allocSizes = getRandomAllocSizes(10);
48 PoolId id = 5;
49
50 ASSERT_NO_THROW(MemoryPool(id, poolSize, *slabAlloc, allocSizes));
51
52 // empty allocSizes must throw
53 std::set<uint32_t> invalidAllocSizes;
54 ASSERT_THROW(MemoryPool(id, poolSize, *slabAlloc, invalidAllocSizes),
55 std::invalid_argument);
56
57 // allocSize with any size more than Slab::kSize must throw as well.
58 invalidAllocSizes = allocSizes;
59 invalidAllocSizes.insert(Slab::kSize + getRandomAllocSize());
60
61 ASSERT_THROW(MemoryPool(id, poolSize, *slabAlloc, invalidAllocSizes),
62 std::invalid_argument);
63}
64
65// allocate memory across the entire size ranges and ensure that the
66// allocations succeed.

Callers

nothing calls this directly

Calls 15

getRandomAllocSizesFunction · 0.85
getRandomPow2AllocSizesFunction · 0.85
fillUpMemoryPoolFunction · 0.85
checkFreeingFunction · 0.85
getNumUsableSlabsMethod · 0.80
getCurrentAllocSizeMethod · 0.80
getNumClassIdMethod · 0.80
allocatedSlabsMethod · 0.80
getPoolSizeMethod · 0.80
makeNewSlabMethod · 0.80
isReleasedMethod · 0.80
eraseMethod · 0.80

Tested by

no test coverage detected