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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#include "mockFuse.h"
#include <boost/test/test_tools.hpp>
FuseMock::FuseMock(std::string ep, Ice::StringSeq a) :
NetFS::FuseApp(std::move(a)),
ops({}),
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;
}
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)
{
for (int n = 0; n < args->argc; n += 1) {
proc(data, args->argv[n], n, args);
}
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;
}
}
return c;
}
void
FuseMock::vlogf(int, const char * fmt, va_list args) const noexcept
{
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->ops)
{
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());
}
|