diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/system/direct_io_ut.cpp | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system/direct_io_ut.cpp')
-rw-r--r-- | util/system/direct_io_ut.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/util/system/direct_io_ut.cpp b/util/system/direct_io_ut.cpp index c6691a8f72..839c3de7ca 100644 --- a/util/system/direct_io_ut.cpp +++ b/util/system/direct_io_ut.cpp @@ -5,7 +5,7 @@ #include <util/system/tempfile.h> #include <util/random/random.h> -#include "direct_io.h" +#include "direct_io.h" static const char* FileName_("./test.file"); @@ -14,43 +14,43 @@ Y_UNIT_TEST_SUITE(TDirectIoTestSuite) { TDirectIOBufferedFile file(FileName_, RdWr | Direct | Seq | CreateAlways, 1 << 15); TVector<ui64> data((1 << 15) + 1); TVector<ui64> readResult(data.size()); - for (auto& i : data) { - i = RandomNumber<ui64>(); - } - for (size_t writePos = 0; writePos < data.size();) { - size_t writeCount = Min<size_t>(1 + RandomNumber<size_t>(1 << 10), data.ysize() - writePos); - file.Write(&data[writePos], sizeof(ui64) * writeCount); - writePos += writeCount; + for (auto& i : data) { + i = RandomNumber<ui64>(); + } + for (size_t writePos = 0; writePos < data.size();) { + size_t writeCount = Min<size_t>(1 + RandomNumber<size_t>(1 << 10), data.ysize() - writePos); + file.Write(&data[writePos], sizeof(ui64) * writeCount); + writePos += writeCount; size_t readPos = RandomNumber(writePos); - size_t readCount = RandomNumber(writePos - readPos); + size_t readCount = RandomNumber(writePos - readPos); UNIT_ASSERT_VALUES_EQUAL( file.Pread(&readResult[0], readCount * sizeof(ui64), readPos * sizeof(ui64)), - readCount * sizeof(ui64)); + readCount * sizeof(ui64)); for (size_t i = 0; i < readCount; ++i) { UNIT_ASSERT_VALUES_EQUAL(readResult[i], data[i + readPos]); } - } - file.Finish(); + } + file.Finish(); TDirectIOBufferedFile fileNew(FileName_, RdOnly | Direct | Seq | OpenAlways, 1 << 15); - for (int i = 0; i < 1000; ++i) { + for (int i = 0; i < 1000; ++i) { size_t readPos = RandomNumber(data.size()); - size_t readCount = RandomNumber(data.size() - readPos); + size_t readCount = RandomNumber(data.size() - readPos); UNIT_ASSERT_VALUES_EQUAL( fileNew.Pread(&readResult[0], readCount * sizeof(ui64), readPos * sizeof(ui64)), - readCount * sizeof(ui64)); - for (size_t j = 0; j < readCount; ++j) { + readCount * sizeof(ui64)); + for (size_t j = 0; j < readCount; ++j) { UNIT_ASSERT_VALUES_EQUAL(readResult[j], data[j + readPos]); - } - } - size_t readCount = data.size(); + } + } + size_t readCount = data.size(); UNIT_ASSERT_VALUES_EQUAL( fileNew.Pread(&readResult[0], readCount * sizeof(ui64), 0), - readCount * sizeof(ui64)); + readCount * sizeof(ui64)); for (size_t i = 0; i < readCount; ++i) { UNIT_ASSERT_VALUES_EQUAL(readResult[i], data[i]); } NFs::Remove(FileName_); - } + } void TestHugeFile(size_t size) { TTempFile tmpFile("test.file"); @@ -77,12 +77,12 @@ Y_UNIT_TEST_SUITE(TDirectIoTestSuite) { } Y_UNIT_TEST(TestHugeFile1) { - if constexpr (sizeof(size_t) > 4) { + if constexpr (sizeof(size_t) > 4) { TestHugeFile(5 * 1024 * 1024 * 1024ULL); } } Y_UNIT_TEST(TestHugeFile2) { - if constexpr (sizeof(size_t) > 4) { + if constexpr (sizeof(size_t) > 4) { TestHugeFile(5 * 1024 * 1024 * 1024ULL + 1111); } } @@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TDirectIoTestSuite) { Y_UNIT_TEST_SUITE(TDirectIoErrorHandling) { Y_UNIT_TEST(Constructor) { // A non-existent file should not be opened for reading - UNIT_ASSERT_EXCEPTION(TDirectIOBufferedFile(FileName_, RdOnly, 1 << 15), TFileError); + UNIT_ASSERT_EXCEPTION(TDirectIOBufferedFile(FileName_, RdOnly, 1 << 15), TFileError); } Y_UNIT_TEST(WritingReadOnlyFileBufferFlushed) { |