From 3523abccb5104d27725e092103b43d75fa2b90d3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 19 Feb 2015 01:14:04 +0000 Subject: Virtualise fues_main so that the ut framework can get access to the operations map --- libfusepp/fuseAppBase.h | 3 ++- netfs/fuse/netfs.cpp | 6 ++++++ netfs/unittests/testCore.cpp | 9 +++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libfusepp/fuseAppBase.h b/libfusepp/fuseAppBase.h index 73a809a..d76fbff 100644 --- a/libfusepp/fuseAppBase.h +++ b/libfusepp/fuseAppBase.h @@ -57,6 +57,7 @@ class FuseAppBase { virtual int onError(const std::exception & err) throw(); virtual int fuse_opt_parse(struct fuse_args *args, void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc) = 0; + virtual int main(int &, char **, const struct fuse_operations *) = 0; #define GetHelper(func) getHelper<&FuseAppBase::func>(typeid(&FuseAppBase::func) != typeid(&FuseApp::func)) template @@ -121,7 +122,7 @@ class FuseAppBase { #endif #endif }; - return fuse_main(args.argc, args.argv, &operations, fa); + return fa->main(args.argc, args.argv, &operations); } struct fuse_args runint(int &, char ** &); diff --git a/netfs/fuse/netfs.cpp b/netfs/fuse/netfs.cpp index 21689f2..f700a74 100644 --- a/netfs/fuse/netfs.cpp +++ b/netfs/fuse/netfs.cpp @@ -13,6 +13,12 @@ class FuseImpl : public NetFS::FuseApp { { return ::fuse_opt_parse(args, data, opts, proc); } + + int main(int & argc, char ** argv, const struct fuse_operations * ops) override + { + return ::fuse_main(argc, argv, ops, this); + } + }; int diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp index 2262444..3be4ed0 100644 --- a/netfs/unittests/testCore.cpp +++ b/netfs/unittests/testCore.cpp @@ -56,6 +56,12 @@ class FuseMock : public NetFS::FuseApp { return 0; } + int main(int &, char **, const struct fuse_operations * o) override + { + o->init(NULL); + return 0; + } + protected: virtual NetFS::Client::ConfigurationPtr ReadConfiguration(const std::string &) const override { @@ -86,8 +92,7 @@ class Core { ic->getProperties()->setProperty("NetFSD.HostNameOverride", "unittest"); daemon->start("NetFSDaemonAdapter", ic, {}); char ** a = argv; - fuse->runint(argc, a); - fuse->init(NULL); + FuseAppBase::run(argc, a, fuse); } ~Core() -- cgit v1.2.3