Simplify mocking thanks to new googletest features
This commit is contained in:
parent
43365c789b
commit
cb01025c81
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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") {
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
@ -15,7 +15,7 @@ using boost::none;
|
||||
|
||||
class DestructorCallback {
|
||||
public:
|
||||
MOCK_CONST_METHOD0(call, void());
|
||||
MOCK_METHOD(void, call, (), (const));
|
||||
};
|
||||
|
||||
class Parent {
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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/");
|
||||
}
|
||||
|
@ -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);
|
||||
}));
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)));
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|