summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-05-02 13:48:07 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2022-05-02 13:48:07 +0100
commitfeff7386c2bae240c04b3ebdd2d4bf15e6429c56 (patch)
tree4d33872dd4ee693325873dfd01ea46fe4e3019cd
parentRethrow flush failures in release (diff)
downloadnetfs-feff7386c2bae240c04b3ebdd2d4bf15e6429c56.tar.bz2
netfs-feff7386c2bae240c04b3ebdd2d4bf15e6429c56.tar.xz
netfs-feff7386c2bae240c04b3ebdd2d4bf15e6429c56.zip
Add test cases that daemonstrate large writes do actually fail
-rw-r--r--netfs/unittests/defaultFuseNoAsync.xml15
-rw-r--r--netfs/unittests/testEdgeCases.cpp36
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"));
+}