summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/blob.cpp25
-rw-r--r--src/blob.h31
-rw-r--r--src/dir.cpp19
-rw-r--r--src/dir.h25
-rw-r--r--src/git.cpp65
-rw-r--r--src/git.h40
-rw-r--r--src/main.cpp44
-rw-r--r--src/repo.cpp86
-rw-r--r--src/repo.h78
-rw-r--r--src/repoList.cpp20
-rw-r--r--src/repoList.h14
-rw-r--r--unittests/config.cpp71
-rw-r--r--unittests/core.cpp147
-rw-r--r--unittests/mockDefs.cpp15
-rw-r--r--unittests/mockDefs.h23
-rw-r--r--unittests/service.cpp31
16 files changed, 331 insertions, 403 deletions
diff --git a/src/blob.cpp b/src/blob.cpp
index 6311b31..4e1b2de 100644
--- a/src/blob.cpp
+++ b/src/blob.cpp
@@ -1,13 +1,10 @@
-#include <Ice/ObjectAdapter.h>
-#include <sys/stat.h>
#include "blob.h"
#include "repo.h"
+#include <Ice/ObjectAdapter.h>
+#include <sys/stat.h>
GitFS::Blob::Blob(const Repo * const r, std::string && path) :
- repo(r),
- entry(Git::TreeEntryByPath(repo->tree, path)),
- blob(getBlob()),
- blobSize(git_blob_rawsize(blob.get())),
+ repo(r), entry(Git::TreeEntryByPath(repo->tree, path)), blob(getBlob()), blobSize(git_blob_rawsize(blob.get())),
blobContent(static_cast<const char *>(git_blob_rawcontent(blob.get())))
{
}
@@ -28,14 +25,13 @@ GitFS::Blob::getBlob() const
}
void
-GitFS::Blob::close(const ::Ice::Current& current)
+GitFS::Blob::close(const ::Ice::Current & current)
{
current.adapter->remove(current.id);
}
-
NetFS::Attr
-GitFS::Blob::fgetattr(ReqEnv, const ::Ice::Current&)
+GitFS::Blob::fgetattr(ReqEnv, const ::Ice::Current &)
{
NetFS::Attr a;
a << *blob << *entry << *repo->commit;
@@ -44,9 +40,8 @@ GitFS::Blob::fgetattr(ReqEnv, const ::Ice::Current&)
return a;
}
-
NetFS::Buffer
-GitFS::Blob::read(long long int o, long long int s, const ::Ice::Current&)
+GitFS::Blob::read(long long int o, long long int s, const ::Ice::Current &)
{
const decltype(blobSize) offset(o);
const decltype(blobSize) size(s);
@@ -57,18 +52,14 @@ GitFS::Blob::read(long long int o, long long int s, const ::Ice::Current&)
return NetFS::Buffer(blobContent + offset, blobContent + offset + len);
}
-
void
-GitFS::Blob::ftruncate(ReqEnv, long long int, const ::Ice::Current&)
+GitFS::Blob::ftruncate(ReqEnv, long long int, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
void
-GitFS::Blob::write(long long int, long long int, Buffer, const ::Ice::Current&)
+GitFS::Blob::write(long long int, long long int, Buffer, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
-
diff --git a/src/blob.h b/src/blob.h
index 923d53d..4398555 100644
--- a/src/blob.h
+++ b/src/blob.h
@@ -1,31 +1,30 @@
#ifndef GITFS_BLOB_H
#define GITFS_BLOB_H
-#include <file.h>
#include "git.h"
+#include <file.h>
namespace GitFS {
using namespace NetFS;
class Repo;
class Blob : public File {
- public:
- Blob(const Repo * const r, std::string &&);
+ public:
+ Blob(const Repo * const r, std::string &&);
- void close(const ::Ice::Current& current) override;
- Attr fgetattr(ReqEnv env, const ::Ice::Current& current) override;
- Buffer read(long long int offset, long long int size, const ::Ice::Current& current) override;
- void ftruncate(ReqEnv env, long long int size, const ::Ice::Current& current) override;
- void write(long long int offset, long long int size, Buffer data, const ::Ice::Current& current) override;
+ void close(const ::Ice::Current & current) override;
+ Attr fgetattr(ReqEnv env, const ::Ice::Current & current) override;
+ Buffer read(long long int offset, long long int size, const ::Ice::Current & current) override;
+ void ftruncate(ReqEnv env, long long int size, const ::Ice::Current & current) override;
+ void write(long long int offset, long long int size, Buffer data, const ::Ice::Current & current) override;
- private:
- Git::BlobPtr getBlob() const;
- const Repo * const repo;
- Git::TreeEntryPtr entry;
- Git::BlobPtr blob;
- const decltype(git_blob_rawsize({})) blobSize;
- const char * const blobContent;
+ private:
+ Git::BlobPtr getBlob() const;
+ const Repo * const repo;
+ Git::TreeEntryPtr entry;
+ Git::BlobPtr blob;
+ const decltype(git_blob_rawsize({})) blobSize;
+ const char * const blobContent;
};
}
#endif
-
diff --git a/src/dir.cpp b/src/dir.cpp
index 78ff83a..9e524aa 100644
--- a/src/dir.cpp
+++ b/src/dir.cpp
@@ -1,12 +1,9 @@
+#include "dir.h"
+#include "repo.h"
#include <Ice/ObjectAdapter.h>
#include <sys/stat.h>
-#include "repo.h"
-#include "dir.h"
-GitFS::Directory::Directory(Repo * const r, std::string && p) :
- repo(r),
- path(std::move(p)),
- subTreeCacheRootId({})
+GitFS::Directory::Directory(Repo * const r, std::string && p) : repo(r), path(std::move(p)), subTreeCacheRootId({})
{
getSubtree();
}
@@ -32,14 +29,13 @@ GitFS::Directory::getSubtree() const
}
void
-GitFS::Directory::close(const ::Ice::Current& current)
+GitFS::Directory::close(const ::Ice::Current & current)
{
current.adapter->remove(current.id);
}
-
NetFS::NameList
-GitFS::Directory::readdir(const ::Ice::Current&)
+GitFS::Directory::readdir(const ::Ice::Current &)
{
const auto subTree = getSubtree();
NetFS::NameList list;
@@ -50,9 +46,8 @@ GitFS::Directory::readdir(const ::Ice::Current&)
return list;
}
-
NetFS::DirectoryContents
-GitFS::Directory::listdir(const ::Ice::Current&)
+GitFS::Directory::listdir(const ::Ice::Current &)
{
const auto subTree = getSubtree();
NetFS::DirectoryContents list;
@@ -70,5 +65,3 @@ GitFS::Directory::listdir(const ::Ice::Current&)
}
return list;
}
-
-
diff --git a/src/dir.h b/src/dir.h
index e8a29df..91d9ddd 100644
--- a/src/dir.h
+++ b/src/dir.h
@@ -1,29 +1,28 @@
#ifndef GITFS_DIRECTORY_H
#define GITFS_DIRECTORY_H
-#include <directory.h>
#include "git.h"
+#include <directory.h>
namespace GitFS {
using namespace NetFS;
class Repo;
class Directory : public NetFS::Directory {
- public:
- Directory(Repo * const r, std::string &&);
+ public:
+ Directory(Repo * const r, std::string &&);
- void close(const ::Ice::Current& current) override;
- NameList readdir(const ::Ice::Current& current) override;
- DirectoryContents listdir(const ::Ice::Current& current) override;
+ void close(const ::Ice::Current & current) override;
+ NameList readdir(const ::Ice::Current & current) override;
+ DirectoryContents listdir(const ::Ice::Current & current) override;
- private:
- Git::TreePtr getSubtree() const;
- Repo * const repo;
- const std::string path;
+ private:
+ Git::TreePtr getSubtree() const;
+ Repo * const repo;
+ const std::string path;
- mutable Git::TreePtr subTreeCache;
- mutable git_oid subTreeCacheRootId;
+ mutable Git::TreePtr subTreeCache;
+ mutable git_oid subTreeCacheRootId;
};
}
#endif
-
diff --git a/src/git.cpp b/src/git.cpp
index f3f437e..1c9da62 100644
--- a/src/git.cpp
+++ b/src/git.cpp
@@ -1,13 +1,12 @@
#include "git.h"
-#include <execinfo.h>
#include <exceptions.h>
-#include <types.h>
+#include <execinfo.h>
#include <sys/stat.h>
+#include <types.h>
namespace GitFS::Git {
template<>
- [[noreturn]]
- void
+ [[noreturn]] void
throwError<NetFS::SystemError>(int err)
{
if (err == GIT_ENOTFOUND) {
@@ -17,63 +16,64 @@ namespace GitFS::Git {
}
template<>
- [[noreturn]]
- void
+ [[noreturn]] void
throwError<NetFS::ConfigError>(int)
{
throw NetFS::ConfigError();
}
- git_oid OidParse(const std::string_view & str)
+ git_oid
+ OidParse(const std::string_view & str)
{
git_oid oid;
gitSafe<NetFS::ConfigError>(git_oid_fromstrn, &oid, str.data(), str.length());
return oid;
}
- RepositoryPtr RepositoryOpenBare(const std::string & path)
+ RepositoryPtr
+ RepositoryOpenBare(const std::string & path)
{
- return gitSafeGet<NetFS::ConfigError>(
- git_repository_open_bare, git_repository_free, path.c_str());
+ return gitSafeGet<NetFS::ConfigError>(git_repository_open_bare, git_repository_free, path.c_str());
}
- BlobPtr BlobLookup(const RepositoryPtr & repo, const git_oid & blob)
+ BlobPtr
+ BlobLookup(const RepositoryPtr & repo, const git_oid & blob)
{
- return gitSafeGet<NetFS::SystemError>(
- git_blob_lookup, git_blob_free, repo.get(), &blob);
+ return gitSafeGet<NetFS::SystemError>(git_blob_lookup, git_blob_free, repo.get(), &blob);
}
- CommitPtr CommitLookup(const RepositoryPtr & repo, const git_oid & commitId)
+ CommitPtr
+ CommitLookup(const RepositoryPtr & repo, const git_oid & commitId)
{
- return gitSafeGet<NetFS::ConfigError>(
- git_commit_lookup, git_commit_free, repo.get(), &commitId);
+ return gitSafeGet<NetFS::ConfigError>(git_commit_lookup, git_commit_free, repo.get(), &commitId);
}
- TreePtr TreeLookup(const RepositoryPtr & repo, const git_oid & treeId)
+ TreePtr
+ TreeLookup(const RepositoryPtr & repo, const git_oid & treeId)
{
- return gitSafeGet<NetFS::SystemError>(
- git_tree_lookup, git_tree_free, repo.get(), &treeId);
+ return gitSafeGet<NetFS::SystemError>(git_tree_lookup, git_tree_free, repo.get(), &treeId);
}
- TreeEntryPtr TreeEntryByPath(const TreePtr & tree, const std::string & path)
+ TreeEntryPtr
+ TreeEntryByPath(const TreePtr & tree, const std::string & path)
{
- return gitSafeGet<NetFS::SystemError>(
- git_tree_entry_bypath, git_tree_entry_free, tree.get(), path.c_str() + 1);
+ return gitSafeGet<NetFS::SystemError>(git_tree_entry_bypath, git_tree_entry_free, tree.get(), path.c_str() + 1);
}
- RefPtr Commitish(const RepositoryPtr & repo, const std::string & name)
+ RefPtr
+ Commitish(const RepositoryPtr & repo, const std::string & name)
{
- return gitSafeGet<NetFS::ConfigError>(
- git_reference_dwim, git_reference_free, repo.get(), name.c_str());
+ return gitSafeGet<NetFS::ConfigError>(git_reference_dwim, git_reference_free, repo.get(), name.c_str());
}
- RefPtr Resolve(const RefPtr & ref)
+ RefPtr
+ Resolve(const RefPtr & ref)
{
- return gitSafeGet<NetFS::ConfigError>(
- git_reference_resolve, git_reference_free, ref.get());
+ return gitSafeGet<NetFS::ConfigError>(git_reference_resolve, git_reference_free, ref.get());
}
}
namespace NetFS {
- Attr & operator<<(Attr & a, const git_tree_entry & e)
+ Attr &
+ operator<<(Attr & a, const git_tree_entry & e)
{
a.mode = git_tree_entry_filemode(&e);
if (S_ISDIR(a.mode)) {
@@ -88,13 +88,15 @@ namespace NetFS {
return a;
}
- Attr & operator<<(Attr & a, const git_commit & c)
+ Attr &
+ operator<<(Attr & a, const git_commit & c)
{
a.ctime = a.atime = a.mtime = git_commit_time(&c);
return a;
}
- Attr & operator<<(Attr & a, const git_blob & b)
+ Attr &
+ operator<<(Attr & a, const git_blob & b)
{
a.blockSize = 1;
a.blocks = a.size = git_blob_rawsize(&b);
@@ -112,4 +114,3 @@ namespace std {
return s;
}
}
-
diff --git a/src/git.h b/src/git.h
index 90eb4f9..96a79bd 100644
--- a/src/git.h
+++ b/src/git.h
@@ -1,38 +1,36 @@
#ifndef GITFS_GIT_H
#define GITFS_GIT_H
-#include <memory>
#include <git2.h>
+#include <memory>
#include <ostream>
namespace GitFS::Git {
- template<typename E>
- [[noreturn]] void throwError(int err);
+ template<typename E>[[noreturn]] void throwError(int err);
- template<typename E, typename ... P, typename ... A>
+ template<typename E, typename... P, typename... A>
void
- gitSafe(int (*func)(P...), A ... p)
+ gitSafe(int (*func)(P...), A... p)
{
if (int _giterror = func(p...)) {
throwError<E>(_giterror);
}
}
- template<typename T>
- using TPtr = std::shared_ptr<T>;
+ template<typename T> using TPtr = std::shared_ptr<T>;
- template<typename E, typename R, typename ... P, typename ... A>
+ template<typename E, typename R, typename... P, typename... A>
auto
- gitSafeGet(int(*get)(R**, P...), void(*release)(R*), A ... p)
+ gitSafeGet(int (*get)(R **, P...), void (*release)(R *), A... p)
{
R * r = nullptr;
gitSafe<E>(get, &r, p...);
return TPtr<R>(r, release);
}
- template<typename E, typename R, typename ... P, typename ... A>
+ template<typename E, typename R, typename... P, typename... A>
auto
- gitSafeGet(int(*get)(R**, P...), A ... p)
+ gitSafeGet(int (*get)(R **, P...), A... p)
{
R * r = nullptr;
gitSafe<E>(get, &r, p...);
@@ -41,28 +39,23 @@ namespace GitFS::Git {
git_oid OidParse(const std::string_view & str);
- using RepositoryPtr = decltype(gitSafeGet<std::exception>(
- git_repository_open_bare, git_repository_free, nullptr));
+ using RepositoryPtr = decltype(gitSafeGet<std::exception>(git_repository_open_bare, git_repository_free, nullptr));
RepositoryPtr RepositoryOpenBare(const std::string & path);
- using BlobPtr = decltype(gitSafeGet<std::exception>(
- git_blob_lookup, git_blob_free, nullptr, nullptr));
+ using BlobPtr = decltype(gitSafeGet<std::exception>(git_blob_lookup, git_blob_free, nullptr, nullptr));
BlobPtr BlobLookup(const RepositoryPtr & repo, const git_oid & blob);
- using CommitPtr = decltype(gitSafeGet<std::exception>(
- git_commit_lookup, git_commit_free, nullptr, nullptr));
+ using CommitPtr = decltype(gitSafeGet<std::exception>(git_commit_lookup, git_commit_free, nullptr, nullptr));
CommitPtr CommitLookup(const RepositoryPtr & repo, const git_oid & commitId);
- using TreePtr = decltype(gitSafeGet<std::exception>(
- git_tree_lookup, git_tree_free, nullptr, nullptr));
+ using TreePtr = decltype(gitSafeGet<std::exception>(git_tree_lookup, git_tree_free, nullptr, nullptr));
TreePtr TreeLookup(const RepositoryPtr & repo, const git_oid & treeId);
- using TreeEntryPtr = decltype(gitSafeGet<std::exception>(
- git_tree_entry_bypath, git_tree_entry_free, nullptr, nullptr));
+ using TreeEntryPtr
+ = decltype(gitSafeGet<std::exception>(git_tree_entry_bypath, git_tree_entry_free, nullptr, nullptr));
TreeEntryPtr TreeEntryByPath(const TreePtr & tree, const std::string & path);
- using RefPtr = decltype(gitSafeGet<std::exception>(
- git_reference_dwim, git_reference_free, nullptr, nullptr));
+ using RefPtr = decltype(gitSafeGet<std::exception>(git_reference_dwim, git_reference_free, nullptr, nullptr));
RefPtr Commitish(const RepositoryPtr & repo, const std::string & name);
RefPtr Resolve(const RefPtr &);
}
@@ -79,4 +72,3 @@ namespace std {
}
#endif
-
diff --git a/src/main.cpp b/src/main.cpp
index c6b1c90..59fa299 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,35 +1,35 @@
-#include <icetrayService.h>
-#include <git2.h>
+#include "repoList.h"
#include <factory.h>
+#include <git2.h>
#include <icecube.h>
-#include "repoList.h"
+#include <icetrayService.h>
namespace GitFS {
class Main : public IceTray::Service {
- public:
- Main()
- {
- git_libgit2_init();
- }
+ public:
+ Main()
+ {
+ git_libgit2_init();
+ }
- ~Main() override
- {
- git_libgit2_shutdown();
- }
+ ~Main() override
+ {
+ git_libgit2_shutdown();
+ }
- Main(const Main &) = delete;
- Main(Main &&) = delete;
+ Main(const Main &) = delete;
+ Main(Main &&) = delete;
- Main & operator=(const Main &) = delete;
- Main & operator=(Main &&) = delete;
+ Main & operator=(const Main &) = delete;
+ Main & operator=(Main &&) = delete;
- void addObjects(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &, const Ice::ObjectAdapterPtr & adp) override
- {
- IceTray::Cube::addObject<NetFS::Service, RepoList>(adp, "Service",
- std::move(ic->getProperties()));
- }
+ void
+ addObjects(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &,
+ const Ice::ObjectAdapterPtr & adp) override
+ {
+ IceTray::Cube::addObject<NetFS::Service, RepoList>(adp, "Service", std::move(ic->getProperties()));
+ }
};
NAMEDFACTORY("default", Main, IceTray::ServiceFactory);
}
-
diff --git a/src/repo.cpp b/src/repo.cpp
index 9bf156a..41e6f7d 100644
--- a/src/repo.cpp
+++ b/src/repo.cpp
@@ -1,21 +1,18 @@
-#include <Ice/ObjectAdapter.h>
-#include <sys/stat.h>
#include "repo.h"
#include "blob.h"
#include "dir.h"
+#include <Ice/ObjectAdapter.h>
+#include <sys/stat.h>
-std::string operator/(const std::string & a, const std::string & b)
+std::string
+operator/(const std::string & a, const std::string & b)
{
return a.empty() ? b : a;
}
GitFS::Repo::Repo(const PropertyReader & properties) :
- repo(Git::RepositoryOpenBare(properties("gitdir"))),
- commitish(properties("commitish") / "master"),
- isBranch(false),
- resolvedAt(0),
- gid(properties("gid") / "root"),
- uid(properties("uid") / "root")
+ repo(Git::RepositoryOpenBare(properties("gitdir"))), commitish(properties("commitish") / "master"), isBranch(false),
+ resolvedAt(0), gid(properties("gid") / "root"), uid(properties("uid") / "root")
{
if (commitish.length() == GIT_OID_HEXSZ) {
commit = Git::CommitLookup(repo, Git::OidParse(commitish));
@@ -31,34 +28,31 @@ void
GitFS::Repo::update()
{
if (!commit || (isBranch && ref && resolvedAt < std::time(nullptr) - 30)) {
- commit = Git::CommitLookup(repo,
- *git_reference_target(Git::Resolve(ref).get()));
+ commit = Git::CommitLookup(repo, *git_reference_target(Git::Resolve(ref).get()));
resolvedAt = std::time(nullptr);
}
tree = Git::TreeLookup(repo, *git_commit_tree_id(commit.get()));
}
void
-GitFS::Repo::disconnect(const ::Ice::Current& current)
+GitFS::Repo::disconnect(const ::Ice::Current & current)
{
current.adapter->remove(current.id);
}
-
NetFS::DirectoryPrxPtr
-GitFS::Repo::opendir(ReqEnv, ::std::string path, const ::Ice::Current& ice)
+GitFS::Repo::opendir(ReqEnv, ::std::string path, const ::Ice::Current & ice)
{
if (path.empty()) {
throw NetFS::SystemError(EINVAL);
}
- return Ice::uncheckedCast<NetFS::DirectoryPrx>(ice.adapter->addWithUUID(
- std::make_shared<Directory>(this, std::move(path))));
+ return Ice::uncheckedCast<NetFS::DirectoryPrx>(
+ ice.adapter->addWithUUID(std::make_shared<Directory>(this, std::move(path))));
}
-
NetFS::VFS
-GitFS::Repo::statfs(ReqEnv, ::std::string path, const ::Ice::Current&)
+GitFS::Repo::statfs(ReqEnv, ::std::string path, const ::Ice::Current &)
{
if (path.empty()) {
throw NetFS::SystemError(EINVAL);
@@ -67,9 +61,8 @@ GitFS::Repo::statfs(ReqEnv, ::std::string path, const ::Ice::Current&)
return {};
}
-
int
-GitFS::Repo::access(ReqEnv, ::std::string path, int mode, const ::Ice::Current&)
+GitFS::Repo::access(ReqEnv, ::std::string path, int mode, const ::Ice::Current &)
{
if (mode & W_OK) {
return EACCES;
@@ -106,9 +99,8 @@ GitFS::Repo::access(ReqEnv, ::std::string path, int mode, const ::Ice::Current&)
}
}
-
NetFS::Attr
-GitFS::Repo::getattr(ReqEnv, ::std::string path, const ::Ice::Current&)
+GitFS::Repo::getattr(ReqEnv, ::std::string path, const ::Ice::Current &)
{
if (path.empty()) {
throw NetFS::SystemError(EINVAL);
@@ -133,9 +125,8 @@ GitFS::Repo::getattr(ReqEnv, ::std::string path, const ::Ice::Current&)
return a;
}
-
::std::string
-GitFS::Repo::readlink(ReqEnv, ::std::string path, const ::Ice::Current&)
+GitFS::Repo::readlink(ReqEnv, ::std::string path, const ::Ice::Current &)
{
if (path.empty() || path == "/") {
throw NetFS::SystemError(EINVAL);
@@ -148,12 +139,11 @@ GitFS::Repo::readlink(ReqEnv, ::std::string path, const ::Ice::Current&)
}
auto blob = Git::BlobLookup(repo, *git_tree_entry_id(e.get()));
auto n = static_cast<const ::std::string::value_type *>(git_blob_rawcontent(blob.get()));
- return { n, n + git_blob_rawsize(blob.get()) };
+ return {n, n + git_blob_rawsize(blob.get())};
}
-
NetFS::FilePrxPtr
-GitFS::Repo::open(ReqEnv, ::std::string path, int, const ::Ice::Current& ice)
+GitFS::Repo::open(ReqEnv, ::std::string path, int, const ::Ice::Current & ice)
{
if (path.empty()) {
throw NetFS::SystemError(EINVAL);
@@ -163,92 +153,78 @@ GitFS::Repo::open(ReqEnv, ::std::string path, int, const ::Ice::Current& ice)
}
update();
- return Ice::uncheckedCast<NetFS::FilePrx>(ice.adapter->addWithUUID(
- std::make_shared<Blob>(this, std::move(path))));
+ return Ice::uncheckedCast<NetFS::FilePrx>(ice.adapter->addWithUUID(std::make_shared<Blob>(this, std::move(path))));
}
-
NetFS::FilePrxPtr
-GitFS::Repo::create(ReqEnv, ::std::string, int, int, const ::Ice::Current&)
+GitFS::Repo::create(ReqEnv, ::std::string, int, int, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
void
-GitFS::Repo::truncate(ReqEnv, ::std::string, long long int, const ::Ice::Current&)
+GitFS::Repo::truncate(ReqEnv, ::std::string, long long int, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
void
-GitFS::Repo::unlink(ReqEnv, ::std::string, const ::Ice::Current&)
+GitFS::Repo::unlink(ReqEnv, ::std::string, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
void
-GitFS::Repo::mkdir(ReqEnv, ::std::string, int, const ::Ice::Current&)
+GitFS::Repo::mkdir(ReqEnv, ::std::string, int, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
void
-GitFS::Repo::rmdir(ReqEnv, ::std::string, const ::Ice::Current&)
+GitFS::Repo::rmdir(ReqEnv, ::std::string, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
void
-GitFS::Repo::mknod(ReqEnv, ::std::string, int, int, const ::Ice::Current&)
+GitFS::Repo::mknod(ReqEnv, ::std::string, int, int, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
void
-GitFS::Repo::symlink(ReqEnv, ::std::string, ::std::string, const ::Ice::Current&)
+GitFS::Repo::symlink(ReqEnv, ::std::string, ::std::string, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
void
-GitFS::Repo::link(ReqEnv, ::std::string, ::std::string, const ::Ice::Current&)
+GitFS::Repo::link(ReqEnv, ::std::string, ::std::string, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
void
-GitFS::Repo::rename(ReqEnv, ::std::string, ::std::string, const Ice::optional<Ice::Int>, const ::Ice::Current&)
+GitFS::Repo::rename(ReqEnv, ::std::string, ::std::string, const Ice::optional<Ice::Int>, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
void
-GitFS::Repo::chmod(ReqEnv, ::std::string, int, const ::Ice::Current&)
+GitFS::Repo::chmod(ReqEnv, ::std::string, int, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
void
-GitFS::Repo::chown(ReqEnv, ::std::string, int, int, const ::Ice::Current&)
+GitFS::Repo::chown(ReqEnv, ::std::string, int, int, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
void
-GitFS::Repo::utimens(ReqEnv, ::std::string, long long int, long long int, long long int, long long int, const ::Ice::Current&)
+GitFS::Repo::utimens(
+ ReqEnv, ::std::string, long long int, long long int, long long int, long long int, const ::Ice::Current &)
{
throw NetFS::SystemError(EROFS);
}
-
-
diff --git a/src/repo.h b/src/repo.h
index 34e5826..9a01c55 100644
--- a/src/repo.h
+++ b/src/repo.h
@@ -1,53 +1,53 @@
#ifndef GITFS_REPO_H
#define GITFS_REPO_H
+#include "git.h"
#include <Ice/Properties.h>
#include <volume.h>
-#include "git.h"
namespace GitFS {
using namespace NetFS;
using PropertyReader = std::function<std::string(const std::string_view &)>;
class Repo : public Volume {
- public:
- Repo(const PropertyReader &);
-
- void disconnect(const ::Ice::Current& current) override;
- DirectoryPrxPtr opendir(ReqEnv env, ::std::string path, const ::Ice::Current& current) override;
- VFS statfs(ReqEnv env, ::std::string path, const ::Ice::Current& current) override;
- int access(ReqEnv env, ::std::string path, int mode, const ::Ice::Current& current) override;
- Attr getattr(ReqEnv env, ::std::string path, const ::Ice::Current& current) override;
- ::std::string readlink(ReqEnv env, ::std::string path, const ::Ice::Current& current) override;
- FilePrxPtr open(ReqEnv env, ::std::string path, int flags, const ::Ice::Current& current) override;
- FilePrxPtr create(ReqEnv env, ::std::string path, int flags, int mode, const ::Ice::Current& current) override;
- void truncate(ReqEnv env, ::std::string path, long long int size, const ::Ice::Current& current) override;
- void unlink(ReqEnv env, ::std::string path, const ::Ice::Current& current) override;
- void mkdir(ReqEnv env, ::std::string path, int mode, const ::Ice::Current& current) override;
- void rmdir(ReqEnv env, ::std::string path, const ::Ice::Current& current) override;
- void mknod(ReqEnv env, ::std::string path, int mode, int dev, const ::Ice::Current& current) override;
- void symlink(ReqEnv env, ::std::string path1, ::std::string path2, const ::Ice::Current& current) override;
- void link(ReqEnv env, ::std::string path1, ::std::string path2, const ::Ice::Current& current) override;
- void rename(ReqEnv env, ::std::string from, ::std::string to, const Ice::optional<Ice::Int>, const ::Ice::Current& current) override;
- void chmod(ReqEnv env, ::std::string path, int mode, const ::Ice::Current& current) override;
- void chown(ReqEnv env, ::std::string path, int uid, int gid, const ::Ice::Current& current) override;
- void utimens(ReqEnv env, ::std::string path, long long int atime, long long int atimens, long long int mtime, long long int mtimens, const ::Ice::Current& current) override;
-
- private:
- void update();
-
- friend class Directory;
- friend class Blob;
- const Git::RepositoryPtr repo;
- const std::string commitish;
- Git::RefPtr ref;
- bool isBranch;
- std::time_t resolvedAt;
- Git::CommitPtr commit;
- Git::TreePtr tree;
- const std::string gid, uid;
+ public:
+ Repo(const PropertyReader &);
+
+ void disconnect(const ::Ice::Current & current) override;
+ DirectoryPrxPtr opendir(ReqEnv env, ::std::string path, const ::Ice::Current & current) override;
+ VFS statfs(ReqEnv env, ::std::string path, const ::Ice::Current & current) override;
+ int access(ReqEnv env, ::std::string path, int mode, const ::Ice::Current & current) override;
+ Attr getattr(ReqEnv env, ::std::string path, const ::Ice::Current & current) override;
+ ::std::string readlink(ReqEnv env, ::std::string path, const ::Ice::Current & current) override;
+ FilePrxPtr open(ReqEnv env, ::std::string path, int flags, const ::Ice::Current & current) override;
+ FilePrxPtr create(ReqEnv env, ::std::string path, int flags, int mode, const ::Ice::Current & current) override;
+ void truncate(ReqEnv env, ::std::string path, long long int size, const ::Ice::Current & current) override;
+ void unlink(ReqEnv env, ::std::string path, const ::Ice::Current & current) override;
+ void mkdir(ReqEnv env, ::std::string path, int mode, const ::Ice::Current & current) override;
+ void rmdir(ReqEnv env, ::std::string path, const ::Ice::Current & current) override;
+ void mknod(ReqEnv env, ::std::string path, int mode, int dev, const ::Ice::Current & current) override;
+ void symlink(ReqEnv env, ::std::string path1, ::std::string path2, const ::Ice::Current & current) override;
+ void link(ReqEnv env, ::std::string path1, ::std::string path2, const ::Ice::Current & current) override;
+ void rename(ReqEnv env, ::std::string from, ::std::string to, const Ice::optional<Ice::Int>,
+ const ::Ice::Current & current) override;
+ void chmod(ReqEnv env, ::std::string path, int mode, const ::Ice::Current & current) override;
+ void chown(ReqEnv env, ::std::string path, int uid, int gid, const ::Ice::Current & current) override;
+ void utimens(ReqEnv env, ::std::string path, long long int atime, long long int atimens, long long int mtime,
+ long long int mtimens, const ::Ice::Current & current) override;
+
+ private:
+ void update();
+
+ friend class Directory;
+ friend class Blob;
+ const Git::RepositoryPtr repo;
+ const std::string commitish;
+ Git::RefPtr ref;
+ bool isBranch;
+ std::time_t resolvedAt;
+ Git::CommitPtr commit;
+ Git::TreePtr tree;
+ const std::string gid, uid;
};
}
#endif
-
-
diff --git a/src/repoList.cpp b/src/repoList.cpp
index 4eb76af..e3dbb0c 100644
--- a/src/repoList.cpp
+++ b/src/repoList.cpp
@@ -1,28 +1,24 @@
-#include <Ice/ObjectAdapter.h>
-#include <Ice/Properties.h>
#include "repoList.h"
#include "repo.h"
+#include <Ice/ObjectAdapter.h>
+#include <Ice/Properties.h>
#include <compileTimeFormatter.h>
-GitFS::RepoList::RepoList(Ice::PropertiesPtr && p) :
- properties(std::move(p))
-{
-}
+GitFS::RepoList::RepoList(Ice::PropertiesPtr && p) : properties(std::move(p)) { }
AdHocFormatter(RepoPropertyName, "GitFS.%?.%?");
NetFS::VolumePrxPtr
-GitFS::RepoList::connect(const ::std::string volume, const ::std::string auth,
- const ::Ice::Current & ice)
+GitFS::RepoList::connect(const ::std::string volume, const ::std::string auth, const ::Ice::Current & ice)
{
if (volume.empty()) {
throw NetFS::ConfigError();
}
const auto propReader = std::bind(&Ice::Properties::getProperty, properties,
- std::bind((std::string(*)(const std::string_view &, const std::string_view &))
- (&RepoPropertyName::get), volume, std::placeholders::_1));
+ std::bind((std::string(*)(const std::string_view &, const std::string_view &))(&RepoPropertyName::get),
+ volume, std::placeholders::_1));
if (propReader("gitdir").empty()) {
throw NetFS::ConfigError();
@@ -30,7 +26,5 @@ GitFS::RepoList::connect(const ::std::string volume, const ::std::string auth,
if (propReader("authkey") != auth) {
throw NetFS::AuthError();
}
- return Ice::uncheckedCast<NetFS::VolumePrx>(
- ice.adapter->addWithUUID(std::make_shared<Repo>(propReader)));
+ return Ice::uncheckedCast<NetFS::VolumePrx>(ice.adapter->addWithUUID(std::make_shared<Repo>(propReader)));
}
-
diff --git a/src/repoList.h b/src/repoList.h
index 0c2ed4b..2e876c2 100644
--- a/src/repoList.h
+++ b/src/repoList.h
@@ -1,20 +1,20 @@
#ifndef GITFS_REPOLIST_H
#define GITFS_REPOLIST_H
-#include <service.h>
#include <Ice/Properties.h>
+#include <service.h>
namespace GitFS {
class RepoList : public NetFS::Service {
- public:
- RepoList(Ice::PropertiesPtr &&);
+ public:
+ RepoList(Ice::PropertiesPtr &&);
- NetFS::VolumePrxPtr connect(const ::std::string volume, const ::std::string auth, const ::Ice::Current& current) override;
+ NetFS::VolumePrxPtr connect(
+ const ::std::string volume, const ::std::string auth, const ::Ice::Current & current) override;
- private:
- const Ice::PropertiesPtr properties;
+ private:
+ const Ice::PropertiesPtr properties;
};
}
#endif
-
diff --git a/unittests/config.cpp b/unittests/config.cpp
index db7570e..20a025a 100644
--- a/unittests/config.cpp
+++ b/unittests/config.cpp
@@ -1,10 +1,10 @@
#define BOOST_TEST_MODULE GitFS_Config
-#include <boost/test/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
+#include <boost/test/unit_test.hpp>
-#include <definedDirs.h>
-#include <compileTimeFormatter.h>
#include "mockDefs.h"
+#include <compileTimeFormatter.h>
+#include <definedDirs.h>
using namespace GitFS;
using namespace GitFS::Test;
@@ -13,34 +13,28 @@ using namespace AdHoc::literals;
namespace btdata = boost::unit_test::data;
class IdsIce : public IceTray::DryIce {
- public:
- IdsIce(const char * uid, const char * gid) : IceTray::DryIce({
- "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()),
- "--GitFS.testrepo.authkey=%?"_fmt("testauth"),
- "--GitFS.testrepo.gid=%?"_fmt(gid),
- "--GitFS.testrepo.uid=%?"_fmt(uid),
- "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c930",
+public:
+ IdsIce(const char * uid, const char * gid) :
+ IceTray::DryIce({
+ "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()),
+ "--GitFS.testrepo.authkey=%?"_fmt("testauth"),
+ "--GitFS.testrepo.gid=%?"_fmt(gid),
+ "--GitFS.testrepo.uid=%?"_fmt(uid),
+ "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c930",
})
- {}
+ {
+ }
};
-const auto USERS = btdata::make({ "root", "gituser", "www" });
-const auto GROUPS = btdata::make({ "root", "gitgroup", "www" });
-const auto DIRS = btdata::make({ "/", "/src", "/unittests/fixtures" });
-const auto FILES = btdata::make({
- "/Jamroot.jam", "/src/repo.cpp", "/unittests/fixtures/executable" });
-const auto LINKS = btdata::make({ "/unittests/fixtures/symlink" });
-const auto COMMITISHS = btdata::make({
- "",
- "master",
- "origin/master",
- "testcommit",
- "7a0ccb40084c3ab31d9856e7f689c0514c28c930"
-});
+const auto USERS = btdata::make({"root", "gituser", "www"});
+const auto GROUPS = btdata::make({"root", "gitgroup", "www"});
+const auto DIRS = btdata::make({"/", "/src", "/unittests/fixtures"});
+const auto FILES = btdata::make({"/Jamroot.jam", "/src/repo.cpp", "/unittests/fixtures/executable"});
+const auto LINKS = btdata::make({"/unittests/fixtures/symlink"});
+const auto COMMITISHS
+ = btdata::make({"", "master", "origin/master", "testcommit", "7a0ccb40084c3ab31d9856e7f689c0514c28c930"});
-BOOST_DATA_TEST_CASE(uid_gid_override_getattr,
- USERS * GROUPS * (DIRS + FILES + LINKS),
- uid, gid, path)
+BOOST_DATA_TEST_CASE(uid_gid_override_getattr, USERS * GROUPS *(DIRS + FILES + LINKS), uid, gid, path)
{
IdsIce s(uid, gid);
VolumeClient c;
@@ -51,9 +45,7 @@ BOOST_DATA_TEST_CASE(uid_gid_override_getattr,
BOOST_CHECK_EQUAL(attr.gid, gid);
}
-BOOST_DATA_TEST_CASE(uid_gid_override_fgetattr,
- USERS * GROUPS * FILES,
- uid, gid, path)
+BOOST_DATA_TEST_CASE(uid_gid_override_fgetattr, USERS * GROUPS * FILES, uid, gid, path)
{
IdsIce s(uid, gid);
VolumeClient c;
@@ -66,9 +58,7 @@ BOOST_DATA_TEST_CASE(uid_gid_override_fgetattr,
file->close();
}
-BOOST_DATA_TEST_CASE(uid_gid_override_list,
- USERS * GROUPS * DIRS,
- uid, gid, path)
+BOOST_DATA_TEST_CASE(uid_gid_override_list, USERS * GROUPS * DIRS, uid, gid, path)
{
IdsIce s(uid, gid);
VolumeClient c;
@@ -84,12 +74,12 @@ BOOST_DATA_TEST_CASE(uid_gid_override_list,
dir->close();
}
-BOOST_DATA_TEST_CASE(commitishs, COMMITISHS * (FILES + DIRS), commitish, path)
+BOOST_DATA_TEST_CASE(commitishs, COMMITISHS *(FILES + DIRS), commitish, path)
{
IceTray::DryIce di({
- "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()),
- "--GitFS.testrepo.authkey=%?"_fmt("testauth"),
- "--GitFS.testrepo.commitish=%?"_fmt(commitish),
+ "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()),
+ "--GitFS.testrepo.authkey=%?"_fmt("testauth"),
+ "--GitFS.testrepo.commitish=%?"_fmt(commitish),
});
VolumeClient c;
BOOST_CHECK_NO_THROW(c.v->ice_ping());
@@ -99,11 +89,10 @@ BOOST_DATA_TEST_CASE(commitishs, COMMITISHS * (FILES + DIRS), commitish, path)
BOOST_DATA_TEST_CASE(bad_commitishs, FILES, commitish) // File paths aren't commitishs
{
IceTray::DryIce di({
- "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()),
- "--GitFS.testrepo.authkey=%?"_fmt("testauth"),
- "--GitFS.testrepo.commitish=%?"_fmt(commitish),
+ "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()),
+ "--GitFS.testrepo.authkey=%?"_fmt("testauth"),
+ "--GitFS.testrepo.commitish=%?"_fmt(commitish),
});
Client c;
BOOST_CHECK_THROW(c.s->connect("testrepo", "testauth"), NetFS::ConfigError);
}
-
diff --git a/unittests/core.cpp b/unittests/core.cpp
index ba25e88..9cd7552 100644
--- a/unittests/core.cpp
+++ b/unittests/core.cpp
@@ -1,22 +1,24 @@
#define BOOST_TEST_MODULE GitFS_Core
-#include <boost/test/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
+#include <boost/test/unit_test.hpp>
#include "mockDefs.h"
-#include "sys/stat.h"
#include "sys/fcntl.h"
+#include "sys/stat.h"
using namespace GitFS;
using namespace GitFS::Test;
namespace std {
- std::ostream & operator<<(std::ostream & strm, const std::tuple<std::string, int> &)
+ std::ostream &
+ operator<<(std::ostream & strm, const std::tuple<std::string, int> &)
{
return strm;
}
template<typename T>
- std::ostream & operator<<(std::ostream & strm, const std::vector<T> & v)
+ std::ostream &
+ operator<<(std::ostream & strm, const std::vector<T> & v)
{
strm << "[ ";
for (const auto & e : v) {
@@ -33,19 +35,23 @@ namespace std {
#define BOOST_CHECK_THROW_SYSTEMERROR(CODE, ERRNO) \
try { \
BOOST_TEST_CHECKPOINT(""); \
- [&](){ CODE ; }(); \
+ [&]() { \
+ CODE; \
+ }(); \
BOOST_ERROR("No exception thrown, NetFS::SystemError expected"); \
- } catch (const NetFS::SystemError & se) { \
+ } \
+ catch (const NetFS::SystemError & se) { \
BOOST_CHECK_EQUAL(se.syserrno, ERRNO); \
- } catch (...) { \
+ } \
+ catch (...) { \
BOOST_ERROR("NetFS::SystemError not thrown"); \
- }\
+ }
BOOST_TEST_GLOBAL_FIXTURE(Service);
BOOST_FIXTURE_TEST_SUITE(volume, VolumeClient);
-BOOST_AUTO_TEST_CASE( unsupported_rofs_ops )
+BOOST_AUTO_TEST_CASE(unsupported_rofs_ops)
{
BOOST_CHECK_THROW_SYSTEMERROR(v->create(env, {}, {}, {}), EROFS);
BOOST_CHECK_THROW_SYSTEMERROR(v->truncate(env, {}, {}), EROFS);
@@ -61,7 +67,7 @@ BOOST_AUTO_TEST_CASE( unsupported_rofs_ops )
BOOST_CHECK_THROW_SYSTEMERROR(v->utimens(env, {}, {}, {}, {}, {}), EROFS);
}
-BOOST_AUTO_TEST_CASE( statfs )
+BOOST_AUTO_TEST_CASE(statfs)
{
// Don't know what this should return, but it shouldn't error given a valid path
BOOST_CHECK_THROW_SYSTEMERROR(v->statfs(env, ""), EINVAL);
@@ -69,42 +75,41 @@ BOOST_AUTO_TEST_CASE( statfs )
}
namespace btdata = boost::unit_test::data;
-const auto INVALIDPATHS = btdata::make({
- ""
-});
+const auto INVALIDPATHS = btdata::make({""});
const auto BADPATHS = btdata::make({
- "/.",
- "/../",
- ".",
- "..",
- "../",
+ "/.",
+ "/../",
+ ".",
+ "..",
+ "../",
});
const auto DIRPATHS = btdata::make({
- "/",
- "/src",
- "/unittests",
- "/unittests/fixtures",
+ "/",
+ "/src",
+ "/unittests",
+ "/unittests/fixtures",
});
const auto REGPATHS = btdata::make({
- "/.gitignore",
- "/Jamroot.jam",
- "/src/Jamfile.jam",
- "/unittests/Jamfile.jam",
+ "/.gitignore",
+ "/Jamroot.jam",
+ "/src/Jamfile.jam",
+ "/unittests/Jamfile.jam",
});
const auto EXECPATHS = btdata::make({
- "/unittests/fixtures/executable",
+ "/unittests/fixtures/executable",
});
const auto LINKPATHS = btdata::make({
- "/unittests/fixtures/symlink",
+ "/unittests/fixtures/symlink",
});
const auto MISSINGPATHS = btdata::make({
- "/.missing",
- "/missing",
- "/src/missing",
- "/unittests/fixtures/missing",
+ "/.missing",
+ "/missing",
+ "/src/missing",
+ "/unittests/fixtures/missing",
});
-BOOST_DATA_TEST_CASE(accessWrite, INVALIDPATHS + DIRPATHS + REGPATHS + EXECPATHS + LINKPATHS + MISSINGPATHS + BADPATHS, path)
+BOOST_DATA_TEST_CASE(
+ accessWrite, INVALIDPATHS + DIRPATHS + REGPATHS + EXECPATHS + LINKPATHS + MISSINGPATHS + BADPATHS, path)
{
BOOST_CHECK_EQUAL(EACCES, v->access(env, path, W_OK));
}
@@ -128,24 +133,23 @@ BOOST_DATA_TEST_CASE(accessExec, EXECPATHS, path)
BOOST_CHECK_EQUAL(0, v->access(env, path, R_OK));
BOOST_CHECK_EQUAL(0, v->access(env, path, X_OK));
}
-BOOST_DATA_TEST_CASE( accessInval, INVALIDPATHS * btdata::make({ R_OK, X_OK }), path, mode)
+BOOST_DATA_TEST_CASE(accessInval, INVALIDPATHS * btdata::make({R_OK, X_OK}), path, mode)
{
BOOST_CHECK_EQUAL(EINVAL, v->access(env, path, mode));
}
-BOOST_DATA_TEST_CASE( accessBad, BADPATHS * btdata::make({ R_OK, X_OK }), path, mode)
+BOOST_DATA_TEST_CASE(accessBad, BADPATHS * btdata::make({R_OK, X_OK}), path, mode)
{
BOOST_CHECK_EQUAL(ENOENT, v->access(env, path, mode));
}
-BOOST_DATA_TEST_CASE( statInval, INVALIDPATHS, path )
+BOOST_DATA_TEST_CASE(statInval, INVALIDPATHS, path)
{
BOOST_CHECK_THROW_SYSTEMERROR(v->getattr(env, path), EINVAL);
}
-BOOST_DATA_TEST_CASE( statBad, BADPATHS, path )
+BOOST_DATA_TEST_CASE(statBad, BADPATHS, path)
{
BOOST_CHECK_THROW_SYSTEMERROR(v->getattr(env, path), ENOENT);
}
-
const auto DIRMODE = S_IFDIR | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
const auto FILEMODE = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH;
const auto EXECMODE = FILEMODE | S_IXUSR | S_IXGRP | S_IXOTH;
@@ -154,7 +158,7 @@ const time_t COMMIT_TIME = 1563621030;
const std::string USER = "root";
const std::string GROUP = "root";
-BOOST_DATA_TEST_CASE( statDirs, DIRPATHS, path )
+BOOST_DATA_TEST_CASE(statDirs, DIRPATHS, path)
{
const auto attr = v->getattr(env, path);
BOOST_CHECK_EQUAL(DIRMODE, attr.mode);
@@ -165,7 +169,7 @@ BOOST_DATA_TEST_CASE( statDirs, DIRPATHS, path )
BOOST_CHECK_EQUAL(USER, attr.uid);
BOOST_CHECK_EQUAL(GROUP, attr.gid);
}
-BOOST_DATA_TEST_CASE( statFiles, REGPATHS, path )
+BOOST_DATA_TEST_CASE(statFiles, REGPATHS, path)
{
const auto attr = v->getattr(env, path);
BOOST_CHECK_EQUAL(FILEMODE, attr.mode);
@@ -176,7 +180,7 @@ BOOST_DATA_TEST_CASE( statFiles, REGPATHS, path )
BOOST_CHECK_EQUAL(USER, attr.uid);
BOOST_CHECK_EQUAL(GROUP, attr.gid);
}
-BOOST_DATA_TEST_CASE( statExecs, EXECPATHS, path )
+BOOST_DATA_TEST_CASE(statExecs, EXECPATHS, path)
{
const auto attr = v->getattr(env, path);
BOOST_CHECK_EQUAL(EXECMODE, attr.mode);
@@ -187,7 +191,7 @@ BOOST_DATA_TEST_CASE( statExecs, EXECPATHS, path )
BOOST_CHECK_EQUAL(USER, attr.uid);
BOOST_CHECK_EQUAL(GROUP, attr.gid);
}
-BOOST_DATA_TEST_CASE( statSymlink, LINKPATHS, path )
+BOOST_DATA_TEST_CASE(statSymlink, LINKPATHS, path)
{
const auto attr = v->getattr(env, path);
BOOST_CHECK_EQUAL(LINKMODE, attr.mode);
@@ -199,40 +203,39 @@ BOOST_DATA_TEST_CASE( statSymlink, LINKPATHS, path )
BOOST_CHECK_EQUAL(GROUP, attr.gid);
}
-
-BOOST_DATA_TEST_CASE( readlinkInval, INVALIDPATHS + DIRPATHS + REGPATHS + EXECPATHS, path )
+BOOST_DATA_TEST_CASE(readlinkInval, INVALIDPATHS + DIRPATHS + REGPATHS + EXECPATHS, path)
{
BOOST_CHECK_THROW_SYSTEMERROR(v->readlink(env, path), EINVAL);
}
-BOOST_DATA_TEST_CASE( readlinkBad, BADPATHS + MISSINGPATHS, path )
+BOOST_DATA_TEST_CASE(readlinkBad, BADPATHS + MISSINGPATHS, path)
{
BOOST_CHECK_THROW_SYSTEMERROR(v->readlink(env, path), ENOENT);
}
-BOOST_DATA_TEST_CASE( readlink, LINKPATHS ^ btdata::make({ "executable" }), path, target )
+BOOST_DATA_TEST_CASE(readlink, LINKPATHS ^ btdata::make({"executable"}), path, target)
{
BOOST_CHECK_EQUAL(target, v->readlink(env, path));
}
-
-BOOST_DATA_TEST_CASE( openDirInval, INVALIDPATHS, path )
+BOOST_DATA_TEST_CASE(openDirInval, INVALIDPATHS, path)
{
BOOST_CHECK_THROW_SYSTEMERROR(v->opendir(env, path), EINVAL);
}
-BOOST_DATA_TEST_CASE( openDirBad, BADPATHS + MISSINGPATHS, path )
+BOOST_DATA_TEST_CASE(openDirBad, BADPATHS + MISSINGPATHS, path)
{
BOOST_CHECK_THROW_SYSTEMERROR(v->opendir(env, path), ENOENT);
}
-BOOST_DATA_TEST_CASE( openDirNotDir, REGPATHS + LINKPATHS + EXECPATHS, path )
+BOOST_DATA_TEST_CASE(openDirNotDir, REGPATHS + LINKPATHS + EXECPATHS, path)
{
BOOST_CHECK_THROW_SYSTEMERROR(v->opendir(env, path), ENOTDIR);
}
const auto DIRCONTENTS = btdata::make<std::vector<std::string>>({
- {".gitignore", "Jamroot.jam", "src", "unittests"},
- {"Jamfile.jam", "blob.cpp", "blob.h", "dir.cpp", "dir.h", "git.cpp", "git.h", "main.cpp", "repo.cpp", "repo.h", "repoList.cpp", "repoList.h"},
- {"Jamfile.jam", "core.cpp", "fixtures", "mockDefs.cpp", "mockDefs.h"},
- {"executable", "symlink"},
+ {".gitignore", "Jamroot.jam", "src", "unittests"},
+ {"Jamfile.jam", "blob.cpp", "blob.h", "dir.cpp", "dir.h", "git.cpp", "git.h", "main.cpp", "repo.cpp", "repo.h",
+ "repoList.cpp", "repoList.h"},
+ {"Jamfile.jam", "core.cpp", "fixtures", "mockDefs.cpp", "mockDefs.h"},
+ {"executable", "symlink"},
});
-BOOST_DATA_TEST_CASE( openDirRead, DIRPATHS ^ DIRCONTENTS, path, contents )
+BOOST_DATA_TEST_CASE(openDirRead, DIRPATHS ^ DIRCONTENTS, path, contents)
{
auto dir = v->opendir(env, path);
BOOST_REQUIRE(dir);
@@ -242,12 +245,15 @@ BOOST_DATA_TEST_CASE( openDirRead, DIRPATHS ^ DIRCONTENTS, path, contents )
dir->close();
}
const auto DIRCONTENTMODES = btdata::make<std::vector<std::tuple<std::string, int>>>({
- {{".gitignore", FILEMODE}, {"Jamroot.jam", FILEMODE}, {"src",DIRMODE}, {"unittests", DIRMODE}},
- {{"Jamfile.jam", FILEMODE}, {"blob.cpp", FILEMODE}, {"blob.h", FILEMODE}, {"dir.cpp", FILEMODE}, {"dir.h", FILEMODE}, {"git.cpp", FILEMODE}, {"git.h", FILEMODE}, {"main.cpp", FILEMODE}, {"repo.cpp", FILEMODE}, {"repo.h", FILEMODE}, {"repoList.cpp", FILEMODE}, {"repoList.h", FILEMODE}},
- {{"Jamfile.jam", FILEMODE}, {"core.cpp", FILEMODE}, {"fixtures", DIRMODE}, {"mockDefs.cpp", FILEMODE}, {"mockDefs.h", FILEMODE}},
- {{"executable", EXECMODE}, {"symlink", LINKMODE}},
+ {{".gitignore", FILEMODE}, {"Jamroot.jam", FILEMODE}, {"src", DIRMODE}, {"unittests", DIRMODE}},
+ {{"Jamfile.jam", FILEMODE}, {"blob.cpp", FILEMODE}, {"blob.h", FILEMODE}, {"dir.cpp", FILEMODE},
+ {"dir.h", FILEMODE}, {"git.cpp", FILEMODE}, {"git.h", FILEMODE}, {"main.cpp", FILEMODE},
+ {"repo.cpp", FILEMODE}, {"repo.h", FILEMODE}, {"repoList.cpp", FILEMODE}, {"repoList.h", FILEMODE}},
+ {{"Jamfile.jam", FILEMODE}, {"core.cpp", FILEMODE}, {"fixtures", DIRMODE}, {"mockDefs.cpp", FILEMODE},
+ {"mockDefs.h", FILEMODE}},
+ {{"executable", EXECMODE}, {"symlink", LINKMODE}},
});
-BOOST_DATA_TEST_CASE( openDirList, DIRPATHS ^ DIRCONTENTMODES, path, contents )
+BOOST_DATA_TEST_CASE(openDirList, DIRPATHS ^ DIRCONTENTMODES, path, contents)
{
auto dir = v->opendir(env, path);
BOOST_REQUIRE(dir);
@@ -260,8 +266,8 @@ BOOST_DATA_TEST_CASE( openDirList, DIRPATHS ^ DIRCONTENTMODES, path, contents )
BOOST_CHECK_EQUAL(COMMIT_TIME, li->second.mtime);
BOOST_CHECK_EQUAL(COMMIT_TIME, li->second.ctime);
BOOST_CHECK_EQUAL(COMMIT_TIME, li->second.atime);
- BOOST_CHECK_EQUAL(USER, li->second.uid);
- BOOST_CHECK_EQUAL(GROUP, li->second.gid);
+ BOOST_CHECK_EQUAL(USER, li->second.uid);
+ BOOST_CHECK_EQUAL(GROUP, li->second.gid);
if (S_ISREG(li->second.mode)) {
BOOST_CHECK_LE(4, li->second.size);
}
@@ -269,24 +275,23 @@ BOOST_DATA_TEST_CASE( openDirList, DIRPATHS ^ DIRCONTENTMODES, path, contents )
dir->close();
}
-
-BOOST_DATA_TEST_CASE( openInval, INVALIDPATHS, path )
+BOOST_DATA_TEST_CASE(openInval, INVALIDPATHS, path)
{
BOOST_CHECK_THROW_SYSTEMERROR(v->open(env, path, O_RDONLY), EINVAL);
}
-BOOST_DATA_TEST_CASE( openBad, BADPATHS + MISSINGPATHS, path )
+BOOST_DATA_TEST_CASE(openBad, BADPATHS + MISSINGPATHS, path)
{
BOOST_CHECK_THROW_SYSTEMERROR(v->open(env, path, O_RDONLY), ENOENT);
}
-BOOST_DATA_TEST_CASE( openNotFileDir, DIRPATHS, path )
+BOOST_DATA_TEST_CASE(openNotFileDir, DIRPATHS, path)
{
BOOST_CHECK_THROW_SYSTEMERROR(v->open(env, path, O_RDONLY), EISDIR);
}
-BOOST_DATA_TEST_CASE( openNotFileLink, LINKPATHS, path )
+BOOST_DATA_TEST_CASE(openNotFileLink, LINKPATHS, path)
{
BOOST_CHECK_THROW_SYSTEMERROR(v->open(env, path, O_RDONLY), ELOOP);
}
-BOOST_DATA_TEST_CASE( openFileROFSOps, REGPATHS + EXECPATHS, path )
+BOOST_DATA_TEST_CASE(openFileROFSOps, REGPATHS + EXECPATHS, path)
{
auto f = v->open(env, path, O_RDONLY);
BOOST_REQUIRE(f);
@@ -295,7 +300,7 @@ BOOST_DATA_TEST_CASE( openFileROFSOps, REGPATHS + EXECPATHS, path )
f->close();
}
-BOOST_DATA_TEST_CASE( openFileGetAttr, REGPATHS + EXECPATHS, path )
+BOOST_DATA_TEST_CASE(openFileGetAttr, REGPATHS + EXECPATHS, path)
{
auto f = v->open(env, path, O_RDONLY);
BOOST_REQUIRE(f);
@@ -309,7 +314,7 @@ BOOST_DATA_TEST_CASE( openFileGetAttr, REGPATHS + EXECPATHS, path )
f->close();
}
-BOOST_DATA_TEST_CASE( openFileRead, REGPATHS + EXECPATHS, path )
+BOOST_DATA_TEST_CASE(openFileRead, REGPATHS + EXECPATHS, path)
{
auto f = v->open(env, path, O_RDONLY);
BOOST_REQUIRE(f);
@@ -328,6 +333,4 @@ BOOST_DATA_TEST_CASE( openFileRead, REGPATHS + EXECPATHS, path )
f->close();
}
-
BOOST_AUTO_TEST_SUITE_END();
-
diff --git a/unittests/mockDefs.cpp b/unittests/mockDefs.cpp
index 1ecf11c..a257758 100644
--- a/unittests/mockDefs.cpp
+++ b/unittests/mockDefs.cpp
@@ -1,28 +1,26 @@
+#include "mockDefs.h"
#include <boost/test/test_tools.hpp>
#include <compileTimeFormatter.h>
#include <definedDirs.h>
-#include "mockDefs.h"
using namespace AdHoc::literals;
GitFS::Test::Service::Service() :
IceTray::DryIce({
- "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()),
- "--GitFS.testrepo.authkey=testauth",
- "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c930",
+ "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()),
+ "--GitFS.testrepo.authkey=testauth",
+ "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c930",
})
{
}
-GitFS::Test::Client::Client() :
- s(getProxy<NetFS::ServicePrx>("Service"))
+GitFS::Test::Client::Client() : s(getProxy<NetFS::ServicePrx>("Service"))
{
BOOST_TEST_REQUIRE(s);
s->ice_ping();
}
-GitFS::Test::VolumeClient::VolumeClient() :
- v(s->connect("testrepo", "testauth"))
+GitFS::Test::VolumeClient::VolumeClient() : v(s->connect("testrepo", "testauth"))
{
BOOST_TEST_REQUIRE(v);
v->ice_ping();
@@ -32,4 +30,3 @@ GitFS::Test::VolumeClient::~VolumeClient()
{
v->disconnect();
}
-
diff --git a/unittests/mockDefs.h b/unittests/mockDefs.h
index f6a6c99..750a256 100644
--- a/unittests/mockDefs.h
+++ b/unittests/mockDefs.h
@@ -1,31 +1,30 @@
#ifndef GITFS_TEST_MOCKDEFS_H
#define GITFS_TEST_MOCKDEFS_H
-#include <visibility.h>
#include <dryice.h>
#include <service.h>
+#include <visibility.h>
namespace GitFS::Test {
class DLL_PUBLIC Service : public IceTray::DryIce {
- public:
- Service();
+ public:
+ Service();
};
class DLL_PUBLIC Client : public IceTray::DryIceClient {
- public:
- Client();
+ public:
+ Client();
- const NetFS::ServicePrxPtr s;
+ const NetFS::ServicePrxPtr s;
};
class DLL_PUBLIC VolumeClient : public Client {
- public:
- VolumeClient();
- ~VolumeClient();
+ public:
+ VolumeClient();
+ ~VolumeClient();
- const NetFS::ReqEnv env;
- const NetFS::VolumePrxPtr v;
+ const NetFS::ReqEnv env;
+ const NetFS::VolumePrxPtr v;
};
}
#endif
-
diff --git a/unittests/service.cpp b/unittests/service.cpp
index 207aa15..b1bab5a 100644
--- a/unittests/service.cpp
+++ b/unittests/service.cpp
@@ -1,10 +1,10 @@
#define BOOST_TEST_MODULE GitFS_Service
-#include <boost/test/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
+#include <boost/test/unit_test.hpp>
-#include <definedDirs.h>
-#include <compileTimeFormatter.h>
#include "mockDefs.h"
+#include <compileTimeFormatter.h>
+#include <definedDirs.h>
using namespace GitFS;
using namespace GitFS::Test;
@@ -12,10 +12,8 @@ using namespace AdHoc::literals;
namespace btdata = boost::unit_test::data;
-BOOST_DATA_TEST_CASE(no_repos,
- btdata::make({ "", "testrepo", "no repo" }) *
- btdata::make({ "", "testauth", "badkey" }),
- repo, key)
+BOOST_DATA_TEST_CASE(
+ no_repos, btdata::make({"", "testrepo", "no repo"}) * btdata::make({"", "testauth", "badkey"}), repo, key)
{
IceTray::DryIce s;
Client c;
@@ -24,14 +22,12 @@ BOOST_DATA_TEST_CASE(no_repos,
BOOST_CHECK_THROW(c.s->connect(repo, key), NetFS::ConfigError);
}
-BOOST_DATA_TEST_CASE(badauth,
- btdata::make({ "", "testAuth", "badkey" }),
- key)
+BOOST_DATA_TEST_CASE(badauth, btdata::make({"", "testAuth", "badkey"}), key)
{
IceTray::DryIce s({
- "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()),
- "--GitFS.testrepo.authkey=testauth",
- "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c930",
+ "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()),
+ "--GitFS.testrepo.authkey=testauth",
+ "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c930",
});
Client c;
BOOST_CHECK_NO_THROW(c.s->ice_ping());
@@ -42,10 +38,10 @@ BOOST_DATA_TEST_CASE(badauth,
BOOST_AUTO_TEST_CASE(missing_repo)
{
IceTray::DryIce s({
- "--GitFS.missing.gitdir=/not/here",
- "--GitFS.missing.commit=7a0ccb40084c3ab31d9856e7f689c0514c28c930",
- "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()),
- "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c931",
+ "--GitFS.missing.gitdir=/not/here",
+ "--GitFS.missing.commit=7a0ccb40084c3ab31d9856e7f689c0514c28c930",
+ "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()),
+ "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c931",
});
Client c;
BOOST_CHECK_NO_THROW(c.s->ice_ping());
@@ -53,4 +49,3 @@ BOOST_AUTO_TEST_CASE(missing_repo)
BOOST_CHECK_THROW(c.s->connect("missing", {}), NetFS::ConfigError);
BOOST_CHECK_THROW(c.s->connect("testrepo", {}), NetFS::ConfigError);
}
-