diff --git a/test/uvw/fs.cpp b/test/uvw/fs.cpp index 7bbd80f4..cd3f53f9 100644 --- a/test/uvw/fs.cpp +++ b/test/uvw/fs.cpp @@ -1176,16 +1176,78 @@ TEST(FsReq, SymlinkAndUnlinkSync) { } -/* 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(); + auto fsReq = loop->resource(); + + bool checkFsReadlinkEvent = false; + + fsReq->on([](const auto &, auto &) { + FAIL(); + }); + + fsReq->on>([&checkFsReadlinkEvent, &linkname](const auto &, auto &request) { + ASSERT_FALSE(checkFsReadlinkEvent); + checkFsReadlinkEvent = true; + request.unlink(linkname); + }); + + fsReq->on>([&linkname](const auto &, auto &request) { + request.readlink(linkname); + }); + + fileReq->on([](const auto &, auto &) { + FAIL(); + }); + + fileReq->on>([&fsReq, &filename, &linkname](const auto &, auto &) { + fsReq->symlink(filename, linkname, 0); + }); + + fileReq->on>([](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) { - // 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(); + auto fsReq = loop->resource(); + +#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) {