diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-09-23 19:33:42 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-09-24 23:13:15 +0100 |
commit | c4cc5b556ce79e55fda1dd1e4a46bc23448306fb (patch) | |
tree | 12877c0fb921b059fce5a9c24130b208e64cd173 /netfs/unittests/mockFuse.cpp | |
parent | Add option terminator to test run command lines (diff) | |
download | netfs-c4cc5b556ce79e55fda1dd1e4a46bc23448306fb.tar.bz2 netfs-c4cc5b556ce79e55fda1dd1e4a46bc23448306fb.tar.xz netfs-c4cc5b556ce79e55fda1dd1e4a46bc23448306fb.zip |
Fuse separation
First swing at separating the fuse library interface with the fuse operations
Diffstat (limited to 'netfs/unittests/mockFuse.cpp')
-rw-r--r-- | netfs/unittests/mockFuse.cpp | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/netfs/unittests/mockFuse.cpp b/netfs/unittests/mockFuse.cpp index da6b07f..fd93388 100644 --- a/netfs/unittests/mockFuse.cpp +++ b/netfs/unittests/mockFuse.cpp @@ -3,7 +3,6 @@ FuseMock::FuseMock(std::string ep, Ice::StringSeq a) : NetFS::FuseApp(std::move(a)), - ops({}), testEndpoint(std::move(ep)), context({}) { @@ -19,34 +18,21 @@ FuseMock::fuse_get_context() return &context; } -int -// NOLINTNEXTLINE(modernize-avoid-c-arrays, hicpp-avoid-c-arrays) -FuseMock::fuse_opt_parse(struct fuse_args * args, void * data, const struct fuse_opt [], fuse_opt_proc_t proc) +void +FuseMock::connectToService() { - for (int n = 0; n < args->argc; n += 1) { - proc(data, args->argv[n], n, args); + if (testEndpoint.empty()) { + return FuseApp::connectToService(); } - return 0; -} -int -FuseMock::main(int, char **, const struct fuse_operations * o) -{ - o->init(nullptr); - ops = *o; - return 0; -} - -NetFS::Client::ConfigurationPtr -FuseMock::ReadConfiguration(const std::filesystem::path & path) const -{ - auto c = FuseApp::ReadConfiguration(path); - for(const auto & r : c->Resources) { - for(auto & e : r.second->Endpoints) { - e = testEndpoint; + if (!service) { + Lock(_lock); + std::string addr = fcr->ServiceIdentity + ":" + testEndpoint; + service = Ice::checkedCast<NetFS::ServicePrx>(ic->stringToProxy(addr)); + if (!service) { + throw std::runtime_error("Invalid service proxy: " + testEndpoint); } } - return c; } void @@ -57,12 +43,7 @@ FuseMock::vlogf(int, const char * fmt, va_list args) const noexcept FuseMockHost::FuseMockHost(std::string ep, const Ice::StringSeq & a) : app(std::make_unique<FuseMock>(std::move(ep), a)), - fuse(&app->ops) + fuse(&app->operations) { - std::vector<char *> argv; - for (auto & arg : a) { - argv.push_back(const_cast<char *>(arg.c_str())); - } - FuseAppBase::run(a.size(), &argv.front(), app.get()); } |