summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--netfs/unittests/mockDaemon.cpp3
-rw-r--r--netfs/unittests/testCore.cpp43
2 files changed, 24 insertions, 22 deletions
diff --git a/netfs/unittests/mockDaemon.cpp b/netfs/unittests/mockDaemon.cpp
index 1ccd6b7..dd8d3fd 100644
--- a/netfs/unittests/mockDaemon.cpp
+++ b/netfs/unittests/mockDaemon.cpp
@@ -2,7 +2,8 @@
#include <buffer.h>
#include <definedDirs.h>
-const std::filesystem::path MockDaemonHost::TestExportRoot(binDir / UniqueExport::get(getpid()));
+const std::filesystem::path MockDaemonHost::TestExportRoot {
+ getenv("XDG_RUNTIME_DIR") / selfExe.filename() / UniqueExport::get(getpid())};
MockDaemon::MockDaemon(std::string ep) : NetFSDaemon(), testEndpoint(std::move(ep)) { }
diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp
index 385b826..0807dab 100644
--- a/netfs/unittests/testCore.cpp
+++ b/netfs/unittests/testCore.cpp
@@ -10,6 +10,7 @@
#include <fuseFiles.h>
#include <ostream>
+const std::filesystem::path tmpDir {getenv("XDG_RUNTIME_DIR") / selfExe.filename()};
const auto testExport = UniqueExport::get(getpid());
const std::string testEndpoint("tcp -h localhost -p 12012");
const std::string testUri("tcp://localhost:12012/testvol");
@@ -55,7 +56,7 @@ public:
"--NetFSD.ConfigPath=" + (rootDir / daemonConfig).string()}),
fuseHost(testEndpoint,
{"--Ice.ThreadPool.Client.Size=6", "--Ice.ThreadPool.Client.SizeMax=20",
- (rootDir / fuseConfig).string() + ":testvol", (binDir / "test").string()}),
+ (rootDir / fuseConfig).string() + ":testvol", (tmpDir / "test").string()}),
ic(daemonHost.ic), fuse(fuseHost.fuse)
{
}
@@ -124,9 +125,9 @@ BOOST_AUTO_TEST_CASE(testNavigation)
int fd = fuse->create("/inside", 0666, &fi);
BOOST_REQUIRE(fd >= 0);
fuse->release("/inside", &fi);
- BOOST_REQUIRE(std::filesystem::exists(binDir / testExport / "inside"));
- BOOST_REQUIRE_EQUAL(lstat((binDir / testExport).c_str(), &rootattr), 0);
- BOOST_REQUIRE_EQUAL(lstat((binDir / testExport / "inside").c_str(), &insideattr), 0);
+ BOOST_REQUIRE(std::filesystem::exists(tmpDir / testExport / "inside"));
+ BOOST_REQUIRE_EQUAL(lstat((tmpDir / testExport).c_str(), &rootattr), 0);
+ BOOST_REQUIRE_EQUAL(lstat((tmpDir / testExport / "inside").c_str(), &insideattr), 0);
BOOST_REQUIRE_EQUAL(0, fuse->getattr("/", &attr, nullptr));
BOOST_REQUIRE_EQUAL(attr, rootattr);
BOOST_REQUIRE_EQUAL(0, fuse->getattr(".", &attr, nullptr));
@@ -152,28 +153,28 @@ BOOST_AUTO_TEST_CASE(testNavigation)
BOOST_AUTO_TEST_CASE(testSandboxing)
{
// A previous (bad) run might create one or more of these:
- std::filesystem::remove(binDir / "outside");
- std::filesystem::remove(binDir / "sub" / "outside");
- std::filesystem::remove(binDir / "sub");
+ std::filesystem::remove(tmpDir / "outside");
+ std::filesystem::remove(tmpDir / "sub" / "outside");
+ std::filesystem::remove(tmpDir / "sub");
struct fuse_file_info fi { };
BOOST_REQUIRE_EQUAL(fuse->create("../outside", 0666, &fi), -EPERM);
- BOOST_REQUIRE(!std::filesystem::exists(binDir / "outside"));
+ BOOST_REQUIRE(!std::filesystem::exists(tmpDir / "outside"));
BOOST_REQUIRE_EQUAL(fuse->create("/../outside", 0666, &fi), -EPERM);
- BOOST_REQUIRE(!std::filesystem::exists(binDir / "outside"));
+ BOOST_REQUIRE(!std::filesystem::exists(tmpDir / "outside"));
BOOST_REQUIRE_EQUAL(fuse->create("../sub/outside", 0666, &fi), -EPERM);
- BOOST_REQUIRE(!std::filesystem::exists(binDir / "sub" / "outside"));
+ BOOST_REQUIRE(!std::filesystem::exists(tmpDir / "sub" / "outside"));
BOOST_REQUIRE_EQUAL(fuse->create("/../sub/outside", 0666, &fi), -EPERM);
- BOOST_REQUIRE(!std::filesystem::exists(binDir / "sub" / "outside"));
+ BOOST_REQUIRE(!std::filesystem::exists(tmpDir / "sub" / "outside"));
BOOST_REQUIRE_EQUAL(fuse->create("../sub/../outside", 0666, &fi), -EPERM);
- BOOST_REQUIRE(!std::filesystem::exists(binDir / "outside"));
+ BOOST_REQUIRE(!std::filesystem::exists(tmpDir / "outside"));
BOOST_REQUIRE_EQUAL(fuse->create("/../sub/../outside", 0666, &fi), -EPERM);
- BOOST_REQUIRE(!std::filesystem::exists(binDir / "outside"));
+ BOOST_REQUIRE(!std::filesystem::exists(tmpDir / "outside"));
BOOST_REQUIRE_EQUAL(fuse->create("/inside", 0666, &fi), 0);
BOOST_REQUIRE_EQUAL(fuse->release("/inside", &fi), 0);
- BOOST_REQUIRE(std::filesystem::exists(binDir / testExport / "inside"));
+ BOOST_REQUIRE(std::filesystem::exists(tmpDir / testExport / "inside"));
BOOST_REQUIRE_EQUAL(fuse->create("inside2", 0666, &fi), 0);
BOOST_REQUIRE_EQUAL(fuse->release("inside2", &fi), 0);
- BOOST_REQUIRE(std::filesystem::exists(binDir / testExport / "inside2"));
+ BOOST_REQUIRE(std::filesystem::exists(tmpDir / testExport / "inside2"));
}
void
@@ -199,7 +200,7 @@ BOOST_AUTO_TEST_CASE(directories)
struct fuse_file_info fi { };
struct stat st { };
BOOST_REQUIRE_EQUAL(fuse->mkdir("/test", 0700), 0);
- BOOST_REQUIRE(std::filesystem::is_directory(binDir / testExport / "test"));
+ BOOST_REQUIRE(std::filesystem::is_directory(tmpDir / testExport / "test"));
BOOST_REQUIRE_EQUAL(fuse->mkdir("/test", 0700), -EEXIST);
BOOST_REQUIRE_EQUAL(fuse->getattr("/test", &st, nullptr), 0);
@@ -232,7 +233,7 @@ BOOST_AUTO_TEST_CASE(directories)
BOOST_REQUIRE_EQUAL(fuse->rmdir("/test"), -ENOTEMPTY);
BOOST_REQUIRE_EQUAL(fuse->rmdir("/test/sub"), 0);
BOOST_REQUIRE_EQUAL(fuse->rmdir("/test"), 0);
- BOOST_REQUIRE(!std::filesystem::is_directory(binDir / testExport / "test"));
+ BOOST_REQUIRE(!std::filesystem::is_directory(tmpDir / testExport / "test"));
BOOST_REQUIRE_EQUAL(fuse->rmdir("/test"), -ENOENT);
BOOST_REQUIRE_EQUAL(fuse->getattr("/test", &st, nullptr), -ENOENT);
BOOST_REQUIRE_EQUAL(fuse->opendir("/test", &fi), -ENOENT);
@@ -510,7 +511,7 @@ BOOST_AUTO_TEST_CASE(utimens)
BOOST_REQUIRE_EQUAL(st.st_mtim.tv_nsec, 0);
BOOST_REQUIRE_EQUAL(st.st_ctim.tv_nsec, 0);
// Real file doesn't
- BOOST_REQUIRE_EQUAL(lstat((binDir / testExport / "file").c_str(), &st), 0);
+ BOOST_REQUIRE_EQUAL(lstat((tmpDir / testExport / "file").c_str(), &st), 0);
BOOST_REQUIRE_EQUAL(st.st_atim.tv_sec, 1);
BOOST_REQUIRE_EQUAL(st.st_atime, 1);
BOOST_REQUIRE_EQUAL(st.st_mtim.tv_sec, 2);
@@ -527,7 +528,7 @@ BOOST_AUTO_TEST_CASE(noListDir)
{
struct fuse_file_info fi { };
BOOST_REQUIRE_EQUAL(fuse->mkdir("/test", 0700), 0);
- BOOST_REQUIRE(std::filesystem::is_directory(binDir / testExport / "test"));
+ BOOST_REQUIRE(std::filesystem::is_directory(tmpDir / testExport / "test"));
BOOST_REQUIRE_EQUAL(fuse->mkdir("/test", 0700), -EEXIST);
BOOST_REQUIRE_EQUAL(fuse->opendir("/test", &fi), 0);
@@ -557,7 +558,7 @@ BOOST_AUTO_TEST_CASE(noListDir)
BOOST_REQUIRE_EQUAL(fuse->rmdir("/test"), -ENOTEMPTY);
BOOST_REQUIRE_EQUAL(fuse->rmdir("/test/sub"), 0);
BOOST_REQUIRE_EQUAL(fuse->rmdir("/test"), 0);
- BOOST_REQUIRE(!std::filesystem::is_directory(binDir / testExport / "test"));
+ BOOST_REQUIRE(!std::filesystem::is_directory(tmpDir / testExport / "test"));
BOOST_REQUIRE_EQUAL(fuse->rmdir("/test"), -ENOENT);
BOOST_REQUIRE_EQUAL(fuse->opendir("/test", &fi), -ENOENT);
}
@@ -613,7 +614,7 @@ BOOST_AUTO_TEST_CASE(uriConnect)
FuseMockHost fuse(std::string(),
{
testUri,
- (binDir / "test").string(),
+ (tmpDir / "test").string(),
});
struct statvfs s;