refactoring
This commit is contained in:
parent
041fdb4acb
commit
e67d8bc6f3
@ -36,7 +36,8 @@ set(TARGET_ASYNC async)
|
||||
set(TARGET_CHECK check)
|
||||
set(TARGET_EMITTER emitter)
|
||||
set(TARGET_EVENT event)
|
||||
set(TARGET_FS fs)
|
||||
set(TARGET_FS_REQ fs_req)
|
||||
set(TARGET_FILE_REQ file_req)
|
||||
set(TARGET_HANDLE handle)
|
||||
set(TARGET_IDLE idle)
|
||||
set(TARGET_LOOP loop)
|
||||
@ -86,16 +87,27 @@ target_include_directories(${TARGET_EVENT} PRIVATE ${COMMON_INCLUDE_DIRS})
|
||||
target_link_libraries(${TARGET_EVENT} PRIVATE ${COMMON_LINK_LIBS})
|
||||
add_test(NAME ${TARGET_EVENT} COMMAND ${TARGET_EVENT})
|
||||
|
||||
# Test TARGET_FS
|
||||
# Test TARGET_FS_REQ
|
||||
|
||||
set(TARGET_FS_SOURCES $<TARGET_OBJECTS:odr> uvw/fs.cpp)
|
||||
set(TARGET_FS_DIR ${CMAKE_CURRENT_BINARY_DIR}/fs)
|
||||
file(MAKE_DIRECTORY ${TARGET_FS_DIR})
|
||||
add_executable(${TARGET_FS} ${TARGET_FS_SOURCES})
|
||||
target_include_directories(${TARGET_FS} PRIVATE ${COMMON_INCLUDE_DIRS})
|
||||
target_link_libraries(${TARGET_FS} PRIVATE ${COMMON_LINK_LIBS})
|
||||
target_compile_definitions(${TARGET_FS} PRIVATE TARGET_FS_DIR="${TARGET_FS_DIR}")
|
||||
add_test(NAME ${TARGET_FS} COMMAND ${TARGET_FS})
|
||||
set(TARGET_FS_REQ_SOURCES $<TARGET_OBJECTS:odr> uvw/fs_req.cpp)
|
||||
set(TARGET_FS_REQ_DIR ${CMAKE_CURRENT_BINARY_DIR}/fs_req)
|
||||
file(MAKE_DIRECTORY ${TARGET_FS_REQ_DIR})
|
||||
add_executable(${TARGET_FS_REQ} ${TARGET_FS_REQ_SOURCES})
|
||||
target_include_directories(${TARGET_FS_REQ} PRIVATE ${COMMON_INCLUDE_DIRS})
|
||||
target_link_libraries(${TARGET_FS_REQ} PRIVATE ${COMMON_LINK_LIBS})
|
||||
target_compile_definitions(${TARGET_FS_REQ} PRIVATE TARGET_FS_REQ_DIR="${TARGET_FS_REQ_DIR}")
|
||||
add_test(NAME ${TARGET_FS_REQ} COMMAND ${TARGET_FS_REQ})
|
||||
|
||||
# Test TARGET_FILE_REQ
|
||||
|
||||
set(TARGET_FILE_REQ_SOURCES $<TARGET_OBJECTS:odr> uvw/file_req.cpp)
|
||||
set(TARGET_FILE_REQ_DIR ${CMAKE_CURRENT_BINARY_DIR}/file_req)
|
||||
file(MAKE_DIRECTORY ${TARGET_FILE_REQ_DIR})
|
||||
add_executable(${TARGET_FILE_REQ} ${TARGET_FILE_REQ_SOURCES})
|
||||
target_include_directories(${TARGET_FILE_REQ} PRIVATE ${COMMON_INCLUDE_DIRS})
|
||||
target_link_libraries(${TARGET_FILE_REQ} PRIVATE ${COMMON_LINK_LIBS})
|
||||
target_compile_definitions(${TARGET_FILE_REQ} PRIVATE TARGET_FILE_REQ_DIR="${TARGET_FILE_REQ_DIR}")
|
||||
add_test(NAME ${TARGET_FILE_REQ} COMMAND ${TARGET_FILE_REQ})
|
||||
|
||||
# Test TARGET_HANDLE
|
||||
|
||||
|
||||
459
test/uvw/file_req.cpp
Normal file
459
test/uvw/file_req.cpp
Normal file
@ -0,0 +1,459 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <uvw.hpp>
|
||||
#include <chrono>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define _CRT_DECLARE_NONSTDC_NAMES 1
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
|
||||
TEST(FileReq, OpenAndClose) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileOpenEvent = false;
|
||||
bool checkFileCloseEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::CLOSE>>([&checkFileCloseEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileCloseEvent);
|
||||
checkFileCloseEvent = true;
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([&checkFileOpenEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileOpenEvent);
|
||||
checkFileOpenEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_WRONLY, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileOpenEvent);
|
||||
ASSERT_TRUE(checkFileCloseEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, OpenAndCloseSync) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_WRONLY, 0644));
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, RW) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileWriteEvent = false;
|
||||
bool checkFileReadEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::READ>>([&checkFileReadEvent](const auto &event, auto &request) {
|
||||
ASSERT_FALSE(checkFileReadEvent);
|
||||
ASSERT_EQ(event.data[0], 42);
|
||||
checkFileReadEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::WRITE>>([&checkFileWriteEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileWriteEvent);
|
||||
checkFileWriteEvent = true;
|
||||
request.read(0, 1);
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.write(std::unique_ptr<char[]>{new char[1]{ 42 }}, 1, 0);
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileWriteEvent);
|
||||
ASSERT_TRUE(checkFileReadEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, RWSync) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
auto writeR = request->writeSync(std::unique_ptr<char[]>{new char[1]{ 42 }}, 1, 0);
|
||||
|
||||
ASSERT_TRUE(writeR.first);
|
||||
ASSERT_EQ(writeR.second, 1);
|
||||
|
||||
auto readR = request->readSync(0, 1);
|
||||
|
||||
ASSERT_TRUE(readR.first);
|
||||
ASSERT_EQ(readR.second.first[0], 42);
|
||||
ASSERT_EQ(readR.second.second, 1);
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(FileReq, Stat) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileStatEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FSTAT>>([&checkFileStatEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileStatEvent);
|
||||
checkFileStatEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.stat();
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileStatEvent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(FileReq, StatSync) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
auto statR = request->statSync();
|
||||
|
||||
ASSERT_TRUE(statR.first);
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, Sync) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileSyncEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FSYNC>>([&checkFileSyncEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileSyncEvent);
|
||||
checkFileSyncEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.sync();
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileSyncEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, SyncSync) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
ASSERT_TRUE(request->syncSync());
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, Datasync) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileDatasyncEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FDATASYNC>>([&checkFileDatasyncEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileDatasyncEvent);
|
||||
checkFileDatasyncEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.datasync();
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileDatasyncEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, DatasyncSync) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
ASSERT_TRUE(request->datasyncSync());
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, Truncate) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileTruncateEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FTRUNCATE>>([&checkFileTruncateEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileTruncateEvent);
|
||||
checkFileTruncateEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.truncate(0);
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileTruncateEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, TruncateSync) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
ASSERT_TRUE(request->truncateSync(0));
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TEST(FileReq, SendFile) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, SendFileSync) {
|
||||
// TODO
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
TEST(FileReq, Chmod) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileChmodEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FCHMOD>>([&checkFileChmodEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileChmodEvent);
|
||||
checkFileChmodEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.chmod(0644);
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileChmodEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, ChmodSync) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
ASSERT_TRUE(request->chmodSync(0644));
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, Utime) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileUtimeEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FUTIME>>([&checkFileUtimeEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileUtimeEvent);
|
||||
checkFileUtimeEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto epoch = now.time_since_epoch();
|
||||
auto value = std::chrono::duration_cast<std::chrono::seconds>(epoch);
|
||||
request.utime(value, value);
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileUtimeEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, UtimeSync) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto epoch = now.time_since_epoch();
|
||||
auto value = std::chrono::duration_cast<std::chrono::seconds>(epoch);
|
||||
|
||||
ASSERT_TRUE(request->utimeSync(value, value));
|
||||
ASSERT_TRUE(request->truncateSync(0));
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, Chown) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileChownEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FCHOWN>>([&checkFileChownEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileChownEvent);
|
||||
checkFileChownEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FSTAT>>([](const auto &event, auto &request) {
|
||||
request.chown(event.stat.st_uid, event.stat.st_gid);
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.stat();
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileChownEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, ChownSync) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
auto statR = request->statSync();
|
||||
|
||||
ASSERT_TRUE(statR.first);
|
||||
ASSERT_TRUE(request->chownSync(statR.second.st_uid, statR.second.st_gid));
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
@ -8,464 +8,8 @@
|
||||
#endif
|
||||
|
||||
|
||||
TEST(FileReq, OpenAndClose) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileOpenEvent = false;
|
||||
bool checkFileCloseEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::CLOSE>>([&checkFileCloseEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileCloseEvent);
|
||||
checkFileCloseEvent = true;
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([&checkFileOpenEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileOpenEvent);
|
||||
checkFileOpenEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_WRONLY, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileOpenEvent);
|
||||
ASSERT_TRUE(checkFileCloseEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, OpenAndCloseSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_WRONLY, 0644));
|
||||
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, RW) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileWriteEvent = false;
|
||||
bool checkFileReadEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::READ>>([&checkFileReadEvent](const auto &event, auto &request) {
|
||||
ASSERT_FALSE(checkFileReadEvent);
|
||||
ASSERT_EQ(event.data[0], 42);
|
||||
checkFileReadEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::WRITE>>([&checkFileWriteEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileWriteEvent);
|
||||
checkFileWriteEvent = true;
|
||||
request.read(0, 1);
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.write(std::unique_ptr<char[]>{new char[1]{ 42 }}, 1, 0);
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileWriteEvent);
|
||||
ASSERT_TRUE(checkFileReadEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, RWSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
auto writeR = request->writeSync(std::unique_ptr<char[]>{new char[1]{ 42 }}, 1, 0);
|
||||
|
||||
ASSERT_TRUE(writeR.first);
|
||||
ASSERT_EQ(writeR.second, 1);
|
||||
|
||||
auto readR = request->readSync(0, 1);
|
||||
|
||||
ASSERT_TRUE(readR.first);
|
||||
ASSERT_EQ(readR.second.first[0], 42);
|
||||
ASSERT_EQ(readR.second.second, 1);
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(FileReq, Stat) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileStatEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FSTAT>>([&checkFileStatEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileStatEvent);
|
||||
checkFileStatEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.stat();
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileStatEvent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(FileReq, StatSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
auto statR = request->statSync();
|
||||
|
||||
ASSERT_TRUE(statR.first);
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, Sync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileSyncEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FSYNC>>([&checkFileSyncEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileSyncEvent);
|
||||
checkFileSyncEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.sync();
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileSyncEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, SyncSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(request->syncSync());
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, Datasync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileDatasyncEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FDATASYNC>>([&checkFileDatasyncEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileDatasyncEvent);
|
||||
checkFileDatasyncEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.datasync();
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileDatasyncEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, DatasyncSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(request->datasyncSync());
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, Truncate) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileTruncateEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FTRUNCATE>>([&checkFileTruncateEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileTruncateEvent);
|
||||
checkFileTruncateEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.truncate(0);
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileTruncateEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, TruncateSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(request->truncateSync(0));
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TEST(FileReq, SendFile) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, SendFileSync) {
|
||||
// TODO
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
TEST(FileReq, Chmod) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileChmodEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FCHMOD>>([&checkFileChmodEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileChmodEvent);
|
||||
checkFileChmodEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.chmod(0644);
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileChmodEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, ChmodSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(request->chmodSync(0644));
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, Utime) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileUtimeEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FUTIME>>([&checkFileUtimeEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileUtimeEvent);
|
||||
checkFileUtimeEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto epoch = now.time_since_epoch();
|
||||
auto value = std::chrono::duration_cast<std::chrono::seconds>(epoch);
|
||||
request.utime(value, value);
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileUtimeEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, UtimeSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto epoch = now.time_since_epoch();
|
||||
auto value = std::chrono::duration_cast<std::chrono::seconds>(epoch);
|
||||
|
||||
ASSERT_TRUE(request->utimeSync(value, value));
|
||||
ASSERT_TRUE(request->truncateSync(0));
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, Chown) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileChownEvent = false;
|
||||
|
||||
request->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FCHOWN>>([&checkFileChownEvent](const auto &, auto &request) {
|
||||
ASSERT_FALSE(checkFileChownEvent);
|
||||
checkFileChownEvent = true;
|
||||
request.close();
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::FSTAT>>([](const auto &event, auto &request) {
|
||||
request.chown(event.stat.st_uid, event.stat.st_gid);
|
||||
});
|
||||
|
||||
request->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||
request.stat();
|
||||
});
|
||||
|
||||
request->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileChownEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, ChownSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
auto statR = request->statSync();
|
||||
|
||||
ASSERT_TRUE(statR.first);
|
||||
ASSERT_TRUE(request->chownSync(statR.second.st_uid, statR.second.st_gid));
|
||||
ASSERT_TRUE(request->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(FsReq, MkdirAndRmdir) {
|
||||
const std::string dirname = std::string{TARGET_FS_DIR} + std::string{"/test.dir"};
|
||||
const std::string dirname = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.dir"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FsReq>();
|
||||
@ -498,7 +42,7 @@ TEST(FsReq, MkdirAndRmdir) {
|
||||
|
||||
|
||||
TEST(FsReq, MkdirAndRmdirSync) {
|
||||
const std::string dirname = std::string{TARGET_FS_DIR} + std::string{"/test.dir"};
|
||||
const std::string dirname = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.dir"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FsReq>();
|
||||
@ -511,7 +55,7 @@ TEST(FsReq, MkdirAndRmdirSync) {
|
||||
|
||||
|
||||
TEST(FsReq, MkdtempAndRmdir) {
|
||||
const std::string dirname = std::string{TARGET_FS_DIR} + std::string{"/test.dir.XXXXXX"};
|
||||
const std::string dirname = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.dir.XXXXXX"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FsReq>();
|
||||
@ -545,7 +89,7 @@ TEST(FsReq, MkdtempAndRmdir) {
|
||||
|
||||
|
||||
TEST(FsReq, MkdtempAndRmdirSync) {
|
||||
const std::string dirname = std::string{TARGET_FS_DIR} + std::string{"/test.dir.XXXXXX"};
|
||||
const std::string dirname = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.dir.XXXXXX"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto request = loop->resource<uvw::FsReq>();
|
||||
@ -573,7 +117,7 @@ TEST(FsReq, ScandirSync) {
|
||||
|
||||
|
||||
TEST(FsReq, Stat) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
@ -611,14 +155,13 @@ TEST(FsReq, Stat) {
|
||||
|
||||
|
||||
TEST(FsReq, StatSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
auto fsReq = loop->resource<uvw::FsReq>();
|
||||
|
||||
ASSERT_TRUE(fileReq->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(fileReq->closeSync());
|
||||
|
||||
auto statR = fsReq->statSync(filename);
|
||||
@ -630,7 +173,7 @@ TEST(FsReq, StatSync) {
|
||||
|
||||
|
||||
TEST(FsReq, Lstat) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
@ -668,14 +211,13 @@ TEST(FsReq, Lstat) {
|
||||
|
||||
|
||||
TEST(FsReq, LstatSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
auto fsReq = loop->resource<uvw::FsReq>();
|
||||
|
||||
ASSERT_TRUE(fileReq->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(fileReq->closeSync());
|
||||
|
||||
auto statR = fsReq->lstatSync(filename);
|
||||
@ -687,8 +229,8 @@ TEST(FsReq, LstatSync) {
|
||||
|
||||
|
||||
TEST(FsReq, Rename) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string rename = std::string{TARGET_FS_DIR} + std::string{"/test.rename"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
const std::string rename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.rename"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
@ -726,15 +268,14 @@ TEST(FsReq, Rename) {
|
||||
|
||||
|
||||
TEST(FsReq, RenameSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string rename = std::string{TARGET_FS_DIR} + std::string{"/test.rename"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
const std::string rename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.rename"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
auto fsReq = loop->resource<uvw::FsReq>();
|
||||
|
||||
ASSERT_TRUE(fileReq->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(fileReq->closeSync());
|
||||
ASSERT_TRUE(fsReq->renameSync(filename, rename));
|
||||
|
||||
@ -743,7 +284,7 @@ TEST(FsReq, RenameSync) {
|
||||
|
||||
|
||||
TEST(FsReq, Access) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
@ -781,14 +322,13 @@ TEST(FsReq, Access) {
|
||||
|
||||
|
||||
TEST(FsReq, AccessSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
auto fsReq = loop->resource<uvw::FsReq>();
|
||||
|
||||
ASSERT_TRUE(fileReq->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(fileReq->closeSync());
|
||||
ASSERT_TRUE(fsReq->accessSync(filename, R_OK));
|
||||
|
||||
@ -797,7 +337,7 @@ TEST(FsReq, AccessSync) {
|
||||
|
||||
|
||||
TEST(FsReq, Chmod) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
@ -835,14 +375,13 @@ TEST(FsReq, Chmod) {
|
||||
|
||||
|
||||
TEST(FsReq, ChmodSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
auto fsReq = loop->resource<uvw::FsReq>();
|
||||
|
||||
ASSERT_TRUE(fileReq->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(fileReq->closeSync());
|
||||
ASSERT_TRUE(fsReq->chmodSync(filename, 0644));
|
||||
|
||||
@ -851,7 +390,7 @@ TEST(FsReq, ChmodSync) {
|
||||
|
||||
|
||||
TEST(FsReq, Utime) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
@ -892,7 +431,7 @@ TEST(FsReq, Utime) {
|
||||
|
||||
|
||||
TEST(FsReq, UtimeSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
@ -912,8 +451,8 @@ TEST(FsReq, UtimeSync) {
|
||||
|
||||
|
||||
TEST(FsReq, LinkAndUnlink) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string linkname = std::string{TARGET_FS_DIR} + std::string{"/test.link"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
const std::string linkname = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.link"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
@ -959,15 +498,14 @@ TEST(FsReq, LinkAndUnlink) {
|
||||
|
||||
|
||||
TEST(FsReq, LinkAndUnlinkSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string linkname = std::string{TARGET_FS_DIR} + std::string{"/test.link"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
const std::string linkname = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.link"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
auto fsReq = loop->resource<uvw::FsReq>();
|
||||
|
||||
ASSERT_TRUE(fileReq->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(fileReq->closeSync());
|
||||
ASSERT_TRUE(fsReq->linkSync(filename, linkname));
|
||||
ASSERT_TRUE(fsReq->unlinkSync(linkname));
|
||||
@ -977,8 +515,8 @@ TEST(FsReq, LinkAndUnlinkSync) {
|
||||
|
||||
|
||||
TEST(FsReq, SymlinkAndUnlink) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string linkname = std::string{TARGET_FS_DIR} + std::string{"/test.link"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
const std::string linkname = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.link"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
@ -1024,15 +562,14 @@ TEST(FsReq, SymlinkAndUnlink) {
|
||||
|
||||
|
||||
TEST(FsReq, SymlinkAndUnlinkSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string linkname = std::string{TARGET_FS_DIR} + std::string{"/test.link"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
const std::string linkname = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.link"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
auto fsReq = loop->resource<uvw::FsReq>();
|
||||
|
||||
ASSERT_TRUE(fileReq->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(fileReq->closeSync());
|
||||
ASSERT_TRUE(fsReq->symlinkSync(filename, linkname, 0));
|
||||
ASSERT_TRUE(fsReq->unlinkSync(linkname));
|
||||
@ -1042,8 +579,8 @@ TEST(FsReq, SymlinkAndUnlinkSync) {
|
||||
|
||||
|
||||
TEST(FsReq, Readlink) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string linkname = std::string{TARGET_FS_DIR} + std::string{"/test.link"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
const std::string linkname = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.link"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
@ -1086,15 +623,14 @@ TEST(FsReq, Readlink) {
|
||||
|
||||
|
||||
TEST(FsReq, ReadlinkSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string linkname = std::string{TARGET_FS_DIR} + std::string{"/test.link"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
const std::string linkname = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.link"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
auto fsReq = loop->resource<uvw::FsReq>();
|
||||
|
||||
ASSERT_TRUE(fileReq->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(fileReq->closeSync());
|
||||
ASSERT_TRUE(fsReq->symlinkSync(filename, linkname, 0));
|
||||
|
||||
@ -1108,7 +644,7 @@ TEST(FsReq, ReadlinkSync) {
|
||||
|
||||
|
||||
TEST(FsReq, Realpath) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
@ -1147,14 +683,13 @@ TEST(FsReq, Realpath) {
|
||||
|
||||
|
||||
TEST(FsReq, RealpathSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
auto fsReq = loop->resource<uvw::FsReq>();
|
||||
|
||||
ASSERT_TRUE(fileReq->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(fileReq->closeSync());
|
||||
|
||||
auto realpathR = fsReq->realpathSync(filename);
|
||||
@ -1167,7 +702,7 @@ TEST(FsReq, RealpathSync) {
|
||||
|
||||
|
||||
TEST(FsReq, Chown) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
@ -1209,14 +744,13 @@ TEST(FsReq, Chown) {
|
||||
|
||||
|
||||
TEST(FsReq, ChownSync) {
|
||||
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.file"};
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto fileReq = loop->resource<uvw::FileReq>();
|
||||
auto fsReq = loop->resource<uvw::FsReq>();
|
||||
|
||||
ASSERT_TRUE(fileReq->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||
|
||||
ASSERT_TRUE(fileReq->closeSync());
|
||||
|
||||
auto statR = fsReq->statSync(filename);
|
||||
Loading…
Reference in New Issue
Block a user