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
69
|
#include "mockMount.h"
#include <boost/test/included/unit_test.hpp>
#include <filesystem>
const std::string testEndpoint("tcp -h localhost -p 12015");
const std::string testUri("tcp://localhost:12015/testvol");
MockFuseApp::MockFuseApp() : NetFS::FuseApp({::testUri}), fargs {}
{
::fuse_opt_add_arg(&fargs, selfExe.c_str());
::fuse_opt_add_arg(&fargs, "-onoauto_cache");
::fuse_opt_add_arg(&fargs, "-oattr_timeout=0");
::fuse_opt_add_arg(&fargs, "-oac_attr_timeout=0");
fs = ::fuse_new(&fargs, &operations, sizeof(fuse_operations), this);
BOOST_REQUIRE(fs);
}
FuseMountPoint::FuseMountPoint() :
MockDaemonHost(::testEndpoint, {"--NetFSD.ConfigPath=" + (rootDir / "defaultDaemon.xml").string()})
{
std::filesystem::remove_all(mntpnt);
std::filesystem::create_directory(mntpnt);
BOOST_REQUIRE_EQUAL(0, ::fuse_mount(fuseApp.fs, mntpnt.c_str()));
th.emplace(::fuse_loop, fuseApp.fs);
BOOST_REQUIRE(th);
}
FuseMountPoint::~FuseMountPoint()
{
::fuse_exit(fuseApp.fs);
th->join();
::fuse_unmount(fuseApp.fs);
std::filesystem::remove(mntpnt);
}
MockFuseApp::~MockFuseApp()
{
::fuse_destroy(fs);
::fuse_opt_free_args(&fargs);
}
struct fuse_context *
MockFuseApp::fuse_get_context()
{
return ::fuse_get_context();
}
char *
MockFuseApp::vstrdupf(const char * fmt, va_list args)
{
char * out {};
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
// NOLINTNEXTLINE(clang-diagnostic-format-nonliteral)
BOOST_REQUIRE_GE(vasprintf(&out, fmt, args), 0);
#pragma GCC diagnostic push
BOOST_REQUIRE(out);
return out;
}
void
MockFuseApp::vlogf(int, const char * fmt, va_list args) const noexcept
{
std::unique_ptr<char, void (*)(void *)> msg(vstrdupf(fmt, args), std::free);
static std::mutex btm;
ScopeLock(btm) {
BOOST_TEST_MESSAGE(msg.get());
}
}
|