diff --git a/src/cryfs/impl/filesystem/CryDir.cpp b/src/cryfs/impl/filesystem/CryDir.cpp index 7b5c017f..6bdef66e 100644 --- a/src/cryfs/impl/filesystem/CryDir.cpp +++ b/src/cryfs/impl/filesystem/CryDir.cpp @@ -68,17 +68,17 @@ unique_ref CryDir::LoadBlob() const { return std::move(*dir_blob); } -unique_ref> CryDir::children() { +vector 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>(); - children->push_back(fspp::Dir::Entry(fspp::Dir::EntryType::DIR, ".")); - children->push_back(fspp::Dir::Entry(fspp::Dir::EntryType::DIR, "..")); + vector 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; } diff --git a/src/cryfs/impl/filesystem/CryDir.h b/src/cryfs/impl/filesystem/CryDir.h index 6424fcc1..7174873f 100644 --- a/src/cryfs/impl/filesystem/CryDir.h +++ b/src/cryfs/impl/filesystem/CryDir.h @@ -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> children() override; + std::vector children() override; fspp::Dir::EntryType getType() const override; diff --git a/src/fspp/fs_interface/Dir.h b/src/fspp/fs_interface/Dir.h index 159809d9..6e9179b9 100644 --- a/src/fspp/fs_interface/Dir.h +++ b/src/fspp/fs_interface/Dir.h @@ -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> children() const = 0; - virtual cpputils::unique_ref> children() = 0; + //virtual std::vector children() const = 0; + virtual std::vector children() = 0; }; } diff --git a/src/fspp/fstest/FsppDirTest.h b/src/fspp/fstest/FsppDirTest.h index eeb973cb..a16f5cc8 100644 --- a/src/fspp/fstest/FsppDirTest.h +++ b/src/fspp/fstest/FsppDirTest.h @@ -24,7 +24,7 @@ public: std::vector 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 diff --git a/src/fspp/fstest/FsppNodeTest_Rename.h b/src/fspp/fstest/FsppNodeTest_Rename.h index 26d1b476..a07f8e4b 100644 --- a/src/fspp/fstest/FsppNodeTest_Rename.h +++ b/src/fspp/fstest/FsppNodeTest_Rename.h @@ -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() { diff --git a/src/fspp/fuse/Filesystem.h b/src/fspp/fuse/Filesystem.h index 3004c85a..241ee621 100644 --- a/src/fspp/fuse/Filesystem.h +++ b/src/fspp/fuse/Filesystem.h @@ -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> readDir(const boost::filesystem::path &path) = 0; + virtual std::vector 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 diff --git a/src/fspp/fuse/Fuse.cpp b/src/fspp/fuse/Fuse.cpp index e27089d3..96faeec8 100644 --- a/src/fspp/fuse/Fuse.cpp +++ b/src/fspp/fuse/Fuse.cpp @@ -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. diff --git a/src/fspp/fuse/InvalidFilesystem.h b/src/fspp/fuse/InvalidFilesystem.h index 8bc82f11..6c91d5e0 100644 --- a/src/fspp/fuse/InvalidFilesystem.h +++ b/src/fspp/fuse/InvalidFilesystem.h @@ -91,7 +91,7 @@ namespace fspp { throw std::logic_error("Filesystem not initialized yet"); } - cpputils::unique_ref> readDir(const boost::filesystem::path &) override { + std::vector readDir(const boost::filesystem::path &) override { throw std::logic_error("Filesystem not initialized yet"); } diff --git a/src/fspp/impl/FilesystemImpl.cpp b/src/fspp/impl/FilesystemImpl.cpp index bc0ffbd7..71c1ca91 100644 --- a/src/fspp/impl/FilesystemImpl.cpp +++ b/src/fspp/impl/FilesystemImpl.cpp @@ -290,7 +290,7 @@ void FilesystemImpl::rename(const bf::path &from, const bf::path &to) { } } -unique_ref> FilesystemImpl::readDir(const bf::path &path) { +vector FilesystemImpl::readDir(const bf::path &path) { PROFILE(_readDirNanosec); auto dir = LoadDir(path); PROFILE(_readDirNanosec_withoutLoading); diff --git a/src/fspp/impl/FilesystemImpl.h b/src/fspp/impl/FilesystemImpl.h index 65927eee..8c20d395 100644 --- a/src/fspp/impl/FilesystemImpl.h +++ b/src/fspp/impl/FilesystemImpl.h @@ -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> readDir(const boost::filesystem::path &path) override; + std::vector 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; diff --git a/test/blobstore/implementations/onblocks/datatreestore/LeafTraverserTest.cpp b/test/blobstore/implementations/onblocks/datatreestore/LeafTraverserTest.cpp index d104f571..0b3c8a93 100644 --- a/test/blobstore/implementations/onblocks/datatreestore/LeafTraverserTest.cpp +++ b/test/blobstore/implementations/onblocks/datatreestore/LeafTraverserTest.cpp @@ -20,8 +20,8 @@ using std::make_shared; class TraversorMock { public: - MOCK_METHOD3(calledExistingLeaf, void(DataLeafNode*, bool, uint32_t)); - MOCK_METHOD1(calledCreateLeaf, shared_ptr(uint32_t)); + MOCK_METHOD(void, calledExistingLeaf, (DataLeafNode*, bool, uint32_t)); + MOCK_METHOD(shared_ptr, calledCreateLeaf, (uint32_t)); }; MATCHER_P(KeyEq, expected, "node blockId equals") { diff --git a/test/blockstore/interface/BlockStore2Test.cpp b/test/blockstore/interface/BlockStore2Test.cpp index e194c693..65ad93e1 100644 --- a/test/blockstore/interface/BlockStore2Test.cpp +++ b/test/blockstore/interface/BlockStore2Test.cpp @@ -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(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)); + 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, 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), (const, override)); }; class BlockStore2Test: public Test { diff --git a/test/blockstore/interface/BlockStoreTest.cpp b/test/blockstore/interface/BlockStoreTest.cpp index 97dad4f2..9487634f 100644 --- a/test/blockstore/interface/BlockStoreTest.cpp +++ b/test/blockstore/interface/BlockStoreTest.cpp @@ -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> tryCreate(const BlockId &blockId, Data data) { - return cpputils::nullcheck(std::unique_ptr(do_create(blockId, data))); - } - MOCK_METHOD2(do_create, Block*(const BlockId &, const Data &data)); - unique_ref overwrite(const BlockId &blockId, Data data) { - return cpputils::nullcheck(std::unique_ptr(do_overwrite(blockId, data))).value(); - } - MOCK_METHOD2(do_overwrite, Block*(const BlockId &, const Data &data)); - optional> load(const BlockId &blockId) { - return cpputils::nullcheck(std::unique_ptr(do_load(blockId))); - } - MOCK_METHOD1(do_load, Block*(const BlockId &)); - void remove(unique_ref 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)); + MOCK_METHOD(BlockId, createBlockId, (), (override)); + MOCK_METHOD(optional>, tryCreate, (const BlockId &, Data data), (override)); + MOCK_METHOD(unique_ref, overwrite, (const BlockId &, Data data), (override)); + MOCK_METHOD(optional>, load, (const BlockId &), (override)); + MOCK_METHOD(void, remove, (unique_ref), (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), (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>(const BlockId &, cpputils::Data)> ReturnNewBlockMock = Invoke( + [] (const BlockId&, cpputils::Data) { + return optional>(unique_ref(make_unique_ref())); + }); + 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(make_unique_ref())); })) - .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(make_unique_ref())); })); 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(make_unique_ref())); })); 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(make_unique_ref())); })); blockStore.create(data); diff --git a/test/cpp-utils/data/DataTest.cpp b/test/cpp-utils/data/DataTest.cpp index b6db3d98..77ca8779 100644 --- a/test/cpp-utils/data/DataTest.cpp +++ b/test/cpp-utils/data/DataTest.cpp @@ -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 { diff --git a/test/cpp-utils/either_test.cpp b/test/cpp-utils/either_test.cpp index e2f1aab7..aa953fb2 100644 --- a/test/cpp-utils/either_test.cpp +++ b/test/cpp-utils/either_test.cpp @@ -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); diff --git a/test/cpp-utils/pointer/cast_test.cpp b/test/cpp-utils/pointer/cast_test.cpp index 887bbbb2..937c89f0 100644 --- a/test/cpp-utils/pointer/cast_test.cpp +++ b/test/cpp-utils/pointer/cast_test.cpp @@ -15,7 +15,7 @@ using boost::none; class DestructorCallback { public: - MOCK_CONST_METHOD0(call, void()); + MOCK_METHOD(void, call, (), (const)); }; class Parent { diff --git a/test/cryfs/impl/config/CryPasswordBasedKeyProviderTest.cpp b/test/cryfs/impl/config/CryPasswordBasedKeyProviderTest.cpp index 3fdde53d..132e6851 100644 --- a/test/cryfs/impl/config/CryPasswordBasedKeyProviderTest.cpp +++ b/test/cryfs/impl/config/CryPasswordBasedKeyProviderTest.cpp @@ -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 { diff --git a/test/cryfs/impl/config/CryPresetPasswordBasedKeyProviderTest.cpp b/test/cryfs/impl/config/CryPresetPasswordBasedKeyProviderTest.cpp index f1875c38..0f1945f8 100644 --- a/test/cryfs/impl/config/CryPresetPasswordBasedKeyProviderTest.cpp +++ b/test/cryfs/impl/config/CryPresetPasswordBasedKeyProviderTest.cpp @@ -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) { diff --git a/test/cryfs/impl/testutils/MockConsole.h b/test/cryfs/impl/testutils/MockConsole.h index 99219640..9b22eac6 100644 --- a/test/cryfs/impl/testutils/MockConsole.h +++ b/test/cryfs/impl/testutils/MockConsole.h @@ -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&)); - 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&), (override)); + MOCK_METHOD(bool, askYesNo, (const std::string&, bool), (override)); + MOCK_METHOD(std::string, askPassword, (const std::string&), (override)); }; ACTION_P(ChooseCipher, cipherName) { diff --git a/test/cryfs/impl/testutils/MockCryKeyProvider.h b/test/cryfs/impl/testutils/MockCryKeyProvider.h index 28a70f88..1cfb4ce7 100644 --- a/test/cryfs/impl/testutils/MockCryKeyProvider.h +++ b/test/cryfs/impl/testutils/MockCryKeyProvider.h @@ -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 diff --git a/test/fspp/fuse/access/FuseAccessErrorTest.cpp b/test/fspp/fuse/access/FuseAccessErrorTest.cpp index 49c5b61c..4e804c0c 100644 --- a/test/fspp/fuse/access/FuseAccessErrorTest.cpp +++ b/test/fspp/fuse/access/FuseAccessErrorTest.cpp @@ -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); diff --git a/test/fspp/fuse/access/FuseAccessFilenameTest.cpp b/test/fspp/fuse/access/FuseAccessFilenameTest.cpp index 418fa967..67d6f053 100644 --- a/test/fspp/fuse/access/FuseAccessFilenameTest.cpp +++ b/test/fspp/fuse/access/FuseAccessFilenameTest.cpp @@ -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); diff --git a/test/fspp/fuse/access/FuseAccessModeTest.cpp b/test/fspp/fuse/access/FuseAccessModeTest.cpp index 8de5936f..f6347d65 100644 --- a/test/fspp/fuse/access/FuseAccessModeTest.cpp +++ b/test/fspp/fuse/access/FuseAccessModeTest.cpp @@ -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()); diff --git a/test/fspp/fuse/closeFile/FuseCloseTest.cpp b/test/fspp/fuse/closeFile/FuseCloseTest.cpp index 183096a7..5d70d7c9 100644 --- a/test/fspp/fuse/closeFile/FuseCloseTest.cpp +++ b/test/fspp/fuse/closeFile/FuseCloseTest.cpp @@ -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); diff --git a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenErrorTest.cpp b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenErrorTest.cpp index 1ba64888..c251626c 100644 --- a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenErrorTest.cpp +++ b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenErrorTest.cpp @@ -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); diff --git a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp index 2b2a3560..2cb36ab0 100644 --- a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp +++ b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp @@ -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. diff --git a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFilenameTest.cpp b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFilenameTest.cpp index 0b724765..dfbe7e61 100644 --- a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFilenameTest.cpp +++ b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFilenameTest.cpp @@ -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); diff --git a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFlagsTest.cpp b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFlagsTest.cpp index 51b2eb06..bcbb2923 100644 --- a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFlagsTest.cpp +++ b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFlagsTest.cpp @@ -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); diff --git a/test/fspp/fuse/flush/FuseFlushErrorTest.cpp b/test/fspp/fuse/flush/FuseFlushErrorTest.cpp index 08d8da98..d7e80e74 100644 --- a/test/fspp/fuse/flush/FuseFlushErrorTest.cpp +++ b/test/fspp/fuse/flush/FuseFlushErrorTest.cpp @@ -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(); diff --git a/test/fspp/fuse/flush/FuseFlushFileDescriptorTest.cpp b/test/fspp/fuse/flush/FuseFlushFileDescriptorTest.cpp index 6ff9e993..23d0f3fc 100644 --- a/test/fspp/fuse/flush/FuseFlushFileDescriptorTest.cpp +++ b/test/fspp/fuse/flush/FuseFlushFileDescriptorTest.cpp @@ -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); diff --git a/test/fspp/fuse/fstat/testutils/FuseFstatTest.cpp b/test/fspp/fuse/fstat/testutils/FuseFstatTest.cpp index 7c90fca9..5efe488b 100644 --- a/test/fspp/fuse/fstat/testutils/FuseFstatTest.cpp +++ b/test/fspp/fuse/fstat/testutils/FuseFstatTest.cpp @@ -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 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)); } diff --git a/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp b/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp index 499536ff..25201f11 100644 --- a/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp +++ b/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp @@ -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); } diff --git a/test/fspp/fuse/lstat/FuseLstatPathParameterTest.cpp b/test/fspp/fuse/lstat/FuseLstatPathParameterTest.cpp index 1037903b..bb7169ef 100644 --- a/test/fspp/fuse/lstat/FuseLstatPathParameterTest.cpp +++ b/test/fspp/fuse/lstat/FuseLstatPathParameterTest.cpp @@ -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/"); } diff --git a/test/fspp/fuse/lstat/testutils/FuseLstatTest.cpp b/test/fspp/fuse/lstat/testutils/FuseLstatTest.cpp index 4670ce9e..a118bbda 100644 --- a/test/fspp/fuse/lstat/testutils/FuseLstatTest.cpp +++ b/test/fspp/fuse/lstat/testutils/FuseLstatTest.cpp @@ -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 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); })); diff --git a/test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp b/test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp index b3e5f0ab..7f016d28 100644 --- a/test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp +++ b/test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp @@ -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()); diff --git a/test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp b/test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp index 528ef512..6919df3e 100644 --- a/test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp +++ b/test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp @@ -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); diff --git a/test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp b/test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp index 0e3774be..a35e712c 100644 --- a/test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp +++ b/test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp @@ -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()); diff --git a/test/fspp/fuse/mkdir/testutils/FuseMkdirTest.cpp b/test/fspp/fuse/mkdir/testutils/FuseMkdirTest.cpp index 28cf580a..17c18457 100644 --- a/test/fspp/fuse/mkdir/testutils/FuseMkdirTest.cpp +++ b/test/fspp/fuse/mkdir/testutils/FuseMkdirTest.cpp @@ -20,8 +20,8 @@ int FuseMkdirTest::MkdirReturnError(const char *dirname, mode_t mode) { } } -Action FuseMkdirTest::FromNowOnReturnIsDirOnLstat() { - return Invoke([this](const char *dirname, mode_t, uid_t, gid_t) { +Action FuseMkdirTest::FromNowOnReturnIsDirOnLstat() { + return Invoke([this](const boost::filesystem::path& dirname, mode_t, uid_t, gid_t) { ReturnIsDirOnLstat(dirname); }); } diff --git a/test/fspp/fuse/mkdir/testutils/FuseMkdirTest.h b/test/fspp/fuse/mkdir/testutils/FuseMkdirTest.h index 3cbeb9ea..0491113f 100644 --- a/test/fspp/fuse/mkdir/testutils/FuseMkdirTest.h +++ b/test/fspp/fuse/mkdir/testutils/FuseMkdirTest.h @@ -11,7 +11,7 @@ public: void Mkdir(const char *dirname, mode_t mode); int MkdirReturnError(const char *dirname, mode_t mode); - ::testing::Action FromNowOnReturnIsDirOnLstat(); + ::testing::Action FromNowOnReturnIsDirOnLstat(); }; #endif diff --git a/test/fspp/fuse/openFile/FuseOpenErrorTest.cpp b/test/fspp/fuse/openFile/FuseOpenErrorTest.cpp index 3c069687..13ae60da 100644 --- a/test/fspp/fuse/openFile/FuseOpenErrorTest.cpp +++ b/test/fspp/fuse/openFile/FuseOpenErrorTest.cpp @@ -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); } diff --git a/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp b/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp index 079cedc4..dea0dbd6 100644 --- a/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp +++ b/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp @@ -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))); diff --git a/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp b/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp index ae77d2d7..f1ab83f8 100644 --- a/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp +++ b/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp @@ -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); diff --git a/test/fspp/fuse/openFile/FuseOpenFlagsTest.cpp b/test/fspp/fuse/openFile/FuseOpenFlagsTest.cpp index fe4e6768..137634f6 100644 --- a/test/fspp/fuse/openFile/FuseOpenFlagsTest.cpp +++ b/test/fspp/fuse/openFile/FuseOpenFlagsTest.cpp @@ -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()); diff --git a/test/fspp/fuse/readDir/FuseReadDirDirnameTest.cpp b/test/fspp/fuse/readDir/FuseReadDirDirnameTest.cpp index df18348f..f569315c 100644 --- a/test/fspp/fuse/readDir/FuseReadDirDirnameTest.cpp +++ b/test/fspp/fuse/readDir/FuseReadDirDirnameTest.cpp @@ -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"); diff --git a/test/fspp/fuse/readDir/FuseReadDirErrorTest.cpp b/test/fspp/fuse/readDir/FuseReadDirErrorTest.cpp index 4d7298e3..ffb96f21 100644 --- a/test/fspp/fuse/readDir/FuseReadDirErrorTest.cpp +++ b/test/fspp/fuse/readDir/FuseReadDirErrorTest.cpp @@ -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); diff --git a/test/fspp/fuse/readDir/FuseReadDirReturnTest.cpp b/test/fspp/fuse/readDir/FuseReadDirReturnTest.cpp index 9f05659b..8f1a759c 100644 --- a/test/fspp/fuse/readDir/FuseReadDirReturnTest.cpp +++ b/test/fspp/fuse/readDir/FuseReadDirReturnTest.cpp @@ -2,22 +2,20 @@ #include #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> LARGE_DIR(int num_entries) { - auto result = make_unique_ref>(); - result->reserve(num_entries); +vector LARGE_DIR(int num_entries) { + vector result; + result.reserve(num_entries); for(int i=0; ipush_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 &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); } diff --git a/test/fspp/fuse/readDir/testutils/FuseReadDirTest.cpp b/test/fspp/fuse/readDir/testutils/FuseReadDirTest.cpp index 036c5b17..3d15eff2 100644 --- a/test/fspp/fuse/readDir/testutils/FuseReadDirTest.cpp +++ b/test/fspp/fuse/readDir/testutils/FuseReadDirTest.cpp @@ -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> FuseReadDirTest::ReadDir(const char *dirname) { +vector FuseReadDirTest::ReadDir(const char *dirname) { auto fs = TestFS(); DIR *dir = openDir(fs.get(), dirname); - auto result = make_unique_ref>(); - readDirEntries(dir, result.get()); + vector 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*(const char*)> FuseReadDirTest::ReturnDirEntries(vector entries) { - vector *direntries = new vector(entries.size(), fspp::Dir::Entry(fspp::Dir::EntryType::FILE, "")); +Action(const boost::filesystem::path&)> FuseReadDirTest::ReturnDirEntries(vector entries) { + vector 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)); } diff --git a/test/fspp/fuse/readDir/testutils/FuseReadDirTest.h b/test/fspp/fuse/readDir/testutils/FuseReadDirTest.h index 19787aca..d1b15eb6 100644 --- a/test/fspp/fuse/readDir/testutils/FuseReadDirTest.h +++ b/test/fspp/fuse/readDir/testutils/FuseReadDirTest.h @@ -10,10 +10,10 @@ class FuseReadDirTest: public FuseTest { public: const char *DIRNAME = "/mydir"; - cpputils::unique_ref> ReadDir(const char *dirname); + std::vector ReadDir(const char *dirname); int ReadDirReturnError(const char *dirname); - static ::testing::Action*(const char*)> ReturnDirEntries(std::vector entries); + static ::testing::Action(const boost::filesystem::path&)> ReturnDirEntries(std::vector entries); private: DIR *openDir(TempTestFS *fs, const char *dirname); diff --git a/test/fspp/fuse/rename/FuseRenameErrorTest.cpp b/test/fspp/fuse/rename/FuseRenameErrorTest.cpp index e8903ad0..d4c9df85 100644 --- a/test/fspp/fuse/rename/FuseRenameErrorTest.cpp +++ b/test/fspp/fuse/rename/FuseRenameErrorTest.cpp @@ -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); diff --git a/test/fspp/fuse/rename/FuseRenameFilenameTest.cpp b/test/fspp/fuse/rename/FuseRenameFilenameTest.cpp index b58b76b1..47182f98 100644 --- a/test/fspp/fuse/rename/FuseRenameFilenameTest.cpp +++ b/test/fspp/fuse/rename/FuseRenameFilenameTest.cpp @@ -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"); diff --git a/test/fspp/fuse/rmdir/FuseRmdirDirnameTest.cpp b/test/fspp/fuse/rmdir/FuseRmdirDirnameTest.cpp index b2c6f0a7..6adfd2e1 100644 --- a/test/fspp/fuse/rmdir/FuseRmdirDirnameTest.cpp +++ b/test/fspp/fuse/rmdir/FuseRmdirDirnameTest.cpp @@ -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()); diff --git a/test/fspp/fuse/rmdir/FuseRmdirErrorTest.cpp b/test/fspp/fuse/rmdir/FuseRmdirErrorTest.cpp index cabf2cdb..a19d489c 100644 --- a/test/fspp/fuse/rmdir/FuseRmdirErrorTest.cpp +++ b/test/fspp/fuse/rmdir/FuseRmdirErrorTest.cpp @@ -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); diff --git a/test/fspp/fuse/rmdir/testutils/FuseRmdirTest.cpp b/test/fspp/fuse/rmdir/testutils/FuseRmdirTest.cpp index 9cdd0001..3b0e1a2a 100644 --- a/test/fspp/fuse/rmdir/testutils/FuseRmdirTest.cpp +++ b/test/fspp/fuse/rmdir/testutils/FuseRmdirTest.cpp @@ -20,8 +20,8 @@ int FuseRmdirTest::RmdirReturnError(const char *dirname) { } } -Action FuseRmdirTest::FromNowOnReturnDoesntExistOnLstat() { - return Invoke([this](const char *dirname) { +Action FuseRmdirTest::FromNowOnReturnDoesntExistOnLstat() { + return Invoke([this](const boost::filesystem::path& dirname) { ReturnDoesntExistOnLstat(dirname); }); } diff --git a/test/fspp/fuse/rmdir/testutils/FuseRmdirTest.h b/test/fspp/fuse/rmdir/testutils/FuseRmdirTest.h index 6f547d49..de6a6dca 100644 --- a/test/fspp/fuse/rmdir/testutils/FuseRmdirTest.h +++ b/test/fspp/fuse/rmdir/testutils/FuseRmdirTest.h @@ -11,7 +11,7 @@ public: void Rmdir(const char *dirname); int RmdirReturnError(const char *dirname); - ::testing::Action FromNowOnReturnDoesntExistOnLstat(); + ::testing::Action FromNowOnReturnDoesntExistOnLstat(); }; #endif diff --git a/test/fspp/fuse/truncate/FuseTruncateErrorTest.cpp b/test/fspp/fuse/truncate/FuseTruncateErrorTest.cpp index e6392d27..6b7673d0 100644 --- a/test/fspp/fuse/truncate/FuseTruncateErrorTest.cpp +++ b/test/fspp/fuse/truncate/FuseTruncateErrorTest.cpp @@ -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)); diff --git a/test/fspp/fuse/truncate/FuseTruncateFilenameTest.cpp b/test/fspp/fuse/truncate/FuseTruncateFilenameTest.cpp index a2628e1d..1201da9a 100644 --- a/test/fspp/fuse/truncate/FuseTruncateFilenameTest.cpp +++ b/test/fspp/fuse/truncate/FuseTruncateFilenameTest.cpp @@ -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)); diff --git a/test/fspp/fuse/truncate/FuseTruncateSizeTest.cpp b/test/fspp/fuse/truncate/FuseTruncateSizeTest.cpp index 036c5ea2..8a5d67c2 100644 --- a/test/fspp/fuse/truncate/FuseTruncateSizeTest.cpp +++ b/test/fspp/fuse/truncate/FuseTruncateSizeTest.cpp @@ -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()); diff --git a/test/fspp/fuse/unlink/FuseUnlinkErrorTest.cpp b/test/fspp/fuse/unlink/FuseUnlinkErrorTest.cpp index 799413d7..b04dd675 100644 --- a/test/fspp/fuse/unlink/FuseUnlinkErrorTest.cpp +++ b/test/fspp/fuse/unlink/FuseUnlinkErrorTest.cpp @@ -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); diff --git a/test/fspp/fuse/unlink/FuseUnlinkFilenameTest.cpp b/test/fspp/fuse/unlink/FuseUnlinkFilenameTest.cpp index ba5c2c47..230a21c8 100644 --- a/test/fspp/fuse/unlink/FuseUnlinkFilenameTest.cpp +++ b/test/fspp/fuse/unlink/FuseUnlinkFilenameTest.cpp @@ -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()); diff --git a/test/fspp/fuse/unlink/testutils/FuseUnlinkTest.cpp b/test/fspp/fuse/unlink/testutils/FuseUnlinkTest.cpp index 9993db4f..63dedf67 100644 --- a/test/fspp/fuse/unlink/testutils/FuseUnlinkTest.cpp +++ b/test/fspp/fuse/unlink/testutils/FuseUnlinkTest.cpp @@ -20,8 +20,8 @@ int FuseUnlinkTest::UnlinkReturnError(const char *filename) { } } -Action FuseUnlinkTest::FromNowOnReturnDoesntExistOnLstat() { - return Invoke([this](const char *filename) { +Action FuseUnlinkTest::FromNowOnReturnDoesntExistOnLstat() { + return Invoke([this](const boost::filesystem::path& filename) { ReturnDoesntExistOnLstat(filename); }); } diff --git a/test/fspp/fuse/unlink/testutils/FuseUnlinkTest.h b/test/fspp/fuse/unlink/testutils/FuseUnlinkTest.h index cfea0bb6..98f2a436 100644 --- a/test/fspp/fuse/unlink/testutils/FuseUnlinkTest.h +++ b/test/fspp/fuse/unlink/testutils/FuseUnlinkTest.h @@ -11,7 +11,7 @@ public: void Unlink(const char *filename); int UnlinkReturnError(const char *filename); - ::testing::Action FromNowOnReturnDoesntExistOnLstat(); + ::testing::Action FromNowOnReturnDoesntExistOnLstat(); }; #endif diff --git a/test/fspp/fuse/utimens/FuseUtimensErrorTest.cpp b/test/fspp/fuse/utimens/FuseUtimensErrorTest.cpp index d00e56df..5704f2ce 100644 --- a/test/fspp/fuse/utimens/FuseUtimensErrorTest.cpp +++ b/test/fspp/fuse/utimens/FuseUtimensErrorTest.cpp @@ -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); diff --git a/test/fspp/fuse/utimens/FuseUtimensFilenameTest.cpp b/test/fspp/fuse/utimens/FuseUtimensFilenameTest.cpp index fec46fbb..9f686823 100644 --- a/test/fspp/fuse/utimens/FuseUtimensFilenameTest.cpp +++ b/test/fspp/fuse/utimens/FuseUtimensFilenameTest.cpp @@ -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); diff --git a/test/fspp/fuse/utimens/FuseUtimensTimeParameterTest.cpp b/test/fspp/fuse/utimens/FuseUtimensTimeParameterTest.cpp index 80066c96..72e95275 100644 --- a/test/fspp/fuse/utimens/FuseUtimensTimeParameterTest.cpp +++ b/test/fspp/fuse/utimens/FuseUtimensTimeParameterTest.cpp @@ -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]); diff --git a/test/fspp/impl/FuseOpenFileListTest.cpp b/test/fspp/impl/FuseOpenFileListTest.cpp index 000f746d..e59fe558 100644 --- a/test/fspp/impl/FuseOpenFileListTest.cpp +++ b/test/fspp/impl/FuseOpenFileListTest.cpp @@ -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 { diff --git a/test/fspp/testutils/FuseTest.cpp b/test/fspp/testutils/FuseTest.cpp index 81b9dc66..7ae9cd39 100644 --- a/test/fspp/testutils/FuseTest.cpp +++ b/test/fspp/testutils/FuseTest.cpp @@ -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 FuseTest::ReturnIsFileWithSize(fspp::num_bytes_t size) { - return Invoke([size](const char*, fspp::fuse::STAT* result) { +Action 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 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 FuseTest::ReturnIsFile = ReturnIsFileWithSize(fspp::num_bytes_t(0)); +Action FuseTest::ReturnIsFile = ReturnIsFileWithSize(fspp::num_bytes_t(0)); Action FuseTest::ReturnIsFileFstat = Invoke([](int, fspp::fuse::STAT* result) { @@ -95,32 +95,32 @@ Action FuseTest::ReturnIsFileFstatWithSize(fspp::n }); } -Action FuseTest::ReturnIsDir = - Invoke([](const char*, fspp::fuse::STAT* result) { +Action 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 FuseTest::ReturnDoesntExist = Throw(fspp::fuse::FuseErrnoException(ENOENT)); +Action 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) { diff --git a/test/fspp/testutils/FuseTest.h b/test/fspp/testutils/FuseTest.h index 1cd80950..b0261f51 100644 --- a/test/fspp/testutils/FuseTest.h +++ b/test/fspp/testutils/FuseTest.h @@ -15,71 +15,35 @@ #include #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> readDir(const boost::filesystem::path &path) override { - return cpputils::nullcheck(std::unique_ptr>(readDir(path.string().c_str()))).value(); - } - MOCK_METHOD1(readDir, std::vector*(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, 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 ReturnIsFile; - static ::testing::Action ReturnIsFileWithSize(fspp::num_bytes_t size); + static ::testing::Action ReturnIsFile; + static ::testing::Action ReturnIsFileWithSize(fspp::num_bytes_t size); static ::testing::Action ReturnIsFileFstat; static ::testing::Action ReturnIsFileFstatWithSize(fspp::num_bytes_t size); - static ::testing::Action ReturnIsDir; - static ::testing::Action ReturnDoesntExist; + static ::testing::Action ReturnIsDir; + static ::testing::Action ReturnDoesntExist; void ReturnIsFileOnLstat(const boost::filesystem::path &path); void ReturnIsFileOnLstatWithSize(const boost::filesystem::path &path, fspp::num_bytes_t size); diff --git a/vendor/googletest/CMakeLists.txt b/vendor/googletest/CMakeLists.txt index f5835f5e..223ff45f 100644 --- a/vendor/googletest/CMakeLists.txt +++ b/vendor/googletest/CMakeLists.txt @@ -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()