Fix clang-tidy warnings

This commit is contained in:
Sebastian Messmer 2021-04-20 23:09:00 -07:00
parent f4945fcfbe
commit 68a4c5646a
79 changed files with 218 additions and 242 deletions

View File

@ -29,6 +29,7 @@ Checks: |
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-avoid-non-const-global-variables,
-clang-analyzer-optin.cplusplus.VirtualCall,
-clang-analyzer-cplusplus.NewDeleteLeaks,
-misc-macro-parentheses,

View File

@ -104,6 +104,7 @@ void DataNodeStore::removeSubtree(unique_ref<DataNode> node) {
remove(std::move(*inner));
}
// NOLINTNEXTLINE(misc-no-recursion)
void DataNodeStore::removeSubtree(uint8_t depth, const BlockId &blockId) {
if (depth == 0) {
remove(blockId);

View File

@ -101,6 +101,7 @@ uint32_t DataTree::forceComputeNumLeaves() const {
return numLeaves();
}
// NOLINTNEXTLINE(misc-no-recursion)
DataTree::SizeCache DataTree::_computeSizeCache(const DataNode &node) const {
const DataLeafNode *leaf = dynamic_cast<const DataLeafNode*>(&node);
if (leaf != nullptr) {

View File

@ -28,6 +28,7 @@ namespace blobstore {
_traverseAndUpdateRoot(root, beginIndex, endIndex, true, onExistingLeaf, onCreateLeaf, onBacktrackFromSubtree);
}
// NOLINTNEXTLINE(misc-no-recursion)
void LeafTraverser::_traverseAndUpdateRoot(unique_ref<DataNode>* root, uint32_t beginIndex, uint32_t endIndex, bool isLeftBorderOfTraversal, function<void (uint32_t index, bool isRightBorderLeaf, LeafHandle leaf)> onExistingLeaf, function<Data (uint32_t index)> onCreateLeaf, function<void (DataInnerNode *node)> onBacktrackFromSubtree) {
ASSERT(beginIndex <= endIndex, "Invalid parameters");
@ -83,6 +84,7 @@ namespace blobstore {
return DataNode::convertToNewInnerNode(std::move(root), _nodeStore->layout(), *copyOfOldRoot);
}
// NOLINTNEXTLINE(misc-no-recursion)
void LeafTraverser::_traverseExistingSubtree(const blockstore::BlockId &blockId, uint8_t depth, uint32_t beginIndex, uint32_t endIndex, uint32_t leafOffset, bool isLeftBorderOfTraversal, bool isRightBorderNode, bool growLastLeaf, function<void (uint32_t index, bool isRightBorderLeaf, LeafHandle leaf)> onExistingLeaf, function<Data (uint32_t index)> onCreateLeaf, function<void (DataInnerNode *node)> onBacktrackFromSubtree) {
if (depth == 0) {
ASSERT(beginIndex <= 1 && endIndex <= 1,
@ -111,6 +113,7 @@ namespace blobstore {
}
}
// NOLINTNEXTLINE(misc-no-recursion)
void LeafTraverser::_traverseExistingSubtree(DataInnerNode *root, uint32_t beginIndex, uint32_t endIndex, uint32_t leafOffset, bool isLeftBorderOfTraversal, bool isRightBorderNode, bool growLastLeaf, function<void (uint32_t index, bool isRightBorderLeaf, LeafHandle leaf)> onExistingLeaf, function<Data (uint32_t index)> onCreateLeaf, function<void (DataInnerNode *node)> onBacktrackFromSubtree) {
ASSERT(beginIndex <= endIndex, "Invalid parameters");
@ -169,6 +172,7 @@ namespace blobstore {
}
}
// NOLINTNEXTLINE(misc-no-recursion)
unique_ref<DataNode> LeafTraverser::_createNewSubtree(uint32_t beginIndex, uint32_t endIndex, uint32_t leafOffset, uint8_t depth, function<Data (uint32_t index)> onCreateLeaf, function<void (DataInnerNode *node)> onBacktrackFromSubtree) {
ASSERT(!_readOnlyTraversal, "Can't create a new subtree in a read-only traversal");
@ -242,6 +246,7 @@ namespace blobstore {
}
}
// NOLINTNEXTLINE(misc-no-recursion)
unique_ref<DataNode> LeafTraverser::_whileRootHasOnlyOneChildRemoveRootReturnChild(const blockstore::BlockId &blockId) {
ASSERT(!_readOnlyTraversal, "Can't decrease tree depth in a read-only traversal");

View File

@ -80,11 +80,11 @@ public:
private:
class Entry final {
public:
Entry(Entry *prev_, Entry *next_): prev(prev_), next(next_), key(nullptr), __value() {
Entry(Entry *prev_, Entry *next_): prev(prev_), next(next_), key(nullptr), _value_() {
}
void init(const Key *key_, Value value_) {
key = key_;
new(__value.data()) Value(std::move(value_));
new(_value_.data()) Value(std::move(value_));
}
Value release() {
Value value = std::move(*_value());
@ -99,9 +99,9 @@ private:
const Key *key;
private:
Value *_value() {
return reinterpret_cast<Value*>(__value.data());
return reinterpret_cast<Value*>(_value_.data());
}
alignas(Value) std::array<char, sizeof(Value)> __value;
alignas(Value) std::array<char, sizeof(Value)> _value_;
DISALLOW_COPY_AND_ASSIGN(Entry);
};

View File

@ -29,7 +29,7 @@ public:
void forEachBlock(std::function<void (const BlockId &)> callback) const override;
//This function should only be used by test cases
void __setKey(const typename Cipher::EncryptionKey &encKey);
void _setKey(const typename Cipher::EncryptionKey &encKey);
private:
@ -188,7 +188,7 @@ uint16_t EncryptedBlockStore2<Cipher>::_readFormatHeader(const cpputils::Data &d
}
template<class Cipher>
void EncryptedBlockStore2<Cipher>::__setKey(const typename Cipher::EncryptionKey &encKey) {
void EncryptedBlockStore2<Cipher>::_setKey(const typename Cipher::EncryptionKey &encKey) {
_encKey = encKey;
}

View File

@ -31,12 +31,12 @@ public:
virtual void store(const BlockId &blockId, const cpputils::Data &data) = 0;
BlockId create(const cpputils::Data& data) {
BlockId blockId = createBlockId();
bool success = tryCreate(blockId, data);
if (success) {
return blockId;
} else {
return create(data);
while (true) {
BlockId blockId = createBlockId();
bool success = tryCreate(blockId, data);
if (success) {
return blockId;
}
}
}

View File

@ -6,9 +6,9 @@
namespace blockstore {
struct _BlockIdTag final {};
struct BlockIdTag final {};
// TODO Split from a BlobId (i.e. IdWrapper<BlobIdTag>)
using BlockId = IdWrapper<_BlockIdTag>;
using BlockId = IdWrapper<BlockIdTag>;
}

View File

@ -7,7 +7,7 @@ using cpputils::Data;
namespace cpputils {
Data SCryptParameters::serialize() const {
Serializer serializer(_serializedSize());
serializer.writeUint64(_N);
serializer.writeUint64(_n);
serializer.writeUint32(_r);
serializer.writeUint32(_p);
serializer.writeTailData(_salt);
@ -20,21 +20,21 @@ namespace cpputils {
SCryptParameters SCryptParameters::deserialize(const cpputils::Data &data) {
Deserializer deserializer(&data);
uint64_t N = deserializer.readUint64();
uint64_t n = deserializer.readUint64();
uint32_t r = deserializer.readUint32();
uint32_t p = deserializer.readUint32();
Data salt = deserializer.readTailData();
deserializer.finished();
return SCryptParameters(std::move(salt), N, r, p);
return SCryptParameters(std::move(salt), n, r, p);
}
#ifndef CRYFS_NO_COMPATIBILITY
SCryptParameters SCryptParameters::deserializeOldFormat(Deserializer *source) {
uint64_t N = source->readUint64();
uint64_t n = source->readUint64();
uint32_t r = source->readUint32();
uint32_t p = source->readUint32();
Data salt = source->readData();
return SCryptParameters(std::move(salt), N, r, p);
return SCryptParameters(std::move(salt), n, r, p);
}
#endif
}

View File

@ -15,13 +15,13 @@ namespace cpputils {
class SCryptParameters final {
public:
SCryptParameters(Data salt, uint64_t N, uint32_t r, uint32_t p)
SCryptParameters(Data salt, uint64_t n, uint32_t r, uint32_t p)
: _salt(std::move(salt)),
_N(N), _r(r), _p(p) { }
_n(n), _r(r), _p(p) { }
SCryptParameters(const SCryptParameters &rhs)
:_salt(rhs._salt.copy()),
_N(rhs._N), _r(rhs._r), _p(rhs._p) { }
_n(rhs._n), _r(rhs._r), _p(rhs._p) { }
SCryptParameters(SCryptParameters &&rhs) = default;
@ -31,7 +31,7 @@ namespace cpputils {
}
_salt = rhs._salt.copy();
_N = rhs._N;
_n = rhs._n;
_r = rhs._r;
_p = rhs._p;
return *this;
@ -43,8 +43,8 @@ namespace cpputils {
return _salt;
}
size_t N() const {
return _N;
size_t n() const {
return _n;
}
size_t r() const {
@ -69,13 +69,13 @@ namespace cpputils {
size_t _serializedSize() const;
Data _salt;
uint64_t _N;
uint64_t _n;
uint32_t _r;
uint32_t _p;
};
inline bool operator==(const SCryptParameters &lhs, const SCryptParameters &rhs) {
return lhs.salt() == rhs.salt() && lhs.N() == rhs.N() && lhs.r() == rhs.r() && lhs.p() == rhs.p();
return lhs.salt() == rhs.salt() && lhs.n() == rhs.n() && lhs.r() == rhs.r() && lhs.p() == rhs.p();
}
inline bool operator!=(const SCryptParameters &lhs, const SCryptParameters &rhs) {

View File

@ -17,7 +17,7 @@ EncryptionKey _derive(size_t keySize, const std::string& password, const SCryptP
static_cast<uint8_t*>(result.data()), result.binaryLength(),
reinterpret_cast<const uint8_t*>(password.c_str()), password.size(),
static_cast<const uint8_t*>(kdfParameters.salt().data()), kdfParameters.salt().size(),
kdfParameters.N(), kdfParameters.r(), kdfParameters.p()
kdfParameters.n(), kdfParameters.r(), kdfParameters.p()
);
if (status != 1) {
throw std::runtime_error("Error running scrypt key derivation. Error code: "+std::to_string(status));

View File

@ -10,12 +10,12 @@
namespace cpputils {
template<class CryptoPPCipher, unsigned int _KEY_SIZE, unsigned int _IV_SIZE, unsigned int _TAG_SIZE>
template<class CryptoPPCipher, unsigned int KEYSIZE_, unsigned int IV_SIZE_, unsigned int TAG_SIZE_>
class AEADCipher {
public:
using EncryptionKey = cpputils::EncryptionKey;
static constexpr unsigned int KEYSIZE = _KEY_SIZE;
static constexpr unsigned int KEYSIZE = KEYSIZE_;
static constexpr unsigned int STRING_KEYSIZE = 2 * KEYSIZE;
static constexpr unsigned int ciphertextSize(unsigned int plaintextBlockSize) {
@ -30,17 +30,17 @@ public:
static boost::optional<Data> decrypt(const CryptoPP::byte *ciphertext, unsigned int ciphertextSize, const EncryptionKey &encKey);
private:
static constexpr unsigned int IV_SIZE = _IV_SIZE;
static constexpr unsigned int TAG_SIZE = _TAG_SIZE;
static constexpr unsigned int IV_SIZE = IV_SIZE_;
static constexpr unsigned int TAG_SIZE = TAG_SIZE_;
};
template<class CryptoPPCipher, unsigned int _KEY_SIZE, unsigned int _IV_SIZE, unsigned int _TAG_SIZE>
constexpr unsigned int AEADCipher<CryptoPPCipher, _KEY_SIZE, _IV_SIZE, _TAG_SIZE>::KEYSIZE;
template<class CryptoPPCipher, unsigned int _KEY_SIZE, unsigned int _IV_SIZE, unsigned int _TAG_SIZE>
constexpr unsigned int AEADCipher<CryptoPPCipher, _KEY_SIZE, _IV_SIZE, _TAG_SIZE>::STRING_KEYSIZE;
template<class CryptoPPCipher, unsigned int KEYSIZE_, unsigned int IV_SIZE_, unsigned int TAG_SIZE_>
constexpr unsigned int AEADCipher<CryptoPPCipher, KEYSIZE_, IV_SIZE_, TAG_SIZE_>::KEYSIZE;
template<class CryptoPPCipher, unsigned int KEYSIZE_, unsigned int IV_SIZE_, unsigned int TAG_SIZE_>
constexpr unsigned int AEADCipher<CryptoPPCipher, KEYSIZE_, IV_SIZE_, TAG_SIZE_>::STRING_KEYSIZE;
template<class CryptoPPCipher, unsigned int _KEY_SIZE, unsigned int _IV_SIZE, unsigned int _TAG_SIZE>
Data AEADCipher<CryptoPPCipher, _KEY_SIZE, _IV_SIZE, _TAG_SIZE>::encrypt(const CryptoPP::byte *plaintext, unsigned int plaintextSize, const EncryptionKey &encKey) {
template<class CryptoPPCipher, unsigned int KEYSIZE_, unsigned int IV_SIZE_, unsigned int TAG_SIZE_>
Data AEADCipher<CryptoPPCipher, KEYSIZE_, IV_SIZE_, TAG_SIZE_>::encrypt(const CryptoPP::byte *plaintext, unsigned int plaintextSize, const EncryptionKey &encKey) {
ASSERT(encKey.binaryLength() == AEADCipher::KEYSIZE, "Wrong key size");
FixedSizeData<IV_SIZE> iv = Random::PseudoRandom().getFixedSize<IV_SIZE>();
@ -58,8 +58,8 @@ Data AEADCipher<CryptoPPCipher, _KEY_SIZE, _IV_SIZE, _TAG_SIZE>::encrypt(const C
return ciphertext;
}
template<class CryptoPPCipher, unsigned int _KEY_SIZE, unsigned int _IV_SIZE, unsigned int _TAG_SIZE>
boost::optional<Data> AEADCipher<CryptoPPCipher, _KEY_SIZE, _IV_SIZE, _TAG_SIZE>::decrypt(const CryptoPP::byte *ciphertext, unsigned int ciphertextSize, const EncryptionKey &encKey) {
template<class CryptoPPCipher, unsigned int KEYSIZE_, unsigned int IV_SIZE_, unsigned int TAG_SIZE_>
boost::optional<Data> AEADCipher<CryptoPPCipher, KEYSIZE_, IV_SIZE_, TAG_SIZE_>::decrypt(const CryptoPP::byte *ciphertext, unsigned int ciphertextSize, const EncryptionKey &encKey) {
ASSERT(encKey.binaryLength() == AEADCipher::KEYSIZE, "Wrong key size");
if (ciphertextSize < IV_SIZE + TAG_SIZE) {

View File

@ -36,7 +36,7 @@ public:
private:
FixedSizeData(): _data() {}
template<size_t _SIZE> friend class FixedSizeData;
template<size_t SIZE_> friend class FixedSizeData;
std::array<unsigned char, BINARY_LENGTH> _data;
};

View File

@ -8,23 +8,23 @@
namespace cpputils {
namespace details {
class _DontEchoStdinToStdoutRAII final {
class DontEchoStdinToStdoutRAII final {
public:
_DontEchoStdinToStdoutRAII() : _old_state() {
DontEchoStdinToStdoutRAII() : _old_state() {
tcgetattr(STDIN_FILENO, &_old_state);
termios new_state = _old_state;
new_state.c_lflag &= ~ECHO;
tcsetattr(STDIN_FILENO, TCSANOW, &new_state);
}
~_DontEchoStdinToStdoutRAII() {
~DontEchoStdinToStdoutRAII() {
tcsetattr(STDIN_FILENO, TCSANOW, &_old_state);
}
private:
termios _old_state;
DISALLOW_COPY_AND_ASSIGN(_DontEchoStdinToStdoutRAII);
DISALLOW_COPY_AND_ASSIGN(DontEchoStdinToStdoutRAII);
};
}
@ -66,7 +66,7 @@ using cpputils::make_unique_ref;
namespace cpputils {
DontEchoStdinToStdoutRAII::DontEchoStdinToStdoutRAII()
: raii(make_unique_ref<details::_DontEchoStdinToStdoutRAII>()) {}
: raii(make_unique_ref<details::DontEchoStdinToStdoutRAII>()) {}
DontEchoStdinToStdoutRAII::~DontEchoStdinToStdoutRAII() {}

View File

@ -14,7 +14,7 @@
namespace cpputils {
namespace details {
class _DontEchoStdinToStdoutRAII;
class DontEchoStdinToStdoutRAII;
}
class DontEchoStdinToStdoutRAII final {
@ -22,7 +22,7 @@ public:
DontEchoStdinToStdoutRAII();
~DontEchoStdinToStdoutRAII();
private:
cpputils::unique_ref<details::_DontEchoStdinToStdoutRAII> raii;
cpputils::unique_ref<details::DontEchoStdinToStdoutRAII> raii;
DISALLOW_COPY_AND_ASSIGN(DontEchoStdinToStdoutRAII);
};

View File

@ -54,7 +54,8 @@ boost::optional<unique_ref<FsBlob>> FsBlobStore::load(const blockstore::BlockId
return fsBlobStore;
}
// NOLINTNEXTLINE(misc-no-recursion)
void FsBlobStore::_migrate(unique_ref<blobstore::Blob> node, const blockstore::BlockId &parentId, SignalCatcher* signalCatcher, std::function<void(uint32_t numNodes)> perBlobCallback) {
FsBlobView::migrate(node.get(), parentId);
perBlobCallback(node->numNodes());

View File

@ -102,7 +102,7 @@ private:
size_t _numBlocks;
};
std::vector<BlockId> _getKnownBlobIds(const path& basedir, const CryConfigLoader::ConfigLoadResult& config, LocalStateDir& localStateDir) {
std::vector<BlockId> getKnownBlobIds(const path& basedir, const CryConfigLoader::ConfigLoadResult& config, LocalStateDir& localStateDir) {
auto blockStore = makeBlockStore(basedir, config, localStateDir);
auto fsBlobStore = make_unique_ref<FsBlobStore>(make_unique_ref<BlobStoreOnBlocks>(std::move(blockStore), config.configFile->config()->BlocksizeBytes()));
@ -116,8 +116,8 @@ std::vector<BlockId> _getKnownBlobIds(const path& basedir, const CryConfigLoader
return knownBlobIds.blockIds();
}
std::vector<BlockId> _getKnownBlockIds(const path& basedir, const CryConfigLoader::ConfigLoadResult& config, LocalStateDir& localStateDir) {
auto knownBlobIds = _getKnownBlobIds(basedir, config, localStateDir);
std::vector<BlockId> getKnownBlockIds(const path& basedir, const CryConfigLoader::ConfigLoadResult& config, LocalStateDir& localStateDir) {
auto knownBlobIds = getKnownBlobIds(basedir, config, localStateDir);
auto blockStore = makeBlockStore(basedir, config, localStateDir);
auto nodeStore = make_unique_ref<DataNodeStore>(std::move(blockStore), config.configFile->config()->BlocksizeBytes());
@ -135,7 +135,7 @@ std::vector<BlockId> _getKnownBlockIds(const path& basedir, const CryConfigLoade
return knownBlockIds.blockIds();
}
set<BlockId> _getAllBlockIds(const path& basedir, const CryConfigLoader::ConfigLoadResult& config, LocalStateDir& localStateDir) {
set<BlockId> getAllBlockIds(const path& basedir, const CryConfigLoader::ConfigLoadResult& config, LocalStateDir& localStateDir) {
auto blockStore = makeBlockStore(basedir, config, localStateDir);
AccumulateBlockIds allBlockIds;
allBlockIds.reserve(blockStore->numBlocks());
@ -218,10 +218,10 @@ int main(int argc, char* argv[]) {
}
cout << "Listing all blocks..." << flush;
set<BlockId> unaccountedBlocks = _getAllBlockIds(basedir, config.right(), localStateDir);
set<BlockId> unaccountedBlocks = getAllBlockIds(basedir, config.right(), localStateDir);
cout << "done" << endl;
vector<BlockId> accountedBlocks = _getKnownBlockIds(basedir, config.right(), localStateDir);
vector<BlockId> accountedBlocks = getKnownBlockIds(basedir, config.right(), localStateDir);
for (const BlockId& blockId : accountedBlocks) {
auto num_erased = unaccountedBlocks.erase(blockId);
ASSERT(1 == num_erased, "Blob id referenced by directory entry but didn't found it on disk? This can't happen.");

View File

@ -24,6 +24,7 @@ void forEachBlock(BlockStore* blockStore, const vector<function<void (const Bloc
});
}
// NOLINTNEXTLINE(misc-no-recursion)
void forEachReachableBlob(FsBlobStore* blobStore, const BlockId& rootId, const vector<function<void (const BlockId& blobId)>>& callbacks) {
for (const auto& callback : callbacks) {
callback(rootId);
@ -47,6 +48,7 @@ void forEachReachableBlob(FsBlobStore* blobStore, const BlockId& rootId, const v
}
}
// NOLINTNEXTLINE(misc-no-recursion)
void forEachReachableBlockInBlob(DataNodeStore* nodeStore, const BlockId& rootId, const vector<function<void (const BlockId& blockId)>>& callbacks) {
for (const auto& callback : callbacks) {
callback(rootId);

View File

@ -64,6 +64,7 @@ public:
return CreateTree(CreateFourLevelMinDataWithLastLeafSize(size));
}
// NOLINTNEXTLINE(misc-no-recursion)
void EXPECT_IS_LEFTMAXDATA_TREE(const BlockId &blockId) {
auto root = nodeStore->load(blockId).value();
DataInnerNode *inner = dynamic_cast<DataInnerNode*>(root.get());
@ -75,6 +76,7 @@ public:
}
}
// NOLINTNEXTLINE(misc-no-recursion)
void EXPECT_IS_MAXDATA_TREE(const BlockId &blockId) {
auto root = nodeStore->load(blockId).value();
DataInnerNode *inner = dynamic_cast<DataInnerNode*>(root.get());
@ -118,6 +120,7 @@ public:
tree->flush();
}
// NOLINTNEXTLINE(misc-no-recursion)
unique_ref<DataLeafNode> LastLeaf(const BlockId &blockId) {
auto root = nodeStore->load(blockId).value();
auto leaf = dynamic_pointer_move<DataLeafNode>(root);

View File

@ -64,6 +64,7 @@ public:
return CreateTree(CreateFourLevelMinDataWithLastLeafSize(size));
}
// NOLINTNEXTLINE(misc-no-recursion)
void EXPECT_IS_LEFTMAXDATA_TREE(const BlockId &blockId) {
auto root = nodeStore->load(blockId).value();
DataInnerNode *inner = dynamic_cast<DataInnerNode*>(root.get());
@ -75,6 +76,7 @@ public:
}
}
// NOLINTNEXTLINE(misc-no-recursion)
void EXPECT_IS_MAXDATA_TREE(const BlockId &blockId) {
auto root = nodeStore->load(blockId).value();
DataInnerNode *inner = dynamic_cast<DataInnerNode*>(root.get());
@ -107,6 +109,7 @@ public:
treeStore.load(blockId).get()->resizeNumBytes(size);
}
// NOLINTNEXTLINE(misc-no-recursion)
unique_ref<DataLeafNode> LastLeaf(const BlockId &blockId) {
auto root = nodeStore->load(blockId).value();
auto leaf = dynamic_pointer_move<DataLeafNode>(root);

View File

@ -2,7 +2,6 @@
#include <blobstore/implementations/onblocks/datatreestore/impl/LeafTraverser.h>
#include <gmock/gmock.h>
using ::testing::_;
using ::testing::Invoke;
using ::testing::Eq;
@ -68,8 +67,8 @@ public:
}
void EXPECT_DONT_TRAVERSE_ANY_LEAVES() {
EXPECT_CALL(traversor, calledExistingLeaf(_, _, _)).Times(0);
EXPECT_CALL(traversor, calledCreateLeaf(_)).Times(0);
EXPECT_CALL(traversor, calledExistingLeaf(testing::_, testing::_, testing::_)).Times(0);
EXPECT_CALL(traversor, calledCreateLeaf(testing::_)).Times(0);
}
void TraverseLeaves(unique_ref<DataNode> root, uint32_t beginIndex, uint32_t endIndex, bool expectReadOnly) {

View File

@ -228,6 +228,7 @@ void DataTreeTest::EXPECT_IS_FULL_THREELEVEL_TREE(const BlockId &blockId) {
}
}
// NOLINTNEXTLINE(misc-no-recursion)
void DataTreeTest::CHECK_DEPTH(int depth, const BlockId &blockId) {
if (depth == 0) {
EXPECT_IS_LEAF_NODE(blockId);

View File

@ -39,6 +39,7 @@ public:
}
private:
// NOLINTNEXTLINE(misc-no-recursion)
int ForEachLeaf(blobstore::onblocks::datanodestore::DataNode *node, int firstLeafIndex, int endLeafIndex, std::function<void (blobstore::onblocks::datanodestore::DataLeafNode*, int)> action) {
if (firstLeafIndex == endLeafIndex) {
return firstLeafIndex;

View File

@ -78,14 +78,14 @@ TEST_F(EncryptedBlockStoreTest, LoadingWithSameKeyWorks_WriteSeparately) {
TEST_F(EncryptedBlockStoreTest, LoadingWithDifferentKeyDoesntWork_WriteOnCreate) {
auto blockId = CreateBlockDirectlyWithFixtureAndReturnKey();
blockStore->__setKey(FakeAuthenticatedCipher::Key2());
blockStore->_setKey(FakeAuthenticatedCipher::Key2());
auto loaded = blockStore->load(blockId);
EXPECT_EQ(boost::none, loaded);
}
TEST_F(EncryptedBlockStoreTest, LoadingWithDifferentKeyDoesntWork_WriteSeparately) {
auto blockId = CreateBlockWriteFixtureToItAndReturnKey();
blockStore->__setKey(FakeAuthenticatedCipher::Key2());
blockStore->_setKey(FakeAuthenticatedCipher::Key2());
auto loaded = blockStore->load(blockId);
EXPECT_EQ(boost::none, loaded);
}

View File

@ -4,7 +4,6 @@
#include <cpp-utils/data/DataFixture.h>
using ::testing::Test;
using ::testing::_;
using ::testing::Return;
using ::testing::Invoke;
using ::testing::Eq;
@ -60,28 +59,28 @@ public:
TEST_F(BlockStore2Test, DataIsPassedThrough0) {
Data data = createDataWithSize(0);
EXPECT_CALL(blockStoreMock, createBlockId()).WillOnce(Return(blockId1));
EXPECT_CALL(blockStoreMock, tryCreate(_, Eq(ByRef(data)))).WillOnce(Return(true));
EXPECT_CALL(blockStoreMock, tryCreate(testing::_, Eq(ByRef(data)))).WillOnce(Return(true));
EXPECT_EQ(blockId1, blockStore.create(data));
}
TEST_F(BlockStore2Test, DataIsPassedThrough1) {
Data data = createDataWithSize(1);
EXPECT_CALL(blockStoreMock, createBlockId()).WillOnce(Return(blockId1));
EXPECT_CALL(blockStoreMock, tryCreate(_, Eq(ByRef(data)))).WillOnce(Return(true));
EXPECT_CALL(blockStoreMock, tryCreate(testing::_, Eq(ByRef(data)))).WillOnce(Return(true));
EXPECT_EQ(blockId1, blockStore.create(data));
}
TEST_F(BlockStore2Test, DataIsPassedThrough1024) {
Data data = createDataWithSize(1024);
EXPECT_CALL(blockStoreMock, createBlockId()).WillOnce(Return(blockId1));
EXPECT_CALL(blockStoreMock, tryCreate(_, Eq(ByRef(data)))).WillOnce(Return(true));
EXPECT_CALL(blockStoreMock, tryCreate(testing::_, Eq(ByRef(data)))).WillOnce(Return(true));
EXPECT_EQ(blockId1, blockStore.create(data));
}
TEST_F(BlockStore2Test, BlockIdIsCorrect) {
Data data = createDataWithSize(1024);
EXPECT_CALL(blockStoreMock, createBlockId()).WillOnce(Return(blockId1));
EXPECT_CALL(blockStoreMock, tryCreate(blockId1, _)).WillOnce(Return(true));
EXPECT_CALL(blockStoreMock, tryCreate(blockId1, testing::_)).WillOnce(Return(true));
EXPECT_EQ(blockId1, blockStore.create(data));
}
@ -89,7 +88,7 @@ TEST_F(BlockStore2Test, TwoBlocksGetDifferentIds) {
EXPECT_CALL(blockStoreMock, createBlockId())
.WillOnce(Return(blockId1))
.WillOnce(Return(blockId2));
EXPECT_CALL(blockStoreMock, tryCreate(_, _))
EXPECT_CALL(blockStoreMock, tryCreate(testing::_, testing::_))
.WillOnce(Invoke([this](const BlockId &blockId, const Data &) {
EXPECT_EQ(blockId1, blockId);
return true;
@ -109,7 +108,7 @@ TEST_F(BlockStore2Test, WillTryADifferentIdIfKeyAlreadyExists) {
EXPECT_CALL(blockStoreMock, createBlockId())
.WillOnce(Return(blockId1))
.WillOnce(Return(blockId2));
EXPECT_CALL(blockStoreMock, tryCreate(_, Eq(ByRef(data))))
EXPECT_CALL(blockStoreMock, tryCreate(testing::_, Eq(ByRef(data))))
.WillOnce(Invoke([this](const BlockId &blockId, const Data &) {
EXPECT_EQ(blockId1, blockId);
return false;
@ -128,7 +127,7 @@ TEST_F(BlockStore2Test, WillTryADifferentIdIfIdAlreadyExistsTwoTimes) {
.WillOnce(Return(blockId1))
.WillOnce(Return(blockId2))
.WillOnce(Return(blockId3));
EXPECT_CALL(blockStoreMock, tryCreate(_, Eq(ByRef(data))))
EXPECT_CALL(blockStoreMock, tryCreate(testing::_, Eq(ByRef(data))))
.WillOnce(Invoke([this](const BlockId &blockId, const Data &) {
EXPECT_EQ(blockId1, blockId);
return false;

View File

@ -5,7 +5,6 @@
#include <cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround.h>
using ::testing::Test;
using ::testing::_;
using ::testing::Return;
using ::testing::Invoke;
using ::testing::Eq;
@ -74,28 +73,28 @@ const Action<optional<unique_ref<Block>>(const BlockId &, cpputils::Data)> Retur
TEST_F(BlockStoreTest, DataIsPassedThrough0) {
Data data = createDataWithSize(0);
EXPECT_CALL(blockStoreMock, createBlockId()).WillOnce(Return(blockId1));
EXPECT_CALL(blockStoreMock, tryCreate(_, Eq(ByRef(data)))).WillOnce(ReturnNewBlockMock);
EXPECT_CALL(blockStoreMock, tryCreate(testing::_, 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, tryCreate(_, Eq(ByRef(data)))).WillOnce(ReturnNewBlockMock);
EXPECT_CALL(blockStoreMock, tryCreate(testing::_, 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, tryCreate(_, Eq(ByRef(data)))).WillOnce(ReturnNewBlockMock);
EXPECT_CALL(blockStoreMock, tryCreate(testing::_, 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, tryCreate(blockId1, _)).WillOnce(ReturnNewBlockMock);
EXPECT_CALL(blockStoreMock, tryCreate(blockId1, testing::_)).WillOnce(ReturnNewBlockMock);
blockStore.create(data);
}
@ -103,7 +102,7 @@ TEST_F(BlockStoreTest, TwoBlocksGetDifferentIds) {
EXPECT_CALL(blockStoreMock, createBlockId())
.WillOnce(Return(blockId1))
.WillOnce(Return(blockId2));
EXPECT_CALL(blockStoreMock, tryCreate(_, _))
EXPECT_CALL(blockStoreMock, tryCreate(testing::_, testing::_))
.WillOnce(Invoke([this](const BlockId &blockId, Data) {
EXPECT_EQ(blockId1, blockId);
return optional<unique_ref<Block>>(unique_ref<Block>(make_unique_ref<BlockMock>()));
@ -123,7 +122,7 @@ TEST_F(BlockStoreTest, WillTryADifferentIdIfKeyAlreadyExists) {
EXPECT_CALL(blockStoreMock, createBlockId())
.WillOnce(Return(blockId1))
.WillOnce(Return(blockId2));
EXPECT_CALL(blockStoreMock, tryCreate(_, Eq(ByRef(data))))
EXPECT_CALL(blockStoreMock, tryCreate(testing::_, Eq(ByRef(data))))
.WillOnce(Invoke([this](const BlockId &blockId, Data ) {
EXPECT_EQ(blockId1, blockId);
return boost::none;
@ -142,7 +141,7 @@ TEST_F(BlockStoreTest, WillTryADifferentIdIfIdAlreadyExistsTwoTimes) {
.WillOnce(Return(blockId1))
.WillOnce(Return(blockId2))
.WillOnce(Return(blockId3));
EXPECT_CALL(blockStoreMock, tryCreate(_, Eq(ByRef(data))))
EXPECT_CALL(blockStoreMock, tryCreate(testing::_, Eq(ByRef(data))))
.WillOnce(Invoke([this](const BlockId &blockId, Data) {
EXPECT_EQ(blockId1, blockId);
return boost::none;

View File

@ -2,7 +2,7 @@
#include <gmock/gmock.h>
#ifdef NDEBUG
#define _REAL_NDEBUG
#define REAL_NDEBUG_
#endif
//Include the ASSERT macro for a debug build
@ -41,7 +41,7 @@ TEST(AssertTest_DebugBuild, AssertMessage) {
);
}
#if !(defined(_MSC_VER) && defined(_REAL_NDEBUG))
#if !(defined(_MSC_VER) && defined(REAL_NDEBUG_))
TEST(AssertTest_DebugBuild, AssertMessageContainsBacktrace) {
EXPECT_DEATH(
ASSERT(2==5, "my message"),

View File

@ -3,7 +3,7 @@
#include <regex>
#ifdef NDEBUG
#define _REAL_NDEBUG
#define REAL_NDEBUG_
#endif
//Include the ASSERT macro for a release build
@ -39,7 +39,7 @@ TEST(AssertTest_ReleaseBuild, AssertMessage) {
}
}
#if !(defined(_MSC_VER) && defined(_REAL_NDEBUG))
#if !(defined(_MSC_VER) && defined(REAL_NDEBUG_))
TEST(AssertTest_ReleaseBuild, AssertMessageContainsBacktrace) {
try {
ASSERT(2==5, "my message");

View File

@ -32,19 +32,19 @@ TEST_F(SCryptParametersTest, Salt_SaveAndLoad) {
TEST_F(SCryptParametersTest, N) {
SCryptParameters cfg(Data(0), 1024, 0, 0);
EXPECT_EQ(1024u, cfg.N());
EXPECT_EQ(1024u, cfg.n());
}
TEST_F(SCryptParametersTest, N_Move) {
SCryptParameters cfg(Data(0), 1024, 0, 0);
SCryptParameters moved = std::move(cfg);
EXPECT_EQ(1024u, moved.N());
EXPECT_EQ(1024u, moved.n());
}
TEST_F(SCryptParametersTest, N_SaveAndLoad) {
SCryptParameters cfg(Data(0), 1024, 0, 0);
SCryptParameters loaded = SaveAndLoad(cfg);
EXPECT_EQ(1024u, loaded.N());
EXPECT_EQ(1024u, loaded.n());
}
TEST_F(SCryptParametersTest, r) {

View File

@ -52,7 +52,7 @@ TEST_F(SCryptTest, UsesCorrectSettings) {
auto derivedKey = scrypt.deriveNewKey(16, "mypassword");
auto parameters = SCryptParameters::deserialize(derivedKey.kdfParameters);
EXPECT_EQ(SCrypt::TestSettings.SALT_LEN, parameters.salt().size());
EXPECT_EQ(SCrypt::TestSettings.N, parameters.N());
EXPECT_EQ(SCrypt::TestSettings.N, parameters.n());
EXPECT_EQ(SCrypt::TestSettings.r, parameters.r());
EXPECT_EQ(SCrypt::TestSettings.p, parameters.p());
}
@ -62,7 +62,7 @@ TEST_F(SCryptTest, UsesCorrectDefaultSettings) {
auto derivedKey = scrypt.deriveNewKey(16, "mypassword");
auto parameters = SCryptParameters::deserialize(derivedKey.kdfParameters);
EXPECT_EQ(SCrypt::DefaultSettings.SALT_LEN, parameters.salt().size());
EXPECT_EQ(SCrypt::DefaultSettings.N, parameters.N());
EXPECT_EQ(SCrypt::DefaultSettings.N, parameters.n());
EXPECT_EQ(SCrypt::DefaultSettings.r, parameters.r());
EXPECT_EQ(SCrypt::DefaultSettings.p, parameters.p());
}

View File

@ -10,7 +10,6 @@ using ::testing::Test;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Return;
using ::testing::_;
using cpputils::TempFile;
@ -276,7 +275,7 @@ TEST_F(DataTestWithMockAllocator, whenMoveAssigning_thenOnlyFreesOnce) {
TEST_F(DataTestWithMockAllocator, whenMoveConstructing_thenOnlyFreesWhenSecondIsDestructed) {
EXPECT_CALL(*allocator, allocate(5)).Times(1).WillOnce(Return(&ptr_target));
EXPECT_CALL(*allocator_ptr, free(_, _)).Times(0);
EXPECT_CALL(*allocator_ptr, free(testing::_, testing::_)).Times(0);
auto data = std::make_unique<Data>(5, std::move(allocator));
Data data2 = std::move(*data);
@ -287,7 +286,7 @@ TEST_F(DataTestWithMockAllocator, whenMoveConstructing_thenOnlyFreesWhenSecondIs
TEST_F(DataTestWithMockAllocator, whenMoveAssigning_thenOnlyFreesWhenSecondIsDestructed) {
EXPECT_CALL(*allocator, allocate(5)).Times(1).WillOnce(Return(&ptr_target));
EXPECT_CALL(*allocator_ptr, free(_, _)).Times(0);
EXPECT_CALL(*allocator_ptr, free(testing::_, testing::_)).Times(0);
auto data = std::make_unique<Data>(5, std::move(allocator));
Data data2(3);

View File

@ -34,6 +34,7 @@ bool readingFileIsSuccessful(const bf::path& filename) {
return file.good();
}
// NOLINTNEXTLINE(misc-no-recursion)
void recursive_copy(const bf::path &src, const bf::path &dst) {
if (bf::exists(dst)) {
throw std::runtime_error(dst.generic_string() + " already exists");

View File

@ -6,7 +6,6 @@ namespace bf = boost::filesystem;
using ::testing::Values;
using ::testing::WithParamInterface;
using ::testing::Return;
using ::testing::_;
using std::vector;
using cpputils::TempFile;
using cryfs::ErrorCode;
@ -122,7 +121,7 @@ TEST_P(CliTest_WrongEnvironment, MountDirIsBaseDir_BothRelative) {
TEST_P(CliTest_WrongEnvironment, BaseDir_DoesntExist) {
_basedir.remove();
// ON_CALL and not EXPECT_CALL, because this is a death test (i.e. it is forked) and gmock EXPECT_CALL in fork children don't report to parents.
ON_CALL(*console, askYesNo("Could not find base directory. Do you want to create it?", _)).WillByDefault(Return(false));
ON_CALL(*console, askYesNo("Could not find base directory. Do you want to create it?", testing::_)).WillByDefault(Return(false));
Test_Run_Error("Error 16: base directory not found", ErrorCode::InaccessibleBaseDir);
}
@ -130,7 +129,7 @@ TEST_P(CliTest_WrongEnvironment, BaseDir_DoesntExist_Noninteractive) {
_basedir.remove();
// We can't set an EXPECT_CALL().Times(0), because this is a death test (i.e. it is forked) and gmock EXPECT_CALL in fork children don't report to parents.
// So we set a default answer that shouldn't crash and check it's not called by checking that it crashes.
ON_CALL(*console, askYesNo("Could not find base directory. Do you want to create it?", _)).WillByDefault(Return(true));
ON_CALL(*console, askYesNo("Could not find base directory. Do you want to create it?", testing::_)).WillByDefault(Return(true));
cpputils::setenv("CRYFS_FRONTEND", "noninteractive");
Test_Run_Error("Error 16: base directory not found", ErrorCode::InaccessibleBaseDir);
cpputils::unsetenv("CRYFS_FRONTEND");
@ -139,7 +138,7 @@ TEST_P(CliTest_WrongEnvironment, BaseDir_DoesntExist_Noninteractive) {
TEST_P(CliTest_WrongEnvironment, BaseDir_DoesntExist_Create) {
if (!GetParam().runningInForeground) {return;} // TODO Make this work also if run in background (see CliTest::EXPECT_RUN_SUCCESS)
_basedir.remove();
ON_CALL(*console, askYesNo("Could not find base directory. Do you want to create it?", _)).WillByDefault(Return(true));
ON_CALL(*console, askYesNo("Could not find base directory. Do you want to create it?", testing::_)).WillByDefault(Return(true));
Test_Run_Success();
EXPECT_TRUE(bf::exists(_basedir.path()) && bf::is_directory(_basedir.path()));
}
@ -183,7 +182,7 @@ TEST_P(CliTest_WrongEnvironment, BaseDir_NoPermission) {
TEST_P(CliTest_WrongEnvironment, MountDir_DoesntExist) {
_mountdir.remove();
// ON_CALL and not EXPECT_CALL, because this is a death test (i.e. it is forked) and gmock EXPECT_CALL in fork children don't report to parents.
ON_CALL(*console, askYesNo("Could not find mount directory. Do you want to create it?", _)).WillByDefault(Return(false));
ON_CALL(*console, askYesNo("Could not find mount directory. Do you want to create it?", testing::_)).WillByDefault(Return(false));
Test_Run_Error("mount directory not found", ErrorCode::InaccessibleMountDir);
}
@ -191,7 +190,7 @@ TEST_P(CliTest_WrongEnvironment, MountDir_DoesntExist_Noninteractive) {
_mountdir.remove();
// We can't set an EXPECT_CALL().Times(0), because this is a death test (i.e. it is forked) and gmock EXPECT_CALL in fork children don't report to parents.
// So we set a default answer that shouldn't crash and check it's not called by checking that it crashes.
ON_CALL(*console, askYesNo("Could not find base directory. Do you want to create it?", _)).WillByDefault(Return(true));
ON_CALL(*console, askYesNo("Could not find base directory. Do you want to create it?", testing::_)).WillByDefault(Return(true));
cpputils::setenv("CRYFS_FRONTEND", "noninteractive");
Test_Run_Error("mount directory not found", ErrorCode::InaccessibleMountDir);
cpputils::unsetenv("CRYFS_FRONTEND");
@ -200,7 +199,7 @@ TEST_P(CliTest_WrongEnvironment, MountDir_DoesntExist_Noninteractive) {
TEST_P(CliTest_WrongEnvironment, MountDir_DoesntExist_Create) {
if (!GetParam().runningInForeground) {return;} // TODO Make this work also if run in background (see CliTest::EXPECT_RUN_SUCCESS)
_mountdir.remove();
ON_CALL(*console, askYesNo("Could not find mount directory. Do you want to create it?", _)).WillByDefault(Return(true));
ON_CALL(*console, askYesNo("Could not find mount directory. Do you want to create it?", testing::_)).WillByDefault(Return(true));
Test_Run_Success();
EXPECT_TRUE(bf::exists(_mountdir.path()) && bf::is_directory(_mountdir.path()));
}

View File

@ -38,11 +38,11 @@ public:
const auto &actualCipher = CryCiphers::find(cipherName);
Data dataFixture = DataFixture::generate(1024);
string encKey = ExpectedCipher::EncryptionKey::CreateKey(Random::PseudoRandom(), ExpectedCipher::KEYSIZE).ToString();
_EXPECT_ENCRYPTS_WITH_ACTUAL_BLOCKSTORE_DECRYPTS_CORRECTLY_WITH_EXPECTED_BLOCKSTORE<ExpectedCipher>(actualCipher, encKey, std::move(dataFixture));
EXPECT_ENCRYPTS_WITH_ACTUAL_BLOCKSTORE_DECRYPTS_CORRECTLY_WITH_EXPECTED_BLOCKSTORE_<ExpectedCipher>(actualCipher, encKey, std::move(dataFixture));
}
template<class ExpectedCipher>
void _EXPECT_ENCRYPTS_WITH_ACTUAL_BLOCKSTORE_DECRYPTS_CORRECTLY_WITH_EXPECTED_BLOCKSTORE(const CryCipher &actualCipher, const std::string &encKey, Data dataFixture) {
void EXPECT_ENCRYPTS_WITH_ACTUAL_BLOCKSTORE_DECRYPTS_CORRECTLY_WITH_EXPECTED_BLOCKSTORE_(const CryCipher &actualCipher, const std::string &encKey, Data dataFixture) {
blockstore::BlockId blockId = blockstore::BlockId::Random();
Data encrypted = _encryptUsingEncryptedBlockStoreWithCipher(actualCipher, encKey, blockId, dataFixture.copy());
Data decrypted = _decryptUsingEncryptedBlockStoreWithCipher<ExpectedCipher>(encKey, blockId, std::move(encrypted));

View File

@ -14,7 +14,6 @@ using cpputils::NoninteractiveConsole;
using std::string;
using std::shared_ptr;
using std::make_shared;
using ::testing::_;
using ::testing::NiceMock;
using ::testing::Return;
using ::testing::ValuesIn;
@ -37,16 +36,16 @@ public:
class CryConfigConsoleTest_Cipher: public CryConfigConsoleTest {};
#define EXPECT_ASK_FOR_CIPHER() \
EXPECT_CALL(*console, askYesNo("Use default settings?", _)).Times(1).WillOnce(Return(false)); \
EXPECT_CALL(*console, askYesNo("Use default settings?", testing::_)).Times(1).WillOnce(Return(false)); \
EXPECT_CALL(*console, ask(HasSubstr("block cipher"), UnorderedElementsAreArray(CryCiphers::supportedCipherNames()))).Times(1)
#define EXPECT_ASK_FOR_BLOCKSIZE() \
EXPECT_CALL(*console, askYesNo("Use default settings?", _)).Times(1).WillOnce(Return(false)); \
EXPECT_CALL(*console, ask(HasSubstr("block size"), _)).Times(1)
EXPECT_CALL(*console, askYesNo("Use default settings?", testing::_)).Times(1).WillOnce(Return(false)); \
EXPECT_CALL(*console, ask(HasSubstr("block size"), testing::_)).Times(1)
#define EXPECT_ASK_FOR_MISSINGBLOCKISINTEGRITYVIOLATION() \
EXPECT_CALL(*console, askYesNo("Use default settings?", _)).Times(1).WillOnce(Return(false)); \
EXPECT_CALL(*console, askYesNo(HasSubstr("missing block"), _)).Times(1)
EXPECT_CALL(*console, askYesNo("Use default settings?", testing::_)).Times(1).WillOnce(Return(false)); \
EXPECT_CALL(*console, askYesNo(HasSubstr("missing block"), testing::_)).Times(1)
TEST_F(CryConfigConsoleTest_Cipher, AsksForCipher) {
EXPECT_ASK_FOR_CIPHER().WillOnce(ChooseAnyCipher());
@ -54,15 +53,15 @@ TEST_F(CryConfigConsoleTest_Cipher, AsksForCipher) {
}
TEST_F(CryConfigConsoleTest_Cipher, ChooseDefaultCipher) {
EXPECT_CALL(*console, askYesNo("Use default settings?", _)).Times(1).WillOnce(Return(true));
EXPECT_CALL(*console, ask(HasSubstr("block cipher"), _)).Times(0);
EXPECT_CALL(*console, askYesNo("Use default settings?", testing::_)).Times(1).WillOnce(Return(true));
EXPECT_CALL(*console, ask(HasSubstr("block cipher"), testing::_)).Times(0);
string cipher = cryconsole.askCipher();
EXPECT_EQ(CryConfigConsole::DEFAULT_CIPHER, cipher);
}
TEST_F(CryConfigConsoleTest_Cipher, ChooseDefaultCipherWhenNoninteractiveEnvironment) {
EXPECT_CALL(*console, askYesNo(HasSubstr("default"), _)).Times(0);
EXPECT_CALL(*console, ask(HasSubstr("block cipher"), _)).Times(0);
EXPECT_CALL(*console, askYesNo(HasSubstr("default"), testing::_)).Times(0);
EXPECT_CALL(*console, ask(HasSubstr("block cipher"), testing::_)).Times(0);
string cipher = noninteractiveCryconsole.askCipher();
EXPECT_EQ(CryConfigConsole::DEFAULT_CIPHER, cipher);
}
@ -78,8 +77,8 @@ TEST_F(CryConfigConsoleTest_Cipher, AsksForMissingBlockIsIntegrityViolation) {
}
TEST_F(CryConfigConsoleTest_Cipher, ChooseDefaultBlocksizeWhenNoninteractiveEnvironment) {
EXPECT_CALL(*console, askYesNo(HasSubstr("default"), _)).Times(0);
EXPECT_CALL(*console, ask(HasSubstr("block size"), _)).Times(0);
EXPECT_CALL(*console, askYesNo(HasSubstr("default"), testing::_)).Times(0);
EXPECT_CALL(*console, ask(HasSubstr("block size"), testing::_)).Times(0);
uint32_t blocksize = noninteractiveCryconsole.askBlocksizeBytes();
EXPECT_EQ(CryConfigConsole::DEFAULT_BLOCKSIZE_BYTES, blocksize);
}
@ -90,11 +89,11 @@ public:
optional<string> cipherWarning = CryCiphers::find(cipherName).warning();
void EXPECT_DONT_SHOW_WARNING() {
EXPECT_CALL(*console, askYesNo(_, _)).Times(0);
EXPECT_CALL(*console, askYesNo(testing::_, testing::_)).Times(0);
}
void EXPECT_SHOW_WARNING(const string &warning) {
EXPECT_CALL(*console, askYesNo(HasSubstr(warning), _)).WillOnce(Return(true));
EXPECT_CALL(*console, askYesNo(HasSubstr(warning), testing::_)).WillOnce(Return(true));
}
};

View File

@ -16,7 +16,6 @@ using cpputils::NoninteractiveConsole;
using std::string;
using std::shared_ptr;
using std::make_shared;
using ::testing::_;
using ::testing::Return;
using ::testing::HasSubstr;
using ::testing::UnorderedElementsAreArray;
@ -29,11 +28,11 @@ using ::testing::NiceMock;
#define EXPECT_ASK_FOR_CIPHER() \
EXPECT_CALL(*console, ask(HasSubstr("block cipher"), UnorderedElementsAreArray(CryCiphers::supportedCipherNames()))).Times(1)
#define EXPECT_DOES_NOT_ASK_FOR_CIPHER() \
EXPECT_CALL(*console, ask(HasSubstr("block cipher"), _)).Times(0)
EXPECT_CALL(*console, ask(HasSubstr("block cipher"), testing::_)).Times(0)
#define EXPECT_ASK_FOR_BLOCKSIZE() \
EXPECT_CALL(*console, ask(HasSubstr("block size"), _)).Times(1)
EXPECT_CALL(*console, ask(HasSubstr("block size"), testing::_)).Times(1)
#define EXPECT_DOES_NOT_ASK_FOR_BLOCKSIZE() \
EXPECT_CALL(*console, ask(HasSubstr("block size"), _)).Times(0)
EXPECT_CALL(*console, ask(HasSubstr("block size"), testing::_)).Times(0)
#define EXPECT_ASK_FOR_MISSINGBLOCKISINTEGRITYVIOLATION() \
EXPECT_CALL(*console, askYesNo(HasSubstr("missing block"), false)).Times(1)
#define EXPECT_DOES_NOT_ASK_FOR_MISSINGBLOCKISINTEGRITYVIOLATION() \
@ -48,8 +47,8 @@ public:
tempLocalStateDir(), localStateDir(tempLocalStateDir.path()),
creator(console, cpputils::Random::PseudoRandom(), localStateDir),
noninteractiveCreator(make_shared<NoninteractiveConsole>(console), cpputils::Random::PseudoRandom(), localStateDir) {
EXPECT_CALL(*console, ask(HasSubstr("block cipher"), _)).WillRepeatedly(ChooseAnyCipher());
EXPECT_CALL(*console, ask(HasSubstr("block size"), _)).WillRepeatedly(Return(0));
EXPECT_CALL(*console, ask(HasSubstr("block cipher"), testing::_)).WillRepeatedly(ChooseAnyCipher());
EXPECT_CALL(*console, ask(HasSubstr("block size"), testing::_)).WillRepeatedly(Return(0));
}
shared_ptr<NiceMock<MockConsole>> console;
cpputils::TempDir tempLocalStateDir;

View File

@ -33,7 +33,6 @@ using std::shared_ptr;
using std::make_shared;
using ::testing::Return;
using ::testing::HasSubstr;
using ::testing::_;
using namespace cryfs;
@ -343,7 +342,7 @@ TEST_F(CryConfigLoaderTest, AsksWhenMigratingOlderFilesystem) {
}
TEST_F(CryConfigLoaderTest, DoesNotAskForMigrationWhenCorrectVersion) {
EXPECT_CALL(*console, askYesNo(HasSubstr("Do you want to attempt a migration now?"), _)).Times(0);
EXPECT_CALL(*console, askYesNo(HasSubstr("Do you want to attempt a migration now?"), testing::_)).Times(0);
CreateWithVersion(gitversion::VersionString(), CryConfig::FilesystemFormatVersion);
EXPECT_TRUE(LoadOrCreate().is_right());
@ -376,7 +375,7 @@ TEST_F(CryConfigLoaderTest, MyClientIdIsLoadedCorrectly) {
}
TEST_F(CryConfigLoaderTest, DoesNotAskForMigrationWhenUpgradesAllowedByProgramArguments_NoninteractiveMode) {
EXPECT_CALL(*console, askYesNo(HasSubstr("migrate"), _)).Times(0);
EXPECT_CALL(*console, askYesNo(HasSubstr("migrate"), testing::_)).Times(0);
string version = olderVersion();
CreateWithVersion(version, version);
@ -384,7 +383,7 @@ TEST_F(CryConfigLoaderTest, DoesNotAskForMigrationWhenUpgradesAllowedByProgramAr
}
TEST_F(CryConfigLoaderTest, DoesNotAskForMigrationWhenUpgradesAllowedByProgramArguments_InteractiveMode) {
EXPECT_CALL(*console, askYesNo(HasSubstr("migrate"), _)).Times(0);
EXPECT_CALL(*console, askYesNo(HasSubstr("migrate"), testing::_)).Times(0);
string version = olderVersion();
CreateWithVersion(version, version);

View File

@ -18,7 +18,6 @@ using testing::Invoke;
using testing::Eq;
using testing::StrEq;
using testing::NiceMock;
using testing::_;
namespace {
@ -76,7 +75,7 @@ TEST_F(CryPasswordBasedKeyProviderTest, requestKeyForExistingFilesystem) {
EXPECT_CALL(askPasswordForNewFilesystem, call()).Times(0);
EXPECT_CALL(askPasswordForExistingFilesystem, call()).Times(1).WillOnce(Return(password));
EXPECT_CALL(*kdf, deriveExistingKey(Eq(keySize), StrEq(password), _)).Times(1).WillOnce(Invoke([&] (auto, auto, const auto& kdfParams) {
EXPECT_CALL(*kdf, deriveExistingKey(Eq(keySize), StrEq(password), testing::_)).Times(1).WillOnce(Invoke([&] (auto, auto, const auto& kdfParams) {
EXPECT_EQ(kdfParameters, kdfParams);
return key;
}));

View File

@ -13,7 +13,6 @@ using cryfs::CryPresetPasswordBasedKeyProvider;
using testing::Invoke;
using testing::Eq;
using testing::StrEq;
using testing::_;
namespace {
@ -46,7 +45,7 @@ TEST(CryPresetPasswordBasedKeyProviderTest, requestKeyForExistingFilesystem) {
auto kdf = make_unique_ref<MockKDF>();
const Data kdfParameters = DataFixture::generate(100);
EXPECT_CALL(*kdf, deriveExistingKey(Eq(keySize), StrEq(password), _)).Times(1).WillOnce(Invoke([&] (auto, auto, const auto& kdfParams) {
EXPECT_CALL(*kdf, deriveExistingKey(Eq(keySize), StrEq(password), testing::_)).Times(1).WillOnce(Invoke([&] (auto, auto, const auto& kdfParams) {
EXPECT_EQ(kdfParameters, kdfParams);
return key;
}));

View File

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

View File

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

View File

@ -2,6 +2,10 @@
#include "../../testutils/OpenFileHandle.h"
#include <condition_variable>
//TODO Figure out what's wrong and enable this test
//Disabled, because it is flaky. libfuse seems to not send the release() event sometimes.
/*
using ::testing::WithParamInterface;
using ::testing::Values;
@ -48,9 +52,6 @@ private:
bool finished;
};
//TODO Figure out what's wrong and enable this test
//Disabled, because it is flaky. libfuse seems to not send the release() event sometimes.
/*
class FuseCloseTest: public FuseTest, public WithParamInterface<int> {
public:
const string FILENAME = "/myfile";

View File

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

View File

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

View File

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

View File

@ -1,10 +1,11 @@
#include "testutils/FuseCreateAndOpenTest.h"
//TODO Disabled because it doesn't seem to work. Fuse doesn't seem to pass flags to create(). Why?
/*
using ::testing::WithParamInterface;
using ::testing::Values;
//TODO Disabled because it doesn't seem to work. Fuse doesn't seem to pass flags to create(). Why?
/*
class FuseCreateAndOpenFlagsTest: public FuseCreateAndOpenTest, public WithParamInterface<mode_t> {
};
INSTANTIATE_TEST_SUITE_P(FuseCreateAndOpenFlagsTest, FuseCreateAndOpenFlagsTest, Values(O_RDWR, O_RDONLY, O_WRONLY));

View File

@ -7,7 +7,6 @@ using ::testing::Eq;
using ::testing::Return;
using ::testing::Throw;
using ::testing::Values;
using ::testing::_;
using fspp::fuse::FuseErrnoException;
@ -24,7 +23,7 @@ INSTANTIATE_TEST_SUITE_P(FuseFlushErrorTest, FuseFlushErrorTest, Values(
TEST_P(FuseFlushErrorTest, ReturnErrorFromFlush) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, openFile(Eq(FILENAME), _)).WillOnce(Return(GetParam()));
EXPECT_CALL(*fsimpl, openFile(Eq(FILENAME), testing::_)).WillOnce(Return(GetParam()));
EXPECT_CALL(*fsimpl, flush(Eq(GetParam()))).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
auto fs = TestFS();

View File

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

View File

@ -2,7 +2,6 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Eq;
@ -29,7 +28,7 @@ TEST_P(FuseFstatErrorTest, ReturnedErrorCodeIsCorrect) {
ReturnDoesntExistOnLstat(FILENAME);
OnCreateAndOpenReturnFileDescriptor(FILENAME, 0);
EXPECT_CALL(*fsimpl, fstat(Eq(0), _)).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
EXPECT_CALL(*fsimpl, fstat(Eq(0), testing::_)).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
auto fs = TestFS();

View File

@ -2,7 +2,6 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Eq;
@ -28,7 +27,7 @@ TEST_P(FuseFstatParameterTest, FileDescriptorIsCorrect) {
ReturnDoesntExistOnLstat(FILENAME);
OnCreateAndOpenReturnFileDescriptor(FILENAME, GetParam());
EXPECT_CALL(*fsimpl, fstat(Eq(GetParam()), _)).Times(1).WillOnce(ReturnIsFileFstat);
EXPECT_CALL(*fsimpl, fstat(Eq(GetParam()), testing::_)).Times(1).WillOnce(ReturnIsFileFstat);
CallFstat(FILENAME);
}

View File

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

View File

@ -2,7 +2,6 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -16,7 +15,7 @@ INSTANTIATE_TEST_SUITE_P(FuseFTruncateErrorTest, FuseFTruncateErrorTest, Values(
TEST_P(FuseFTruncateErrorTest, ReturnedErrorIsCorrect) {
ReturnIsFileOnLstat(FILENAME);
OnOpenReturnFileDescriptor(FILENAME, 0);
EXPECT_CALL(*fsimpl, ftruncate(0, _))
EXPECT_CALL(*fsimpl, ftruncate(0, testing::_))
.Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
//Needed to make ::ftruncate system call return successfully
ReturnIsFileOnFstat(0);

View File

@ -2,7 +2,6 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Eq;
@ -18,7 +17,7 @@ INSTANTIATE_TEST_SUITE_P(FuseFTruncateFileDescriptorTest, FuseFTruncateFileDescr
TEST_P(FuseFTruncateFileDescriptorTest, FileDescriptorIsCorrect) {
ReturnIsFileOnLstat(FILENAME);
OnOpenReturnFileDescriptor(FILENAME, GetParam());
EXPECT_CALL(*fsimpl, ftruncate(Eq(GetParam()), _))
EXPECT_CALL(*fsimpl, ftruncate(Eq(GetParam()), testing::_))
.Times(1).WillOnce(Return());
//Needed to make ::ftruncate system call return successfully
ReturnIsFileOnFstat(GetParam());

View File

@ -3,7 +3,6 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::Eq;
using ::testing::_;
using ::testing::Throw;
using ::testing::WithParamInterface;
using ::testing::Values;
@ -17,14 +16,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(Eq(FILENAME), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile);
EXPECT_CALL(*fsimpl, lstat(Eq(FILENAME), testing::_)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile);
errno = 0;
int error = LstatPathReturnError(FILENAME);
EXPECT_EQ(0, error);
}
TEST_P(FuseLstatErrorTest, ReturnError) {
EXPECT_CALL(*fsimpl, lstat(Eq(FILENAME), _)).Times(AtLeast(1)).WillRepeatedly(Throw(FuseErrnoException(GetParam())));
EXPECT_CALL(*fsimpl, lstat(Eq(FILENAME), testing::_)).Times(AtLeast(1)).WillRepeatedly(Throw(FuseErrnoException(GetParam())));
int error = LstatPathReturnError(FILENAME);
EXPECT_EQ(GetParam(), error);
}

View File

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

View File

@ -2,7 +2,6 @@
using std::function;
using ::testing::Eq;
using ::testing::_;
using ::testing::Invoke;
void FuseLstatTest::LstatPath(const std::string &path) {
@ -41,7 +40,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(Eq(FILENAME), _)).WillRepeatedly(Invoke([implementation](const boost::filesystem::path&, fspp::fuse::STAT *stat) {
EXPECT_CALL(*fsimpl, lstat(Eq(FILENAME), testing::_)).WillRepeatedly(Invoke([implementation](const boost::filesystem::path&, fspp::fuse::STAT *stat) {
implementation(stat);
}));

View File

@ -1,6 +1,5 @@
#include "testutils/FuseMkdirTest.h"
using ::testing::_;
using ::testing::Eq;
class FuseMkdirDirnameTest: public FuseMkdirTest {
@ -8,7 +7,7 @@ class FuseMkdirDirnameTest: public FuseMkdirTest {
TEST_F(FuseMkdirDirnameTest, Mkdir) {
ReturnDoesntExistOnLstat("/mydir");
EXPECT_CALL(*fsimpl, mkdir(Eq("/mydir"), _, _, _))
EXPECT_CALL(*fsimpl, mkdir(Eq("/mydir"), testing::_, testing::_, testing::_))
// 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 +18,7 @@ TEST_F(FuseMkdirDirnameTest, Mkdir) {
TEST_F(FuseMkdirDirnameTest, MkdirNested) {
ReturnIsDirOnLstat("/mydir");
ReturnDoesntExistOnLstat("/mydir/mysubdir");
EXPECT_CALL(*fsimpl, mkdir(Eq("/mydir/mysubdir"), _, _, _))
EXPECT_CALL(*fsimpl, mkdir(Eq("/mydir/mysubdir"), testing::_, testing::_, testing::_))
// 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 +30,7 @@ TEST_F(FuseMkdirDirnameTest, MkdirNested2) {
ReturnIsDirOnLstat("/mydir");
ReturnIsDirOnLstat("/mydir/mydir2");
ReturnDoesntExistOnLstat("/mydir/mydir2/mydir3");
EXPECT_CALL(*fsimpl, mkdir(Eq("/mydir/mydir2/mydir3"), _, _, _))
EXPECT_CALL(*fsimpl, mkdir(Eq("/mydir/mydir2/mydir3"), testing::_, testing::_, testing::_))
// After mkdir was called, lstat should return that it is a dir.
// This is needed to make the ::mkdir() syscall pass.
.Times(1).WillOnce(FromNowOnReturnIsDirOnLstat());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,6 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Eq;
@ -27,7 +26,7 @@ INSTANTIATE_TEST_SUITE_P(FuseReadErrorTest, FuseReadErrorTest, Values(EAGAIN, EB
TEST_P(FuseReadErrorTest, ReturnErrorOnFirstReadCall) {
EXPECT_CALL(*fsimpl, read(0, _, _, _))
EXPECT_CALL(*fsimpl, read(0, testing::_, testing::_, testing::_))
.WillRepeatedly(Throw(FuseErrnoException(GetParam())));
char *buf = new char[READCOUNT.value()];
@ -41,14 +40,14 @@ TEST_P(FuseReadErrorTest, ReturnErrorOnSecondReadCall) {
// We store the number of bytes the first call could successfully read and check later that our
// read syscall returns exactly this number of bytes
fspp::num_bytes_t successfullyReadBytes = fspp::num_bytes_t(-1);
EXPECT_CALL(*fsimpl, read(0, _, _, Eq(fspp::num_bytes_t(0))))
EXPECT_CALL(*fsimpl, read(0, testing::_, testing::_, Eq(fspp::num_bytes_t(0))))
.Times(1)
.WillOnce(Invoke([&successfullyReadBytes](int, void*, fspp::num_bytes_t count, fspp::num_bytes_t) {
// Store the number of successfully read bytes
successfullyReadBytes = count;
return count;
}));
EXPECT_CALL(*fsimpl, read(0, _, _, Ne(fspp::num_bytes_t(0))))
EXPECT_CALL(*fsimpl, read(0, testing::_, testing::_, Ne(fspp::num_bytes_t(0))))
.WillRepeatedly(Throw(FuseErrnoException(GetParam())));
char *buf = new char[READCOUNT.value()];

View File

@ -2,7 +2,6 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Eq;
@ -17,7 +16,7 @@ INSTANTIATE_TEST_SUITE_P(FuseReadFileDescriptorTest, FuseReadFileDescriptorTest,
TEST_P(FuseReadFileDescriptorTest, FileDescriptorIsCorrect) {
ReturnIsFileOnLstatWithSize(FILENAME, fspp::num_bytes_t(1));
OnOpenReturnFileDescriptor(FILENAME, GetParam());
EXPECT_CALL(*fsimpl, read(Eq(GetParam()), _, _, _))
EXPECT_CALL(*fsimpl, read(Eq(GetParam()), testing::_, testing::_, testing::_))
.Times(1).WillOnce(ReturnSuccessfulRead);
std::array<char, 1> buf{};

View File

@ -2,9 +2,6 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using namespace fspp::fuse;
class FuseReadOverflowTest: public FuseReadTest {
@ -16,7 +13,7 @@ public:
void SetUp() override {
ReturnIsFileOnLstatWithSize(FILENAME, FILESIZE);
OnOpenReturnFileDescriptor(FILENAME, 0);
EXPECT_CALL(*fsimpl, read(0, _, _, _)).WillRepeatedly(ReturnSuccessfulReadRegardingSize(FILESIZE));
EXPECT_CALL(*fsimpl, read(0, testing::_, testing::_, testing::_)).WillRepeatedly(ReturnSuccessfulReadRegardingSize(FILESIZE));
}
};

View File

@ -9,7 +9,6 @@
#include <tuple>
#include <cstdlib>
using ::testing::_;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Combine;
@ -52,7 +51,7 @@ public:
testFile = std::make_unique<InMemoryFile>(DataFixture::generate(testData.fileSize().value()));
ReturnIsFileOnLstatWithSize(FILENAME, testData.fileSize());
OnOpenReturnFileDescriptor(FILENAME, 0);
EXPECT_CALL(*fsimpl, read(0, _, _, _))
EXPECT_CALL(*fsimpl, read(0, testing::_, testing::_, testing::_))
.WillRepeatedly(ReadFromFile);
}

View File

@ -2,7 +2,6 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::Throw;
using ::testing::Return;
using ::testing::WithParamInterface;
@ -17,14 +16,14 @@ INSTANTIATE_TEST_SUITE_P(FuseStatfsErrorTest, FuseStatfsErrorTest, Values(EACCES
TEST_F(FuseStatfsErrorTest, ReturnNoError) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, statfs(_)).Times(1).WillOnce(Return());
EXPECT_CALL(*fsimpl, statfs(testing::_)).Times(1).WillOnce(Return());
int error = StatfsReturnError(FILENAME);
EXPECT_EQ(0, error);
}
TEST_P(FuseStatfsErrorTest, ReturnError) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, statfs( _)).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
EXPECT_CALL(*fsimpl, statfs(testing::_)).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
int error = StatfsReturnError(FILENAME);
EXPECT_EQ(GetParam(), error);
}

View File

@ -1,7 +1,6 @@
#include "FuseStatfsTest.h"
using std::function;
using ::testing::_;
using ::testing::Invoke;
void FuseStatfsTest::Statfs(const std::string &path) {
@ -33,7 +32,7 @@ int FuseStatfsTest::StatfsReturnError(const std::string &path, struct ::statvfs
struct ::statvfs FuseStatfsTest::CallStatfsWithImpl(function<void(struct ::statvfs*)> implementation) {
ReturnIsFileOnLstat(FILENAME);
EXPECT_CALL(*fsimpl, statfs(_)).WillRepeatedly(Invoke([implementation](struct ::statvfs *stat) {
EXPECT_CALL(*fsimpl, statfs(testing::_)).WillRepeatedly(Invoke([implementation](struct ::statvfs *stat) {
implementation(stat);
}));

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,6 @@
#include <tuple>
#include <cstdlib>
using ::testing::_;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Combine;
@ -49,7 +48,7 @@ public:
testFile = std::make_unique<WriteableInMemoryFile>(DataFixture::generate(testData.fileSize().value(), 1));
ReturnIsFileOnLstatWithSize(FILENAME, testData.fileSize());
OnOpenReturnFileDescriptor(FILENAME, 0);
EXPECT_CALL(*fsimpl, write(0, _, _, _))
EXPECT_CALL(*fsimpl, write(0, testing::_, testing::_, testing::_))
.WillRepeatedly(WriteToFile);
}

View File

@ -2,7 +2,6 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Eq;
@ -27,7 +26,7 @@ INSTANTIATE_TEST_SUITE_P(FuseWriteErrorTest, FuseWriteErrorTest, Values(EAGAIN,
TEST_P(FuseWriteErrorTest, ReturnErrorOnFirstWriteCall) {
EXPECT_CALL(*fsimpl, write(0, _, _, _))
EXPECT_CALL(*fsimpl, write(0, testing::_, testing::_, testing::_))
.WillRepeatedly(Throw(FuseErrnoException(GetParam())));
char *buf = new char[WRITECOUNT.value()];
@ -41,13 +40,13 @@ TEST_P(FuseWriteErrorTest, ReturnErrorOnSecondWriteCall) {
// We store the number of bytes the first call could successfully write and check later that our
// write syscall returns exactly this number of bytes
fspp::num_bytes_t successfullyWrittenBytes = fspp::num_bytes_t(-1);
EXPECT_CALL(*fsimpl, write(0, _, _, Eq(fspp::num_bytes_t(0))))
EXPECT_CALL(*fsimpl, write(0, testing::_, testing::_, Eq(fspp::num_bytes_t(0))))
.Times(1)
.WillOnce(Invoke([&successfullyWrittenBytes](int, const void*, fspp::num_bytes_t count, fspp::num_bytes_t) {
// Store the number of successfully written bytes
successfullyWrittenBytes = count;
}));
EXPECT_CALL(*fsimpl, write(0, _, _, Ne(fspp::num_bytes_t(0))))
EXPECT_CALL(*fsimpl, write(0, testing::_, testing::_, Ne(fspp::num_bytes_t(0))))
.WillRepeatedly(Throw(FuseErrnoException(GetParam())));
char *buf = new char[WRITECOUNT.value()];

View File

@ -2,7 +2,6 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::WithParamInterface;
using ::testing::Values;
using ::testing::Eq;
@ -18,7 +17,7 @@ INSTANTIATE_TEST_SUITE_P(FuseWriteFileDescriptorTest, FuseWriteFileDescriptorTes
TEST_P(FuseWriteFileDescriptorTest, FileDescriptorIsCorrect) {
ReturnIsFileOnLstat(FILENAME);
OnOpenReturnFileDescriptor(FILENAME, GetParam());
EXPECT_CALL(*fsimpl, write(Eq(GetParam()), _, _, _))
EXPECT_CALL(*fsimpl, write(Eq(GetParam()), testing::_, testing::_, testing::_))
.Times(1).WillOnce(Return());
std::array<char, 1> buf{};

View File

@ -4,7 +4,6 @@
#include "fspp/fs_interface/FuseErrnoException.h"
using ::testing::_;
using ::testing::Invoke;
using ::testing::Action;
@ -26,7 +25,7 @@ public:
: FILESIZE(filesize), WRITESIZE(writesize), OFFSET(offset), testFile(DataFixture::generate(FILESIZE.value())), writeData(DataFixture::generate(WRITESIZE.value())) {
ReturnIsFileOnLstatWithSize(FILENAME, FILESIZE);
OnOpenReturnFileDescriptor(FILENAME, 0);
EXPECT_CALL(*fsimpl, write(0, _, _, _)).WillRepeatedly(WriteToFile);
EXPECT_CALL(*fsimpl, write(0, testing::_, testing::_, testing::_)).WillRepeatedly(WriteToFile);
}
// This write() mock implementation writes to the stored virtual file.

View File

@ -1,7 +1,6 @@
#include "FuseTest.h"
using ::testing::Eq;
using ::testing::_;
using ::testing::Return;
using ::testing::Throw;
using ::testing::Action;
@ -20,6 +19,7 @@ MockFilesystem::MockFilesystem() {}
MockFilesystem::~MockFilesystem() {}
FuseTest::FuseTest(): fsimpl(make_shared<MockFilesystem>()), _context(boost::none) {
using ::testing::_;
auto defaultAction = Throw(FuseErrnoException(EIO));
ON_CALL(*fsimpl, openFile(_,_)).WillByDefault(defaultAction);
ON_CALL(*fsimpl, closeFile(_)).WillByDefault(defaultAction);
@ -109,7 +109,7 @@ Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> FuseTest::Return
Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> FuseTest::ReturnDoesntExist = Throw(fspp::fuse::FuseErrnoException(ENOENT));
void FuseTest::OnOpenReturnFileDescriptor(const char *filename, int descriptor) {
EXPECT_CALL(*fsimpl, openFile(Eq(filename), _)).Times(1).WillOnce(Return(descriptor));
EXPECT_CALL(*fsimpl, openFile(Eq(filename), testing::_)).Times(1).WillOnce(Return(descriptor));
}
void FuseTest::ReturnIsFileOnLstat(const bf::path &path) {
@ -129,9 +129,9 @@ void FuseTest::ReturnDoesntExistOnLstat(const bf::path &path) {
}
void FuseTest::ReturnIsFileOnFstat(int descriptor) {
EXPECT_CALL(*fsimpl, fstat(descriptor, _)).WillRepeatedly(ReturnIsFileFstat);
EXPECT_CALL(*fsimpl, fstat(descriptor, testing::_)).WillRepeatedly(ReturnIsFileFstat);
}
void FuseTest::ReturnIsFileOnFstatWithSize(int descriptor, fspp::num_bytes_t size) {
EXPECT_CALL(*fsimpl, fstat(descriptor, _)).WillRepeatedly(ReturnIsFileFstatWithSize(size));
EXPECT_CALL(*fsimpl, fstat(descriptor, testing::_)).WillRepeatedly(ReturnIsFileFstatWithSize(size));
}

View File

@ -79,12 +79,12 @@ private:
public:
//TODO Combine ReturnIsFile and ReturnIsFileFstat. This should be possible in gmock by either (a) using ::testing::Undefined as parameter type or (b) using action macros
static ::testing::Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> ReturnIsFile;
static ::testing::Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> ReturnIsFileWithSize(fspp::num_bytes_t size);
static ::testing::Action<void(int, fspp::fuse::STAT*)> ReturnIsFileFstat;
static ::testing::Action<void(int, fspp::fuse::STAT*)> ReturnIsFileFstatWithSize(fspp::num_bytes_t size);
static ::testing::Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> ReturnIsDir;
static ::testing::Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> ReturnDoesntExist;
static ::testing::Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> ReturnIsFile; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
static ::testing::Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> ReturnIsFileWithSize(fspp::num_bytes_t size); // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
static ::testing::Action<void(int, fspp::fuse::STAT*)> ReturnIsFileFstat; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
static ::testing::Action<void(int, fspp::fuse::STAT*)> ReturnIsFileFstatWithSize(fspp::num_bytes_t size); // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
static ::testing::Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> ReturnIsDir; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
static ::testing::Action<void(const boost::filesystem::path&, fspp::fuse::STAT*)> ReturnDoesntExist; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
void ReturnIsFileOnLstat(const boost::filesystem::path &path);
void ReturnIsFileOnLstatWithSize(const boost::filesystem::path &path, fspp::num_bytes_t size);

View File

@ -7,6 +7,7 @@
#include <cpp-utils/assert/assert.h>
namespace {
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
boost::optional<boost::filesystem::path> executable;
}