mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
pow-testgiver support
This commit is contained in:
parent
dbde9c1c40
commit
f064b1047a
257 changed files with 6665 additions and 2608 deletions
|
@ -28,6 +28,8 @@
|
|||
#include "td/utils/Slice.h"
|
||||
#include "td/utils/tests.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
using namespace td;
|
||||
|
||||
TEST(Port, files) {
|
||||
|
@ -51,44 +53,38 @@ TEST(Port, files) {
|
|||
int cnt = 0;
|
||||
const int ITER_COUNT = 1000;
|
||||
for (int i = 0; i < ITER_COUNT; i++) {
|
||||
walk_path(main_dir,
|
||||
[&](CSlice name, WalkPath::Type type) {
|
||||
if (type == WalkPath::Type::NotDir) {
|
||||
ASSERT_TRUE(name == fd_path || name == fd2_path);
|
||||
}
|
||||
cnt++;
|
||||
})
|
||||
.ensure();
|
||||
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
|
||||
if (type == WalkPath::Type::NotDir) {
|
||||
ASSERT_TRUE(name == fd_path || name == fd2_path);
|
||||
}
|
||||
cnt++;
|
||||
}).ensure();
|
||||
}
|
||||
ASSERT_EQ((5 * 2 + 2) * ITER_COUNT, cnt);
|
||||
bool was_abort = false;
|
||||
walk_path(main_dir,
|
||||
[&](CSlice name, WalkPath::Type type) {
|
||||
CHECK(!was_abort);
|
||||
if (type == WalkPath::Type::EnterDir && ends_with(name, PSLICE() << TD_DIR_SLASH << "B")) {
|
||||
was_abort = true;
|
||||
return WalkPath::Action::Abort;
|
||||
}
|
||||
return WalkPath::Action::Continue;
|
||||
})
|
||||
.ensure();
|
||||
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
|
||||
CHECK(!was_abort);
|
||||
if (type == WalkPath::Type::EnterDir && ends_with(name, PSLICE() << TD_DIR_SLASH << "B")) {
|
||||
was_abort = true;
|
||||
return WalkPath::Action::Abort;
|
||||
}
|
||||
return WalkPath::Action::Continue;
|
||||
}).ensure();
|
||||
CHECK(was_abort);
|
||||
|
||||
cnt = 0;
|
||||
bool is_first_dir = true;
|
||||
walk_path(main_dir,
|
||||
[&](CSlice name, WalkPath::Type type) {
|
||||
cnt++;
|
||||
if (type == WalkPath::Type::EnterDir) {
|
||||
if (is_first_dir) {
|
||||
is_first_dir = false;
|
||||
} else {
|
||||
return WalkPath::Action::SkipDir;
|
||||
}
|
||||
}
|
||||
return WalkPath::Action::Continue;
|
||||
})
|
||||
.ensure();
|
||||
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
|
||||
cnt++;
|
||||
if (type == WalkPath::Type::EnterDir) {
|
||||
if (is_first_dir) {
|
||||
is_first_dir = false;
|
||||
} else {
|
||||
return WalkPath::Action::SkipDir;
|
||||
}
|
||||
}
|
||||
return WalkPath::Action::Continue;
|
||||
}).ensure();
|
||||
ASSERT_EQ(6, cnt);
|
||||
|
||||
ASSERT_EQ(0u, fd.get_size().move_as_ok());
|
||||
|
@ -111,6 +107,22 @@ TEST(Port, files) {
|
|||
ASSERT_STREQ("Habcd world?!", buf_slice.substr(0, 13));
|
||||
}
|
||||
|
||||
TEST(Port, SparseFiles) {
|
||||
CSlice path = "sparse.txt";
|
||||
unlink(path).ignore();
|
||||
auto fd = FileFd::open(path, FileFd::Write | FileFd::CreateNew).move_as_ok();
|
||||
ASSERT_EQ(0, fd.get_size().move_as_ok());
|
||||
ASSERT_EQ(0, fd.get_real_size().move_as_ok());
|
||||
int64 offset = 100000000;
|
||||
fd.pwrite("a", offset).ensure();
|
||||
ASSERT_EQ(offset + 1, fd.get_size().move_as_ok());
|
||||
auto real_size = fd.get_real_size().move_as_ok();
|
||||
if (real_size >= offset + 1) {
|
||||
LOG(ERROR) << "File system doesn't support sparse files, rewind during streaming can be slow";
|
||||
}
|
||||
unlink(path).ensure();
|
||||
}
|
||||
|
||||
TEST(Port, Writev) {
|
||||
std::vector<IoSlice> vec;
|
||||
CSlice test_file_path = "test.txt";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue