Simplify mocking thanks to new googletest features

This commit is contained in:
Sebastian Messmer 2019-10-13 23:49:57 +08:00 committed by Sebastian Messmer
parent 43365c789b
commit cb01025c81
68 changed files with 268 additions and 317 deletions

View File

@ -68,17 +68,17 @@ unique_ref<DirBlobRef> CryDir::LoadBlob() const {
return std::move(*dir_blob);
}
unique_ref<vector<fspp::Dir::Entry>> CryDir::children() {
vector<fspp::Dir::Entry> CryDir::children() {
device()->callFsActionCallbacks();
if (!isRootDir()) { // NOLINT (workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82481 )
//TODO Instead of doing nothing when we're the root directory, handle timestamps in the root dir correctly (and delete isRootDir() function)
parent()->updateAccessTimestampForChild(blockId(), fsblobstore::TimestampUpdateBehavior::RELATIME);
}
auto children = make_unique_ref<vector<fspp::Dir::Entry>>();
children->push_back(fspp::Dir::Entry(fspp::Dir::EntryType::DIR, "."));
children->push_back(fspp::Dir::Entry(fspp::Dir::EntryType::DIR, ".."));
vector<fspp::Dir::Entry> children;
children.push_back(fspp::Dir::Entry(fspp::Dir::EntryType::DIR, "."));
children.push_back(fspp::Dir::Entry(fspp::Dir::EntryType::DIR, ".."));
auto blob = LoadBlob();
blob->AppendChildrenTo(children.get());
blob->AppendChildrenTo(&children);
return children;
}

View File

@ -19,7 +19,7 @@ public:
void createSymlink(const std::string &name, const boost::filesystem::path &target, fspp::uid_t uid, fspp::gid_t gid) override;
//TODO Make Entry a public class instead of hidden in DirBlob (which is not publicly visible)
cpputils::unique_ref<std::vector<fspp::Dir::Entry>> children() override;
std::vector<fspp::Dir::Entry> children() override;
fspp::Dir::EntryType getType() const override;

View File

@ -32,8 +32,8 @@ public:
virtual void createSymlink(const std::string &name, const boost::filesystem::path &target, fspp::uid_t uid, fspp::gid_t gid) = 0;
//TODO Allow alternative implementation returning only children names without more information
//virtual std::unique_ptr<std::vector<std::string>> children() const = 0;
virtual cpputils::unique_ref<std::vector<Entry>> children() = 0;
//virtual std::vector<std::string> children() const = 0;
virtual std::vector<Entry> children() = 0;
};
}

View File

@ -24,7 +24,7 @@ public:
std::vector<fspp::Dir::Entry> expectedChildren = expected;
expectedChildren.push_back(fspp::Dir::Entry(fspp::Dir::EntryType::DIR, "."));
expectedChildren.push_back(fspp::Dir::Entry(fspp::Dir::EntryType::DIR, ".."));
EXPECT_UNORDERED_EQ(expectedChildren, *dir->children());
EXPECT_UNORDERED_EQ(expectedChildren, dir->children());
}
template<class Entry>

View File

