blob: b283d7bf5b1df9b97b4b16b43719fc6cfcae8699 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include "mockFuse.h"
#include <boost/test/test_tools.hpp>
#include <buffer.h>
FuseMock::FuseMock(std::string ep, Ice::StringSeq a) :
NetFS::FuseApp(std::move(a)), testEndpoint(std::move(ep)), context({})
{
::memset(&context, 0, sizeof(fuse_context));
context.pid = getpid();
context.uid = getuid();
context.gid = getgid();
}
struct fuse_context *
FuseMock::fuse_get_context()
{
return &context;
}
void
FuseMock::connectToService()
{
if (testEndpoint.empty()) {
return FuseApp::connectToService();
}
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);
}
}
}
void
FuseMock::vlogf(int, const char * fmt, va_list args) const noexcept
{
static std::mutex btm;
ScopeLock(btm) {
BOOST_TEST_MESSAGE(vstringf(fmt, args));
}
}
FuseMockHost::FuseMockHost(std::string ep, const Ice::StringSeq & a) :
app(std::make_unique<FuseMock>(std::move(ep), a)), fuse(&app->operations)
{
if (app->operations.init) {
app->operations.init(nullptr, nullptr);
}
}
|