From 68a4c5646ab903fede18f6ab987c97f35e342d38 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Tue, 20 Apr 2021 23:09:00 -0700 Subject: [PATCH] Fix clang-tidy warnings --- .clang-tidy | 1 + .../onblocks/datanodestore/DataNodeStore.cpp | 1 + .../onblocks/datatreestore/DataTree.cpp | 1 + .../datatreestore/impl/LeafTraverser.cpp | 5 ++++ .../implementations/caching/cache/QueueMap.h | 8 +++--- .../encrypted/EncryptedBlockStore2.h | 4 +-- src/blockstore/interface/BlockStore2.h | 12 ++++----- src/blockstore/utils/BlockId.h | 4 +-- src/cpp-utils/crypto/kdf/SCryptParameters.cpp | 10 +++---- src/cpp-utils/crypto/kdf/SCryptParameters.h | 16 +++++------ src/cpp-utils/crypto/kdf/Scrypt.cpp | 2 +- src/cpp-utils/crypto/symmetric/AEAD_Cipher.h | 24 ++++++++--------- src/cpp-utils/data/FixedSizeData.h | 2 +- .../io/DontEchoStdinToStdoutRAII.cpp | 10 +++---- src/cpp-utils/io/DontEchoStdinToStdoutRAII.h | 4 +-- .../filesystem/fsblobstore/FsBlobStore.cpp | 3 ++- src/stats/main.cpp | 12 ++++----- src/stats/traversal.cpp | 2 ++ .../DataTreeTest_ResizeByTraversing.cpp | 3 +++ .../DataTreeTest_ResizeNumBytes.cpp | 3 +++ .../datatreestore/LeafTraverserTest.cpp | 5 ++-- .../datatreestore/testutils/DataTreeTest.cpp | 1 + .../testutils/TwoLevelDataFixture.h | 1 + .../EncryptedBlockStoreTest_Specific.cpp | 4 +-- test/blockstore/interface/BlockStore2Test.cpp | 15 +++++------ test/blockstore/interface/BlockStoreTest.cpp | 15 +++++------ test/cpp-utils/assert/assert_debug_test.cpp | 4 +-- test/cpp-utils/assert/assert_release_test.cpp | 4 +-- .../crypto/kdf/SCryptParametersTest.cpp | 6 ++--- test/cpp-utils/crypto/kdf/SCryptTest.cpp | 4 +-- test/cpp-utils/data/DataTest.cpp | 5 ++-- test/cryfs-cli/CliTest_IntegrityCheck.cpp | 1 + test/cryfs-cli/CliTest_WrongEnvironment.cpp | 13 +++++---- test/cryfs/impl/config/CryCipherTest.cpp | 4 +-- .../impl/config/CryConfigConsoleTest.cpp | 27 +++++++++---------- .../impl/config/CryConfigCreatorTest.cpp | 11 ++++---- .../cryfs/impl/config/CryConfigLoaderTest.cpp | 7 +++-- .../CryPasswordBasedKeyProviderTest.cpp | 3 +-- .../CryPresetPasswordBasedKeyProviderTest.cpp | 3 +-- test/fspp/fuse/access/FuseAccessErrorTest.cpp | 3 +-- .../fuse/access/FuseAccessFilenameTest.cpp | 7 +++-- test/fspp/fuse/closeFile/FuseCloseTest.cpp | 7 ++--- .../FuseCreateAndOpenErrorTest.cpp | 5 ++-- .../FuseCreateAndOpenFileDescriptorTest.cpp | 5 ++-- .../FuseCreateAndOpenFilenameTest.cpp | 7 +++-- .../FuseCreateAndOpenFlagsTest.cpp | 5 ++-- test/fspp/fuse/flush/FuseFlushErrorTest.cpp | 3 +-- .../flush/FuseFlushFileDescriptorTest.cpp | 3 +-- test/fspp/fuse/fstat/FuseFstatErrorTest.cpp | 3 +-- .../fuse/fstat/FuseFstatParameterTest.cpp | 3 +-- .../fuse/fstat/testutils/FuseFstatTest.cpp | 3 +-- .../fuse/ftruncate/FuseFTruncateErrorTest.cpp | 3 +-- .../FuseFTruncateFileDescriptorTest.cpp | 3 +-- test/fspp/fuse/lstat/FuseLstatErrorTest.cpp | 5 ++-- .../fuse/lstat/FuseLstatPathParameterTest.cpp | 11 ++++---- .../fuse/lstat/testutils/FuseLstatTest.cpp | 3 +-- test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp | 7 +++-- test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp | 5 ++-- test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp | 3 +-- test/fspp/fuse/openFile/FuseOpenErrorTest.cpp | 5 ++-- .../openFile/FuseOpenFileDescriptorTest.cpp | 5 ++-- .../fuse/openFile/FuseOpenFilenameTest.cpp | 7 +++-- test/fspp/fuse/read/FuseReadErrorTest.cpp | 7 +++-- .../fuse/read/FuseReadFileDescriptorTest.cpp | 3 +-- test/fspp/fuse/read/FuseReadOverflowTest.cpp | 5 +--- .../fuse/read/FuseReadReturnedDataTest.cpp | 3 +-- test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp | 5 ++-- .../fuse/statfs/testutils/FuseStatfsTest.cpp | 3 +-- .../fuse/truncate/FuseTruncateErrorTest.cpp | 3 +-- .../truncate/FuseTruncateFilenameTest.cpp | 7 +++-- .../fuse/utimens/FuseUtimensErrorTest.cpp | 3 +-- .../fuse/utimens/FuseUtimensFilenameTest.cpp | 13 +++++---- test/fspp/fuse/write/FuseWriteDataTest.cpp | 3 +-- test/fspp/fuse/write/FuseWriteErrorTest.cpp | 7 +++-- .../write/FuseWriteFileDescriptorTest.cpp | 3 +-- .../fspp/fuse/write/FuseWriteOverflowTest.cpp | 3 +-- test/fspp/testutils/FuseTest.cpp | 8 +++--- test/fspp/testutils/FuseTest.h | 12 ++++----- test/my-gtest-main/my-gtest-main.cpp | 1 + 79 files changed, 218 insertions(+), 242 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 3a6bd573..1582d653 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -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, diff --git a/src/blobstore/implementations/onblocks/datanodestore/DataNodeStore.cpp b/src/blobstore/implementations/onblocks/datanodestore/DataNodeStore.cpp index 5149b2e3..2fbe1cde 100644 --- a/src/blobstore/implementations/onblocks/datanodestore/DataNodeStore.cpp +++ b/src/blobstore/implementations/onblocks/datanodestore/DataNodeStore.cpp @@ -104,6 +104,7 @@ void DataNodeStore::removeSubtree(unique_ref node) { remove(std::move(*inner)); } +// NOLINTNEXTLINE(misc-no-recursion) void DataNodeStore::removeSubtree(uint8_t depth, const BlockId &blockId) { if (depth == 0) { remove(blockId); diff --git a/src/blobstore/implementations/onblocks/datatreestore/DataTree.cpp b/src/blobstore/implementations/onblocks/datatreestore/DataTree.cpp index e04b3c89..5d85052d 100644 --- a/src/blobstore/implementations/onblocks/datatreestore/DataTree.cpp +++ b/src/blobstore/implementations/onblocks/datatreestore/DataTree.cpp @@ -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(&node); if (leaf != nullptr) { diff --git a/src/blobstore/implementations/onblocks/datatreestore/impl/LeafTraverser.cpp b/src/blobstore/implementations/onblocks/datatreestore/impl/LeafTraverser.cpp index 1a17e297..259ed165 100644 --- a/src/blobstore/implementations/onblocks/datatreestore/impl/LeafTraverser.cpp +++ b/src/blobstore/implementations/onblocks/datatreestore/impl/LeafTraverser.cpp @@ -28,6 +28,7 @@ namespace blobstore { _traverseAndUpdateRoot(root, beginIndex, endIndex, true, onExistingLeaf, onCreateLeaf, onBacktrackFromSubtree); } + // NOLINTNEXTLINE(misc-no-recursion) void LeafTraverser::_traverseAndUpdateRoot(unique_ref* root, uint32_t beginIndex, uint32_t endIndex, bool isLeftBorderOfTraversal, function onExistingLeaf, function onCreateLeaf, function 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 onExistingLeaf, function onCreateLeaf, function 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 onExistingLeaf, function onCreateLeaf, function onBacktrackFromSubtree) { ASSERT(beginIndex <= endIndex, "Invalid parameters"); @@ -169,6 +172,7 @@ namespace blobstore { } } + // NOLINTNEXTLINE(misc-no-recursion) unique_ref LeafTraverser::_createNewSubtree(uint32_t beginIndex, uint32_t endIndex, uint32_t leafOffset, uint8_t depth, function onCreateLeaf, function 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 LeafTraverser::_whileRootHasOnlyOneChildRemoveRootReturnChild(const blockstore::BlockId &blockId) { ASSERT(!_readOnlyTraversal, "Can't decrease tree depth in a read-only traversal"); diff --git a/src/blockstore/implementations/caching/cache/QueueMap.h b/src/blockstore/implementations/caching/cache/QueueMap.h index e541b3ad..22225474 100644 --- a/src/blockstore/implementations/caching/cache/QueueMap.h +++ b/src/blockstore/implementations/caching/cache/QueueMap.h @@ -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.data()); + return reinterpret_cast(_value_.data()); } - alignas(Value) std::array __value; + alignas(Value) std::array _value_; DISALLOW_COPY_AND_ASSIGN(Entry); }; diff --git a/src/blockstore/implementations/encrypted/EncryptedBlockStore2.h b/src/blockstore/implementations/encrypted/EncryptedBlockStore2.h index 95194fb2..d320ad31 100644 --- a/src/blockstore/implementations/encrypted/EncryptedBlockStore2.h +++ b/src/blockstore/implementations/encrypted/EncryptedBlockStore2.h @@ -29,7 +29,7 @@ public: void forEachBlock(std::function 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::_readFormatHeader(const cpputils::Data &d } template -void EncryptedBlockStore2::__setKey(const typename Cipher::EncryptionKey &encKey) { +void EncryptedBlockStore2::_setKey(const typename Cipher::EncryptionKey &encKey) { _encKey = encKey; } diff --git a/src/blockstore/interface/BlockStore2.h b/src/blockstore/interface/BlockStore2.h index affb69f8..11c08d3a 100644 --- a/src/blockstore/interface/BlockStore2.h +++ b/src/blockstore/interface/BlockStore2.h @@ -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; + } } } diff --git a/src/blockstore/utils/BlockId.h b/src/blockstore/utils/BlockId.h index b12b9a44..b6a03360 100644 --- a/src/blockstore/utils/BlockId.h +++ b/src/blockstore/utils/BlockId.h @@ -6,9 +6,9 @@ namespace blockstore { -struct _BlockIdTag final {}; +struct BlockIdTag final {}; // TODO Split from a BlobId (i.e. IdWrapper) -using BlockId = IdWrapper<_BlockIdTag>; +using BlockId = IdWrapper; } diff --git a/src/cpp-utils/crypto/kdf/SCryptParameters.cpp b/src/cpp-utils/crypto/kdf/SCryptParameters.cpp index 8159811f..e7a90b34 100644 --- a/src/cpp-utils/crypto/kdf/SCryptParameters.cpp +++ b/src/cpp-utils/crypto/kdf/SCryptParameters.cpp @@ -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 } diff --git a/src/cpp-utils/crypto/kdf/SCryptParameters.h b/src/cpp-utils/crypto/kdf/SCryptParameters.h index aa22dfb6..cea0097f 100644 --- a/src/cpp-utils/crypto/kdf/SCryptParameters.h +++ b/src/cpp-utils/crypto/kdf/SCryptParameters.h @@ -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) { diff --git a/src/cpp-utils/crypto/kdf/Scrypt.cpp b/src/cpp-utils/crypto/kdf/Scrypt.cpp index f97d6940..1fec96ce 100644 --- a/src/cpp-utils/crypto/kdf/Scrypt.cpp +++ b/src/cpp-utils/crypto/kdf/Scrypt.cpp @@ -17,7 +17,7 @@ EncryptionKey _derive(size_t keySize, const std::string& password, const SCryptP static_cast(result.data()), result.binaryLength(), reinterpret_cast(password.c_str()), password.size(), static_cast(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)); diff --git a/src/cpp-utils/crypto/symmetric/AEAD_Cipher.h b/src/cpp-utils/crypto/symmetric/AEAD_Cipher.h index 67a0c364..42ce3481 100644 --- a/src/cpp-utils/crypto/symmetric/AEAD_Cipher.h +++ b/src/cpp-utils/crypto/symmetric/AEAD_Cipher.h @@ -10,12 +10,12 @@ namespace cpputils { -template +template 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 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 -constexpr unsigned int AEADCipher::KEYSIZE; -template -constexpr unsigned int AEADCipher::STRING_KEYSIZE; +template +constexpr unsigned int AEADCipher::KEYSIZE; +template +constexpr unsigned int AEADCipher::STRING_KEYSIZE; -template -Data AEADCipher::encrypt(const CryptoPP::byte *plaintext, unsigned int plaintextSize, const EncryptionKey &encKey) { +template +Data AEADCipher::encrypt(const CryptoPP::byte *plaintext, unsigned int plaintextSize, const EncryptionKey &encKey) { ASSERT(encKey.binaryLength() == AEADCipher::KEYSIZE, "Wrong key size"); FixedSizeData iv = Random::PseudoRandom().getFixedSize(); @@ -58,8 +58,8 @@ Data AEADCipher::encrypt(const C return ciphertext; } -template -boost::optional AEADCipher::decrypt(const CryptoPP::byte *ciphertext, unsigned int ciphertextSize, const EncryptionKey &encKey) { +template +boost::optional AEADCipher::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) { diff --git a/src/cpp-utils/data/FixedSizeData.h b/src/cpp-utils/data/FixedSizeData.h index e2938e35..58833996 100644 --- a/src/cpp-utils/data/FixedSizeData.h +++ b/src/cpp-utils/data/FixedSizeData.h @@ -36,7 +36,7 @@ public: private: FixedSizeData(): _data() {} - template friend class FixedSizeData; + template friend class FixedSizeData; std::array _data; }; diff --git a/src/cpp-utils/io/DontEchoStdinToStdoutRAII.cpp b/src/cpp-utils/io/DontEchoStdinToStdoutRAII.cpp index be5c7558..f7b70c80 100644 --- a/src/cpp-utils/io/DontEchoStdinToStdoutRAII.cpp +++ b/src/cpp-utils/io/DontEchoStdinToStdoutRAII.cpp @@ -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()) {} + : raii(make_unique_ref()) {} DontEchoStdinToStdoutRAII::~DontEchoStdinToStdoutRAII() {} diff --git a/src/cpp-utils/io/DontEchoStdinToStdoutRAII.h b/src/cpp-utils/io/DontEchoStdinToStdoutRAII.h index c4f47be4..382b3687 100644 --- a/src/cpp-utils/io/DontEchoStdinToStdoutRAII.h +++ b/src/cpp-utils/io/DontEchoStdinToStdoutRAII.h @@ -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 raii; + cpputils::unique_ref raii; DISALLOW_COPY_AND_ASSIGN(DontEchoStdinToStdoutRAII); }; diff --git a/src/cryfs/impl/filesystem/fsblobstore/FsBlobStore.cpp b/src/cryfs/impl/filesystem/fsblobstore/FsBlobStore.cpp index bbebf1fa..d1d780d3 100644 --- a/src/cryfs/impl/filesystem/fsblobstore/FsBlobStore.cpp +++ b/src/cryfs/impl/filesystem/fsblobstore/FsBlobStore.cpp @@ -54,7 +54,8 @@ boost::optional> FsBlobStore::load(const blockstore::BlockId return fsBlobStore; } - + + // NOLINTNEXTLINE(misc-no-recursion) void FsBlobStore::_migrate(unique_ref node, const blockstore::BlockId &parentId, SignalCatcher* signalCatcher, std::function perBlobCallback) { FsBlobView::migrate(node.get(), parentId); perBlobCallback(node->numNodes()); diff --git a/src/stats/main.cpp b/src/stats/main.cpp index ef043cc5..1f2c8c83 100644 --- a/src/stats/main.cpp +++ b/src/stats/main.cpp @@ -102,7 +102,7 @@ private: size_t _numBlocks; }; -std::vector _getKnownBlobIds(const path& basedir, const CryConfigLoader::ConfigLoadResult& config, LocalStateDir& localStateDir) { +std::vector getKnownBlobIds(const path& basedir, const CryConfigLoader::ConfigLoadResult& config, LocalStateDir& localStateDir) { auto blockStore = makeBlockStore(basedir, config, localStateDir); auto fsBlobStore = make_unique_ref(make_unique_ref(std::move(blockStore), config.configFile->config()->BlocksizeBytes())); @@ -116,8 +116,8 @@ std::vector _getKnownBlobIds(const path& basedir, const CryConfigLoader return knownBlobIds.blockIds(); } -std::vector _getKnownBlockIds(const path& basedir, const CryConfigLoader::ConfigLoadResult& config, LocalStateDir& localStateDir) { - auto knownBlobIds = _getKnownBlobIds(basedir, config, localStateDir); +std::vector 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(std::move(blockStore), config.configFile->config()->BlocksizeBytes()); @@ -135,7 +135,7 @@ std::vector _getKnownBlockIds(const path& basedir, const CryConfigLoade return knownBlockIds.blockIds(); } -set _getAllBlockIds(const path& basedir, const CryConfigLoader::ConfigLoadResult& config, LocalStateDir& localStateDir) { +set 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 unaccountedBlocks = _getAllBlockIds(basedir, config.right(), localStateDir); + set unaccountedBlocks = getAllBlockIds(basedir, config.right(), localStateDir); cout << "done" << endl; - vector accountedBlocks = _getKnownBlockIds(basedir, config.right(), localStateDir); + vector 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."); diff --git a/src/stats/traversal.cpp b/src/stats/traversal.cpp index a33dc363..0861030f 100644 --- a/src/stats/traversal.cpp +++ b/src/stats/traversal.cpp @@ -24,6 +24,7 @@ void forEachBlock(BlockStore* blockStore, const vector>& 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>& callbacks) { for (const auto& callback : callbacks) { callback(rootId); diff --git a/test/blobstore/implementations/onblocks/datatreestore/DataTreeTest_ResizeByTraversing.cpp b/test/blobstore/implementations/onblocks/datatreestore/DataTreeTest_ResizeByTraversing.cpp index 392827f5..26f8b9bf 100644 --- a/test/blobstore/implementations/onblocks/datatreestore/DataTreeTest_ResizeByTraversing.cpp +++ b/test/blobstore/implementations/onblocks/datatreestore/DataTreeTest_ResizeByTraversing.cpp @@ -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(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(root.get()); @@ -118,6 +120,7 @@ public: tree->flush(); } + // NOLINTNEXTLINE(misc-no-recursion) unique_ref LastLeaf(const BlockId &blockId) { auto root = nodeStore->load(blockId).value(); auto leaf = dynamic_pointer_move(root); diff --git a/test/blobstore/implementations/onblocks/datatreestore/DataTreeTest_ResizeNumBytes.cpp b/test/blobstore/implementations/onblocks/datatreestore/DataTreeTest_ResizeNumBytes.cpp index 6cae8b88..a3d4e763 100644 --- a/test/blobstore/implementations/onblocks/datatreestore/DataTreeTest_ResizeNumBytes.cpp +++ b/test/blobstore/implementations/onblocks/datatreestore/DataTreeTest_ResizeNumBytes.cpp @@ -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(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(root.get()); @@ -107,6 +109,7 @@ public: treeStore.load(blockId).get()->resizeNumBytes(size); } + // NOLINTNEXTLINE(misc-no-recursion) unique_ref LastLeaf(const BlockId &blockId) { auto root = nodeStore->load(blockId).value(); auto leaf = dynamic_pointer_move(root); diff --git a/test/blobstore/implementations/onblocks/datatreestore/LeafTraverserTest.cpp b/test/blobstore/implementations/onblocks/datatreestore/LeafTraverserTest.cpp index 0b3c8a93..966e3d53 100644 --- a/test/blobstore/implementations/onblocks/datatreestore/LeafTraverserTest.cpp +++ b/test/blobstore/implementations/onblocks/datatreestore/LeafTraverserTest.cpp @@ -2,7 +2,6 @@ #include #include -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 root, uint32_t beginIndex, uint32_t endIndex, bool expectReadOnly) { diff --git a/test/blobstore/implementations/onblocks/datatreestore/testutils/DataTreeTest.cpp b/test/blobstore/implementations/onblocks/datatreestore/testutils/DataTreeTest.cpp index 4f54a6df..e3436fba 100644 --- a/test/blobstore/implementations/onblocks/datatreestore/testutils/DataTreeTest.cpp +++ b/test/blobstore/implementations/onblocks/datatreestore/testutils/DataTreeTest.cpp @@ -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); diff --git a/test/blobstore/implementations/onblocks/datatreestore/testutils/TwoLevelDataFixture.h b/test/blobstore/implementations/onblocks/datatreestore/testutils/TwoLevelDataFixture.h index fd59a231..f757853c 100644 --- a/test/blobstore/implementations/onblocks/datatreestore/testutils/TwoLevelDataFixture.h +++ b/test/blobstore/implementations/onblocks/datatreestore/testutils/TwoLevelDataFixture.h @@ -39,6 +39,7 @@ public: } private: + // NOLINTNEXTLINE(misc-no-recursion) int ForEachLeaf(blobstore::onblocks::datanodestore::DataNode *node, int firstLeafIndex, int endLeafIndex, std::function action) { if (firstLeafIndex == endLeafIndex) { return firstLeafIndex; diff --git a/test/blockstore/implementations/encrypted/EncryptedBlockStoreTest_Specific.cpp b/test/blockstore/implementations/encrypted/EncryptedBlockStoreTest_Specific.cpp index 840532f7..28101a56 100644 --- a/test/blockstore/implementations/encrypted/EncryptedBlockStoreTest_Specific.cpp +++ b/test/blockstore/implementations/encrypted/EncryptedBlockStoreTest_Specific.cpp @@ -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); } diff --git a/test/blockstore/interface/BlockStore2Test.cpp b/test/blockstore/interface/BlockStore2Test.cpp index 65ad93e1..d11230a3 100644 --- a/test/blockstore/interface/BlockStore2Test.cpp +++ b/test/blockstore/interface/BlockStore2Test.cpp @@ -4,7 +4,6 @@ #include 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; diff --git a/test/blockstore/interface/BlockStoreTest.cpp b/test/blockstore/interface/BlockStoreTest.cpp index 5cacde5e..65f375d8 100644 --- a/test/blockstore/interface/BlockStoreTest.cpp +++ b/test/blockstore/interface/BlockStoreTest.cpp @@ -5,7 +5,6 @@ #include using ::testing::Test; -using ::testing::_; using ::testing::Return; using ::testing::Invoke; using ::testing::Eq; @@ -74,28 +73,28 @@ const Action>(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(make_unique_ref())); @@ -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; diff --git a/test/cpp-utils/assert/assert_debug_test.cpp b/test/cpp-utils/assert/assert_debug_test.cpp index 379ee97b..9e3a2220 100644 --- a/test/cpp-utils/assert/assert_debug_test.cpp +++ b/test/cpp-utils/assert/assert_debug_test.cpp @@ -2,7 +2,7 @@ #include #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"), diff --git a/test/cpp-utils/assert/assert_release_test.cpp b/test/cpp-utils/assert/assert_release_test.cpp index 2aa0b6ee..5dd73824 100644 --- a/test/cpp-utils/assert/assert_release_test.cpp +++ b/test/cpp-utils/assert/assert_release_test.cpp @@ -3,7 +3,7 @@ #include #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"); diff --git a/test/cpp-utils/crypto/kdf/SCryptParametersTest.cpp b/test/cpp-utils/crypto/kdf/SCryptParametersTest.cpp index 619efbc6..e4353593 100644 --- a/test/cpp-utils/crypto/kdf/SCryptParametersTest.cpp +++ b/test/cpp-utils/crypto/kdf/SCryptParametersTest.cpp @@ -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) { diff --git a/test/cpp-utils/crypto/kdf/SCryptTest.cpp b/test/cpp-utils/crypto/kdf/SCryptTest.cpp index 9e3f1728..4cdfffe2 100644 --- a/test/cpp-utils/crypto/kdf/SCryptTest.cpp +++ b/test/cpp-utils/crypto/kdf/SCryptTest.cpp @@ -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()); } diff --git a/test/cpp-utils/data/DataTest.cpp b/test/cpp-utils/data/DataTest.cpp index 77ca8779..76d1b53d 100644 --- a/test/cpp-utils/data/DataTest.cpp +++ b/test/cpp-utils/data/DataTest.cpp @@ -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(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(5, std::move(allocator)); Data data2(3); diff --git a/test/cryfs-cli/CliTest_IntegrityCheck.cpp b/test/cryfs-cli/CliTest_IntegrityCheck.cpp index 762caa6a..4ac5c30c 100644 --- a/test/cryfs-cli/CliTest_IntegrityCheck.cpp +++ b/test/cryfs-cli/CliTest_IntegrityCheck.cpp @@ -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"); diff --git a/test/cryfs-cli/CliTest_WrongEnvironment.cpp b/test/cryfs-cli/CliTest_WrongEnvironment.cpp index 1f80f08d..7fe5fd09 100644 --- a/test/cryfs-cli/CliTest_WrongEnvironment.cpp +++ b/test/cryfs-cli/CliTest_WrongEnvironment.cpp @@ -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())); } diff --git a/test/cryfs/impl/config/CryCipherTest.cpp b/test/cryfs/impl/config/CryCipherTest.cpp index 786a72ea..9c54e225 100644 --- a/test/cryfs/impl/config/CryCipherTest.cpp +++ b/test/cryfs/impl/config/CryCipherTest.cpp @@ -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(actualCipher, encKey, std::move(dataFixture)); + EXPECT_ENCRYPTS_WITH_ACTUAL_BLOCKSTORE_DECRYPTS_CORRECTLY_WITH_EXPECTED_BLOCKSTORE_(actualCipher, encKey, std::move(dataFixture)); } template - 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(encKey, blockId, std::move(encrypted)); diff --git a/test/cryfs/impl/config/CryConfigConsoleTest.cpp b/test/cryfs/impl/config/CryConfigConsoleTest.cpp index ea4bc50c..9d684732 100644 --- a/test/cryfs/impl/config/CryConfigConsoleTest.cpp +++ b/test/cryfs/impl/config/CryConfigConsoleTest.cpp @@ -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 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)); } }; diff --git a/test/cryfs/impl/config/CryConfigCreatorTest.cpp b/test/cryfs/impl/config/CryConfigCreatorTest.cpp index ee6b28f5..eeb42c5a 100644 --- a/test/cryfs/impl/config/CryConfigCreatorTest.cpp +++ b/test/cryfs/impl/config/CryConfigCreatorTest.cpp @@ -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(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> console; cpputils::TempDir tempLocalStateDir; diff --git a/test/cryfs/impl/config/CryConfigLoaderTest.cpp b/test/cryfs/impl/config/CryConfigLoaderTest.cpp index 6c5fc618..ec1ea1f4 100644 --- a/test/cryfs/impl/config/CryConfigLoaderTest.cpp +++ b/test/cryfs/impl/config/CryConfigLoaderTest.cpp @@ -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); diff --git a/test/cryfs/impl/config/CryPasswordBasedKeyProviderTest.cpp b/test/cryfs/impl/config/CryPasswordBasedKeyProviderTest.cpp index d553fe90..2bcde410 100644 --- a/test/cryfs/impl/config/CryPasswordBasedKeyProviderTest.cpp +++ b/test/cryfs/impl/config/CryPasswordBasedKeyProviderTest.cpp @@ -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; })); diff --git a/test/cryfs/impl/config/CryPresetPasswordBasedKeyProviderTest.cpp b/test/cryfs/impl/config/CryPresetPasswordBasedKeyProviderTest.cpp index a5f0da20..b8b7a9d2 100644 --- a/test/cryfs/impl/config/CryPresetPasswordBasedKeyProviderTest.cpp +++ b/test/cryfs/impl/config/CryPresetPasswordBasedKeyProviderTest.cpp @@ -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(); 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; })); diff --git a/test/fspp/fuse/access/FuseAccessErrorTest.cpp b/test/fspp/fuse/access/FuseAccessErrorTest.cpp index 4e804c0c..e2b47de4 100644 --- a/test/fspp/fuse/access/FuseAccessErrorTest.cpp +++ b/test/fspp/fuse/access/FuseAccessErrorTest.cpp @@ -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); diff --git a/test/fspp/fuse/access/FuseAccessFilenameTest.cpp b/test/fspp/fuse/access/FuseAccessFilenameTest.cpp index 67d6f053..517dc6d2 100644 --- a/test/fspp/fuse/access/FuseAccessFilenameTest.cpp +++ b/test/fspp/fuse/access/FuseAccessFilenameTest.cpp @@ -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); diff --git a/test/fspp/fuse/closeFile/FuseCloseTest.cpp b/test/fspp/fuse/closeFile/FuseCloseTest.cpp index f3291691..80899ef3 100644 --- a/test/fspp/fuse/closeFile/FuseCloseTest.cpp +++ b/test/fspp/fuse/closeFile/FuseCloseTest.cpp @@ -2,6 +2,10 @@ #include "../../testutils/OpenFileHandle.h" #include +//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 { public: const string FILENAME = "/myfile"; diff --git a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenErrorTest.cpp b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenErrorTest.cpp index c251626c..6310301c 100644 --- a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenErrorTest.cpp +++ b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenErrorTest.cpp @@ -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); diff --git a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp index 4be910aa..ea931563 100644 --- a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp +++ b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp @@ -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)); diff --git a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFilenameTest.cpp b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFilenameTest.cpp index dfbe7e61..aa3f9ecd 100644 --- a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFilenameTest.cpp +++ b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFilenameTest.cpp @@ -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); diff --git a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFlagsTest.cpp b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFlagsTest.cpp index 77bf8b23..d5a516bb 100644 --- a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFlagsTest.cpp +++ b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFlagsTest.cpp @@ -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 { }; INSTANTIATE_TEST_SUITE_P(FuseCreateAndOpenFlagsTest, FuseCreateAndOpenFlagsTest, Values(O_RDWR, O_RDONLY, O_WRONLY)); diff --git a/test/fspp/fuse/flush/FuseFlushErrorTest.cpp b/test/fspp/fuse/flush/FuseFlushErrorTest.cpp index d7e80e74..bfa7626d 100644 --- a/test/fspp/fuse/flush/FuseFlushErrorTest.cpp +++ b/test/fspp/fuse/flush/FuseFlushErrorTest.cpp @@ -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(); diff --git a/test/fspp/fuse/flush/FuseFlushFileDescriptorTest.cpp b/test/fspp/fuse/flush/FuseFlushFileDescriptorTest.cpp index 23d0f3fc..7ec4c1a5 100644 --- a/test/fspp/fuse/flush/FuseFlushFileDescriptorTest.cpp +++ b/test/fspp/fuse/flush/FuseFlushFileDescriptorTest.cpp @@ -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); diff --git a/test/fspp/fuse/fstat/FuseFstatErrorTest.cpp b/test/fspp/fuse/fstat/FuseFstatErrorTest.cpp index ddd08310..8b75abe5 100644 --- a/test/fspp/fuse/fstat/FuseFstatErrorTest.cpp +++ b/test/fspp/fuse/fstat/FuseFstatErrorTest.cpp @@ -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(); diff --git a/test/fspp/fuse/fstat/FuseFstatParameterTest.cpp b/test/fspp/fuse/fstat/FuseFstatParameterTest.cpp index 2d217fa6..9009f8d2 100644 --- a/test/fspp/fuse/fstat/FuseFstatParameterTest.cpp +++ b/test/fspp/fuse/fstat/FuseFstatParameterTest.cpp @@ -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); } diff --git a/test/fspp/fuse/fstat/testutils/FuseFstatTest.cpp b/test/fspp/fuse/fstat/testutils/FuseFstatTest.cpp index 5efe488b..6d4b320a 100644 --- a/test/fspp/fuse/fstat/testutils/FuseFstatTest.cpp +++ b/test/fspp/fuse/fstat/testutils/FuseFstatTest.cpp @@ -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 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)); } diff --git a/test/fspp/fuse/ftruncate/FuseFTruncateErrorTest.cpp b/test/fspp/fuse/ftruncate/FuseFTruncateErrorTest.cpp index 587293e6..5832c489 100644 --- a/test/fspp/fuse/ftruncate/FuseFTruncateErrorTest.cpp +++ b/test/fspp/fuse/ftruncate/FuseFTruncateErrorTest.cpp @@ -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); diff --git a/test/fspp/fuse/ftruncate/FuseFTruncateFileDescriptorTest.cpp b/test/fspp/fuse/ftruncate/FuseFTruncateFileDescriptorTest.cpp index 673a82cb..93f723e8 100644 --- a/test/fspp/fuse/ftruncate/FuseFTruncateFileDescriptorTest.cpp +++ b/test/fspp/fuse/ftruncate/FuseFTruncateFileDescriptorTest.cpp @@ -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()); diff --git a/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp b/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp index 25201f11..f6dd299b 100644 --- a/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp +++ b/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp @@ -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); } diff --git a/test/fspp/fuse/lstat/FuseLstatPathParameterTest.cpp b/test/fspp/fuse/lstat/FuseLstatPathParameterTest.cpp index bb7169ef..c6ad885a 100644 --- a/test/fspp/fuse/lstat/FuseLstatPathParameterTest.cpp +++ b/test/fspp/fuse/lstat/FuseLstatPathParameterTest.cpp @@ -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/"); } diff --git a/test/fspp/fuse/lstat/testutils/FuseLstatTest.cpp b/test/fspp/fuse/lstat/testutils/FuseLstatTest.cpp index a118bbda..d0246eba 100644 --- a/test/fspp/fuse/lstat/testutils/FuseLstatTest.cpp +++ b/test/fspp/fuse/lstat/testutils/FuseLstatTest.cpp @@ -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 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); })); diff --git a/test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp b/test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp index 7f016d28..c09bc6f4 100644 --- a/test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp +++ b/test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp @@ -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()); diff --git a/test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp b/test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp index 6919df3e..e4cb487c 100644 --- a/test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp +++ b/test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp @@ -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); diff --git a/test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp b/test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp index a35e712c..31b0c45f 100644 --- a/test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp +++ b/test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp @@ -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()); diff --git a/test/fspp/fuse/openFile/FuseOpenErrorTest.cpp b/test/fspp/fuse/openFile/FuseOpenErrorTest.cpp index 13ae60da..ac08f060 100644 --- a/test/fspp/fuse/openFile/FuseOpenErrorTest.cpp +++ b/test/fspp/fuse/openFile/FuseOpenErrorTest.cpp @@ -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); } diff --git a/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp b/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp index 51f1f139..f4ddfa92 100644 --- a/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp +++ b/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp @@ -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); } diff --git a/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp b/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp index f1ab83f8..a09a3f20 100644 --- a/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp +++ b/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp @@ -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); diff --git a/test/fspp/fuse/read/FuseReadErrorTest.cpp b/test/fspp/fuse/read/FuseReadErrorTest.cpp index f9e34986..3772a1c1 100644 --- a/test/fspp/fuse/read/FuseReadErrorTest.cpp +++ b/test/fspp/fuse/read/FuseReadErrorTest.cpp @@ -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()]; diff --git a/test/fspp/fuse/read/FuseReadFileDescriptorTest.cpp b/test/fspp/fuse/read/FuseReadFileDescriptorTest.cpp index 0c54c795..1a5d8d39 100644 --- a/test/fspp/fuse/read/FuseReadFileDescriptorTest.cpp +++ b/test/fspp/fuse/read/FuseReadFileDescriptorTest.cpp @@ -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 buf{}; diff --git a/test/fspp/fuse/read/FuseReadOverflowTest.cpp b/test/fspp/fuse/read/FuseReadOverflowTest.cpp index 54f33f64..ef39f6fe 100644 --- a/test/fspp/fuse/read/FuseReadOverflowTest.cpp +++ b/test/fspp/fuse/read/FuseReadOverflowTest.cpp @@ -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)); } }; diff --git a/test/fspp/fuse/read/FuseReadReturnedDataTest.cpp b/test/fspp/fuse/read/FuseReadReturnedDataTest.cpp index 63f0cdd0..54d3ed28 100644 --- a/test/fspp/fuse/read/FuseReadReturnedDataTest.cpp +++ b/test/fspp/fuse/read/FuseReadReturnedDataTest.cpp @@ -9,7 +9,6 @@ #include #include -using ::testing::_; using ::testing::WithParamInterface; using ::testing::Values; using ::testing::Combine; @@ -52,7 +51,7 @@ public: testFile = std::make_unique(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); } diff --git a/test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp b/test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp index d30c827c..0ef53749 100644 --- a/test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp +++ b/test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp @@ -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); } diff --git a/test/fspp/fuse/statfs/testutils/FuseStatfsTest.cpp b/test/fspp/fuse/statfs/testutils/FuseStatfsTest.cpp index fe00807b..651c85d0 100644 --- a/test/fspp/fuse/statfs/testutils/FuseStatfsTest.cpp +++ b/test/fspp/fuse/statfs/testutils/FuseStatfsTest.cpp @@ -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 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); })); diff --git a/test/fspp/fuse/truncate/FuseTruncateErrorTest.cpp b/test/fspp/fuse/truncate/FuseTruncateErrorTest.cpp index 6b7673d0..65048974 100644 --- a/test/fspp/fuse/truncate/FuseTruncateErrorTest.cpp +++ b/test/fspp/fuse/truncate/FuseTruncateErrorTest.cpp @@ -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)); diff --git a/test/fspp/fuse/truncate/FuseTruncateFilenameTest.cpp b/test/fspp/fuse/truncate/FuseTruncateFilenameTest.cpp index 1201da9a..54508d4a 100644 --- a/test/fspp/fuse/truncate/FuseTruncateFilenameTest.cpp +++ b/test/fspp/fuse/truncate/FuseTruncateFilenameTest.cpp @@ -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)); diff --git a/test/fspp/fuse/utimens/FuseUtimensErrorTest.cpp b/test/fspp/fuse/utimens/FuseUtimensErrorTest.cpp index 5704f2ce..ad6732fb 100644 --- a/test/fspp/fuse/utimens/FuseUtimensErrorTest.cpp +++ b/test/fspp/fuse/utimens/FuseUtimensErrorTest.cpp @@ -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); diff --git a/test/fspp/fuse/utimens/FuseUtimensFilenameTest.cpp b/test/fspp/fuse/utimens/FuseUtimensFilenameTest.cpp index 9f686823..95885b17 100644 --- a/test/fspp/fuse/utimens/FuseUtimensFilenameTest.cpp +++ b/test/fspp/fuse/utimens/FuseUtimensFilenameTest.cpp @@ -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); diff --git a/test/fspp/fuse/write/FuseWriteDataTest.cpp b/test/fspp/fuse/write/FuseWriteDataTest.cpp index ac857bcd..29c3b827 100644 --- a/test/fspp/fuse/write/FuseWriteDataTest.cpp +++ b/test/fspp/fuse/write/FuseWriteDataTest.cpp @@ -7,7 +7,6 @@ #include #include -using ::testing::_; using ::testing::WithParamInterface; using ::testing::Values; using ::testing::Combine; @@ -49,7 +48,7 @@ public: testFile = std::make_unique(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); } diff --git a/test/fspp/fuse/write/FuseWriteErrorTest.cpp b/test/fspp/fuse/write/FuseWriteErrorTest.cpp index 88f772bd..932f384e 100644 --- a/test/fspp/fuse/write/FuseWriteErrorTest.cpp +++ b/test/fspp/fuse/write/FuseWriteErrorTest.cpp @@ -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()]; diff --git a/test/fspp/fuse/write/FuseWriteFileDescriptorTest.cpp b/test/fspp/fuse/write/FuseWriteFileDescriptorTest.cpp index 6b91892b..714a3876 100644 --- a/test/fspp/fuse/write/FuseWriteFileDescriptorTest.cpp +++ b/test/fspp/fuse/write/FuseWriteFileDescriptorTest.cpp @@ -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 buf{}; diff --git a/test/fspp/fuse/write/FuseWriteOverflowTest.cpp b/test/fspp/fuse/write/FuseWriteOverflowTest.cpp index d81da83f..73943b82 100644 --- a/test/fspp/fuse/write/FuseWriteOverflowTest.cpp +++ b/test/fspp/fuse/write/FuseWriteOverflowTest.cpp @@ -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. diff --git a/test/fspp/testutils/FuseTest.cpp b/test/fspp/testutils/FuseTest.cpp index fed165a2..ba44a1e0 100644 --- a/test/fspp/testutils/FuseTest.cpp +++ b/test/fspp/testutils/FuseTest.cpp @@ -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()), _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 FuseTest::Return Action 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)); } diff --git a/test/fspp/testutils/FuseTest.h b/test/fspp/testutils/FuseTest.h index c4075d0f..8430182f 100644 --- a/test/fspp/testutils/FuseTest.h +++ b/test/fspp/testutils/FuseTest.h @@ -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 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 ReturnIsFile; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + static ::testing::Action ReturnIsFileWithSize(fspp::num_bytes_t size); // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + static ::testing::Action ReturnIsFileFstat; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + static ::testing::Action ReturnIsFileFstatWithSize(fspp::num_bytes_t size); // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + static ::testing::Action ReturnIsDir; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + static ::testing::Action 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); diff --git a/test/my-gtest-main/my-gtest-main.cpp b/test/my-gtest-main/my-gtest-main.cpp index c526e1a4..91d2d942 100644 --- a/test/my-gtest-main/my-gtest-main.cpp +++ b/test/my-gtest-main/my-gtest-main.cpp @@ -7,6 +7,7 @@ #include namespace { + // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) boost::optional executable; }