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

Function RunHardlinkTest

util/system/fs_ut.cpp:150–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150static void RunHardlinkTest(const TFsPath& src, const TFsPath& dst) {
151 NFs::Remove(src);
152 NFs::Remove(dst);
153
154 {
155 TFile file(src, CreateNew | WrOnly);
156 file.Write("123", 3);
157 }
158
159 UNIT_ASSERT(NFs::HardLink(src, dst));
160
161 {
162 TFile file(dst, OpenExisting | RdOnly);
163 UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 3);
164 }
165 {
166 TFile file(src, OpenExisting | WrOnly);
167 file.Write("1234", 4);
168 }
169 {
170 TFile file(dst, OpenExisting | RdOnly);
171 UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 4);
172 }
173 {
174 TFile file(dst, OpenExisting | WrOnly);
175 file.Write("12345", 5);
176 }
177
178 {
179 TFile file(src, OpenExisting | RdOnly);
180 UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 5);
181 }
182
183 UNIT_ASSERT(NFs::Remove(dst));
184 UNIT_ASSERT(NFs::Remove(src));
185}
186
187void TFsTest::TestHardlink() {
188 RunHardlinkTest("tempfile", "hardlinkfile");

Callers 1

TestHardlinkMethod · 0.85

Calls 2

WriteMethod · 0.45
GetLengthMethod · 0.45

Tested by 1

TestHardlinkMethod · 0.68