summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-02-19 01:19:36 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-02-19 01:19:36 +0000
commit936bf79d6d5b8c67cf850ef8e510fcdd87622ca9 (patch)
tree3a5b0a542b4bab4ae78a3c2ce5bcbf4fd4c06b56
parentKeep a copy of fuse operations map (diff)
downloadnetfs-936bf79d6d5b8c67cf850ef8e510fcdd87622ca9.tar.bz2
netfs-936bf79d6d5b8c67cf850ef8e510fcdd87622ca9.tar.xz
netfs-936bf79d6d5b8c67cf850ef8e510fcdd87622ca9.zip
Refactor mocked stuff in wrappers for easy setup/teardown and expose the fuse operations map instead of the app instance
-rw-r--r--netfs/unittests/testCore.cpp72
1 files changed, 50 insertions, 22 deletions
diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp
index 0f74925..495c5a7 100644
--- a/netfs/unittests/testCore.cpp
+++ b/netfs/unittests/testCore.cpp
@@ -35,6 +35,35 @@ class MockDaemon : public NetFSDaemon {
}
};
+class MockDaemonHost {
+ public:
+ MockDaemonHost() :
+ params({}),
+ ic(Ice::initialize(params)),
+ daemon(new MockDaemon(ic))
+ {
+ ic->getProperties()->setProperty("NetFSD.HostNameOverride", "unittest");
+ daemon->start("NetFSDaemonAdapter", ic, {});
+
+ }
+
+ ~MockDaemonHost()
+ {
+ delete daemon;
+ ic->destroy();
+ }
+
+ Ice::StringSeq params;
+ Ice::CommunicatorPtr ic;
+ NetFSDaemon * daemon;
+};
+typedef boost::shared_ptr<MockDaemonHost> MockDaemonHostPtr;
+
+char * argv[] = {
+ strdup((RootDir / ":testvol").string().c_str()),
+ strdup((RootDir / "test").string().c_str())
+};
+
class FuseMock : public NetFS::FuseApp {
public:
FuseMock(int & argc, char ** argv) :
@@ -81,39 +110,38 @@ class FuseMock : public NetFS::FuseApp {
fuse_context context;
};
-char * argv[] = {
- strdup((RootDir / ":testvol").string().c_str()),
- strdup((RootDir / "test").string().c_str())
-};
-
-class Core {
+class FuseMockHost {
public:
- Core() :
- params({}),
- ic(Ice::initialize(params)),
- daemon(new MockDaemon(ic)),
+ FuseMockHost() :
argc(2),
- fuse(new FuseMock(argc, argv))
+ app(new FuseMock(argc, argv)),
+ fuse(&app->ops)
{
- ic->getProperties()->setProperty("NetFSD.HostNameOverride", "unittest");
- daemon->start("NetFSDaemonAdapter", ic, {});
char ** a = argv;
- FuseAppBase::run(argc, a, fuse);
+ FuseAppBase::run(argc, a, app);
}
- ~Core()
+ int argc;
+ FuseMock * app;
+ fuse_operations * fuse;
+};
+
+class Core {
+ public:
+ Core() :
+ ic(daemonHost.ic),
+ daemon(daemonHost.daemon),
+ fuse(fuseHost.fuse)
{
- delete fuse;
- delete daemon;
- ic->destroy();
}
protected:
- Ice::StringSeq params;
+ MockDaemonHost daemonHost;
+ FuseMockHost fuseHost;
+
Ice::CommunicatorPtr ic;
- NetFSDaemon * daemon;
- int argc;
- FuseAppBase * fuse;
+ NetFSDaemon * const daemon;
+ fuse_operations * fuse;;
};
BOOST_FIXTURE_TEST_SUITE( NetfsCore, Core )