summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-02-28 15:29:44 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-05-06 00:40:50 +0100
commit382659a30d8ace7e01fe1a90abf4b43b90663da3 (patch)
treec68dca87afdb09def38d6c1ee4d06d76073afa72
parentFix exception throwing on invalid fs proxy (diff)
downloadnetfs-382659a30d8ace7e01fe1a90abf4b43b90663da3.tar.bz2
netfs-382659a30d8ace7e01fe1a90abf4b43b90663da3.tar.xz
netfs-382659a30d8ace7e01fe1a90abf4b43b90663da3.zip
Add a test over reconnecting to daemon following a restart with open files
-rw-r--r--netfs/unittests/testCore.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp
index 495c5a7..ba330cd 100644
--- a/netfs/unittests/testCore.cpp
+++ b/netfs/unittests/testCore.cpp
@@ -167,3 +167,46 @@ BOOST_AUTO_TEST_CASE ( clientInitialised )
BOOST_AUTO_TEST_SUITE_END();
+
+BOOST_AUTO_TEST_CASE ( createAndDaemonRestart )
+{
+ MockDaemonHostPtr daemon(new MockDaemonHost());
+ FuseMockHost fuse;
+
+ struct statvfs s;
+ BOOST_REQUIRE_EQUAL(0, fuse.fuse->statfs("/", &s));
+
+ const char * fileName = "/createMe";
+ BOOST_CHECKPOINT("Create a new file");
+ struct fuse_file_info fh;
+ memset(&fh, 0, sizeof(fh));
+ fh.flags = O_WRONLY | O_CREAT | O_APPEND;
+ BOOST_REQUIRE_EQUAL(0, fuse.fuse->create(fileName, 0100644, &fh));
+ BOOST_REQUIRE(fh.fh);
+
+ BOOST_CHECKPOINT("Fetch file attributes");
+ struct stat st;
+ BOOST_REQUIRE_EQUAL(0, fuse.fuse->fgetattr(fileName, &st, &fh));
+ BOOST_REQUIRE_EQUAL(st.st_size, 0);
+ BOOST_REQUIRE_EQUAL(st.st_uid, getuid());
+ BOOST_REQUIRE_EQUAL(st.st_gid, getgid());
+
+ BOOST_CHECKPOINT("Write some data");
+ char someData[890];
+ BOOST_REQUIRE_EQUAL(sizeof(someData), fuse.fuse->write(fileName, someData, sizeof(someData), 0, &fh));
+
+ BOOST_REQUIRE_EQUAL(0, fuse.fuse->fgetattr(fileName, &st, &fh));
+ BOOST_REQUIRE_EQUAL(st.st_size, sizeof(someData));
+
+ BOOST_CHECKPOINT("Delete old daemon object");
+ daemon.reset();
+ BOOST_CHECKPOINT("Create new daemon object");
+ daemon = MockDaemonHostPtr(new MockDaemonHost());
+
+ BOOST_CHECKPOINT("Fetch file attributes again");
+ BOOST_REQUIRE_EQUAL(0, fuse.fuse->fgetattr(fileName, &st, &fh));
+
+ BOOST_CHECKPOINT("Close file");
+ BOOST_REQUIRE_EQUAL(0, fuse.fuse->release(fileName, &fh));
+}
+