| 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) |
nothing calls this directly
no test coverage detected