aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/file_ut.cpp
diff options
context:
space:
mode:
authoralevitskii <alevitskii@yandex-team.com>2025-01-20 21:52:05 +0300
committeralevitskii <alevitskii@yandex-team.com>2025-01-20 22:31:15 +0300
commitc9d773da0955088ede07abe271f712d9138694db (patch)
treee8143a9d6db70f60d639b1ae7f2e1cbac7556908 /util/system/file_ut.cpp
parentc5a9fee73a0e921ad63674012d1730c96e45fa27 (diff)
downloadydb-c9d773da0955088ede07abe271f712d9138694db.tar.gz
clang-format 18 in STYLE_CPP
clang-format 18 in STYLE\_CPP commit_hash:e2018ac17a95817f09e131ee6d5316b2bdc2d39e
Diffstat (limited to 'util/system/file_ut.cpp')
-rw-r--r--util/system/file_ut.cpp99
1 files changed, 50 insertions, 49 deletions
diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp
index 959633f579..312a0e8f2c 100644
--- a/util/system/file_ut.cpp
+++ b/util/system/file_ut.cpp
@@ -335,73 +335,74 @@ void TFileTest::TestPread() {
#define TMPFS_MAGIC 0x01021994
#endif
-void TFileTest::TestCache(){
+void TFileTest::TestCache() {
#ifdef _linux_
- {// create file in /tmp, current dir could be tmpfs which does not support fadvise
- TFile file(MakeTempName("/tmp"), OpenAlways | Transient | RdWr | NoReadAhead);
+ { // 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;
-}
+ 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);
+ 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.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.FlushCache();
+ UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 7);
-file.EvictCache();
-UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 0);
+ file.EvictCache();
+ UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 0);
-file.PrefetchCache();
-UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 7);
+ 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.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.PrefetchCache();
+ UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 12345);
-file.FlushCache();
-file.EvictCache();
-UNIT_ASSERT_LE(file.CountCache(), 0);
+ file.FlushCache();
+ file.EvictCache();
+ UNIT_ASSERT_LE(file.CountCache(), 0);
-file.Resize(33333333);
-file.PrefetchCache(11111111, 11111111);
-UNIT_ASSERT_GE(file.CountCache(), 11111111);
+ 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);
+ 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);
+ 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);
+ // 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);
-}
+ file.EvictCache();
+ UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), 0);
+ }
#else
- {TFile file(MakeTempName(), OpenAlways | Transient | RdWr);
+ {
+ TFile file(MakeTempName(), OpenAlways | Transient | RdWr);
-file.Resize(12345);
+ 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);
-}
+ UNIT_ASSERT_VALUES_EQUAL(file.CountCache(), -1);
+ file.PrefetchCache();
+ file.FlushCache();
+ file.EvictCache();
+ UNIT_ASSERT_VALUES_EQUAL(file.CountCache(0, 12345), -1);
+ }
#endif
}