diff options
-rw-r--r-- | netfs/unittests/defaultFuseNoAsync.xml | 15 | ||||
-rw-r--r-- | netfs/unittests/testEdgeCases.cpp | 36 |
2 files changed, 51 insertions, 0 deletions
diff --git a/netfs/unittests/defaultFuseNoAsync.xml b/netfs/unittests/defaultFuseNoAsync.xml new file mode 100644 index 0000000..5350180 --- /dev/null +++ b/netfs/unittests/defaultFuseNoAsync.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="ascii"?> +<config> + <resources> + <resource> + <name>testvol</name> + <resource> + <export>testvol</export> + <async>false</async> + <endpoints> + <endpoint>overridden</endpoint> + </endpoints> + </resource> + </resource> + </resources> +</config> diff --git a/netfs/unittests/testEdgeCases.cpp b/netfs/unittests/testEdgeCases.cpp index 51a1931..5249aed 100644 --- a/netfs/unittests/testEdgeCases.cpp +++ b/netfs/unittests/testEdgeCases.cpp @@ -120,3 +120,39 @@ BOOST_AUTO_TEST_CASE(manyThreads) BOOST_CHECK_GT(success, 800); BOOST_CHECK_EQUAL(failure, 0); } + +BOOST_AUTO_TEST_CASE(bigWritesAsync) +{ + MockDaemonHost daemon(testEndpoint, {"--NetFSD.ConfigPath=" + (rootDir / "defaultDaemon.xml").string()}); + FuseMockHost fuse(testEndpoint, {(rootDir / "defaultFuse.xml").string() + ":testvol", (rootDir / "test").string()}); + + std::vector<char> buf(1 * 1024 * 1024); + fuse_file_info fi {}; + fi.flags = O_RDWR; + auto fd = fuse.fuse->create("/big", 0600, &fi); + BOOST_REQUIRE_GE(fd, 0); + BOOST_REQUIRE_NE(fi.fh, 0); + // async success + BOOST_CHECK_EQUAL(buf.size(), fuse.fuse->write("/big", buf.data(), buf.size(), 0, &fi)); + // failure on flush/close + BOOST_REQUIRE_EQUAL(-EIO, fuse.fuse->release("/big", &fi)); + BOOST_CHECK_EQUAL(0, std::filesystem::file_size(daemon.TestExportRoot / "big")); +} + +BOOST_AUTO_TEST_CASE(bigWritesNoAsync) +{ + MockDaemonHost daemon(testEndpoint, {"--NetFSD.ConfigPath=" + (rootDir / "defaultDaemon.xml").string()}); + FuseMockHost fuse( + testEndpoint, {(rootDir / "defaultFuseNoAsync.xml").string() + ":testvol", (rootDir / "test").string()}); + + std::vector<char> buf(1 * 1024 * 1024); + fuse_file_info fi {}; + fi.flags = O_RDWR; + auto fd = fuse.fuse->create("/big", 0600, &fi); + BOOST_REQUIRE_GE(fd, 0); + BOOST_REQUIRE_NE(fi.fh, 0); + // sync fail + BOOST_CHECK_EQUAL(-EIO, fuse.fuse->write("/big", buf.data(), buf.size(), 0, &fi)); + BOOST_REQUIRE_EQUAL(0, fuse.fuse->release("/big", &fi)); + BOOST_CHECK_EQUAL(0, std::filesystem::file_size(daemon.TestExportRoot / "big")); +} |