summaryrefslogtreecommitdiffstats
path: root/util/system/file_ut.cpp
diff options
context:
space:
mode:
authorkhlebnikov <[email protected]>2022-02-10 16:50:08 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:50:08 +0300
commit6cffcf9a14a1dd07278bd534c7cca706ec2827b3 (patch)
tree48eb57e1d9fd00d624ca68bb3418c3c041d1b096 /util/system/file_ut.cpp
parent1977f1c7bcb225f59f789f5f8735e03eb0c87e1c (diff)
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'util/system/file_ut.cpp')
-rw-r--r--util/system/file_ut.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp
index 941e6a50f3d..99c882bbbb7 100644
--- a/util/system/file_ut.cpp
+++ b/util/system/file_ut.cpp
@@ -23,7 +23,7 @@ class TFileTest: public TTestBase {
UNIT_TEST(TestRead);
UNIT_TEST(TestRawPread);
UNIT_TEST(TestPread);
- UNIT_TEST(TestCache);
+ UNIT_TEST(TestCache);
UNIT_TEST_SUITE_END();
public:
@@ -37,7 +37,7 @@ public:
void TestRead();
void TestRawPread();
void TestPread();
- void TestCache();
+ void TestCache();
inline void TestLinkTo() {
TTempFile tmp1("tmp1");
@@ -327,90 +327,90 @@ void TFileTest::TestPread() {
}
}
-#ifdef _linux_
+#ifdef _linux_
#include <sys/statfs.h>
-#endif
-
-#ifndef TMPFS_MAGIC
+#endif
+
+#ifndef TMPFS_MAGIC
#define TMPFS_MAGIC 0x01021994
-#endif
-
+#endif
+
void TFileTest::TestCache(){
-#ifdef _linux_
+#ifdef _linux_
{// create file in /tmp, current dir could be tmpfs which does not support fadvise
TFile file(MakeTempName("/tmp"), OpenAlways | Transient | RdWr | NoReadAhead);
-
+
struct statfs fs;
if (!fstatfs(file.GetHandle(), &fs) && fs.f_type == TMPFS_MAGIC) {
return;
}
-
+
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 0);
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(0, 0), 0);
-
+
file.Resize(7);
file.PrefetchCache();
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 7);
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(3, 2), 2);
-
+
file.FlushCache();
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 7);
-
+
file.EvictCache();
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 0);
-
+
file.PrefetchCache();
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 7);
-
+
file.Resize(12345);
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 4096);
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(4096, 0), 0);
-
+
file.PrefetchCache();
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 12345);
-
+
file.FlushCache();
file.EvictCache();
UNIT_ASSERT_LE(file.CountCache(), 0);
-
+
file.Resize(33333333);
file.PrefetchCache(11111111, 11111111);
UNIT_ASSERT_GE(file.CountCache(), 11111111);
-
+
UNIT_ASSERT_LE(file.CountCache(0, 11111111), 1111111);
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(11111111, 11111111), 11111111);
UNIT_ASSERT_LE(file.CountCache(22222222, 11111111), 1111111);
-
+
file.FlushCache(11111111, 11111111);
UNIT_ASSERT_GE(file.CountCache(), 11111111);
-
+
// first and last incomplete pages could stay in cache
file.EvictCache(11111111, 11111111);
UNIT_ASSERT_LT(file.CountCache(11111111, 11111111), 4096 * 2);
-
+
file.EvictCache();
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 0);
}
-#else
+#else
{TFile file(MakeTempName(), OpenAlways | Transient | RdWr);
-
+
file.Resize(12345);
-
+
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), -1);
file.PrefetchCache();
file.FlushCache();
file.EvictCache();
UNIT_ASSERT_VALUES_EQUAL(file.CountCache(0, 12345), -1);
}
-#endif
-}
-
+#endif
+}
+
Y_UNIT_TEST_SUITE(TTestDecodeOpenMode) {
Y_UNIT_TEST(It) {
UNIT_ASSERT_VALUES_EQUAL("0", DecodeOpenMode(0));
UNIT_ASSERT_VALUES_EQUAL("RdOnly", DecodeOpenMode(RdOnly));
UNIT_ASSERT_VALUES_EQUAL("RdWr", DecodeOpenMode(RdWr));
UNIT_ASSERT_VALUES_EQUAL("WrOnly|ForAppend", DecodeOpenMode(WrOnly | ForAppend));
- UNIT_ASSERT_VALUES_EQUAL("RdWr|CreateAlways|CreateNew|ForAppend|Transient|CloseOnExec|Temp|Sync|Direct|DirectAligned|Seq|NoReuse|NoReadAhead|AX|AR|AW|AWOther|0xF8888000", DecodeOpenMode(0xFFFFFFFF));
+ UNIT_ASSERT_VALUES_EQUAL("RdWr|CreateAlways|CreateNew|ForAppend|Transient|CloseOnExec|Temp|Sync|Direct|DirectAligned|Seq|NoReuse|NoReadAhead|AX|AR|AW|AWOther|0xF8888000", DecodeOpenMode(0xFFFFFFFF));
}
}