MCPcopy Create free account
hub / github.com/catboost/catboost / Y_UNIT_TEST

Function Y_UNIT_TEST

util/system/mincore_ut.cpp:14–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12 static const char* FileName_("./mappped_file");
13
14 Y_UNIT_TEST(TestLockAndInCore) {
15 TVector<char> content(2_MB);
16
17 TTempFile cleanup(FileName_);
18 TFile file(FileName_, CreateAlways | WrOnly);
19 file.Write(content.data(), content.size());
20 file.Close();
21
22 TFileMap mappedFile(FileName_, TMemoryMapCommon::oRdWr);
23 mappedFile.Map(0, mappedFile.Length());
24 UNIT_ASSERT_EQUAL(mappedFile.MappedSize(), content.size());
25 UNIT_ASSERT_EQUAL(mappedFile.Length(), static_cast<i64>(content.size()));
26
27 LockMemory(mappedFile.Ptr(), mappedFile.Length());
28
29 TVector<unsigned char> incore(mappedFile.Length() / NSystemInfo::GetPageSize());
30 InCoreMemory(mappedFile.Ptr(), mappedFile.Length(), incore.data(), incore.size());
31
32 // compile and run on all platforms, but assume non-zero results only on Linux
33#if defined(_linux_)
34 for (const auto& flag : incore) {
35 UNIT_ASSERT(IsPageInCore(flag));
36 }
37#endif
38 }
39} // Y_UNIT_TEST_SUITE(MincoreSuite)

Callers

nothing calls this directly

Calls 12

LockMemoryFunction · 0.85
InCoreMemoryFunction · 0.85
IsPageInCoreFunction · 0.85
GetPageSizeFunction · 0.50
WriteMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
CloseMethod · 0.45
MapMethod · 0.45
LengthMethod · 0.45
MappedSizeMethod · 0.45
PtrMethod · 0.45

Tested by

no test coverage detected