tests for FileReq: SendFile/SendFileSync
This commit is contained in:
parent
e103e56963
commit
da81f219d1
@ -38,7 +38,7 @@ TEST(FileReq, OpenAndCloseErr) {
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, OpenErrSync) {
|
||||
TEST(FileReq, OpenAndCloseErrSync) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/err.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
@ -381,16 +381,66 @@ TEST(FileReq, TruncateSync) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TEST(FileReq, SendFile) {
|
||||
// TODO
|
||||
const std::string srcFilename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/src.file"};
|
||||
const std::string dstFilename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/dst.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto srcReq = loop->resource<uvw::FileReq>();
|
||||
auto dstReq = loop->resource<uvw::FileReq>();
|
||||
|
||||
bool checkFileSendFileEvent = false;
|
||||
|
||||
dstReq->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
dstReq->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([&srcReq](const auto &, auto &req) {
|
||||
srcReq->sendfile(static_cast<uvw::FileHandle>(req), 0, 0);
|
||||
});
|
||||
|
||||
srcReq->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||
FAIL();
|
||||
});
|
||||
|
||||
srcReq->on<uvw::FsEvent<uvw::FileReq::Type::SENDFILE>>([&checkFileSendFileEvent, &dstReq](const auto &, auto &req) {
|
||||
ASSERT_FALSE(checkFileSendFileEvent);
|
||||
checkFileSendFileEvent = true;
|
||||
dstReq->close();
|
||||
req.close();
|
||||
});
|
||||
|
||||
srcReq->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([&dstFilename, &dstReq](const auto &, auto &) {
|
||||
dstReq->open(dstFilename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
|
||||
});
|
||||
|
||||
srcReq->open(srcFilename, O_CREAT | O_RDONLY | O_TRUNC, 0644);
|
||||
|
||||
loop->run();
|
||||
|
||||
ASSERT_TRUE(checkFileSendFileEvent);
|
||||
}
|
||||
|
||||
|
||||
TEST(FileReq, SendFileSync) {
|
||||
// TODO
|
||||
const std::string srcFilename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/src.file"};
|
||||
const std::string dstFilename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/dst.file"};
|
||||
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto srcReq = loop->resource<uvw::FileReq>();
|
||||
auto dstReq = loop->resource<uvw::FileReq>();
|
||||
|
||||
ASSERT_TRUE(srcReq->openSync(srcFilename, O_CREAT | O_RDONLY | O_TRUNC, 0644));
|
||||
ASSERT_TRUE(dstReq->openSync(dstFilename, O_CREAT | O_WRONLY | O_TRUNC, 0644));
|
||||
|
||||
auto sendfileR = srcReq->sendfileSync(static_cast<uvw::FileHandle>(*dstReq), 0, 0);
|
||||
|
||||
ASSERT_TRUE(sendfileR.first);
|
||||
ASSERT_TRUE(srcReq->closeSync());
|
||||
ASSERT_TRUE(dstReq->closeSync());
|
||||
|
||||
loop->run();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
TEST(FileReq, Chmod) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user