tests: fs/FsReq/Readlink and fs/FsReq/ReadlinkSync
This commit is contained in:
parent
8a1fee0f9b
commit
05c44dc9de
@ -1176,16 +1176,78 @@ TEST(FsReq, SymlinkAndUnlinkSync) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
TEST(FsReq, Readlink) {
|
TEST(FsReq, Readlink) {
|
||||||
// TODO
|
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"};
|
||||||
|
|
||||||
|
auto loop = uvw::Loop::getDefault();
|
||||||
|
auto fileReq = loop->resource<uvw::FileReq>();
|
||||||
|
auto fsReq = loop->resource<uvw::FsReq>();
|
||||||
|
|
||||||
|
bool checkFsReadlinkEvent = false;
|
||||||
|
|
||||||
|
fsReq->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||||
|
FAIL();
|
||||||
|
});
|
||||||
|
|
||||||
|
fsReq->on<uvw::FsEvent<uvw::FsReq::Type::READLINK>>([&checkFsReadlinkEvent, &linkname](const auto &, auto &request) {
|
||||||
|
ASSERT_FALSE(checkFsReadlinkEvent);
|
||||||
|
checkFsReadlinkEvent = true;
|
||||||
|
request.unlink(linkname);
|
||||||
|
});
|
||||||
|
|
||||||
|
fsReq->on<uvw::FsEvent<uvw::FsReq::Type::SYMLINK>>([&linkname](const auto &, auto &request) {
|
||||||
|
request.readlink(linkname);
|
||||||
|
});
|
||||||
|
|
||||||
|
fileReq->on<uvw::ErrorEvent>([](const auto &, auto &) {
|
||||||
|
FAIL();
|
||||||
|
});
|
||||||
|
|
||||||
|
fileReq->on<uvw::FsEvent<uvw::FileReq::Type::CLOSE>>([&fsReq, &filename, &linkname](const auto &, auto &) {
|
||||||
|
fsReq->symlink(filename, linkname, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
fileReq->on<uvw::FsEvent<uvw::FileReq::Type::OPEN>>([](const auto &, auto &request) {
|
||||||
|
request.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
fileReq->open(filename, _O_CREAT | _O_RDWR | _O_TRUNC, 0644);
|
||||||
|
#else
|
||||||
|
fileReq->open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
loop->run();
|
||||||
|
|
||||||
|
ASSERT_TRUE(checkFsReadlinkEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(FsReq, ReadlinkSync) {
|
TEST(FsReq, ReadlinkSync) {
|
||||||
// TODO
|
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"};
|
||||||
|
|
||||||
|
auto loop = uvw::Loop::getDefault();
|
||||||
|
auto fileReq = loop->resource<uvw::FileReq>();
|
||||||
|
auto fsReq = loop->resource<uvw::FsReq>();
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
ASSERT_TRUE(fileReq->openSync(filename, _O_CREAT | _O_RDWR | _O_TRUNC, 0644));
|
||||||
|
#else
|
||||||
|
ASSERT_TRUE(fileReq->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ASSERT_TRUE(fileReq->closeSync());
|
||||||
|
ASSERT_TRUE(fsReq->symlinkSync(filename, linkname, 0));
|
||||||
|
|
||||||
|
auto readlinkR = fsReq->readlinkSync(linkname);
|
||||||
|
|
||||||
|
ASSERT_TRUE(readlinkR.first);
|
||||||
|
ASSERT_TRUE(fsReq->unlinkSync(linkname));
|
||||||
|
|
||||||
|
loop->run();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
TEST(FsReq, Realpath) {
|
TEST(FsReq, Realpath) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user