diff options
-rw-r--r-- | netfs/unittests/testCore.cpp | 72 |
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 ) |