@ -136,9 +136,9 @@ public:
void Test_Overwrite_DoesntHaveSameEntryTwice() {
auto node = this->CreateNode("/oldname");
this->CreateNode("/newname");
EXPECT_EQ(4u, this->LoadDir("/")->children()->size()); // 4, because of '.' and '..'
EXPECT_EQ(4u, this->LoadDir("/")->children().size()); // 4, because of '.' and '..'
node->rename("/newname");
EXPECT_EQ(3u, this->LoadDir("/")->children()->size()); // 3, because of '.' and '..'
EXPECT_EQ(3u, this->LoadDir("/")->children().size()); // 3, because of '.' and '..'
}
void Test_Overwrite_Error_DirWithFile_InSameDir() {

View File

@ -45,7 +45,7 @@ public:
virtual void utimens(const boost::filesystem::path &path, timespec lastAccessTime, timespec lastModificationTime) = 0;
virtual void statfs(struct ::statvfs *fsstat) = 0;
//TODO We shouldn't use Dir::Entry here, that's in another layer
virtual cpputils::unique_ref<std::vector<Dir::Entry>> readDir(const boost::filesystem::path &path) = 0;
virtual std::vector<Dir::Entry> readDir(const boost::filesystem::path &path) = 0;
//TODO Test createSymlink
virtual void createSymlink(const boost::filesystem::path &to, const boost::filesystem::path &from, ::uid_t uid, ::gid_t gid) = 0;
//TODO Test readSymlink

View File

@ -1034,7 +1034,7 @@ int Fuse::readdir(const bf::path &path, void *buf, fuse_fill_dir_t filler, int64
ASSERT(is_valid_fspp_path(path), "has to be an absolute path");
auto entries = _fs->readDir(path);
fspp::fuse::STAT stbuf{};
for (const auto &entry : *entries) {
for (const auto &entry : entries) {
//We could pass more file metadata to filler() in its third parameter,
//but it doesn't help performance since fuse ignores everything in stbuf
//except for file-type bits in st_mode and (if used) st_ino.

View File

@ -91,7 +91,7 @@ namespace fspp {
throw std::logic_error("Filesystem not initialized yet");
}
cpputils::unique_ref<std::vector<Dir::Entry>> readDir(const boost::filesystem::path &) override {
std::vector<Dir::Entry> readDir(const boost::filesystem::path &) override {
throw std::logic_error("Filesystem not initialized yet");
}

View File

@ -290,7 +290,7 @@ void FilesystemImpl::rename(const bf::path &from, const bf::path &to) {
}
}
unique_ref<vector<Dir::Entry>> FilesystemImpl::readDir(const bf::path &path) {
vector<Dir::Entry> FilesystemImpl::readDir(const bf::path &path) {
PROFILE(_readDirNanosec);
auto dir = LoadDir(path);
PROFILE(_readDirNanosec_withoutLoading);

View File

@ -43,7 +43,7 @@ public:
void rmdir(const boost::filesystem::path &path) override;
void unlink(const boost::filesystem::path &path) override;
void rename(const boost::filesystem::path &from, const boost::filesystem::path &to) override;
cpputils::unique_ref<std::vector<Dir::Entry>> readDir(const boost::filesystem::path &path) override;
std::vector<Dir::Entry> readDir(const boost::filesystem::path &path) override;
void utimens(const boost::filesystem::path &path, timespec lastAccessTime, timespec lastModificationTime) override;
void statfs(struct ::statvfs *fsstat) override;
void createSymlink(const boost::filesystem::path &to, const boost::filesystem::path &from, ::uid_t uid, ::gid_t gid) override;

View File

@ -20,8 +20,8 @@ using std::make_shared;
class TraversorMock {
public:
MOCK_METHOD3(calledExistingLeaf, void(DataLeafNode*, bool, uint32_t));
MOCK_METHOD1(calledCreateLeaf, shared_ptr<Data>(uint32_t));
MOCK_METHOD(void, calledExistingLeaf, (DataLeafNode*, bool, uint32_t));
MOCK_METHOD(shared_ptr<Data>, calledCreateLeaf, (uint32_t));
};
MATCHER_P(KeyEq, expected, "node blockId equals") {

View File

@ -25,15 +25,15 @@ using namespace blockstore;
class BlockStore2Mock: public BlockStore2 {
public:
MOCK_CONST_METHOD0(createBlockId, BlockId());
MOCK_METHOD2(tryCreate, bool(const BlockId &blockId, const cpputils::Data &data));
MOCK_METHOD2(store, void(const BlockId &, const Data &data));
MOCK_CONST_METHOD1(load, optional<Data>(const BlockId &));
MOCK_METHOD1(remove, bool(const BlockId &));
MOCK_CONST_METHOD0(numBlocks, uint64_t());
MOCK_CONST_METHOD0(estimateNumFreeBytes, uint64_t());
MOCK_CONST_METHOD1(blockSizeFromPhysicalBlockSize, uint64_t(uint64_t));
MOCK_CONST_METHOD1(forEachBlock, void(std::function<void (const blockstore::BlockId &)>));
MOCK_METHOD(BlockId, createBlockId, (), (const, override));
MOCK_METHOD(bool, tryCreate, (const BlockId &blockId, const cpputils::Data &data), (override));
MOCK_METHOD(void, store, (const BlockId &, const Data &data), (override));
MOCK_METHOD(optional<Data>, load, (const BlockId &), (const, override));
MOCK_METHOD(bool, remove, (const BlockId &), (override));
MOCK_METHOD(uint64_t, numBlocks, (), (const, override));
MOCK_METHOD(uint64_t, estimateNumFreeBytes, (), (const, override));
MOCK_METHOD(uint64_t, blockSizeFromPhysicalBlockSize, (uint64_t), (const, override));
MOCK_METHOD(void, forEachBlock, (std::function<void (const blockstore::BlockId &)>), (const, override));
};
class BlockStore2Test: public Test {

View File

@ -9,47 +9,39 @@ using ::testing::Return;
using ::testing::Invoke;
using ::testing::Eq;
using ::testing::ByRef;
using ::testing::Action;
using std::string;
using cpputils::Data;
using cpputils::DataFixture;
using cpputils::unique_ref;
using cpputils::make_unique_ref;
using boost::optional;
using namespace blockstore;
class BlockStoreMock: public BlockStore {
public:
MOCK_METHOD0(createBlockId, BlockId());
optional<unique_ref<Block>> tryCreate(const BlockId &blockId, Data data) {
return cpputils::nullcheck(std::unique_ptr<Block>(do_create(blockId, data)));
}
MOCK_METHOD2(do_create, Block*(const BlockId &, const Data &data));
unique_ref<Block> overwrite(const BlockId &blockId, Data data) {
return cpputils::nullcheck(std::unique_ptr<Block>(do_overwrite(blockId, data))).value();
}
MOCK_METHOD2(do_overwrite, Block*(const BlockId &, const Data &data));
optional<unique_ref<Block>> load(const BlockId &blockId) {
return cpputils::nullcheck(std::unique_ptr<Block>(do_load(blockId)));
}
MOCK_METHOD1(do_load, Block*(const BlockId &));
void remove(unique_ref<Block> block) {UNUSED(block);}
MOCK_METHOD1(remove, void(const BlockId &));
MOCK_CONST_METHOD0(numBlocks, uint64_t());
MOCK_CONST_METHOD0(estimateNumFreeBytes, uint64_t());
MOCK_CONST_METHOD1(blockSizeFromPhysicalBlockSize, uint64_t(uint64_t));
MOCK_CONST_METHOD1(forEachBlock, void(std::function<void (const blockstore::BlockId &)>));
MOCK_METHOD(BlockId, createBlockId, (), (override));
MOCK_METHOD(optional<unique_ref<Block>>, tryCreate, (const BlockId &, Data data), (override));
MOCK_METHOD(unique_ref<Block>, overwrite, (const BlockId &, Data data), (override));
MOCK_METHOD(optional<unique_ref<Block>>, load, (const BlockId &), (override));
MOCK_METHOD(void, remove, (unique_ref<Block>), (override));
MOCK_METHOD(void, remove, (const BlockId &), (override));
MOCK_METHOD(uint64_t, numBlocks, (), (const, override));
MOCK_METHOD(uint64_t, estimateNumFreeBytes, (), (const, override));
MOCK_METHOD(uint64_t, blockSizeFromPhysicalBlockSize, (uint64_t), (const, override));
MOCK_METHOD(void, forEachBlock, (std::function<void (const blockstore::BlockId &)>), (const, override));
};
class BlockMock: public Block {
public:
BlockMock(): Block(BlockId::Random()) {}
MOCK_CONST_METHOD0(data, const void*());
MOCK_METHOD3(write, void(const void*, uint64_t, uint64_t));
MOCK_METHOD0(flush, void());
MOCK_CONST_METHOD0(size, size_t());
MOCK_METHOD1(resize, void(size_t));
MOCK_CONST_METHOD0(blockId, const BlockId&());
MOCK_METHOD(const void*, data, (), (const, override));
MOCK_METHOD(void, write, (const void*, uint64_t, uint64_t), (override));
MOCK_METHOD(void, flush, (), (override));
MOCK_METHOD(size_t, size, (), (const, override));
MOCK_METHOD(void, resize, (size_t), (override));
};
class BlockStoreTest: public Test {
@ -73,31 +65,36 @@ public:
}
};
const Action<optional<unique_ref<Block>>(const BlockId &, cpputils::Data)> ReturnNewBlockMock = Invoke(
[] (const BlockId&, cpputils::Data) {
return optional<unique_ref<Block>>(unique_ref<Block>(make_unique_ref<BlockMock>()));
});
TEST_F(BlockStoreTest, DataIsPassedThrough0) {
Data data = createDataWithSize(0);
EXPECT_CALL(blockStoreMock, createBlockId()).WillOnce(Return(blockId1));
EXPECT_CALL(blockStoreMock, do_create(_, Eq(ByRef(data)))).WillOnce(Return(new BlockMock));
EXPECT_CALL(blockStoreMock, tryCreate(_, Eq(ByRef(data)))).WillOnce(ReturnNewBlockMock);
blockStore.create(data);
}
TEST_F(BlockStoreTest, DataIsPassedThrough1) {
Data data = createDataWithSize(1);
EXPECT_CALL(blockStoreMock, createBlockId()).WillOnce(Return(blockId1));
EXPECT_CALL(blockStoreMock, do_create(_, Eq(ByRef(data)))).WillOnce(Return(new BlockMock));
EXPECT_CALL(blockStoreMock, tryCreate(_, Eq(ByRef(data)))).WillOnce(ReturnNewBlockMock);
blockStore.create(data);
}
TEST_F(BlockStoreTest, DataIsPassedThrough1024) {
Data data = createDataWithSize(1024);
EXPECT_CALL(blockStoreMock, createBlockId()).WillOnce(Return(blockId1));
EXPECT_CALL(blockStoreMock, do_create(_, Eq(ByRef(data)))).WillOnce(Return(new BlockMock));
EXPECT_CALL(blockStoreMock, tryCreate(_, Eq(ByRef(data)))).WillOnce(ReturnNewBlockMock);
blockStore.create(data);
}
TEST_F(BlockStoreTest, BlockIdIsCorrect) {
Data data = createDataWithSize(1024);
EXPECT_CALL(blockStoreMock, createBlockId()).WillOnce(Return(blockId1));
EXPECT_CALL(blockStoreMock, do_create(blockId1, _)).WillOnce(Return(new BlockMock));
EXPECT_CALL(blockStoreMock, tryCreate(blockId1, _)).WillOnce(ReturnNewBlockMock);
blockStore.create(data);
}
@ -105,14 +102,14 @@ TEST_F(BlockStoreTest, TwoBlocksGetDifferentIds) {
EXPECT_CALL(blockStoreMock, createBlockId())
.WillOnce(Return(blockId1))
.WillOnce(Return(blockId2));
EXPECT_CALL(blockStoreMock, do_create(_, _))
.WillOnce(Invoke([this](const BlockId &blockId, const Data &) {
EXPECT_CALL(blockStoreMock, tryCreate(_, _))
.WillOnce(Invoke([this](const BlockId &blockId, Data) {
EXPECT_EQ(blockId1, blockId);
return new BlockMock;
return optional<unique_ref<Block>>(unique_ref<Block>(make_unique_ref<BlockMock>()));
}))
.WillOnce(Invoke([this](const BlockId &blockId, const Data &) {
.WillOnce(Invoke([this](const BlockId &blockId, Data) {
EXPECT_EQ(blockId2, blockId);
return new BlockMock;
return optional<unique_ref<Block>>(unique_ref<Block>(make_unique_ref<BlockMock>()));
}));
Data data = createDataWithSize(1024);
@ -125,14 +122,14 @@ TEST_F(BlockStoreTest, WillTryADifferentIdIfKeyAlreadyExists) {
EXPECT_CALL(blockStoreMock, createBlockId())
.WillOnce(Return(blockId1))
.WillOnce(Return(blockId2));
EXPECT_CALL(blockStoreMock, do_create(_, Eq(ByRef(data))))
.WillOnce(Invoke([this](const BlockId &blockId, const Data &) {
EXPECT_CALL(blockStoreMock, tryCreate(_, Eq(ByRef(data))))
.WillOnce(Invoke([this](const BlockId &blockId, Data ) {
EXPECT_EQ(blockId1, blockId);
return nullptr;
return boost::none;
}))
.WillOnce(Invoke([this](const BlockId &blockId, const Data &) {
.WillOnce(Invoke([this](const BlockId &blockId, Data ) {
EXPECT_EQ(blockId2, blockId);
return new BlockMock;
return optional<unique_ref<Block>>(unique_ref<Block>(make_unique_ref<BlockMock>()));
}));
blockStore.create(data);
@ -144,18 +141,18 @@ TEST_F(BlockStoreTest, WillTryADifferentIdIfIdAlreadyExistsTwoTimes) {
.WillOnce(Return(blockId1))
.WillOnce(Return(blockId2))
.WillOnce(Return(blockId3));
EXPECT_CALL(blockStoreMock, do_create(_, Eq(ByRef(data))))
.WillOnce(Invoke([this](const BlockId &blockId, const Data &) {
EXPECT_CALL(blockStoreMock, tryCreate(_, Eq(ByRef(data))))
.WillOnce(Invoke([this](const BlockId &blockId, Data) {
EXPECT_EQ(blockId1, blockId);
return nullptr;
return boost::none;
}))
.WillOnce(Invoke([this](const BlockId &blockId, const Data &) {
.WillOnce(Invoke([this](const BlockId &blockId, Data) {
EXPECT_EQ(blockId2, blockId);
return nullptr;
return boost::none;
}))
.WillOnce(Invoke([this](const BlockId &blockId, const Data &) {
.WillOnce(Invoke([this](const BlockId &blockId, Data) {
EXPECT_EQ(blockId3, blockId);
return new BlockMock;
return optional<unique_ref<Block>>(unique_ref<Block>(make_unique_ref<BlockMock>()));
}));
blockStore.create(data);

View File

@ -229,8 +229,8 @@ TEST_P(DataTestWithStringParam, ToAndFromString) {
}
struct MockAllocator final : public Allocator {
MOCK_METHOD1(allocate, void* (size_t));
MOCK_METHOD2(free, void(void*, size_t));
MOCK_METHOD(void* , allocate, (size_t), (override));
MOCK_METHOD(void, free, (void*, size_t), (override));
};
class DataTestWithMockAllocator: public DataTest {

View File

@ -1120,7 +1120,7 @@ TEST(EitherTest, givenLeftAndRightWithSameType_thenAreUnequal) {
namespace {
class DestructorCallback {
public:
MOCK_CONST_METHOD0(call, void());
MOCK_METHOD(void, call, (), (const));
void EXPECT_CALLED(int times = 1) {
EXPECT_CALL(*this, call()).Times(times);

View File

@ -15,7 +15,7 @@ using boost::none;
class DestructorCallback {
public:
MOCK_CONST_METHOD0(call, void());
MOCK_METHOD(void, call, (), (const));
};
class Parent {

View File

@ -22,13 +22,13 @@ using testing::_;
class MockCallable {
public:
MOCK_METHOD0(call, std::string());
MOCK_METHOD(std::string, call, ());
};
class MockKDF : public PasswordBasedKDF {
public:
MOCK_METHOD3(deriveExistingKey, EncryptionKey(size_t keySize, const string& password, const Data& kdfParameters));
MOCK_METHOD2(deriveNewKey, KeyResult(size_t keySize, const string& password));
MOCK_METHOD(EncryptionKey, deriveExistingKey, (size_t keySize, const string& password, const Data& kdfParameters), (override));
MOCK_METHOD(KeyResult, deriveNewKey, (size_t keySize, const string& password), (override));
};
class CryPasswordBasedKeyProviderTest : public ::testing::Test {

View File

@ -17,8 +17,8 @@ using testing::_;
class MockKDF : public PasswordBasedKDF {
public:
MOCK_METHOD3(deriveExistingKey, EncryptionKey(size_t keySize, const string& password, const Data& kdfParameters));
MOCK_METHOD2(deriveNewKey, KeyResult(size_t keySize, const string& password));
MOCK_METHOD(EncryptionKey, deriveExistingKey, (size_t keySize, const string& password, const Data& kdfParameters), (override));
MOCK_METHOD(KeyResult, deriveNewKey, (size_t keySize, const string& password), (override));
};
TEST(CryPresetPasswordBasedKeyProviderTest, requestKeyForNewFilesystem) {

View File

@ -7,10 +7,10 @@
class MockConsole: public cpputils::Console {
public:
MOCK_METHOD1(print, void(const std::string&));
MOCK_METHOD2(ask, unsigned int(const std::string&, const std::vector<std::string>&));
MOCK_METHOD2(askYesNo, bool(const std::string&, bool));
MOCK_METHOD1(askPassword, std::string(const std::string&));
MOCK_METHOD(void, print, (const std::string&), (override));
MOCK_METHOD(unsigned int, ask, (const std::string&, const std::vector<std::string>&), (override));
MOCK_METHOD(bool, askYesNo, (const std::string&, bool), (override));
MOCK_METHOD(std::string, askPassword, (const std::string&), (override));
};
ACTION_P(ChooseCipher, cipherName) {

View File

@ -7,8 +7,8 @@
class MockCryKeyProvider: public cryfs::CryKeyProvider {
public:
MOCK_METHOD2(requestKeyForExistingFilesystem, cpputils::EncryptionKey(size_t keySize, const cpputils::Data& kdfParameters));
MOCK_METHOD1(requestKeyForNewFilesystem, cryfs::CryKeyProvider::KeyResult(size_t keySize));
MOCK_METHOD(cpputils::EncryptionKey, requestKeyForExistingFilesystem, (size_t keySize, const cpputils::Data& kdfParameters), (override));
MOCK_METHOD(cryfs::CryKeyProvider::KeyResult, requestKeyForNewFilesystem, (size_t keySize), (override));
};
#endif

View File

@ -3,7 +3,7 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -17,7 +17,7 @@ INSTANTIATE_TEST_SUITE_P(FuseAccessErrorTest, FuseAccessErrorTest, Values(EACCES
TEST_P(FuseAccessErrorTest, ReturnedErrorIsCorrect) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, access(StrEq(FILENAME), _))
EXPECT_CALL(*fsimpl, access(Eq(FILENAME), _))
.Times(AtLeast(1)).WillRepeatedly(Throw(FuseErrnoException(GetParam())));
int error = AccessFileReturnError(FILENAME, 0);

View File

@ -1,7 +1,7 @@
#include "testutils/FuseAccessTest.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Return;
class FuseAccessFilenameTest: public FuseAccessTest {
@ -9,7 +9,7 @@ class FuseAccessFilenameTest: public FuseAccessTest {
TEST_F(FuseAccessFilenameTest, AccessFile) {
ReturnIsFileOnLstat("/myfile");
EXPECT_CALL(*fsimpl, access(StrEq("/myfile"), _))
EXPECT_CALL(*fsimpl, access(Eq("/myfile"), _))
.Times(1).WillOnce(Return());
AccessFile("/myfile", 0);
@ -18,7 +18,7 @@ TEST_F(FuseAccessFilenameTest, AccessFile) {
TEST_F(FuseAccessFilenameTest, AccessFileNested) {
ReturnIsDirOnLstat("/mydir");
ReturnIsFileOnLstat("/mydir/myfile");
EXPECT_CALL(*fsimpl, access(StrEq("/mydir/myfile"), _))
EXPECT_CALL(*fsimpl, access(Eq("/mydir/myfile"), _))
.Times(1).WillOnce(Return());
AccessFile("/mydir/myfile", 0);
@ -28,7 +28,7 @@ TEST_F(FuseAccessFilenameTest, AccessFileNested2) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
ReturnIsFileOnLstat("/mydir/mydir2/myfile");
EXPECT_CALL(*fsimpl, access(StrEq("/mydir/mydir2/myfile"), _))
EXPECT_CALL(*fsimpl, access(Eq("/mydir/mydir2/myfile"), _))
.Times(1).WillOnce(Return());
AccessFile("/mydir/mydir2/myfile", 0);

View File

@ -1,6 +1,6 @@
#include "testutils/FuseAccessTest.h"
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Return;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -12,7 +12,7 @@ INSTANTIATE_TEST_SUITE_P(FuseAccessModeTest, FuseAccessModeTest, Values(0, F_OK,
TEST_P(FuseAccessModeTest, AccessFile) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, access(StrEq(FILENAME), GetParam()))
EXPECT_CALL(*fsimpl, access(Eq(FILENAME), GetParam()))
.Times(1).WillOnce(Return());
AccessFile(FILENAME, GetParam());

View File

@ -79,7 +79,7 @@ INSTANTIATE_TEST_SUITE_P(FuseCloseTest, FuseCloseTest, Values(0, 1, 2, 100, 1024
Barrier barrier;
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), _)).WillOnce(Return(GetParam()));
EXPECT_CALL(*fsimpl, openFile(Eq(FILENAME), _)).WillOnce(Return(GetParam()));
{
//InSequence fileCloseSequence;
EXPECT_CALL(*fsimpl, flush(Eq(GetParam()))).Times(1);

View File

@ -6,7 +6,7 @@ using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Return;
using ::testing::Throw;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::_;
using namespace fspp::fuse;
@ -17,7 +17,7 @@ INSTANTIATE_TEST_SUITE_P(FuseCreateAndOpenErrorTest, FuseCreateAndOpenErrorTest,
TEST_F(FuseCreateAndOpenErrorTest, ReturnNoError) {
ReturnDoesntExistOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq(FILENAME), _, _, _)).Times(1).WillOnce(Return(1));
EXPECT_CALL(*fsimpl, createAndOpenFile(Eq(FILENAME), _, _, _)).Times(1).WillOnce(Return(1));
//For the syscall to succeed, we also need to give an fstat implementation.
ReturnIsFileOnFstat(1);
@ -27,7 +27,7 @@ TEST_F(FuseCreateAndOpenErrorTest, ReturnNoError) {
TEST_P(FuseCreateAndOpenErrorTest, ReturnError) {
ReturnDoesntExistOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq(FILENAME), _, _, _)).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
EXPECT_CALL(*fsimpl, createAndOpenFile(Eq(FILENAME), _, _, _)).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
int error = CreateAndOpenFileReturnError(FILENAME, O_RDONLY);
EXPECT_EQ(GetParam(), error);

View File

@ -1,7 +1,7 @@
#include "testutils/FuseCreateAndOpenTest.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Return;
@ -34,7 +34,7 @@ INSTANTIATE_TEST_SUITE_P(FuseCreateAndOpenFileDescriptorTest, FuseCreateAndOpenF
TEST_P(FuseCreateAndOpenFileDescriptorTest, TestReturnedFileDescriptor) {
ReturnDoesntExistOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq(FILENAME), _, _, _))
EXPECT_CALL(*fsimpl, createAndOpenFile(Eq(FILENAME), _, _, _))
.Times(1).WillOnce(Return(GetParam()));
EXPECT_CALL(*fsimpl, read(GetParam(), _, _, _)).Times(1).WillOnce(Return(fspp::num_bytes_t(1)));
//For the syscall to succeed, we also need to give an fstat implementation.

View File

@ -1,7 +1,7 @@
#include "testutils/FuseCreateAndOpenTest.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Return;
class FuseCreateAndOpenFilenameTest: public FuseCreateAndOpenTest {
@ -10,7 +10,7 @@ public:
TEST_F(FuseCreateAndOpenFilenameTest, CreateAndOpenFile) {
ReturnDoesntExistOnLstat("/myfile");
EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq("/myfile"), _, _, _))
EXPECT_CALL(*fsimpl, createAndOpenFile(Eq("/myfile"), _, _, _))
.Times(1).WillOnce(Return(0));
//For the syscall to succeed, we also need to give an fstat implementation.
ReturnIsFileOnFstat(0);
@ -21,7 +21,7 @@ TEST_F(FuseCreateAndOpenFilenameTest, CreateAndOpenFile) {
TEST_F(FuseCreateAndOpenFilenameTest, CreateAndOpenFileNested) {
ReturnIsDirOnLstat("/mydir");
ReturnDoesntExistOnLstat("/mydir/myfile");
EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq("/mydir/myfile"), _, _, _))
EXPECT_CALL(*fsimpl, createAndOpenFile(Eq("/mydir/myfile"), _, _, _))
.Times(1).WillOnce(Return(0));
//For the syscall to succeed, we also need to give an fstat implementation.
ReturnIsFileOnFstat(0);
@ -33,7 +33,7 @@ TEST_F(FuseCreateAndOpenFilenameTest, CreateAndOpenFileNested2) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
ReturnDoesntExistOnLstat("/mydir/mydir2/myfile");
EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq("/mydir/mydir2/myfile"), _, _, _))
EXPECT_CALL(*fsimpl, createAndOpenFile(Eq("/mydir/mydir2/myfile"), _, _, _))
.Times(1).WillOnce(Return(0));
//For the syscall to succeed, we also need to give an fstat implementation.
ReturnIsFileOnFstat(0);

View File

@ -10,7 +10,7 @@ INSTANTIATE_TEST_SUITE_P(FuseCreateAndOpenFlagsTest, FuseCreateAndOpenFlagsTest,
//TODO Disabled because it doesn't seem to work. Fuse doesn't seem to pass flags to create(). Why?
/*TEST_P(FuseCreateAndOpenFlagsTest, testFlags) {
ReturnDoesntExistOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq(FILENAME), OpenFlagsEq(GetParam()), _, _))
EXPECT_CALL(*fsimpl, createAndOpenFile(Eq(FILENAME), OpenFlagsEq(GetParam()), _, _))
.Times(1).WillOnce(Return(0));
//For the syscall to succeed, we also need to give an fstat implementation.
ReturnIsFileOnFstat(0);

View File

@ -3,7 +3,6 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::WithParamInterface;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Return;
using ::testing::Throw;
@ -25,7 +24,7 @@ INSTANTIATE_TEST_SUITE_P(FuseFlushErrorTest, FuseFlushErrorTest, Values(
TEST_P(FuseFlushErrorTest, ReturnErrorFromFlush) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), _)).WillOnce(Return(GetParam()));
EXPECT_CALL(*fsimpl, openFile(Eq(FILENAME), _)).WillOnce(Return(GetParam()));
EXPECT_CALL(*fsimpl, flush(Eq(GetParam()))).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
auto fs = TestFS();

View File

@ -1,7 +1,6 @@
#include "testutils/FuseFlushTest.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -27,7 +26,7 @@ INSTANTIATE_TEST_SUITE_P(FuseFlushFileDescriptorTest, FuseFlushFileDescriptorTes
TEST_P(FuseFlushFileDescriptorTest, FlushOnCloseFile) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), _)).WillOnce(Return(GetParam()));
EXPECT_CALL(*fsimpl, openFile(Eq(FILENAME), _)).WillOnce(Return(GetParam()));
EXPECT_CALL(*fsimpl, flush(Eq(GetParam()))).Times(1);
OpenAndCloseFile(FILENAME);

View File

@ -1,6 +1,6 @@
#include "FuseFstatTest.h"
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::_;
using ::testing::Return;
using cpputils::unique_ref;
@ -25,5 +25,5 @@ unique_ref<OpenFileHandle> FuseFstatTest::CreateFileAllowErrors(const TempTestFS
}
void FuseFstatTest::OnCreateAndOpenReturnFileDescriptor(const char *filename, int descriptor) {
EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq(filename), _, _, _)).Times(1).WillOnce(Return(descriptor));
EXPECT_CALL(*fsimpl, createAndOpenFile(Eq(filename), _, _, _)).Times(1).WillOnce(Return(descriptor));
}

View File

@ -2,7 +2,7 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::_;
using ::testing::Throw;
using ::testing::WithParamInterface;
@ -17,14 +17,14 @@ public:
INSTANTIATE_TEST_SUITE_P(LstatErrorCodes, FuseLstatErrorTest, Values(EACCES, EBADF, EFAULT, ELOOP, ENAMETOOLONG, ENOENT, ENOMEM, ENOTDIR, EOVERFLOW, EINVAL, ENOTDIR));
TEST_F(FuseLstatErrorTest, ReturnNoError) {
EXPECT_CALL(*fsimpl, lstat(StrEq(FILENAME), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile);
EXPECT_CALL(*fsimpl, lstat(Eq(FILENAME), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile);
errno = 0;
int error = LstatPathReturnError(FILENAME);
EXPECT_EQ(0, error);
}
TEST_P(FuseLstatErrorTest, ReturnError) {
EXPECT_CALL(*fsimpl, lstat(StrEq(FILENAME), _)).Times(AtLeast(1)).WillRepeatedly(Throw(FuseErrnoException(GetParam())));
EXPECT_CALL(*fsimpl, lstat(Eq(FILENAME), _)).Times(AtLeast(1)).WillRepeatedly(Throw(FuseErrnoException(GetParam())));
int error = LstatPathReturnError(FILENAME);
EXPECT_EQ(GetParam(), error);
}

View File

@ -1,37 +1,37 @@
#include "testutils/FuseLstatTest.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::AtLeast;
class FuseLstatPathParameterTest: public FuseLstatTest {
};
TEST_F(FuseLstatPathParameterTest, PathParameterIsCorrectRoot) {
EXPECT_CALL(*fsimpl, lstat(StrEq("/"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsDir);
EXPECT_CALL(*fsimpl, lstat(Eq("/"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsDir);
LstatPath("/");
}
TEST_F(FuseLstatPathParameterTest, PathParameterIsCorrectSimpleFile) {
EXPECT_CALL(*fsimpl, lstat(StrEq("/myfile"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile);
EXPECT_CALL(*fsimpl, lstat(Eq("/myfile"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile);
LstatPath("/myfile");
}
TEST_F(FuseLstatPathParameterTest, PathParameterIsCorrectSimpleDir) {
EXPECT_CALL(*fsimpl, lstat(StrEq("/mydir"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsDir);
EXPECT_CALL(*fsimpl, lstat(Eq("/mydir"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsDir);
LstatPath("/mydir/");
}
TEST_F(FuseLstatPathParameterTest, PathParameterIsCorrectNestedFile) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
EXPECT_CALL(*fsimpl, lstat(StrEq("/mydir/mydir2/myfile"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile);
EXPECT_CALL(*fsimpl, lstat(Eq("/mydir/mydir2/myfile"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile);
LstatPath("/mydir/mydir2/myfile");
}
TEST_F(FuseLstatPathParameterTest, PathParameterIsCorrectNestedDir) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
EXPECT_CALL(*fsimpl, lstat(StrEq("/mydir/mydir2/mydir3"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsDir);
EXPECT_CALL(*fsimpl, lstat(Eq("/mydir/mydir2/mydir3"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsDir);
LstatPath("/mydir/mydir2/mydir3/");
}

View File

@ -1,7 +1,7 @@
#include "FuseLstatTest.h"
using std::function;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::_;
using ::testing::Invoke;
@ -41,7 +41,7 @@ fspp::fuse::STAT FuseLstatTest::CallDirLstatWithImpl(function<void(fspp::fuse::S
}
fspp::fuse::STAT FuseLstatTest::CallLstatWithImpl(function<void(fspp::fuse::STAT*)> implementation) {
EXPECT_CALL(*fsimpl, lstat(StrEq(FILENAME), _)).WillRepeatedly(Invoke([implementation](const char*, fspp::fuse::STAT *stat) {
EXPECT_CALL(*fsimpl, lstat(Eq(FILENAME), _)).WillRepeatedly(Invoke([implementation](const boost::filesystem::path&, fspp::fuse::STAT *stat) {
implementation(stat);
}));

View File

@ -1,14 +1,14 @@
#include "testutils/FuseMkdirTest.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
class FuseMkdirDirnameTest: public FuseMkdirTest {
};
TEST_F(FuseMkdirDirnameTest, Mkdir) {
ReturnDoesntExistOnLstat("/mydir");
EXPECT_CALL(*fsimpl, mkdir(StrEq("/mydir"), _, _, _))
EXPECT_CALL(*fsimpl, mkdir(Eq("/mydir"), _, _, _))
// After mkdir was called, lstat should return that it is a dir.
// This is needed to make the ::mkdir() syscall pass.
.Times(1).WillOnce(FromNowOnReturnIsDirOnLstat());
@ -19,7 +19,7 @@ TEST_F(FuseMkdirDirnameTest, Mkdir) {
TEST_F(FuseMkdirDirnameTest, MkdirNested) {
ReturnIsDirOnLstat("/mydir");
ReturnDoesntExistOnLstat("/mydir/mysubdir");
EXPECT_CALL(*fsimpl, mkdir(StrEq("/mydir/mysubdir"), _, _, _))
EXPECT_CALL(*fsimpl, mkdir(Eq("/mydir/mysubdir"), _, _, _))
// After mkdir was called, lstat should return that it is a dir.
// This is needed to make the ::mkdir() syscall pass.
.Times(1).WillOnce(FromNowOnReturnIsDirOnLstat());
@ -31,7 +31,7 @@ TEST_F(FuseMkdirDirnameTest, MkdirNested2) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
ReturnDoesntExistOnLstat("/mydir/mydir2/mydir3");
EXPECT_CALL(*fsimpl, mkdir(StrEq("/mydir/mydir2/mydir3"), _, _, _))
EXPECT_CALL(*fsimpl, mkdir(Eq("/mydir/mydir2/mydir3"), _, _, _))
// After mkdir was called, lstat should return that it is a dir.
// This is needed to make the ::mkdir() syscall pass.
.Times(1).WillOnce(FromNowOnReturnIsDirOnLstat());

View File

@ -3,7 +3,7 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -16,7 +16,7 @@ INSTANTIATE_TEST_SUITE_P(FuseMkdirErrorTest, FuseMkdirErrorTest, Values(EACCES,
TEST_F(FuseMkdirErrorTest, NoError) {
ReturnDoesntExistOnLstat(DIRNAME);
EXPECT_CALL(*fsimpl, mkdir(StrEq(DIRNAME), _, _, _))
EXPECT_CALL(*fsimpl, mkdir(Eq(DIRNAME), _, _, _))
.Times(1).WillOnce(FromNowOnReturnIsDirOnLstat());
int error = MkdirReturnError(DIRNAME, 0);
@ -25,7 +25,7 @@ TEST_F(FuseMkdirErrorTest, NoError) {
TEST_P(FuseMkdirErrorTest, ReturnedErrorIsCorrect) {
ReturnDoesntExistOnLstat(DIRNAME);
EXPECT_CALL(*fsimpl, mkdir(StrEq(DIRNAME), _, _, _))
EXPECT_CALL(*fsimpl, mkdir(Eq(DIRNAME), _, _, _))
.Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
int error = MkdirReturnError(DIRNAME, 0);

View File

@ -1,7 +1,7 @@
#include "testutils/FuseMkdirTest.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -12,7 +12,7 @@ INSTANTIATE_TEST_SUITE_P(FuseMkdirModeTest, FuseMkdirModeTest, Values(0, S_IRUSR
TEST_P(FuseMkdirModeTest, Mkdir) {
ReturnDoesntExistOnLstat(DIRNAME);
EXPECT_CALL(*fsimpl, mkdir(StrEq(DIRNAME), GetParam(), _, _))
EXPECT_CALL(*fsimpl, mkdir(Eq(DIRNAME), GetParam(), _, _))
.Times(1).WillOnce(FromNowOnReturnIsDirOnLstat());
Mkdir(DIRNAME, GetParam());

View File

@ -20,8 +20,8 @@ int FuseMkdirTest::MkdirReturnError(const char *dirname, mode_t mode) {
}
}
Action<void(const char*, mode_t, uid_t, gid_t)> FuseMkdirTest::FromNowOnReturnIsDirOnLstat() {
return Invoke([this](const char *dirname, mode_t, uid_t, gid_t) {
Action<void(const boost::filesystem::path&, mode_t, uid_t, gid_t)> FuseMkdirTest::FromNowOnReturnIsDirOnLstat() {
return Invoke([this](const boost::filesystem::path& dirname, mode_t, uid_t, gid_t) {
ReturnIsDirOnLstat(dirname);
});
}

View File

@ -11,7 +11,7 @@ public:
void Mkdir(const char *dirname, mode_t mode);
int MkdirReturnError(const char *dirname, mode_t mode);
::testing::Action<void(const char*, mode_t, uid_t, gid_t)> FromNowOnReturnIsDirOnLstat();
::testing::Action<void(const boost::filesystem::path&, mode_t, uid_t, gid_t)> FromNowOnReturnIsDirOnLstat();
};
#endif

View File

@ -6,7 +6,7 @@ using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Return;
using ::testing::Throw;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::_;
using namespace fspp::fuse;
@ -17,7 +17,7 @@ INSTANTIATE_TEST_SUITE_P(FuseOpenErrorTest, FuseOpenErrorTest, Values(EACCES, ED
TEST_F(FuseOpenErrorTest, ReturnNoError) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), _)).Times(1).WillOnce(Return(1));
EXPECT_CALL(*fsimpl, openFile(Eq(FILENAME), _)).Times(1).WillOnce(Return(1));
errno = 0;
int error = OpenFileReturnError(FILENAME, O_RDONLY);
EXPECT_EQ(0, error);
@ -25,7 +25,7 @@ TEST_F(FuseOpenErrorTest, ReturnNoError) {
TEST_P(FuseOpenErrorTest, ReturnError) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), _)).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
EXPECT_CALL(*fsimpl, openFile(Eq(FILENAME), _)).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
int error = OpenFileReturnError(FILENAME, O_RDONLY);
EXPECT_EQ(GetParam(), error);
}

View File

@ -1,7 +1,7 @@
#include "testutils/FuseOpenTest.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Return;
@ -34,7 +34,7 @@ INSTANTIATE_TEST_SUITE_P(FuseOpenFileDescriptorTest, FuseOpenFileDescriptorTest,
TEST_P(FuseOpenFileDescriptorTest, TestReturnedFileDescriptor) {
ReturnIsFileOnLstatWithSize(FILENAME, fspp::num_bytes_t(1));
EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), _))
EXPECT_CALL(*fsimpl, openFile(Eq(FILENAME), _))
.Times(1).WillOnce(Return(GetParam()));
EXPECT_CALL(*fsimpl, read(GetParam(), _, _, _)).Times(1).WillOnce(Return(fspp::num_bytes_t(1)));

View File

@ -1,7 +1,7 @@
#include "testutils/FuseOpenTest.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Return;
class FuseOpenFilenameTest: public FuseOpenTest {
@ -10,7 +10,7 @@ public:
TEST_F(FuseOpenFilenameTest, OpenFile) {
ReturnIsFileOnLstat("/myfile");
EXPECT_CALL(*fsimpl, openFile(StrEq("/myfile"), _))
EXPECT_CALL(*fsimpl, openFile(Eq("/myfile"), _))
.Times(1).WillOnce(Return(0));
OpenFile("/myfile", O_RDONLY);
@ -19,7 +19,7 @@ TEST_F(FuseOpenFilenameTest, OpenFile) {
TEST_F(FuseOpenFilenameTest, OpenFileNested) {
ReturnIsDirOnLstat("/mydir");
ReturnIsFileOnLstat("/mydir/myfile");
EXPECT_CALL(*fsimpl, openFile(StrEq("/mydir/myfile"), _))
EXPECT_CALL(*fsimpl, openFile(Eq("/mydir/myfile"), _))
.Times(1).WillOnce(Return(0));
OpenFile("/mydir/myfile", O_RDONLY);
@ -29,7 +29,7 @@ TEST_F(FuseOpenFilenameTest, OpenFileNested2) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
ReturnIsFileOnLstat("/mydir/mydir2/myfile");
EXPECT_CALL(*fsimpl, openFile(StrEq("/mydir/mydir2/myfile"), _))
EXPECT_CALL(*fsimpl, openFile(Eq("/mydir/mydir2/myfile"), _))
.Times(1).WillOnce(Return(0));
OpenFile("/mydir/mydir2/myfile", O_RDONLY);

View File

@ -1,6 +1,6 @@
#include "testutils/FuseOpenTest.h"
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Return;
@ -11,7 +11,7 @@ INSTANTIATE_TEST_SUITE_P(FuseOpenFlagsTest, FuseOpenFlagsTest, Values(O_RDWR, O_
TEST_P(FuseOpenFlagsTest, testFlags) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), OpenFlagsEq(GetParam())))
EXPECT_CALL(*fsimpl, openFile(Eq(FILENAME), OpenFlagsEq(GetParam())))
.Times(1).WillOnce(Return(0));
OpenFile(FILENAME, GetParam());

View File

@ -1,6 +1,6 @@
#include "testutils/FuseReadDirTest.h"
using ::testing::StrEq;
using ::testing::Eq;
using std::string;
@ -9,7 +9,7 @@ public:
};
TEST_F(FuseReadDirDirnameTest, ReadRootDir) {
EXPECT_CALL(*fsimpl, readDir(StrEq("/")))
EXPECT_CALL(*fsimpl, readDir(Eq("/")))
.Times(1).WillOnce(ReturnDirEntries({}));
ReadDir("/");
@ -17,7 +17,7 @@ TEST_F(FuseReadDirDirnameTest, ReadRootDir) {
TEST_F(FuseReadDirDirnameTest, ReadDir) {
ReturnIsDirOnLstat("/mydir");
EXPECT_CALL(*fsimpl, readDir(StrEq("/mydir")))
EXPECT_CALL(*fsimpl, readDir(Eq("/mydir")))
.Times(1).WillOnce(ReturnDirEntries({}));
ReadDir("/mydir");
@ -26,7 +26,7 @@ TEST_F(FuseReadDirDirnameTest, ReadDir) {
TEST_F(FuseReadDirDirnameTest, ReadDirNested) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
EXPECT_CALL(*fsimpl, readDir(StrEq("/mydir/mydir2")))
EXPECT_CALL(*fsimpl, readDir(Eq("/mydir/mydir2")))
.Times(1).WillOnce(ReturnDirEntries({}));
ReadDir("/mydir/mydir2");
@ -36,7 +36,7 @@ TEST_F(FuseReadDirDirnameTest, ReadDirNested2) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
ReturnIsDirOnLstat("/mydir/mydir2/mydir3");
EXPECT_CALL(*fsimpl, readDir(StrEq("/mydir/mydir2/mydir3")))
EXPECT_CALL(*fsimpl, readDir(Eq("/mydir/mydir2/mydir3")))
.Times(1).WillOnce(ReturnDirEntries({}));
ReadDir("/mydir/mydir2/mydir3");

View File

@ -2,7 +2,7 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -19,7 +19,7 @@ INSTANTIATE_TEST_SUITE_P(FuseReadDirErrorTest, FuseReadDirErrorTest, Values(EACC
TEST_F(FuseReadDirErrorTest, NoError) {
ReturnIsDirOnLstat(DIRNAME);
EXPECT_CALL(*fsimpl, readDir(StrEq(DIRNAME)))
EXPECT_CALL(*fsimpl, readDir(Eq(DIRNAME)))
.Times(1).WillOnce(ReturnDirEntries({}));
int error = ReadDirReturnError(DIRNAME);
@ -28,7 +28,7 @@ TEST_F(FuseReadDirErrorTest, NoError) {
TEST_P(FuseReadDirErrorTest, ReturnedErrorCodeIsCorrect) {
ReturnIsDirOnLstat(DIRNAME);
EXPECT_CALL(*fsimpl, readDir(StrEq(DIRNAME)))
EXPECT_CALL(*fsimpl, readDir(Eq(DIRNAME)))
.Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
int error = ReadDirReturnError(DIRNAME);

View File

@ -2,22 +2,20 @@
#include <cpp-utils/pointer/unique_ref.h>
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::WithParamInterface;
using ::testing::Values;
using cpputils::unique_ref;
using cpputils::make_unique_ref;
using std::vector;
using std::string;
using namespace fspp::fuse;
unique_ref<vector<string>> LARGE_DIR(int num_entries) {
auto result = make_unique_ref<vector<string>>();
result->reserve(num_entries);
vector<string> LARGE_DIR(int num_entries) {
vector<string> result;
result.reserve(num_entries);
for(int i=0; i<num_entries; ++i) {
result->push_back("File "+std::to_string(i)+" file");
result.push_back("File "+std::to_string(i)+" file");
}
return result;
}
@ -26,11 +24,11 @@ class FuseReadDirReturnTest: public FuseReadDirTest, public WithParamInterface<v
public:
void testDirEntriesAreCorrect(const vector<string> &direntries) {
ReturnIsDirOnLstat(DIRNAME);
EXPECT_CALL(*fsimpl, readDir(StrEq(DIRNAME)))
EXPECT_CALL(*fsimpl, readDir(Eq(DIRNAME)))
.Times(1).WillOnce(ReturnDirEntries(direntries));
auto returned_dir_entries = ReadDir(DIRNAME);
EXPECT_EQ(direntries, *returned_dir_entries);
EXPECT_EQ(direntries, returned_dir_entries);
}
};
INSTANTIATE_TEST_SUITE_P(FuseReadDirReturnTest, FuseReadDirReturnTest, Values(
@ -49,7 +47,7 @@ TEST_P(FuseReadDirReturnTest, ReturnedDirEntriesAreCorrect) {
// (probably because it is doing a lot of construction work on the start of the test program)
TEST_F(FuseReadDirReturnTest, ReturnedDirEntriesAreCorrect_LargeDir1000) {
auto direntries = LARGE_DIR(1000);
testDirEntriesAreCorrect(*direntries);
testDirEntriesAreCorrect(direntries);
}
// If using this with GTest Value-Parametrized TEST_P, it breaks some other unrelated tests
@ -57,5 +55,5 @@ TEST_F(FuseReadDirReturnTest, ReturnedDirEntriesAreCorrect_LargeDir1000) {
// DISABLED, because it uses a lot of memory
TEST_F(FuseReadDirReturnTest, DISABLED_ReturnedDirEntriesAreCorrect_LargeDir1000000) {
auto direntries = LARGE_DIR(1000000);
testDirEntriesAreCorrect(*direntries);
testDirEntriesAreCorrect(direntries);
}

View File

@ -1,6 +1,5 @@
#include "FuseReadDirTest.h"
using cpputils::unique_ref;
using cpputils::make_unique_ref;
using std::vector;
using std::string;
@ -8,13 +7,13 @@ using std::string;
using ::testing::Action;
using ::testing::Return;
unique_ref<vector<string>> FuseReadDirTest::ReadDir(const char *dirname) {
vector<string> FuseReadDirTest::ReadDir(const char *dirname) {
auto fs = TestFS();
DIR *dir = openDir(fs.get(), dirname);
auto result = make_unique_ref<vector<string>>();
readDirEntries(dir, result.get());
vector<string> result;
readDirEntries(dir, &result);
closeDir(dir);
return result;
}
@ -78,10 +77,10 @@ void FuseReadDirTest::closeDir(DIR *dir) {
EXPECT_EQ(0, retval) << "Closing dir failed";
}
Action<vector<fspp::Dir::Entry>*(const char*)> FuseReadDirTest::ReturnDirEntries(vector<std::string> entries) {
vector<fspp::Dir::Entry> *direntries = new vector<fspp::Dir::Entry>(entries.size(), fspp::Dir::Entry(fspp::Dir::EntryType::FILE, ""));
Action<vector<fspp::Dir::Entry>(const boost::filesystem::path&)> FuseReadDirTest::ReturnDirEntries(vector<std::string> entries) {
vector<fspp::Dir::Entry> direntries(entries.size(), fspp::Dir::Entry(fspp::Dir::EntryType::FILE, ""));
for(size_t i = 0; i < entries.size(); ++i) {
(*direntries)[i].name = entries[i];
direntries[i].name = entries[i];
}
return Return(direntries);
return Return(std::move(direntries));
}

View File

@ -10,10 +10,10 @@ class FuseReadDirTest: public FuseTest {
public:
const char *DIRNAME = "/mydir";
cpputils::unique_ref<std::vector<std::string>> ReadDir(const char *dirname);
std::vector<std::string> ReadDir(const char *dirname);
int ReadDirReturnError(const char *dirname);
static ::testing::Action<std::vector<fspp::Dir::Entry>*(const char*)> ReturnDirEntries(std::vector<std::string> entries);
static ::testing::Action<std::vector<fspp::Dir::Entry>(const boost::filesystem::path&)> ReturnDirEntries(std::vector<std::string> entries);
private:
DIR *openDir(TempTestFS *fs, const char *dirname);

View File

@ -1,7 +1,7 @@
#include "testutils/FuseRenameTest.h"
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -15,7 +15,7 @@ INSTANTIATE_TEST_SUITE_P(FuseRenameErrorTest, FuseRenameErrorTest, Values(EACCES
TEST_P(FuseRenameErrorTest, ReturnedErrorIsCorrect) {
ReturnIsFileOnLstat(FILENAME1);
ReturnDoesntExistOnLstat(FILENAME2);
EXPECT_CALL(*fsimpl, rename(StrEq(FILENAME1), StrEq(FILENAME2)))
EXPECT_CALL(*fsimpl, rename(Eq(FILENAME1), Eq(FILENAME2)))
.Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
int error = RenameReturnError(FILENAME1, FILENAME2);

View File

@ -1,6 +1,6 @@
#include "testutils/FuseRenameTest.h"
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Return;
class FuseRenameFilenameTest: public FuseRenameTest {
@ -9,7 +9,7 @@ class FuseRenameFilenameTest: public FuseRenameTest {
TEST_F(FuseRenameFilenameTest, RenameFileRootToRoot) {
ReturnIsFileOnLstat("/myfile");
ReturnDoesntExistOnLstat("/myrenamedfile");
EXPECT_CALL(*fsimpl, rename(StrEq("/myfile"), StrEq("/myrenamedfile")))
EXPECT_CALL(*fsimpl, rename(Eq("/myfile"), Eq("/myrenamedfile")))
.Times(1).WillOnce(Return());
Rename("/myfile", "/myrenamedfile");
@ -19,7 +19,7 @@ TEST_F(FuseRenameFilenameTest, RenameFileRootToNested) {
ReturnIsFileOnLstat("/myfile");
ReturnIsDirOnLstat("/mydir");
ReturnDoesntExistOnLstat("/mydir/myrenamedfile");
EXPECT_CALL(*fsimpl, rename(StrEq("/myfile"), StrEq("/mydir/myrenamedfile")))
EXPECT_CALL(*fsimpl, rename(Eq("/myfile"), Eq("/mydir/myrenamedfile")))
.Times(1).WillOnce(Return());
Rename("/myfile", "/mydir/myrenamedfile");
@ -29,7 +29,7 @@ TEST_F(FuseRenameFilenameTest, RenameFileNestedToRoot) {
ReturnDoesntExistOnLstat("/myrenamedfile");
ReturnIsDirOnLstat("/mydir");
ReturnIsFileOnLstat("/mydir/myfile");
EXPECT_CALL(*fsimpl, rename(StrEq("/mydir/myfile"), StrEq("/myrenamedfile")))
EXPECT_CALL(*fsimpl, rename(Eq("/mydir/myfile"), Eq("/myrenamedfile")))
.Times(1).WillOnce(Return());
Rename("/mydir/myfile", "/myrenamedfile");
@ -39,7 +39,7 @@ TEST_F(FuseRenameFilenameTest, RenameFileNestedToNested) {
ReturnIsDirOnLstat("/mydir");
ReturnIsFileOnLstat("/mydir/myfile");
ReturnDoesntExistOnLstat("/mydir/myrenamedfile");
EXPECT_CALL(*fsimpl, rename(StrEq("/mydir/myfile"), StrEq("/mydir/myrenamedfile")))
EXPECT_CALL(*fsimpl, rename(Eq("/mydir/myfile"), Eq("/mydir/myrenamedfile")))
.Times(1).WillOnce(Return());
Rename("/mydir/myfile", "/mydir/myrenamedfile");
@ -50,7 +50,7 @@ TEST_F(FuseRenameFilenameTest, RenameFileNestedToNested2) {
ReturnIsDirOnLstat("/mydir/mydir2");
ReturnIsFileOnLstat("/mydir/mydir2/myfile");
ReturnDoesntExistOnLstat("/mydir/mydir2/myrenamedfile");
EXPECT_CALL(*fsimpl, rename(StrEq("/mydir/mydir2/myfile"), StrEq("/mydir/mydir2/myrenamedfile")))
EXPECT_CALL(*fsimpl, rename(Eq("/mydir/mydir2/myfile"), Eq("/mydir/mydir2/myrenamedfile")))
.Times(1).WillOnce(Return());
Rename("/mydir/mydir2/myfile", "/mydir/mydir2/myrenamedfile");
@ -61,7 +61,7 @@ TEST_F(FuseRenameFilenameTest, RenameFileNestedToNested_DifferentFolder) {
ReturnIsDirOnLstat("/mydir2");
ReturnIsFileOnLstat("/mydir/myfile");
ReturnDoesntExistOnLstat("/mydir2/myrenamedfile");
EXPECT_CALL(*fsimpl, rename(StrEq("/mydir/myfile"), StrEq("/mydir2/myrenamedfile")))
EXPECT_CALL(*fsimpl, rename(Eq("/mydir/myfile"), Eq("/mydir2/myrenamedfile")))
.Times(1).WillOnce(Return());
Rename("/mydir/myfile", "/mydir2/myrenamedfile");
@ -70,7 +70,7 @@ TEST_F(FuseRenameFilenameTest, RenameFileNestedToNested_DifferentFolder) {
TEST_F(FuseRenameFilenameTest, RenameDirRootToRoot) {
ReturnIsDirOnLstat("/mydir");
ReturnDoesntExistOnLstat("/myrenameddir");
EXPECT_CALL(*fsimpl, rename(StrEq("/mydir"), StrEq("/myrenameddir")))
EXPECT_CALL(*fsimpl, rename(Eq("/mydir"), Eq("/myrenameddir")))
.Times(1).WillOnce(Return());
Rename("/mydir", "/myrenameddir");
@ -80,7 +80,7 @@ TEST_F(FuseRenameFilenameTest, RenameDirRootToNested) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/myrootdir");
ReturnDoesntExistOnLstat("/myrootdir/myrenameddir");
EXPECT_CALL(*fsimpl, rename(StrEq("/mydir"), StrEq("/myrootdir/myrenameddir")))
EXPECT_CALL(*fsimpl, rename(Eq("/mydir"), Eq("/myrootdir/myrenameddir")))
.Times(1).WillOnce(Return());
Rename("/mydir", "/myrootdir/myrenameddir");
@ -90,7 +90,7 @@ TEST_F(FuseRenameFilenameTest, RenameDirNestedToRoot) {
ReturnDoesntExistOnLstat("/myrenameddir");
ReturnIsDirOnLstat("/myrootdir");
ReturnIsDirOnLstat("/myrootdir/mydir");
EXPECT_CALL(*fsimpl, rename(StrEq("/myrootdir/mydir"), StrEq("/myrenameddir")))
EXPECT_CALL(*fsimpl, rename(Eq("/myrootdir/mydir"), Eq("/myrenameddir")))
.Times(1).WillOnce(Return());
Rename("/myrootdir/mydir", "/myrenameddir");
@ -100,7 +100,7 @@ TEST_F(FuseRenameFilenameTest, RenameDirNestedToNested) {
ReturnIsDirOnLstat("/myrootdir");
ReturnIsDirOnLstat("/myrootdir/mydir");
ReturnDoesntExistOnLstat("/myrootdir/myrenameddir");
EXPECT_CALL(*fsimpl, rename(StrEq("/myrootdir/mydir"), StrEq("/myrootdir/myrenameddir")))
EXPECT_CALL(*fsimpl, rename(Eq("/myrootdir/mydir"), Eq("/myrootdir/myrenameddir")))
.Times(1).WillOnce(Return());
Rename("/myrootdir/mydir", "/myrootdir/myrenameddir");
@ -111,7 +111,7 @@ TEST_F(FuseRenameFilenameTest, RenameDirNestedToNested2) {
ReturnIsDirOnLstat("/myrootdir/myrootdir2");
ReturnIsDirOnLstat("/myrootdir/myrootdir2/mydir");
ReturnDoesntExistOnLstat("/myrootdir/myrootdir2/myrenameddir");
EXPECT_CALL(*fsimpl, rename(StrEq("/myrootdir/myrootdir2/mydir"), StrEq("/myrootdir/myrootdir2/myrenameddir")))
EXPECT_CALL(*fsimpl, rename(Eq("/myrootdir/myrootdir2/mydir"), Eq("/myrootdir/myrootdir2/myrenameddir")))
.Times(1).WillOnce(Return());
Rename("/myrootdir/myrootdir2/mydir", "/myrootdir/myrootdir2/myrenameddir");
@ -122,7 +122,7 @@ TEST_F(FuseRenameFilenameTest, RenameDirNestedToNested_DifferentFolder) {
ReturnIsDirOnLstat("/myrootdir2");
ReturnIsDirOnLstat("/myrootdir/mydir");
ReturnDoesntExistOnLstat("/myrootdir2/myrenameddir");
EXPECT_CALL(*fsimpl, rename(StrEq("/myrootdir/mydir"), StrEq("/myrootdir2/myrenameddir")))
EXPECT_CALL(*fsimpl, rename(Eq("/myrootdir/mydir"), Eq("/myrootdir2/myrenameddir")))
.Times(1).WillOnce(Return());
Rename("/myrootdir/mydir", "/myrootdir2/myrenameddir");

View File

@ -1,13 +1,13 @@
#include "testutils/FuseRmdirTest.h"
using ::testing::StrEq;
using ::testing::Eq;
class FuseRmdirDirnameTest: public FuseRmdirTest {
};
TEST_F(FuseRmdirDirnameTest, Rmdir) {
ReturnIsDirOnLstat("/mydir");
EXPECT_CALL(*fsimpl, rmdir(StrEq("/mydir")))
EXPECT_CALL(*fsimpl, rmdir(Eq("/mydir")))
// After rmdir was called, lstat should return that it doesn't exist anymore
// This is needed to make the ::rmdir() syscall pass.
.Times(1).WillOnce(FromNowOnReturnDoesntExistOnLstat());
@ -18,7 +18,7 @@ TEST_F(FuseRmdirDirnameTest, Rmdir) {
TEST_F(FuseRmdirDirnameTest, RmdirNested) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mysubdir");
EXPECT_CALL(*fsimpl, rmdir(StrEq("/mydir/mysubdir")))
EXPECT_CALL(*fsimpl, rmdir(Eq("/mydir/mysubdir")))
// After rmdir was called, lstat should return that it doesn't exist anymore
// This is needed to make the ::rmdir() syscall pass.
.Times(1).WillOnce(FromNowOnReturnDoesntExistOnLstat());
@ -30,7 +30,7 @@ TEST_F(FuseRmdirDirnameTest, RmdirNested2) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
ReturnIsDirOnLstat("/mydir/mydir2/mydir3");
EXPECT_CALL(*fsimpl, rmdir(StrEq("/mydir/mydir2/mydir3")))
EXPECT_CALL(*fsimpl, rmdir(Eq("/mydir/mydir2/mydir3")))
// After rmdir was called, lstat should return that it doesn't exist anymore
// This is needed to make the ::rmdir() syscall pass.
.Times(1).WillOnce(FromNowOnReturnDoesntExistOnLstat());

View File

@ -1,7 +1,7 @@
#include "testutils/FuseRmdirTest.h"
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -14,7 +14,7 @@ INSTANTIATE_TEST_SUITE_P(FuseRmdirErrorTest, FuseRmdirErrorTest, Values(EACCES,
TEST_P(FuseRmdirErrorTest, ReturnedErrorIsCorrect) {
ReturnIsDirOnLstat(DIRNAME);
EXPECT_CALL(*fsimpl, rmdir(StrEq(DIRNAME)))
EXPECT_CALL(*fsimpl, rmdir(Eq(DIRNAME)))
.Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
int error = RmdirReturnError(DIRNAME);

View File

@ -20,8 +20,8 @@ int FuseRmdirTest::RmdirReturnError(const char *dirname) {
}
}
Action<void(const char*)> FuseRmdirTest::FromNowOnReturnDoesntExistOnLstat() {
return Invoke([this](const char *dirname) {
Action<void(const boost::filesystem::path&)> FuseRmdirTest::FromNowOnReturnDoesntExistOnLstat() {
return Invoke([this](const boost::filesystem::path& dirname) {
ReturnDoesntExistOnLstat(dirname);
});
}

View File

@ -11,7 +11,7 @@ public:
void Rmdir(const char *dirname);
int RmdirReturnError(const char *dirname);
::testing::Action<void(const char*)> FromNowOnReturnDoesntExistOnLstat();
::testing::Action<void(const boost::filesystem::path&)> FromNowOnReturnDoesntExistOnLstat();
};
#endif

View File

@ -2,7 +2,7 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -15,7 +15,7 @@ INSTANTIATE_TEST_SUITE_P(FuseTruncateErrorTest, FuseTruncateErrorTest, Values(EA
TEST_P(FuseTruncateErrorTest, ReturnedErrorIsCorrect) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, truncate(StrEq(FILENAME), _))
EXPECT_CALL(*fsimpl, truncate(Eq(FILENAME), _))
.Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
int error = TruncateFileReturnError(FILENAME, fspp::num_bytes_t(0));

View File

@ -1,7 +1,7 @@
#include "testutils/FuseTruncateTest.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Return;
class FuseTruncateFilenameTest: public FuseTruncateTest {
@ -9,7 +9,7 @@ class FuseTruncateFilenameTest: public FuseTruncateTest {
TEST_F(FuseTruncateFilenameTest, TruncateFile) {
ReturnIsFileOnLstat("/myfile");
EXPECT_CALL(*fsimpl, truncate(StrEq("/myfile"), _))
EXPECT_CALL(*fsimpl, truncate(Eq("/myfile"), _))
.Times(1).WillOnce(Return());
TruncateFile("/myfile", fspp::num_bytes_t(0));
@ -18,7 +18,7 @@ TEST_F(FuseTruncateFilenameTest, TruncateFile) {
TEST_F(FuseTruncateFilenameTest, TruncateFileNested) {
ReturnIsDirOnLstat("/mydir");
ReturnIsFileOnLstat("/mydir/myfile");
EXPECT_CALL(*fsimpl, truncate(StrEq("/mydir/myfile"), _))
EXPECT_CALL(*fsimpl, truncate(Eq("/mydir/myfile"), _))
.Times(1).WillOnce(Return());
TruncateFile("/mydir/myfile", fspp::num_bytes_t(0));
@ -28,7 +28,7 @@ TEST_F(FuseTruncateFilenameTest, TruncateFileNested2) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
ReturnIsFileOnLstat("/mydir/mydir2/myfile");
EXPECT_CALL(*fsimpl, truncate(StrEq("/mydir/mydir2/myfile"), _))
EXPECT_CALL(*fsimpl, truncate(Eq("/mydir/mydir2/myfile"), _))
.Times(1).WillOnce(Return());
TruncateFile("/mydir/mydir2/myfile", fspp::num_bytes_t(0));

View File

@ -1,6 +1,6 @@
#include "testutils/FuseTruncateTest.h"
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Return;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -18,7 +18,7 @@ INSTANTIATE_TEST_SUITE_P(FuseTruncateSizeTest, FuseTruncateSizeTest, Values(
TEST_P(FuseTruncateSizeTest, TruncateFile) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, truncate(StrEq(FILENAME), Eq(GetParam())))
EXPECT_CALL(*fsimpl, truncate(Eq(FILENAME), Eq(GetParam())))
.Times(1).WillOnce(Return());
TruncateFile(FILENAME, GetParam());

View File

@ -1,7 +1,7 @@
#include "testutils/FuseUnlinkTest.h"
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -14,7 +14,7 @@ INSTANTIATE_TEST_SUITE_P(FuseUnlinkErrorTest, FuseUnlinkErrorTest, Values(EACCES
TEST_P(FuseUnlinkErrorTest, ReturnedErrorIsCorrect) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, unlink(StrEq(FILENAME)))
EXPECT_CALL(*fsimpl, unlink(Eq(FILENAME)))
.Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
int error = UnlinkReturnError(FILENAME);

View File

@ -1,13 +1,13 @@
#include "testutils/FuseUnlinkTest.h"
using ::testing::StrEq;
using ::testing::Eq;
class FuseUnlinkFilenameTest: public FuseUnlinkTest {
};
TEST_F(FuseUnlinkFilenameTest, Unlink) {
ReturnIsFileOnLstat("/mydir");
EXPECT_CALL(*fsimpl, unlink(StrEq("/mydir")))
EXPECT_CALL(*fsimpl, unlink(Eq("/mydir")))
// After rmdir was called, lstat should return that it doesn't exist anymore
// This is needed to make the ::rmdir() syscall pass.
.Times(1).WillOnce(FromNowOnReturnDoesntExistOnLstat());
@ -18,7 +18,7 @@ TEST_F(FuseUnlinkFilenameTest, Unlink) {
TEST_F(FuseUnlinkFilenameTest, UnlinkNested) {
ReturnIsDirOnLstat("/mydir");
ReturnIsFileOnLstat("/mydir/mysubdir");
EXPECT_CALL(*fsimpl, unlink(StrEq("/mydir/mysubdir")))
EXPECT_CALL(*fsimpl, unlink(Eq("/mydir/mysubdir")))
// After rmdir was called, lstat should return that it doesn't exist anymore
// This is needed to make the ::rmdir() syscall pass.
.Times(1).WillOnce(FromNowOnReturnDoesntExistOnLstat());
@ -30,7 +30,7 @@ TEST_F(FuseUnlinkFilenameTest, UnlinkNested2) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
ReturnIsFileOnLstat("/mydir/mydir2/mydir3");
EXPECT_CALL(*fsimpl, unlink(StrEq("/mydir/mydir2/mydir3")))
EXPECT_CALL(*fsimpl, unlink(Eq("/mydir/mydir2/mydir3")))
// After rmdir was called, lstat should return that it doesn't exist anymore
// This is needed to make the ::rmdir() syscall pass.
.Times(1).WillOnce(FromNowOnReturnDoesntExistOnLstat());

View File

@ -20,8 +20,8 @@ int FuseUnlinkTest::UnlinkReturnError(const char *filename) {
}
}
Action<void(const char*)> FuseUnlinkTest::FromNowOnReturnDoesntExistOnLstat() {
return Invoke([this](const char *filename) {
Action<void(const boost::filesystem::path&)> FuseUnlinkTest::FromNowOnReturnDoesntExistOnLstat() {
return Invoke([this](const boost::filesystem::path& filename) {
ReturnDoesntExistOnLstat(filename);
});
}

View File

@ -11,7 +11,7 @@ public:
void Unlink(const char *filename);
int UnlinkReturnError(const char *filename);
::testing::Action<void(const char*)> FromNowOnReturnDoesntExistOnLstat();
::testing::Action<void(const boost::filesystem::path&)> FromNowOnReturnDoesntExistOnLstat();
};
#endif

View File

@ -2,7 +2,7 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -15,7 +15,7 @@ INSTANTIATE_TEST_SUITE_P(FuseUtimensErrorTest, FuseUtimensErrorTest, Values(EACC
TEST_P(FuseUtimensErrorTest, ReturnedErrorIsCorrect) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, utimens(StrEq(FILENAME), _, _))
EXPECT_CALL(*fsimpl, utimens(Eq(FILENAME), _, _))
.Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
int error = UtimensReturnError(FILENAME, TIMEVALUE, TIMEVALUE);

View File

@ -1,7 +1,7 @@
#include "testutils/FuseUtimensTest.h"
using ::testing::_;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Return;
class FuseUtimensFilenameTest: public FuseUtimensTest {
@ -9,7 +9,7 @@ class FuseUtimensFilenameTest: public FuseUtimensTest {
TEST_F(FuseUtimensFilenameTest, UtimensFile) {
ReturnIsFileOnLstat("/myfile");
EXPECT_CALL(*fsimpl, utimens(StrEq("/myfile"), _, _))
EXPECT_CALL(*fsimpl, utimens(Eq("/myfile"), _, _))
.Times(1).WillOnce(Return());
Utimens("/myfile", TIMEVALUE, TIMEVALUE);
@ -18,7 +18,7 @@ TEST_F(FuseUtimensFilenameTest, UtimensFile) {
TEST_F(FuseUtimensFilenameTest, UtimensFileNested) {
ReturnIsDirOnLstat("/mydir");
ReturnIsFileOnLstat("/mydir/myfile");
EXPECT_CALL(*fsimpl, utimens(StrEq("/mydir/myfile"), _, _))
EXPECT_CALL(*fsimpl, utimens(Eq("/mydir/myfile"), _, _))
.Times(1).WillOnce(Return());
Utimens("/mydir/myfile", TIMEVALUE, TIMEVALUE);
@ -28,7 +28,7 @@ TEST_F(FuseUtimensFilenameTest, UtimensFileNested2) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
ReturnIsFileOnLstat("/mydir/mydir2/myfile");
EXPECT_CALL(*fsimpl, utimens(StrEq("/mydir/mydir2/myfile"), _, _))
EXPECT_CALL(*fsimpl, utimens(Eq("/mydir/mydir2/myfile"), _, _))
.Times(1).WillOnce(Return());
Utimens("/mydir/mydir2/myfile", TIMEVALUE, TIMEVALUE);
@ -36,7 +36,7 @@ TEST_F(FuseUtimensFilenameTest, UtimensFileNested2) {
TEST_F(FuseUtimensFilenameTest, UtimensDir) {
ReturnIsDirOnLstat("/mydir");
EXPECT_CALL(*fsimpl, utimens(StrEq("/mydir"), _, _))
EXPECT_CALL(*fsimpl, utimens(Eq("/mydir"), _, _))
.Times(1).WillOnce(Return());
Utimens("/mydir", TIMEVALUE, TIMEVALUE);
@ -45,7 +45,7 @@ TEST_F(FuseUtimensFilenameTest, UtimensDir) {
TEST_F(FuseUtimensFilenameTest, UtimensDirNested) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
EXPECT_CALL(*fsimpl, utimens(StrEq("/mydir/mydir2"), _, _))
EXPECT_CALL(*fsimpl, utimens(Eq("/mydir/mydir2"), _, _))
.Times(1).WillOnce(Return());
Utimens("/mydir/mydir2", TIMEVALUE, TIMEVALUE);
@ -55,7 +55,7 @@ TEST_F(FuseUtimensFilenameTest, UtimensDirNested2) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
ReturnIsDirOnLstat("/mydir/mydir2/mydir3");
EXPECT_CALL(*fsimpl, utimens(StrEq("/mydir/mydir2/mydir3"), _, _))
EXPECT_CALL(*fsimpl, utimens(Eq("/mydir/mydir2/mydir3"), _, _))
.Times(1).WillOnce(Return());
Utimens("/mydir/mydir2/mydir3", TIMEVALUE, TIMEVALUE);

View File

@ -1,6 +1,6 @@
#include "testutils/FuseUtimensTest.h"
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::Return;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -23,7 +23,7 @@ INSTANTIATE_TEST_SUITE_P(FuseUtimensTimeParameterTest, FuseUtimensTimeParameterT
TEST_P(FuseUtimensTimeParameterTest, Utimens) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, utimens(StrEq(FILENAME), TimeSpecEq(GetParam()[0]), TimeSpecEq(GetParam()[1])))
EXPECT_CALL(*fsimpl, utimens(Eq(FILENAME), TimeSpecEq(GetParam()[0]), TimeSpecEq(GetParam()[1])))
.Times(1).WillOnce(Return());
Utimens(FILENAME, GetParam()[0], GetParam()[1]);

View File

@ -17,13 +17,13 @@ public:
~MockOpenFile() {destructed = true;}
MOCK_CONST_METHOD0(stat, OpenFile::stat_info());
MOCK_CONST_METHOD1(truncate, void(fspp::num_bytes_t));
MOCK_CONST_METHOD3(read, fspp::num_bytes_t(void*, fspp::num_bytes_t, fspp::num_bytes_t));
MOCK_METHOD3(write, void(const void*, fspp::num_bytes_t, fspp::num_bytes_t));
MOCK_METHOD0(flush, void());
MOCK_METHOD0(fsync, void());
MOCK_METHOD0(fdatasync, void());
MOCK_METHOD(OpenFile::stat_info, stat, (), (const, override));
MOCK_METHOD(void, truncate, (fspp::num_bytes_t), (const, override));
MOCK_METHOD(fspp::num_bytes_t, read, (void*, fspp::num_bytes_t, fspp::num_bytes_t), (const, override));
MOCK_METHOD(void, write, (const void*, fspp::num_bytes_t, fspp::num_bytes_t), (override));
MOCK_METHOD(void, flush, (), (override));
MOCK_METHOD(void, fsync, (), (override));
MOCK_METHOD(void, fdatasync, (), (override));
};
struct FuseOpenFileListTest: public ::testing::Test {

View File

@ -1,6 +1,6 @@
#include "FuseTest.h"
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::_;
using ::testing::Return;
using ::testing::Throw;
@ -70,8 +70,8 @@ const bf::path &FuseTest::TempTestFS::mountDir() const {
return _mountDir.path();
}
Action<void(const char*, fspp::fuse::STAT*)> FuseTest::ReturnIsFileWithSize(fspp::num_bytes_t size) {
return Invoke([size](const char*, fspp::fuse::STAT* result) {
Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> FuseTest::ReturnIsFileWithSize(fspp::num_bytes_t size) {
return Invoke([size](const boost::filesystem::path&, fspp::fuse::STAT* result) {
result->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH;
result->st_nlink = 1;
result->st_size = size.value();
@ -79,7 +79,7 @@ Action<void(const char*, fspp::fuse::STAT*)> FuseTest::ReturnIsFileWithSize(fspp
}
//TODO Combine ReturnIsFile and ReturnIsFileFstat. This should be possible in gmock by either (a) using ::testing::Undefined as parameter type or (b) using action macros
Action<void(const char*, fspp::fuse::STAT*)> FuseTest::ReturnIsFile = ReturnIsFileWithSize(fspp::num_bytes_t(0));
Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> FuseTest::ReturnIsFile = ReturnIsFileWithSize(fspp::num_bytes_t(0));
Action<void(int, fspp::fuse::STAT*)> FuseTest::ReturnIsFileFstat =
Invoke([](int, fspp::fuse::STAT* result) {
@ -95,32 +95,32 @@ Action<void(int, fspp::fuse::STAT*)> FuseTest::ReturnIsFileFstatWithSize(fspp::n
});
}
Action<void(const char*, fspp::fuse::STAT*)> FuseTest::ReturnIsDir =
Invoke([](const char*, fspp::fuse::STAT* result) {
Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> FuseTest::ReturnIsDir =
Invoke([](const boost::filesystem::path&, fspp::fuse::STAT* result) {
result->st_mode = S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH;
result->st_nlink = 1;
});
Action<void(const char*, fspp::fuse::STAT*)> FuseTest::ReturnDoesntExist = Throw(fspp::fuse::FuseErrnoException(ENOENT));
Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> FuseTest::ReturnDoesntExist = Throw(fspp::fuse::FuseErrnoException(ENOENT));
void FuseTest::OnOpenReturnFileDescriptor(const char *filename, int descriptor) {
EXPECT_CALL(*fsimpl, openFile(StrEq(filename), _)).Times(1).WillOnce(Return(descriptor));
EXPECT_CALL(*fsimpl, openFile(Eq(filename), _)).Times(1).WillOnce(Return(descriptor));
}
void FuseTest::ReturnIsFileOnLstat(const bf::path &path) {
EXPECT_CALL(*fsimpl, lstat(::testing::StrEq(path.string().c_str()), ::testing::_)).WillRepeatedly(ReturnIsFile);
EXPECT_CALL(*fsimpl, lstat(Eq(path), ::testing::_)).WillRepeatedly(ReturnIsFile);
}
void FuseTest::ReturnIsFileOnLstatWithSize(const bf::path &path, const fspp::num_bytes_t size) {
EXPECT_CALL(*fsimpl, lstat(::testing::StrEq(path.string().c_str()), ::testing::_)).WillRepeatedly(ReturnIsFileWithSize(size));
EXPECT_CALL(*fsimpl, lstat(Eq(path), ::testing::_)).WillRepeatedly(ReturnIsFileWithSize(size));
}
void FuseTest::ReturnIsDirOnLstat(const bf::path &path) {
EXPECT_CALL(*fsimpl, lstat(::testing::StrEq(path.string().c_str()), ::testing::_)).WillRepeatedly(ReturnIsDir);
EXPECT_CALL(*fsimpl, lstat(Eq(path), ::testing::_)).WillRepeatedly(ReturnIsDir);
}
void FuseTest::ReturnDoesntExistOnLstat(const bf::path &path) {
EXPECT_CALL(*fsimpl, lstat(::testing::StrEq(path.string().c_str()), ::testing::_)).WillRepeatedly(ReturnDoesntExist);
EXPECT_CALL(*fsimpl, lstat(Eq(path), ::testing::_)).WillRepeatedly(ReturnDoesntExist);
}
void FuseTest::ReturnIsFileOnFstat(int descriptor) {

View File

@ -15,71 +15,35 @@
#include <cpp-utils/tempfile/TempDir.h>
#include "FuseThread.h"
#define MOCK_PATH_METHOD1(NAME, RETURNTYPE) \
RETURNTYPE NAME(const boost::filesystem::path &path) override { \
return NAME(path.string().c_str()); \
} \
MOCK_METHOD1(NAME, RETURNTYPE(const char*)) \
#define MOCK_PATH_METHOD2(NAME, RETURNTYPE, PARAM1) \
RETURNTYPE NAME(const boost::filesystem::path &path, PARAM1 param1) override { \
return NAME(path.string().c_str(), param1); \
} \
MOCK_METHOD2(NAME, RETURNTYPE(const char*, PARAM1)) \
#define MOCK_PATH_METHOD3(NAME, RETURNTYPE, PARAM1, PARAM2) \
RETURNTYPE NAME(const boost::filesystem::path &path, PARAM1 p1, PARAM2 p2) override { \
return NAME(path.string().c_str(), p1, p2); \
} \
MOCK_METHOD3(NAME, RETURNTYPE(const char*, PARAM1, PARAM2)) \
#define MOCK_PATH_METHOD4(NAME, RETURNTYPE, PARAM1, PARAM2, PARAM3) \
RETURNTYPE NAME(const boost::filesystem::path &path, PARAM1 p1, PARAM2 p2, PARAM3 p3) override { \
return NAME(path.string().c_str(), p1, p2, p3); \
} \
MOCK_METHOD4(NAME, RETURNTYPE(const char*, PARAM1, PARAM2, PARAM3)) \
class MockFilesystem: public fspp::fuse::Filesystem {
public:
MockFilesystem();
virtual ~MockFilesystem();
MOCK_PATH_METHOD2(openFile, int, int);
MOCK_METHOD1(closeFile, void(int));
MOCK_PATH_METHOD2(lstat, void, fspp::fuse::STAT*);
MOCK_METHOD2(fstat, void(int, fspp::fuse::STAT*));
MOCK_PATH_METHOD2(truncate, void, fspp::num_bytes_t);
MOCK_METHOD2(ftruncate, void(int, fspp::num_bytes_t));
MOCK_METHOD4(read, fspp::num_bytes_t(int, void*, fspp::num_bytes_t, fspp::num_bytes_t));
MOCK_METHOD4(write, void(int, const void*, fspp::num_bytes_t, fspp::num_bytes_t));
MOCK_METHOD1(flush, void(int));
MOCK_METHOD1(fsync, void(int));
MOCK_METHOD1(fdatasync, void(int));
MOCK_PATH_METHOD2(access, void, int);
MOCK_PATH_METHOD4(createAndOpenFile, int, mode_t, uid_t, gid_t);
MOCK_PATH_METHOD4(mkdir, void, mode_t, uid_t, gid_t);
MOCK_PATH_METHOD1(rmdir, void);
MOCK_PATH_METHOD1(unlink, void);
void rename(const boost::filesystem::path &from, const boost::filesystem::path &to) override {
return rename(from.string().c_str(), to.string().c_str());
}
MOCK_METHOD2(rename, void(const char*, const char*));
cpputils::unique_ref<std::vector<fspp::Dir::Entry>> readDir(const boost::filesystem::path &path) override {
return cpputils::nullcheck(std::unique_ptr<std::vector<fspp::Dir::Entry>>(readDir(path.string().c_str()))).value();
}
MOCK_METHOD1(readDir, std::vector<fspp::Dir::Entry>*(const char*));
void utimens(const boost::filesystem::path &path, timespec lastAccessTime, timespec lastModificationTime) override {
return utimens(path.string().c_str(), lastAccessTime, lastModificationTime);
}
MOCK_METHOD3(utimens, void(const char*, timespec, timespec));
MOCK_METHOD1(statfs, void(struct statvfs*));
void createSymlink(const boost::filesystem::path &to, const boost::filesystem::path &from, uid_t uid, gid_t gid) override {
return createSymlink(to.string().c_str(), from.string().c_str(), uid, gid);
}
MOCK_PATH_METHOD2(chmod, void, mode_t);
MOCK_PATH_METHOD3(chown, void, uid_t, gid_t);
MOCK_METHOD4(createSymlink, void(const char*, const char*, uid_t, gid_t));
MOCK_PATH_METHOD3(readSymlink, void, char*, fspp::num_bytes_t);
MOCK_METHOD(int, openFile, (const boost::filesystem::path&, int), (override));
MOCK_METHOD(void, closeFile, (int), (override));
MOCK_METHOD(void, lstat, (const boost::filesystem::path&, fspp::fuse::STAT*), (override));
MOCK_METHOD(void, fstat, (int, fspp::fuse::STAT*), (override));
MOCK_METHOD(void, truncate, (const boost::filesystem::path&, fspp::num_bytes_t), (override));
MOCK_METHOD(void, ftruncate, (int, fspp::num_bytes_t), (override));
MOCK_METHOD(fspp::num_bytes_t, read, (int, void*, fspp::num_bytes_t, fspp::num_bytes_t), (override));
MOCK_METHOD(void, write, (int, const void*, fspp::num_bytes_t, fspp::num_bytes_t), (override));
MOCK_METHOD(void, flush, (int), (override));
MOCK_METHOD(void, fsync, (int), (override));
MOCK_METHOD(void, fdatasync, (int), (override));
MOCK_METHOD(void, access, (const boost::filesystem::path&, int), (override));
MOCK_METHOD(int, createAndOpenFile, (const boost::filesystem::path&, mode_t, uid_t, gid_t), (override));
MOCK_METHOD(void, mkdir, (const boost::filesystem::path&, mode_t, uid_t, gid_t), (override));
MOCK_METHOD(void, rmdir, (const boost::filesystem::path&), (override));
MOCK_METHOD(void, unlink, (const boost::filesystem::path&), (override));
MOCK_METHOD(void, rename, (const boost::filesystem::path&, const boost::filesystem::path&), (override));
MOCK_METHOD(std::vector<fspp::Dir::Entry>, readDir, (const boost::filesystem::path &path), (override));
MOCK_METHOD(void, utimens, (const boost::filesystem::path&, timespec, timespec), (override));
MOCK_METHOD(void, statfs, (struct statvfs*), (override));
MOCK_METHOD(void, chmod, (const boost::filesystem::path&, mode_t), (override));
MOCK_METHOD(void, chown, (const boost::filesystem::path&, uid_t, gid_t), (override));
MOCK_METHOD(void, createSymlink, (const boost::filesystem::path&, const boost::filesystem::path&, uid_t, gid_t), (override));
MOCK_METHOD(void, readSymlink, (const boost::filesystem::path&, char*, fspp::num_bytes_t), (override));
};
class FuseTest: public ::testing::Test {
@ -106,12 +70,12 @@ public:
//TODO Combine ReturnIsFile and ReturnIsFileFstat. This should be possible in gmock by either (a) using ::testing::Undefined as parameter type or (b) using action macros
static ::testing::Action<void(const char*, fspp::fuse::STAT*)> ReturnIsFile;
static ::testing::Action<void(const char*, fspp::fuse::STAT*)> ReturnIsFileWithSize(fspp::num_bytes_t size);
static ::testing::Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> ReturnIsFile;
static ::testing::Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> ReturnIsFileWithSize(fspp::num_bytes_t size);
static ::testing::Action<void(int, fspp::fuse::STAT*)> ReturnIsFileFstat;
static ::testing::Action<void(int, fspp::fuse::STAT*)> ReturnIsFileFstatWithSize(fspp::num_bytes_t size);
static ::testing::Action<void(const char*, fspp::fuse::STAT*)> ReturnIsDir;
static ::testing::Action<void(const char*, fspp::fuse::STAT*)> ReturnDoesntExist;
static ::testing::Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> ReturnIsDir;
static ::testing::Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> ReturnDoesntExist;
void ReturnIsFileOnLstat(const boost::filesystem::path &path);
void ReturnIsFileOnLstatWithSize(const boost::filesystem::path &path, fspp::num_bytes_t size);

View File

@ -6,13 +6,8 @@ if (BUILD_TESTING)
set(INSTALL_GTEST off CACHE BOOL "" FORCE)
set(INSTALL_GMOCK off CACHE BOOL "" FORCE)
add_subdirectory(gtest EXCLUDE_FROM_ALL)
add_library(googletest INTERFACE)
target_link_libraries(googletest INTERFACE gtest gmock)
target_include_directories(googletest SYSTEM INTERFACE ${gtest_INCLUDE_DIRS}/include SYSTEM INTERFACE ${gmock_INCLUDE_DIRS}/include)
# Disable "missing override" warning because gmock MOCK_METHOD() don't use override :(
if (NOT WIN32)
target_compile_options(googletest INTERFACE "-Wno-inconsistent-missing-override")
endif()
endif()