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

Method testSerializationBasic

cachelib/allocator/tests/MMTypeTest.h:313–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311
312template <typename MMType>
313void MMTypeTest<MMType>::testSerializationBasic(Config config) {
314 // add some nodes to the container and ensure that they are marked
315 // accessible and can be traversed through the eviction iterator.
316 Container c1(config, {});
317 std::vector<std::unique_ptr<Node>> nodes;
318 createSimpleContainer(c1, nodes);
319
320 testAddBasic(c1, nodes);
321
322 // save state and restore
323 auto serializedData = c1.saveState();
324
325 // c2 should behave the same as c1
326 Container c2(serializedData, {});
327 ASSERT_EQ(c2.getStats().size, nodes.size());
328
329 for (auto& node : nodes) {
330 bool foundNode = false;
331 for (auto it = c2.getEvictionIterator(); it; ++it) {
332 if (&*node == &*it) {
333 foundNode = true;
334 break;
335 }
336 }
337 verifyIterationVariants(c2);
338 ASSERT_TRUE(foundNode);
339 foundNode = false;
340 }
341
342 testAddBasic(c2, nodes);
343}
344
345template <typename MMType>
346size_t MMTypeTest<MMType>::getListSize(const Container& c,

Callers

nothing calls this directly

Calls 4

saveStateMethod · 0.45
getStatsMethod · 0.45
sizeMethod · 0.45
getEvictionIteratorMethod · 0.45

Tested by

no test coverage detected