From 449133e3dac9836ddf9e8b11ca65b1d1470b96e0 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Mon, 3 Dec 2018 01:57:21 -0500 Subject: [PATCH] - Allow callback when fuse filesystem is mounted - Use that callback to initialize the file system instead of initializing it up front --- src/cryfs-cli/Cli.cpp | 42 ++++--- src/cryfs-cli/Cli.h | 2 + src/fspp/fuse/Fuse.cpp | 12 +- src/fspp/fuse/Fuse.h | 5 +- src/fspp/fuse/InvalidFilesystem.h | 110 ++++++++++++++++++ src/fspp/impl/FilesystemImpl.cpp | 4 +- src/fspp/impl/FilesystemImpl.h | 4 +- test/fspp/fuse/access/FuseAccessErrorTest.cpp | 2 +- .../fuse/access/FuseAccessFilenameTest.cpp | 6 +- test/fspp/fuse/access/FuseAccessModeTest.cpp | 2 +- test/fspp/fuse/closeFile/FuseCloseTest.cpp | 6 +- .../FuseCreateAndOpenErrorTest.cpp | 4 +- .../FuseCreateAndOpenFileDescriptorTest.cpp | 4 +- .../FuseCreateAndOpenFilenameTest.cpp | 6 +- .../FuseCreateAndOpenFlagsTest.cpp | 2 +- .../fuse/fdatasync/FuseFdatasyncErrorTest.cpp | 2 +- .../FuseFdatasyncFileDescriptorTest.cpp | 2 +- test/fspp/fuse/flush/FuseFlushErrorTest.cpp | 4 +- .../flush/FuseFlushFileDescriptorTest.cpp | 4 +- test/fspp/fuse/fstat/FuseFstatErrorTest.cpp | 2 +- .../fuse/fstat/FuseFstatParameterTest.cpp | 2 +- .../fuse/fstat/testutils/FuseFstatTest.cpp | 2 +- test/fspp/fuse/fsync/FuseFsyncErrorTest.cpp | 2 +- .../fsync/FuseFsyncFileDescriptorTest.cpp | 2 +- .../fuse/ftruncate/FuseFTruncateErrorTest.cpp | 2 +- .../FuseFTruncateFileDescriptorTest.cpp | 2 +- .../fuse/ftruncate/FuseFTruncateSizeTest.cpp | 2 +- test/fspp/fuse/lstat/FuseLstatErrorTest.cpp | 4 +- .../fuse/lstat/FuseLstatPathParameterTest.cpp | 10 +- .../fuse/lstat/testutils/FuseLstatTest.cpp | 2 +- test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp | 6 +- test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp | 4 +- test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp | 2 +- test/fspp/fuse/openFile/FuseOpenErrorTest.cpp | 4 +- .../openFile/FuseOpenFileDescriptorTest.cpp | 4 +- .../fuse/openFile/FuseOpenFilenameTest.cpp | 6 +- test/fspp/fuse/openFile/FuseOpenFlagsTest.cpp | 2 +- test/fspp/fuse/read/FuseReadErrorTest.cpp | 6 +- .../fuse/read/FuseReadFileDescriptorTest.cpp | 2 +- test/fspp/fuse/read/FuseReadOverflowTest.cpp | 2 +- .../fuse/read/FuseReadReturnedDataTest.cpp | 2 +- .../fuse/readDir/FuseReadDirDirnameTest.cpp | 8 +- .../fuse/readDir/FuseReadDirErrorTest.cpp | 4 +- .../fuse/readDir/FuseReadDirReturnTest.cpp | 2 +- test/fspp/fuse/rename/FuseRenameErrorTest.cpp | 2 +- .../fuse/rename/FuseRenameFilenameTest.cpp | 24 ++-- test/fspp/fuse/rmdir/FuseRmdirDirnameTest.cpp | 6 +- test/fspp/fuse/rmdir/FuseRmdirErrorTest.cpp | 2 +- test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp | 4 +- .../fuse/statfs/testutils/FuseStatfsTest.cpp | 2 +- .../fuse/truncate/FuseTruncateErrorTest.cpp | 2 +- .../truncate/FuseTruncateFilenameTest.cpp | 6 +- .../fuse/truncate/FuseTruncateSizeTest.cpp | 2 +- test/fspp/fuse/unlink/FuseUnlinkErrorTest.cpp | 2 +- .../fuse/unlink/FuseUnlinkFilenameTest.cpp | 6 +- .../fuse/utimens/FuseUtimensErrorTest.cpp | 2 +- .../fuse/utimens/FuseUtimensFilenameTest.cpp | 12 +- .../utimens/FuseUtimensTimeParameterTest.cpp | 2 +- test/fspp/fuse/write/FuseWriteDataTest.cpp | 2 +- test/fspp/fuse/write/FuseWriteErrorTest.cpp | 6 +- .../write/FuseWriteFileDescriptorTest.cpp | 2 +- .../fspp/fuse/write/FuseWriteOverflowTest.cpp | 2 +- test/fspp/testutils/FuseTest.cpp | 74 ++++++------ test/fspp/testutils/FuseTest.h | 4 +- 64 files changed, 301 insertions(+), 172 deletions(-) create mode 100644 src/fspp/fuse/InvalidFilesystem.h diff --git a/src/cryfs-cli/Cli.cpp b/src/cryfs-cli/Cli.cpp index 15e6186a..88cade03 100644 --- a/src/cryfs-cli/Cli.cpp +++ b/src/cryfs-cli/Cli.cpp @@ -67,8 +67,8 @@ using gitversion::VersionCompare; namespace cryfs { - Cli::Cli(RandomGenerator &keyGenerator, const SCryptSettings& scryptSettings, shared_ptr console): - _keyGenerator(keyGenerator), _scryptSettings(scryptSettings), _console(), _noninteractive(false) { + Cli::Cli(RandomGenerator &keyGenerator, const SCryptSettings &scryptSettings, shared_ptr console): + _keyGenerator(keyGenerator), _scryptSettings(scryptSettings), _console(), _noninteractive(false), _idleUnmounter(none), _device(none) { _noninteractive = Environment::isNoninteractive(); if (_noninteractive) { _console = make_shared(console); @@ -221,23 +221,29 @@ namespace cryfs { void Cli::_runFilesystem(const ProgramOptions &options) { try { - LocalStateDir localStateDir(Environment::localStateDir()); - auto blockStore = make_unique_ref(options.baseDir()); - auto config = _loadOrCreateConfig(options, localStateDir); - CryDevice device(std::move(config.configFile), std::move(blockStore), std::move(localStateDir), config.myClientId, - options.allowIntegrityViolations(), config.configFile.config()->missingBlockIsIntegrityViolation()); - _sanityCheckFilesystem(&device); - fspp::FilesystemImpl fsimpl(&device); - fspp::fuse::Fuse fuse(&fsimpl, "cryfs", "cryfs@" + options.baseDir().string()); + LocalStateDir localStateDir(Environment::localStateDir()); + auto blockStore = make_unique_ref(options.baseDir()); + auto config = _loadOrCreateConfig(options, localStateDir); + const bool missingBlockIsIntegrityViolation = config.configFile.config()->missingBlockIsIntegrityViolation(); + _device = optional>(make_unique_ref(std::move(config.configFile), std::move(blockStore), std::move(localStateDir), config.myClientId, + options.allowIntegrityViolations(), missingBlockIsIntegrityViolation)); + _sanityCheckFilesystem(_device->get()); - _initLogfile(options); + auto initFilesystem = [this, &options] (fspp::fuse::Fuse *fuse){ + ASSERT(_device != none, "File system not ready to be initialized. Was it already initialized before?"); - //TODO Test auto unmounting after idle timeout - //TODO This can fail due to a race condition if the filesystem isn't started yet (e.g. passing --unmount-idle 0"). - auto idleUnmounter = _createIdleCallback(options.unmountAfterIdleMinutes(), [&fuse] { fuse.stop(); }); - if (idleUnmounter != none) { - device.onFsAction(std::bind(&CallAfterTimeout::resetTimer, idleUnmounter->get())); - } + //TODO Test auto unmounting after idle timeout + _idleUnmounter = _createIdleCallback(options.unmountAfterIdleMinutes(), [fuse] {fuse->stop();}); + if (_idleUnmounter != none) { + (*_device)->onFsAction(std::bind(&CallAfterTimeout::resetTimer, _idleUnmounter->get())); + } + + return make_shared(std::move(*_device)); + }; + + auto fuse = make_unique_ref(initFilesystem, "cryfs", "cryfs@" + options.baseDir().string()); + + _initLogfile(options); #ifdef __APPLE__ std::cout << "\nMounting filesystem. To unmount, call:\n$ umount " << options.mountDir() << "\n" << std::endl; @@ -245,7 +251,7 @@ namespace cryfs { std::cout << "\nMounting filesystem. To unmount, call:\n$ fusermount -u " << options.mountDir() << "\n" << std::endl; #endif - fuse.run(options.mountDir(), options.fuseOptions()); + fuse->run(options.mountDir(), options.fuseOptions()); } catch (const CryfsException &e) { throw; // CryfsException is only thrown if setup goes wrong. Throw it through so that we get the correct process exit code. } catch (const std::exception &e) { diff --git a/src/cryfs-cli/Cli.h b/src/cryfs-cli/Cli.h index 433a8a3b..b5f70388 100644 --- a/src/cryfs-cli/Cli.h +++ b/src/cryfs-cli/Cli.h @@ -48,6 +48,8 @@ namespace cryfs { cpputils::SCryptSettings _scryptSettings; std::shared_ptr _console; bool _noninteractive; + boost::optional> _idleUnmounter; + boost::optional> _device; DISALLOW_COPY_AND_ASSIGN(Cli); }; diff --git a/src/fspp/fuse/Fuse.cpp b/src/fspp/fuse/Fuse.cpp index 4ab62c43..769b0351 100644 --- a/src/fspp/fuse/Fuse.cpp +++ b/src/fspp/fuse/Fuse.cpp @@ -8,12 +8,15 @@ #include #include #include +#include "InvalidFilesystem.h" using std::vector; using std::string; namespace bf = boost::filesystem; using namespace cpputils::logging; +using std::make_shared; +using std::shared_ptr; using namespace fspp::fuse; namespace { @@ -226,8 +229,8 @@ Fuse::~Fuse() { _argv.clear(); } -Fuse::Fuse(Filesystem *fs, std::string fstype, boost::optional fsname) - :_fs(fs), _mountdir(), _running(false), _fstype(std::move(fstype)), _fsname(std::move(fsname)) { +Fuse::Fuse(std::function (Fuse *fuse)> init, std::string fstype, boost::optional fsname) + :_init(std::move(init)), _fs(make_shared()), _mountdir(), _running(false), _fstype(std::move(fstype)), _fsname(std::move(fsname)) { } void Fuse::_logException(const std::exception &e) { @@ -717,7 +720,6 @@ int Fuse::write(const bf::path &path, const char *buf, size_t size, int64_t offs } } -//TODO int Fuse::statfs(const bf::path &path, struct ::statvfs *fsstat) { #ifdef FSPP_LOG LOG(DEBUG, "statfs({}, _)", path); @@ -859,6 +861,8 @@ int Fuse::fsyncdir(const bf::path &path, int datasync, fuse_file_info *fileinfo) void Fuse::init(fuse_conn_info *conn) { UNUSED(conn); + _fs = _init(this); + LOG(INFO, "Filesystem started."); _running = true; @@ -869,8 +873,10 @@ void Fuse::init(fuse_conn_info *conn) { } void Fuse::destroy() { + _fs = make_shared(); LOG(INFO, "Filesystem stopped."); _running = false; + cpputils::logging::logger()->flush(); } int Fuse::access(const bf::path &path, int mask) { diff --git a/src/fspp/fuse/Fuse.h b/src/fspp/fuse/Fuse.h index 0a2c5fdd..a140d846 100644 --- a/src/fspp/fuse/Fuse.h +++ b/src/fspp/fuse/Fuse.h @@ -21,7 +21,7 @@ class Filesystem; class Fuse final { public: - explicit Fuse(Filesystem *fs, std::string fstype, boost::optional fsname); + explicit Fuse(std::function (Fuse *fuse)> init, std::string fstype, boost::optional fsname); ~Fuse(); void run(const boost::filesystem::path &mountdir, const std::vector &fuseOptions); @@ -68,7 +68,8 @@ private: std::vector _build_argv(const boost::filesystem::path &mountdir, const std::vector &fuseOptions); void _add_fuse_option_if_not_exists(std::vector *argv, const std::string &key, const std::string &value); - Filesystem *_fs; + std::function (Fuse *fuse)> _init; + std::shared_ptr _fs; boost::filesystem::path _mountdir; std::vector _argv; std::atomic _running; diff --git a/src/fspp/fuse/InvalidFilesystem.h b/src/fspp/fuse/InvalidFilesystem.h new file mode 100644 index 00000000..8bc82f11 --- /dev/null +++ b/src/fspp/fuse/InvalidFilesystem.h @@ -0,0 +1,110 @@ +#pragma once +#ifndef MESSMER_FSPP_FUSE_INVALIDFILESYSTEM_H_ +#define MESSMER_FSPP_FUSE_INVALIDFILESYSTEM_H_ + +#include "Filesystem.h" + +namespace fspp { + namespace fuse { + class InvalidFilesystem final : public Filesystem { + int createAndOpenFile(const boost::filesystem::path &, ::mode_t , ::uid_t , ::gid_t ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + int openFile(const boost::filesystem::path &, int ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void flush(int ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void closeFile(int ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void lstat(const boost::filesystem::path &, fspp::fuse::STAT *) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void fstat(int , fspp::fuse::STAT *) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void chmod(const boost::filesystem::path &, ::mode_t ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void chown(const boost::filesystem::path &, ::uid_t , ::gid_t ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void truncate(const boost::filesystem::path &, fspp::num_bytes_t ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void ftruncate(int , fspp::num_bytes_t ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + fspp::num_bytes_t read(int , void *, fspp::num_bytes_t , fspp::num_bytes_t ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void write(int , const void *, fspp::num_bytes_t , fspp::num_bytes_t ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void fsync(int ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void fdatasync(int ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void access(const boost::filesystem::path &, int ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void mkdir(const boost::filesystem::path &, ::mode_t , ::uid_t , ::gid_t ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void rmdir(const boost::filesystem::path &) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void unlink(const boost::filesystem::path &) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void rename(const boost::filesystem::path &, const boost::filesystem::path &) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void utimens(const boost::filesystem::path &, timespec , timespec ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void statfs(struct ::statvfs *) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + cpputils::unique_ref> readDir(const boost::filesystem::path &) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void createSymlink(const boost::filesystem::path &, const boost::filesystem::path &, ::uid_t , ::gid_t ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + void readSymlink(const boost::filesystem::path &, char *, fspp::num_bytes_t ) override { + throw std::logic_error("Filesystem not initialized yet"); + } + + }; + } +} + +#endif diff --git a/src/fspp/impl/FilesystemImpl.cpp b/src/fspp/impl/FilesystemImpl.cpp index d6f15740..e32f8720 100644 --- a/src/fspp/impl/FilesystemImpl.cpp +++ b/src/fspp/impl/FilesystemImpl.cpp @@ -32,7 +32,7 @@ using namespace cpputils::logging; #define PROFILE(name) #endif -FilesystemImpl::FilesystemImpl(Device *device) +FilesystemImpl::FilesystemImpl(cpputils::unique_ref device) : #ifdef FSPP_PROFILE _loadFileNanosec(0), _loadDirNanosec(0), _loadSymlinkNanosec(0), _openFileNanosec(0), _flushNanosec(0), @@ -44,7 +44,7 @@ FilesystemImpl::FilesystemImpl(Device *device) _utimensNanosec(0), _statfsNanosec(0), _createSymlinkNanosec(0), _createSymlinkNanosec_withoutLoading(0), _readSymlinkNanosec(0), _readSymlinkNanosec_withoutLoading(0), #endif - _device(device), _open_files() + _device(std::move(device)), _open_files() { } diff --git a/src/fspp/impl/FilesystemImpl.h b/src/fspp/impl/FilesystemImpl.h index eaebd140..65927eee 100644 --- a/src/fspp/impl/FilesystemImpl.h +++ b/src/fspp/impl/FilesystemImpl.h @@ -21,7 +21,7 @@ class OpenFile; class FilesystemImpl final: public fuse::Filesystem { public: - explicit FilesystemImpl(Device *device); + explicit FilesystemImpl(cpputils::unique_ref device); virtual ~FilesystemImpl(); int openFile(const boost::filesystem::path &path, int flags) override; @@ -93,7 +93,7 @@ private: std::atomic _readSymlinkNanosec_withoutLoading; #endif - Device *_device; + cpputils::unique_ref _device; FuseOpenFileList _open_files; DISALLOW_COPY_AND_ASSIGN(FilesystemImpl); diff --git a/test/fspp/fuse/access/FuseAccessErrorTest.cpp b/test/fspp/fuse/access/FuseAccessErrorTest.cpp index 95ee0e2b..dad07268 100644 --- a/test/fspp/fuse/access/FuseAccessErrorTest.cpp +++ b/test/fspp/fuse/access/FuseAccessErrorTest.cpp @@ -17,7 +17,7 @@ INSTANTIATE_TEST_CASE_P(FuseAccessErrorTest, FuseAccessErrorTest, Values(EACCES, TEST_P(FuseAccessErrorTest, ReturnedErrorIsCorrect) { ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, access(StrEq(FILENAME), _)) + EXPECT_CALL(*fsimpl, access(StrEq(FILENAME), _)) .Times(AtLeast(1)).WillRepeatedly(Throw(FuseErrnoException(GetParam()))); int error = AccessFileReturnError(FILENAME, 0); diff --git a/test/fspp/fuse/access/FuseAccessFilenameTest.cpp b/test/fspp/fuse/access/FuseAccessFilenameTest.cpp index 751edf1e..418fa967 100644 --- a/test/fspp/fuse/access/FuseAccessFilenameTest.cpp +++ b/test/fspp/fuse/access/FuseAccessFilenameTest.cpp @@ -9,7 +9,7 @@ class FuseAccessFilenameTest: public FuseAccessTest { TEST_F(FuseAccessFilenameTest, AccessFile) { ReturnIsFileOnLstat("/myfile"); - EXPECT_CALL(fsimpl, access(StrEq("/myfile"), _)) + EXPECT_CALL(*fsimpl, access(StrEq("/myfile"), _)) .Times(1).WillOnce(Return()); AccessFile("/myfile", 0); @@ -18,7 +18,7 @@ TEST_F(FuseAccessFilenameTest, AccessFile) { TEST_F(FuseAccessFilenameTest, AccessFileNested) { ReturnIsDirOnLstat("/mydir"); ReturnIsFileOnLstat("/mydir/myfile"); - EXPECT_CALL(fsimpl, access(StrEq("/mydir/myfile"), _)) + EXPECT_CALL(*fsimpl, access(StrEq("/mydir/myfile"), _)) .Times(1).WillOnce(Return()); AccessFile("/mydir/myfile", 0); @@ -28,7 +28,7 @@ TEST_F(FuseAccessFilenameTest, AccessFileNested2) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); ReturnIsFileOnLstat("/mydir/mydir2/myfile"); - EXPECT_CALL(fsimpl, access(StrEq("/mydir/mydir2/myfile"), _)) + EXPECT_CALL(*fsimpl, access(StrEq("/mydir/mydir2/myfile"), _)) .Times(1).WillOnce(Return()); AccessFile("/mydir/mydir2/myfile", 0); diff --git a/test/fspp/fuse/access/FuseAccessModeTest.cpp b/test/fspp/fuse/access/FuseAccessModeTest.cpp index 316f6659..a5d1fd4c 100644 --- a/test/fspp/fuse/access/FuseAccessModeTest.cpp +++ b/test/fspp/fuse/access/FuseAccessModeTest.cpp @@ -12,7 +12,7 @@ INSTANTIATE_TEST_CASE_P(FuseAccessModeTest, FuseAccessModeTest, Values(0, F_OK, TEST_P(FuseAccessModeTest, AccessFile) { ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, access(StrEq(FILENAME), GetParam())) + EXPECT_CALL(*fsimpl, access(StrEq(FILENAME), GetParam())) .Times(1).WillOnce(Return()); AccessFile(FILENAME, GetParam()); diff --git a/test/fspp/fuse/closeFile/FuseCloseTest.cpp b/test/fspp/fuse/closeFile/FuseCloseTest.cpp index ae6ab205..eb60889c 100644 --- a/test/fspp/fuse/closeFile/FuseCloseTest.cpp +++ b/test/fspp/fuse/closeFile/FuseCloseTest.cpp @@ -79,11 +79,11 @@ INSTANTIATE_TEST_CASE_P(FuseCloseTest, FuseCloseTest, Values(0, 1, 2, 100, 1024* Barrier barrier; ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, openFile(StrEq(FILENAME), _)).WillOnce(Return(GetParam())); + EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), _)).WillOnce(Return(GetParam())); { //InSequence fileCloseSequence; - EXPECT_CALL(fsimpl, flush(Eq(GetParam()))).Times(1); - EXPECT_CALL(fsimpl, closeFile(Eq(GetParam()))).Times(1).WillOnce(Invoke([&barrier] (int) { + EXPECT_CALL(*fsimpl, flush(Eq(GetParam()))).Times(1); + EXPECT_CALL(*fsimpl, closeFile(Eq(GetParam()))).Times(1).WillOnce(Invoke([&barrier] (int) { // Release the waiting lock at the end of this test case, because the fuse release() came in now. barrier.Release(); })); diff --git a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenErrorTest.cpp b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenErrorTest.cpp index 838bf014..7212a33f 100644 --- a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenErrorTest.cpp +++ b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenErrorTest.cpp @@ -17,7 +17,7 @@ INSTANTIATE_TEST_CASE_P(FuseCreateAndOpenErrorTest, FuseCreateAndOpenErrorTest, TEST_F(FuseCreateAndOpenErrorTest, ReturnNoError) { ReturnDoesntExistOnLstat(FILENAME); - EXPECT_CALL(fsimpl, createAndOpenFile(StrEq(FILENAME), _, _, _)).Times(1).WillOnce(Return(1)); + EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq(FILENAME), _, _, _)).Times(1).WillOnce(Return(1)); //For the syscall to succeed, we also need to give an fstat implementation. ReturnIsFileOnFstat(1); @@ -27,7 +27,7 @@ TEST_F(FuseCreateAndOpenErrorTest, ReturnNoError) { TEST_P(FuseCreateAndOpenErrorTest, ReturnError) { ReturnDoesntExistOnLstat(FILENAME); - EXPECT_CALL(fsimpl, createAndOpenFile(StrEq(FILENAME), _, _, _)).Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); + EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq(FILENAME), _, _, _)).Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); int error = CreateAndOpenFileReturnError(FILENAME, O_RDONLY); EXPECT_EQ(GetParam(), error); diff --git a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp index 35f0708f..0b07ccf2 100644 --- a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp +++ b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFileDescriptorTest.cpp @@ -34,9 +34,9 @@ INSTANTIATE_TEST_CASE_P(FuseCreateAndOpenFileDescriptorTest, FuseCreateAndOpenFi TEST_P(FuseCreateAndOpenFileDescriptorTest, TestReturnedFileDescriptor) { ReturnDoesntExistOnLstat(FILENAME); - EXPECT_CALL(fsimpl, createAndOpenFile(StrEq(FILENAME), _, _, _)) + EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq(FILENAME), _, _, _)) .Times(1).WillOnce(Return(GetParam())); - EXPECT_CALL(fsimpl, read(GetParam(), _, _, _)).Times(1).WillOnce(Return(fspp::num_bytes_t(1))); + EXPECT_CALL(*fsimpl, read(GetParam(), _, _, _)).Times(1).WillOnce(Return(fspp::num_bytes_t(1))); //For the syscall to succeed, we also need to give an fstat implementation. ReturnIsFileOnFstatWithSize(GetParam(), fspp::num_bytes_t(1)); diff --git a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFilenameTest.cpp b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFilenameTest.cpp index a9e3a900..0b724765 100644 --- a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFilenameTest.cpp +++ b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFilenameTest.cpp @@ -10,7 +10,7 @@ public: TEST_F(FuseCreateAndOpenFilenameTest, CreateAndOpenFile) { ReturnDoesntExistOnLstat("/myfile"); - EXPECT_CALL(fsimpl, createAndOpenFile(StrEq("/myfile"), _, _, _)) + EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq("/myfile"), _, _, _)) .Times(1).WillOnce(Return(0)); //For the syscall to succeed, we also need to give an fstat implementation. ReturnIsFileOnFstat(0); @@ -21,7 +21,7 @@ TEST_F(FuseCreateAndOpenFilenameTest, CreateAndOpenFile) { TEST_F(FuseCreateAndOpenFilenameTest, CreateAndOpenFileNested) { ReturnIsDirOnLstat("/mydir"); ReturnDoesntExistOnLstat("/mydir/myfile"); - EXPECT_CALL(fsimpl, createAndOpenFile(StrEq("/mydir/myfile"), _, _, _)) + EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq("/mydir/myfile"), _, _, _)) .Times(1).WillOnce(Return(0)); //For the syscall to succeed, we also need to give an fstat implementation. ReturnIsFileOnFstat(0); @@ -33,7 +33,7 @@ TEST_F(FuseCreateAndOpenFilenameTest, CreateAndOpenFileNested2) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); ReturnDoesntExistOnLstat("/mydir/mydir2/myfile"); - EXPECT_CALL(fsimpl, createAndOpenFile(StrEq("/mydir/mydir2/myfile"), _, _, _)) + EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq("/mydir/mydir2/myfile"), _, _, _)) .Times(1).WillOnce(Return(0)); //For the syscall to succeed, we also need to give an fstat implementation. ReturnIsFileOnFstat(0); diff --git a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFlagsTest.cpp b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFlagsTest.cpp index b8ff7b6c..18ccf490 100644 --- a/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFlagsTest.cpp +++ b/test/fspp/fuse/createAndOpenFile/FuseCreateAndOpenFlagsTest.cpp @@ -10,7 +10,7 @@ INSTANTIATE_TEST_CASE_P(FuseCreateAndOpenFlagsTest, FuseCreateAndOpenFlagsTest, //TODO Disabled because it doesn't seem to work. Fuse doesn't seem to pass flags to create(). Why? /*TEST_P(FuseCreateAndOpenFlagsTest, testFlags) { ReturnDoesntExistOnLstat(FILENAME); - EXPECT_CALL(fsimpl, createAndOpenFile(StrEq(FILENAME), OpenFlagsEq(GetParam()), _, _)) + EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq(FILENAME), OpenFlagsEq(GetParam()), _, _)) .Times(1).WillOnce(Return(0)); //For the syscall to succeed, we also need to give an fstat implementation. ReturnIsFileOnFstat(0); diff --git a/test/fspp/fuse/fdatasync/FuseFdatasyncErrorTest.cpp b/test/fspp/fuse/fdatasync/FuseFdatasyncErrorTest.cpp index 6008769c..7f621cb5 100644 --- a/test/fspp/fuse/fdatasync/FuseFdatasyncErrorTest.cpp +++ b/test/fspp/fuse/fdatasync/FuseFdatasyncErrorTest.cpp @@ -15,7 +15,7 @@ INSTANTIATE_TEST_CASE_P(FuseFdatasyncErrorTest, FuseFdatasyncErrorTest, Values(E TEST_P(FuseFdatasyncErrorTest, ReturnedErrorIsCorrect) { ReturnIsFileOnLstat(FILENAME); OnOpenReturnFileDescriptor(FILENAME, 0); - EXPECT_CALL(fsimpl, fdatasync(0)) + EXPECT_CALL(*fsimpl, fdatasync(0)) .Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); int error = FdatasyncFileReturnError(FILENAME); diff --git a/test/fspp/fuse/fdatasync/FuseFdatasyncFileDescriptorTest.cpp b/test/fspp/fuse/fdatasync/FuseFdatasyncFileDescriptorTest.cpp index 47495c1a..07f6ea27 100644 --- a/test/fspp/fuse/fdatasync/FuseFdatasyncFileDescriptorTest.cpp +++ b/test/fspp/fuse/fdatasync/FuseFdatasyncFileDescriptorTest.cpp @@ -17,7 +17,7 @@ INSTANTIATE_TEST_CASE_P(FuseFdatasyncFileDescriptorTest, FuseFdatasyncFileDescri TEST_P(FuseFdatasyncFileDescriptorTest, FileDescriptorIsCorrect) { ReturnIsFileOnLstat(FILENAME); OnOpenReturnFileDescriptor(FILENAME, GetParam()); - EXPECT_CALL(fsimpl, fdatasync(Eq(GetParam()))) + EXPECT_CALL(*fsimpl, fdatasync(Eq(GetParam()))) .Times(1).WillOnce(Return()); FdatasyncFile(FILENAME); diff --git a/test/fspp/fuse/flush/FuseFlushErrorTest.cpp b/test/fspp/fuse/flush/FuseFlushErrorTest.cpp index 54da7bf1..d9e5364f 100644 --- a/test/fspp/fuse/flush/FuseFlushErrorTest.cpp +++ b/test/fspp/fuse/flush/FuseFlushErrorTest.cpp @@ -19,8 +19,8 @@ INSTANTIATE_TEST_CASE_P(FuseFlushErrorTest, FuseFlushErrorTest, Values(EBADF, EI TEST_P(FuseFlushErrorTest, ReturnErrorFromFlush) { ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, openFile(StrEq(FILENAME), _)).WillOnce(Return(GetParam())); - EXPECT_CALL(fsimpl, flush(Eq(GetParam()))).Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); + EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), _)).WillOnce(Return(GetParam())); + EXPECT_CALL(*fsimpl, flush(Eq(GetParam()))).Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); auto fs = TestFS(); auto fd = OpenFile(fs.get(), FILENAME); diff --git a/test/fspp/fuse/flush/FuseFlushFileDescriptorTest.cpp b/test/fspp/fuse/flush/FuseFlushFileDescriptorTest.cpp index 5c34dc28..fc0fd4d4 100644 --- a/test/fspp/fuse/flush/FuseFlushFileDescriptorTest.cpp +++ b/test/fspp/fuse/flush/FuseFlushFileDescriptorTest.cpp @@ -27,8 +27,8 @@ INSTANTIATE_TEST_CASE_P(FuseFlushFileDescriptorTest, FuseFlushFileDescriptorTest TEST_P(FuseFlushFileDescriptorTest, FlushOnCloseFile) { ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, openFile(StrEq(FILENAME), _)).WillOnce(Return(GetParam())); - EXPECT_CALL(fsimpl, flush(Eq(GetParam()))).Times(1); + EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), _)).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 7e05e61b..f766378a 100644 --- a/test/fspp/fuse/fstat/FuseFstatErrorTest.cpp +++ b/test/fspp/fuse/fstat/FuseFstatErrorTest.cpp @@ -29,7 +29,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), _)).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 ac285102..ba76a081 100644 --- a/test/fspp/fuse/fstat/FuseFstatParameterTest.cpp +++ b/test/fspp/fuse/fstat/FuseFstatParameterTest.cpp @@ -28,7 +28,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()), _)).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 d74a3e63..7c90fca9 100644 --- a/test/fspp/fuse/fstat/testutils/FuseFstatTest.cpp +++ b/test/fspp/fuse/fstat/testutils/FuseFstatTest.cpp @@ -25,5 +25,5 @@ unique_ref FuseFstatTest::CreateFileAllowErrors(const TempTestFS } void FuseFstatTest::OnCreateAndOpenReturnFileDescriptor(const char *filename, int descriptor) { - EXPECT_CALL(fsimpl, createAndOpenFile(StrEq(filename), _, _, _)).Times(1).WillOnce(Return(descriptor)); + EXPECT_CALL(*fsimpl, createAndOpenFile(StrEq(filename), _, _, _)).Times(1).WillOnce(Return(descriptor)); } diff --git a/test/fspp/fuse/fsync/FuseFsyncErrorTest.cpp b/test/fspp/fuse/fsync/FuseFsyncErrorTest.cpp index a1f1e800..11c65f92 100644 --- a/test/fspp/fuse/fsync/FuseFsyncErrorTest.cpp +++ b/test/fspp/fuse/fsync/FuseFsyncErrorTest.cpp @@ -15,7 +15,7 @@ INSTANTIATE_TEST_CASE_P(FuseFsyncErrorTest, FuseFsyncErrorTest, Values(EBADF, EI TEST_P(FuseFsyncErrorTest, ReturnedErrorIsCorrect) { ReturnIsFileOnLstat(FILENAME); OnOpenReturnFileDescriptor(FILENAME, 0); - EXPECT_CALL(fsimpl, fsync(0)) + EXPECT_CALL(*fsimpl, fsync(0)) .Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); int error = FsyncFileReturnError(FILENAME); diff --git a/test/fspp/fuse/fsync/FuseFsyncFileDescriptorTest.cpp b/test/fspp/fuse/fsync/FuseFsyncFileDescriptorTest.cpp index 49eea2b7..6749e64a 100644 --- a/test/fspp/fuse/fsync/FuseFsyncFileDescriptorTest.cpp +++ b/test/fspp/fuse/fsync/FuseFsyncFileDescriptorTest.cpp @@ -17,7 +17,7 @@ INSTANTIATE_TEST_CASE_P(FuseFsyncFileDescriptorTest, FuseFsyncFileDescriptorTest TEST_P(FuseFsyncFileDescriptorTest, FileDescriptorIsCorrect) { ReturnIsFileOnLstat(FILENAME); OnOpenReturnFileDescriptor(FILENAME, GetParam()); - EXPECT_CALL(fsimpl, fsync(Eq(GetParam()))) + EXPECT_CALL(*fsimpl, fsync(Eq(GetParam()))) .Times(1).WillOnce(Return()); FsyncFile(FILENAME); diff --git a/test/fspp/fuse/ftruncate/FuseFTruncateErrorTest.cpp b/test/fspp/fuse/ftruncate/FuseFTruncateErrorTest.cpp index 4448c998..4f96c2db 100644 --- a/test/fspp/fuse/ftruncate/FuseFTruncateErrorTest.cpp +++ b/test/fspp/fuse/ftruncate/FuseFTruncateErrorTest.cpp @@ -16,7 +16,7 @@ INSTANTIATE_TEST_CASE_P(FuseFTruncateErrorTest, FuseFTruncateErrorTest, Values(E TEST_P(FuseFTruncateErrorTest, ReturnedErrorIsCorrect) { ReturnIsFileOnLstat(FILENAME); OnOpenReturnFileDescriptor(FILENAME, 0); - EXPECT_CALL(fsimpl, ftruncate(0, _)) + EXPECT_CALL(*fsimpl, ftruncate(0, _)) .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 e50c4afd..9a540aff 100644 --- a/test/fspp/fuse/ftruncate/FuseFTruncateFileDescriptorTest.cpp +++ b/test/fspp/fuse/ftruncate/FuseFTruncateFileDescriptorTest.cpp @@ -18,7 +18,7 @@ INSTANTIATE_TEST_CASE_P(FuseFTruncateFileDescriptorTest, FuseFTruncateFileDescri TEST_P(FuseFTruncateFileDescriptorTest, FileDescriptorIsCorrect) { ReturnIsFileOnLstat(FILENAME); OnOpenReturnFileDescriptor(FILENAME, GetParam()); - EXPECT_CALL(fsimpl, ftruncate(Eq(GetParam()), _)) + EXPECT_CALL(*fsimpl, ftruncate(Eq(GetParam()), _)) .Times(1).WillOnce(Return()); //Needed to make ::ftruncate system call return successfully ReturnIsFileOnFstat(GetParam()); diff --git a/test/fspp/fuse/ftruncate/FuseFTruncateSizeTest.cpp b/test/fspp/fuse/ftruncate/FuseFTruncateSizeTest.cpp index 3afd6477..ea8a7df3 100644 --- a/test/fspp/fuse/ftruncate/FuseFTruncateSizeTest.cpp +++ b/test/fspp/fuse/ftruncate/FuseFTruncateSizeTest.cpp @@ -18,7 +18,7 @@ INSTANTIATE_TEST_CASE_P(FuseFTruncateSizeTest, FuseFTruncateSizeTest, Values( TEST_P(FuseFTruncateSizeTest, FTruncateFile) { ReturnIsFileOnLstat(FILENAME); OnOpenReturnFileDescriptor(FILENAME, 0); - EXPECT_CALL(fsimpl, ftruncate(Eq(0), GetParam())) + EXPECT_CALL(*fsimpl, ftruncate(Eq(0), GetParam())) .Times(1).WillOnce(Return()); //Needed to make ::ftruncate system call return successfully ReturnIsFileOnFstat(0); diff --git a/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp b/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp index 86d66bce..ae259313 100644 --- a/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp +++ b/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp @@ -17,14 +17,14 @@ public: INSTANTIATE_TEST_CASE_P(LstatErrorCodes, FuseLstatErrorTest, Values(EACCES, EBADF, EFAULT, ELOOP, ENAMETOOLONG, ENOENT, ENOMEM, ENOTDIR, EOVERFLOW, EINVAL, ENOTDIR)); TEST_F(FuseLstatErrorTest, ReturnNoError) { - EXPECT_CALL(fsimpl, lstat(StrEq(FILENAME), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile); + EXPECT_CALL(*fsimpl, lstat(StrEq(FILENAME), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile); errno = 0; int error = LstatPathReturnError(FILENAME); EXPECT_EQ(0, error); } TEST_P(FuseLstatErrorTest, ReturnError) { - EXPECT_CALL(fsimpl, lstat(StrEq(FILENAME), _)).Times(AtLeast(1)).WillRepeatedly(Throw(FuseErrnoException(GetParam()))); + EXPECT_CALL(*fsimpl, lstat(StrEq(FILENAME), _)).Times(AtLeast(1)).WillRepeatedly(Throw(FuseErrnoException(GetParam()))); int error = LstatPathReturnError(FILENAME); EXPECT_EQ(GetParam(), error); } diff --git a/test/fspp/fuse/lstat/FuseLstatPathParameterTest.cpp b/test/fspp/fuse/lstat/FuseLstatPathParameterTest.cpp index 0dc9d762..1037903b 100644 --- a/test/fspp/fuse/lstat/FuseLstatPathParameterTest.cpp +++ b/test/fspp/fuse/lstat/FuseLstatPathParameterTest.cpp @@ -8,30 +8,30 @@ class FuseLstatPathParameterTest: public FuseLstatTest { }; TEST_F(FuseLstatPathParameterTest, PathParameterIsCorrectRoot) { - EXPECT_CALL(fsimpl, lstat(StrEq("/"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsDir); + EXPECT_CALL(*fsimpl, lstat(StrEq("/"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsDir); LstatPath("/"); } TEST_F(FuseLstatPathParameterTest, PathParameterIsCorrectSimpleFile) { - EXPECT_CALL(fsimpl, lstat(StrEq("/myfile"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile); + EXPECT_CALL(*fsimpl, lstat(StrEq("/myfile"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile); LstatPath("/myfile"); } TEST_F(FuseLstatPathParameterTest, PathParameterIsCorrectSimpleDir) { - EXPECT_CALL(fsimpl, lstat(StrEq("/mydir"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsDir); + EXPECT_CALL(*fsimpl, lstat(StrEq("/mydir"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsDir); LstatPath("/mydir/"); } TEST_F(FuseLstatPathParameterTest, PathParameterIsCorrectNestedFile) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); - EXPECT_CALL(fsimpl, lstat(StrEq("/mydir/mydir2/myfile"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile); + EXPECT_CALL(*fsimpl, lstat(StrEq("/mydir/mydir2/myfile"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsFile); LstatPath("/mydir/mydir2/myfile"); } TEST_F(FuseLstatPathParameterTest, PathParameterIsCorrectNestedDir) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); - EXPECT_CALL(fsimpl, lstat(StrEq("/mydir/mydir2/mydir3"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsDir); + EXPECT_CALL(*fsimpl, lstat(StrEq("/mydir/mydir2/mydir3"), _)).Times(AtLeast(1)).WillRepeatedly(ReturnIsDir); LstatPath("/mydir/mydir2/mydir3/"); } diff --git a/test/fspp/fuse/lstat/testutils/FuseLstatTest.cpp b/test/fspp/fuse/lstat/testutils/FuseLstatTest.cpp index 7133ccbf..4670ce9e 100644 --- a/test/fspp/fuse/lstat/testutils/FuseLstatTest.cpp +++ b/test/fspp/fuse/lstat/testutils/FuseLstatTest.cpp @@ -41,7 +41,7 @@ fspp::fuse::STAT FuseLstatTest::CallDirLstatWithImpl(function implementation) { - EXPECT_CALL(fsimpl, lstat(StrEq(FILENAME), _)).WillRepeatedly(Invoke([implementation](const char*, fspp::fuse::STAT *stat) { + EXPECT_CALL(*fsimpl, lstat(StrEq(FILENAME), _)).WillRepeatedly(Invoke([implementation](const char*, fspp::fuse::STAT *stat) { implementation(stat); })); diff --git a/test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp b/test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp index 77f18b6f..b3e5f0ab 100644 --- a/test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp +++ b/test/fspp/fuse/mkdir/FuseMkdirDirnameTest.cpp @@ -8,7 +8,7 @@ class FuseMkdirDirnameTest: public FuseMkdirTest { TEST_F(FuseMkdirDirnameTest, Mkdir) { ReturnDoesntExistOnLstat("/mydir"); - EXPECT_CALL(fsimpl, mkdir(StrEq("/mydir"), _, _, _)) + EXPECT_CALL(*fsimpl, mkdir(StrEq("/mydir"), _, _, _)) // After mkdir was called, lstat should return that it is a dir. // This is needed to make the ::mkdir() syscall pass. .Times(1).WillOnce(FromNowOnReturnIsDirOnLstat()); @@ -19,7 +19,7 @@ TEST_F(FuseMkdirDirnameTest, Mkdir) { TEST_F(FuseMkdirDirnameTest, MkdirNested) { ReturnIsDirOnLstat("/mydir"); ReturnDoesntExistOnLstat("/mydir/mysubdir"); - EXPECT_CALL(fsimpl, mkdir(StrEq("/mydir/mysubdir"), _, _, _)) + EXPECT_CALL(*fsimpl, mkdir(StrEq("/mydir/mysubdir"), _, _, _)) // After mkdir was called, lstat should return that it is a dir. // This is needed to make the ::mkdir() syscall pass. .Times(1).WillOnce(FromNowOnReturnIsDirOnLstat()); @@ -31,7 +31,7 @@ TEST_F(FuseMkdirDirnameTest, MkdirNested2) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); ReturnDoesntExistOnLstat("/mydir/mydir2/mydir3"); - EXPECT_CALL(fsimpl, mkdir(StrEq("/mydir/mydir2/mydir3"), _, _, _)) + EXPECT_CALL(*fsimpl, mkdir(StrEq("/mydir/mydir2/mydir3"), _, _, _)) // After mkdir was called, lstat should return that it is a dir. // This is needed to make the ::mkdir() syscall pass. .Times(1).WillOnce(FromNowOnReturnIsDirOnLstat()); diff --git a/test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp b/test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp index fd513124..8d07d5cc 100644 --- a/test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp +++ b/test/fspp/fuse/mkdir/FuseMkdirErrorTest.cpp @@ -16,7 +16,7 @@ INSTANTIATE_TEST_CASE_P(FuseMkdirErrorTest, FuseMkdirErrorTest, Values(EACCES, E TEST_F(FuseMkdirErrorTest, NoError) { ReturnDoesntExistOnLstat(DIRNAME); - EXPECT_CALL(fsimpl, mkdir(StrEq(DIRNAME), _, _, _)) + EXPECT_CALL(*fsimpl, mkdir(StrEq(DIRNAME), _, _, _)) .Times(1).WillOnce(FromNowOnReturnIsDirOnLstat()); int error = MkdirReturnError(DIRNAME, 0); @@ -25,7 +25,7 @@ TEST_F(FuseMkdirErrorTest, NoError) { TEST_P(FuseMkdirErrorTest, ReturnedErrorIsCorrect) { ReturnDoesntExistOnLstat(DIRNAME); - EXPECT_CALL(fsimpl, mkdir(StrEq(DIRNAME), _, _, _)) + EXPECT_CALL(*fsimpl, mkdir(StrEq(DIRNAME), _, _, _)) .Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); int error = MkdirReturnError(DIRNAME, 0); diff --git a/test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp b/test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp index c593147a..526d4ca6 100644 --- a/test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp +++ b/test/fspp/fuse/mkdir/FuseMkdirModeTest.cpp @@ -12,7 +12,7 @@ INSTANTIATE_TEST_CASE_P(FuseMkdirModeTest, FuseMkdirModeTest, Values(0, S_IRUSR, TEST_P(FuseMkdirModeTest, Mkdir) { ReturnDoesntExistOnLstat(DIRNAME); - EXPECT_CALL(fsimpl, mkdir(StrEq(DIRNAME), GetParam(), _, _)) + EXPECT_CALL(*fsimpl, mkdir(StrEq(DIRNAME), GetParam(), _, _)) .Times(1).WillOnce(FromNowOnReturnIsDirOnLstat()); Mkdir(DIRNAME, GetParam()); diff --git a/test/fspp/fuse/openFile/FuseOpenErrorTest.cpp b/test/fspp/fuse/openFile/FuseOpenErrorTest.cpp index 87e67ed8..784fd17c 100644 --- a/test/fspp/fuse/openFile/FuseOpenErrorTest.cpp +++ b/test/fspp/fuse/openFile/FuseOpenErrorTest.cpp @@ -17,7 +17,7 @@ INSTANTIATE_TEST_CASE_P(FuseOpenErrorTest, FuseOpenErrorTest, Values(EACCES, EDQ TEST_F(FuseOpenErrorTest, ReturnNoError) { ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, openFile(StrEq(FILENAME), _)).Times(1).WillOnce(Return(1)); + EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), _)).Times(1).WillOnce(Return(1)); errno = 0; int error = OpenFileReturnError(FILENAME, O_RDONLY); EXPECT_EQ(0, error); @@ -25,7 +25,7 @@ TEST_F(FuseOpenErrorTest, ReturnNoError) { TEST_P(FuseOpenErrorTest, ReturnError) { ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, openFile(StrEq(FILENAME), _)).Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); + EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), _)).Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); int error = OpenFileReturnError(FILENAME, O_RDONLY); EXPECT_EQ(GetParam(), error); } diff --git a/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp b/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp index 19c0c0ab..b386f4e6 100644 --- a/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp +++ b/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp @@ -34,9 +34,9 @@ INSTANTIATE_TEST_CASE_P(FuseOpenFileDescriptorTest, FuseOpenFileDescriptorTest, TEST_P(FuseOpenFileDescriptorTest, TestReturnedFileDescriptor) { ReturnIsFileOnLstatWithSize(FILENAME, fspp::num_bytes_t(1)); - EXPECT_CALL(fsimpl, openFile(StrEq(FILENAME), _)) + EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), _)) .Times(1).WillOnce(Return(GetParam())); - EXPECT_CALL(fsimpl, read(GetParam(), _, _, _)).Times(1).WillOnce(Return(fspp::num_bytes_t(1))); + EXPECT_CALL(*fsimpl, read(GetParam(), _, _, _)).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 98d7994d..ae77d2d7 100644 --- a/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp +++ b/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp @@ -10,7 +10,7 @@ public: TEST_F(FuseOpenFilenameTest, OpenFile) { ReturnIsFileOnLstat("/myfile"); - EXPECT_CALL(fsimpl, openFile(StrEq("/myfile"), _)) + EXPECT_CALL(*fsimpl, openFile(StrEq("/myfile"), _)) .Times(1).WillOnce(Return(0)); OpenFile("/myfile", O_RDONLY); @@ -19,7 +19,7 @@ TEST_F(FuseOpenFilenameTest, OpenFile) { TEST_F(FuseOpenFilenameTest, OpenFileNested) { ReturnIsDirOnLstat("/mydir"); ReturnIsFileOnLstat("/mydir/myfile"); - EXPECT_CALL(fsimpl, openFile(StrEq("/mydir/myfile"), _)) + EXPECT_CALL(*fsimpl, openFile(StrEq("/mydir/myfile"), _)) .Times(1).WillOnce(Return(0)); OpenFile("/mydir/myfile", O_RDONLY); @@ -29,7 +29,7 @@ TEST_F(FuseOpenFilenameTest, OpenFileNested2) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); ReturnIsFileOnLstat("/mydir/mydir2/myfile"); - EXPECT_CALL(fsimpl, openFile(StrEq("/mydir/mydir2/myfile"), _)) + EXPECT_CALL(*fsimpl, openFile(StrEq("/mydir/mydir2/myfile"), _)) .Times(1).WillOnce(Return(0)); OpenFile("/mydir/mydir2/myfile", O_RDONLY); diff --git a/test/fspp/fuse/openFile/FuseOpenFlagsTest.cpp b/test/fspp/fuse/openFile/FuseOpenFlagsTest.cpp index 644f6e0f..21f3fa97 100644 --- a/test/fspp/fuse/openFile/FuseOpenFlagsTest.cpp +++ b/test/fspp/fuse/openFile/FuseOpenFlagsTest.cpp @@ -11,7 +11,7 @@ INSTANTIATE_TEST_CASE_P(FuseOpenFlagsTest, FuseOpenFlagsTest, Values(O_RDWR, O_R TEST_P(FuseOpenFlagsTest, testFlags) { ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, openFile(StrEq(FILENAME), OpenFlagsEq(GetParam()))) + EXPECT_CALL(*fsimpl, openFile(StrEq(FILENAME), OpenFlagsEq(GetParam()))) .Times(1).WillOnce(Return(0)); OpenFile(FILENAME, GetParam()); diff --git a/test/fspp/fuse/read/FuseReadErrorTest.cpp b/test/fspp/fuse/read/FuseReadErrorTest.cpp index 12940ef3..da864e5b 100644 --- a/test/fspp/fuse/read/FuseReadErrorTest.cpp +++ b/test/fspp/fuse/read/FuseReadErrorTest.cpp @@ -27,7 +27,7 @@ INSTANTIATE_TEST_CASE_P(FuseReadErrorTest, FuseReadErrorTest, Values(EAGAIN, EBA TEST_P(FuseReadErrorTest, ReturnErrorOnFirstReadCall) { - EXPECT_CALL(fsimpl, read(0, _, _, _)) + EXPECT_CALL(*fsimpl, read(0, _, _, _)) .WillRepeatedly(Throw(FuseErrnoException(GetParam()))); char *buf = new char[READCOUNT.value()]; @@ -41,14 +41,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, _, _, 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, _, _, 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 b091670d..9470b1ab 100644 --- a/test/fspp/fuse/read/FuseReadFileDescriptorTest.cpp +++ b/test/fspp/fuse/read/FuseReadFileDescriptorTest.cpp @@ -17,7 +17,7 @@ INSTANTIATE_TEST_CASE_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()), _, _, _)) .Times(1).WillOnce(ReturnSuccessfulRead); char buf[1]; diff --git a/test/fspp/fuse/read/FuseReadOverflowTest.cpp b/test/fspp/fuse/read/FuseReadOverflowTest.cpp index 85907b93..43c9dc44 100644 --- a/test/fspp/fuse/read/FuseReadOverflowTest.cpp +++ b/test/fspp/fuse/read/FuseReadOverflowTest.cpp @@ -16,7 +16,7 @@ public: void SetUp() override { ReturnIsFileOnLstatWithSize(FILENAME, FILESIZE); OnOpenReturnFileDescriptor(FILENAME, 0); - EXPECT_CALL(fsimpl, read(0, _, _, _)).WillRepeatedly(ReturnSuccessfulReadRegardingSize(FILESIZE)); + EXPECT_CALL(*fsimpl, read(0, _, _, _)).WillRepeatedly(ReturnSuccessfulReadRegardingSize(FILESIZE)); } }; diff --git a/test/fspp/fuse/read/FuseReadReturnedDataTest.cpp b/test/fspp/fuse/read/FuseReadReturnedDataTest.cpp index acdbd303..c497e2e1 100644 --- a/test/fspp/fuse/read/FuseReadReturnedDataTest.cpp +++ b/test/fspp/fuse/read/FuseReadReturnedDataTest.cpp @@ -52,7 +52,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, _, _, _)) .WillRepeatedly(ReadFromFile); } diff --git a/test/fspp/fuse/readDir/FuseReadDirDirnameTest.cpp b/test/fspp/fuse/readDir/FuseReadDirDirnameTest.cpp index 58c094ab..df18348f 100644 --- a/test/fspp/fuse/readDir/FuseReadDirDirnameTest.cpp +++ b/test/fspp/fuse/readDir/FuseReadDirDirnameTest.cpp @@ -9,7 +9,7 @@ public: }; TEST_F(FuseReadDirDirnameTest, ReadRootDir) { - EXPECT_CALL(fsimpl, readDir(StrEq("/"))) + EXPECT_CALL(*fsimpl, readDir(StrEq("/"))) .Times(1).WillOnce(ReturnDirEntries({})); ReadDir("/"); @@ -17,7 +17,7 @@ TEST_F(FuseReadDirDirnameTest, ReadRootDir) { TEST_F(FuseReadDirDirnameTest, ReadDir) { ReturnIsDirOnLstat("/mydir"); - EXPECT_CALL(fsimpl, readDir(StrEq("/mydir"))) + EXPECT_CALL(*fsimpl, readDir(StrEq("/mydir"))) .Times(1).WillOnce(ReturnDirEntries({})); ReadDir("/mydir"); @@ -26,7 +26,7 @@ TEST_F(FuseReadDirDirnameTest, ReadDir) { TEST_F(FuseReadDirDirnameTest, ReadDirNested) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); - EXPECT_CALL(fsimpl, readDir(StrEq("/mydir/mydir2"))) + EXPECT_CALL(*fsimpl, readDir(StrEq("/mydir/mydir2"))) .Times(1).WillOnce(ReturnDirEntries({})); ReadDir("/mydir/mydir2"); @@ -36,7 +36,7 @@ TEST_F(FuseReadDirDirnameTest, ReadDirNested2) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); ReturnIsDirOnLstat("/mydir/mydir2/mydir3"); - EXPECT_CALL(fsimpl, readDir(StrEq("/mydir/mydir2/mydir3"))) + EXPECT_CALL(*fsimpl, readDir(StrEq("/mydir/mydir2/mydir3"))) .Times(1).WillOnce(ReturnDirEntries({})); ReadDir("/mydir/mydir2/mydir3"); diff --git a/test/fspp/fuse/readDir/FuseReadDirErrorTest.cpp b/test/fspp/fuse/readDir/FuseReadDirErrorTest.cpp index e4d7bfb3..5de5872f 100644 --- a/test/fspp/fuse/readDir/FuseReadDirErrorTest.cpp +++ b/test/fspp/fuse/readDir/FuseReadDirErrorTest.cpp @@ -19,7 +19,7 @@ INSTANTIATE_TEST_CASE_P(FuseReadDirErrorTest, FuseReadDirErrorTest, Values(EACCE TEST_F(FuseReadDirErrorTest, NoError) { ReturnIsDirOnLstat(DIRNAME); - EXPECT_CALL(fsimpl, readDir(StrEq(DIRNAME))) + EXPECT_CALL(*fsimpl, readDir(StrEq(DIRNAME))) .Times(1).WillOnce(ReturnDirEntries({})); int error = ReadDirReturnError(DIRNAME); @@ -28,7 +28,7 @@ TEST_F(FuseReadDirErrorTest, NoError) { TEST_P(FuseReadDirErrorTest, ReturnedErrorCodeIsCorrect) { ReturnIsDirOnLstat(DIRNAME); - EXPECT_CALL(fsimpl, readDir(StrEq(DIRNAME))) + EXPECT_CALL(*fsimpl, readDir(StrEq(DIRNAME))) .Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); int error = ReadDirReturnError(DIRNAME); diff --git a/test/fspp/fuse/readDir/FuseReadDirReturnTest.cpp b/test/fspp/fuse/readDir/FuseReadDirReturnTest.cpp index dc38ac55..367e4239 100644 --- a/test/fspp/fuse/readDir/FuseReadDirReturnTest.cpp +++ b/test/fspp/fuse/readDir/FuseReadDirReturnTest.cpp @@ -26,7 +26,7 @@ class FuseReadDirReturnTest: public FuseReadDirTest, public WithParamInterface &direntries) { ReturnIsDirOnLstat(DIRNAME); - EXPECT_CALL(fsimpl, readDir(StrEq(DIRNAME))) + EXPECT_CALL(*fsimpl, readDir(StrEq(DIRNAME))) .Times(1).WillOnce(ReturnDirEntries(direntries)); auto returned_dir_entries = ReadDir(DIRNAME); diff --git a/test/fspp/fuse/rename/FuseRenameErrorTest.cpp b/test/fspp/fuse/rename/FuseRenameErrorTest.cpp index c844d985..db0e35a0 100644 --- a/test/fspp/fuse/rename/FuseRenameErrorTest.cpp +++ b/test/fspp/fuse/rename/FuseRenameErrorTest.cpp @@ -15,7 +15,7 @@ INSTANTIATE_TEST_CASE_P(FuseRenameErrorTest, FuseRenameErrorTest, Values(EACCES, TEST_P(FuseRenameErrorTest, ReturnedErrorIsCorrect) { ReturnIsFileOnLstat(FILENAME1); ReturnDoesntExistOnLstat(FILENAME2); - EXPECT_CALL(fsimpl, rename(StrEq(FILENAME1), StrEq(FILENAME2))) + EXPECT_CALL(*fsimpl, rename(StrEq(FILENAME1), StrEq(FILENAME2))) .Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); int error = RenameReturnError(FILENAME1, FILENAME2); diff --git a/test/fspp/fuse/rename/FuseRenameFilenameTest.cpp b/test/fspp/fuse/rename/FuseRenameFilenameTest.cpp index beb4a5a6..b58b76b1 100644 --- a/test/fspp/fuse/rename/FuseRenameFilenameTest.cpp +++ b/test/fspp/fuse/rename/FuseRenameFilenameTest.cpp @@ -9,7 +9,7 @@ class FuseRenameFilenameTest: public FuseRenameTest { TEST_F(FuseRenameFilenameTest, RenameFileRootToRoot) { ReturnIsFileOnLstat("/myfile"); ReturnDoesntExistOnLstat("/myrenamedfile"); - EXPECT_CALL(fsimpl, rename(StrEq("/myfile"), StrEq("/myrenamedfile"))) + EXPECT_CALL(*fsimpl, rename(StrEq("/myfile"), StrEq("/myrenamedfile"))) .Times(1).WillOnce(Return()); Rename("/myfile", "/myrenamedfile"); @@ -19,7 +19,7 @@ TEST_F(FuseRenameFilenameTest, RenameFileRootToNested) { ReturnIsFileOnLstat("/myfile"); ReturnIsDirOnLstat("/mydir"); ReturnDoesntExistOnLstat("/mydir/myrenamedfile"); - EXPECT_CALL(fsimpl, rename(StrEq("/myfile"), StrEq("/mydir/myrenamedfile"))) + EXPECT_CALL(*fsimpl, rename(StrEq("/myfile"), StrEq("/mydir/myrenamedfile"))) .Times(1).WillOnce(Return()); Rename("/myfile", "/mydir/myrenamedfile"); @@ -29,7 +29,7 @@ TEST_F(FuseRenameFilenameTest, RenameFileNestedToRoot) { ReturnDoesntExistOnLstat("/myrenamedfile"); ReturnIsDirOnLstat("/mydir"); ReturnIsFileOnLstat("/mydir/myfile"); - EXPECT_CALL(fsimpl, rename(StrEq("/mydir/myfile"), StrEq("/myrenamedfile"))) + EXPECT_CALL(*fsimpl, rename(StrEq("/mydir/myfile"), StrEq("/myrenamedfile"))) .Times(1).WillOnce(Return()); Rename("/mydir/myfile", "/myrenamedfile"); @@ -39,7 +39,7 @@ TEST_F(FuseRenameFilenameTest, RenameFileNestedToNested) { ReturnIsDirOnLstat("/mydir"); ReturnIsFileOnLstat("/mydir/myfile"); ReturnDoesntExistOnLstat("/mydir/myrenamedfile"); - EXPECT_CALL(fsimpl, rename(StrEq("/mydir/myfile"), StrEq("/mydir/myrenamedfile"))) + EXPECT_CALL(*fsimpl, rename(StrEq("/mydir/myfile"), StrEq("/mydir/myrenamedfile"))) .Times(1).WillOnce(Return()); Rename("/mydir/myfile", "/mydir/myrenamedfile"); @@ -50,7 +50,7 @@ TEST_F(FuseRenameFilenameTest, RenameFileNestedToNested2) { ReturnIsDirOnLstat("/mydir/mydir2"); ReturnIsFileOnLstat("/mydir/mydir2/myfile"); ReturnDoesntExistOnLstat("/mydir/mydir2/myrenamedfile"); - EXPECT_CALL(fsimpl, rename(StrEq("/mydir/mydir2/myfile"), StrEq("/mydir/mydir2/myrenamedfile"))) + EXPECT_CALL(*fsimpl, rename(StrEq("/mydir/mydir2/myfile"), StrEq("/mydir/mydir2/myrenamedfile"))) .Times(1).WillOnce(Return()); Rename("/mydir/mydir2/myfile", "/mydir/mydir2/myrenamedfile"); @@ -61,7 +61,7 @@ TEST_F(FuseRenameFilenameTest, RenameFileNestedToNested_DifferentFolder) { ReturnIsDirOnLstat("/mydir2"); ReturnIsFileOnLstat("/mydir/myfile"); ReturnDoesntExistOnLstat("/mydir2/myrenamedfile"); - EXPECT_CALL(fsimpl, rename(StrEq("/mydir/myfile"), StrEq("/mydir2/myrenamedfile"))) + EXPECT_CALL(*fsimpl, rename(StrEq("/mydir/myfile"), StrEq("/mydir2/myrenamedfile"))) .Times(1).WillOnce(Return()); Rename("/mydir/myfile", "/mydir2/myrenamedfile"); @@ -70,7 +70,7 @@ TEST_F(FuseRenameFilenameTest, RenameFileNestedToNested_DifferentFolder) { TEST_F(FuseRenameFilenameTest, RenameDirRootToRoot) { ReturnIsDirOnLstat("/mydir"); ReturnDoesntExistOnLstat("/myrenameddir"); - EXPECT_CALL(fsimpl, rename(StrEq("/mydir"), StrEq("/myrenameddir"))) + EXPECT_CALL(*fsimpl, rename(StrEq("/mydir"), StrEq("/myrenameddir"))) .Times(1).WillOnce(Return()); Rename("/mydir", "/myrenameddir"); @@ -80,7 +80,7 @@ TEST_F(FuseRenameFilenameTest, RenameDirRootToNested) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/myrootdir"); ReturnDoesntExistOnLstat("/myrootdir/myrenameddir"); - EXPECT_CALL(fsimpl, rename(StrEq("/mydir"), StrEq("/myrootdir/myrenameddir"))) + EXPECT_CALL(*fsimpl, rename(StrEq("/mydir"), StrEq("/myrootdir/myrenameddir"))) .Times(1).WillOnce(Return()); Rename("/mydir", "/myrootdir/myrenameddir"); @@ -90,7 +90,7 @@ TEST_F(FuseRenameFilenameTest, RenameDirNestedToRoot) { ReturnDoesntExistOnLstat("/myrenameddir"); ReturnIsDirOnLstat("/myrootdir"); ReturnIsDirOnLstat("/myrootdir/mydir"); - EXPECT_CALL(fsimpl, rename(StrEq("/myrootdir/mydir"), StrEq("/myrenameddir"))) + EXPECT_CALL(*fsimpl, rename(StrEq("/myrootdir/mydir"), StrEq("/myrenameddir"))) .Times(1).WillOnce(Return()); Rename("/myrootdir/mydir", "/myrenameddir"); @@ -100,7 +100,7 @@ TEST_F(FuseRenameFilenameTest, RenameDirNestedToNested) { ReturnIsDirOnLstat("/myrootdir"); ReturnIsDirOnLstat("/myrootdir/mydir"); ReturnDoesntExistOnLstat("/myrootdir/myrenameddir"); - EXPECT_CALL(fsimpl, rename(StrEq("/myrootdir/mydir"), StrEq("/myrootdir/myrenameddir"))) + EXPECT_CALL(*fsimpl, rename(StrEq("/myrootdir/mydir"), StrEq("/myrootdir/myrenameddir"))) .Times(1).WillOnce(Return()); Rename("/myrootdir/mydir", "/myrootdir/myrenameddir"); @@ -111,7 +111,7 @@ TEST_F(FuseRenameFilenameTest, RenameDirNestedToNested2) { ReturnIsDirOnLstat("/myrootdir/myrootdir2"); ReturnIsDirOnLstat("/myrootdir/myrootdir2/mydir"); ReturnDoesntExistOnLstat("/myrootdir/myrootdir2/myrenameddir"); - EXPECT_CALL(fsimpl, rename(StrEq("/myrootdir/myrootdir2/mydir"), StrEq("/myrootdir/myrootdir2/myrenameddir"))) + EXPECT_CALL(*fsimpl, rename(StrEq("/myrootdir/myrootdir2/mydir"), StrEq("/myrootdir/myrootdir2/myrenameddir"))) .Times(1).WillOnce(Return()); Rename("/myrootdir/myrootdir2/mydir", "/myrootdir/myrootdir2/myrenameddir"); @@ -122,7 +122,7 @@ TEST_F(FuseRenameFilenameTest, RenameDirNestedToNested_DifferentFolder) { ReturnIsDirOnLstat("/myrootdir2"); ReturnIsDirOnLstat("/myrootdir/mydir"); ReturnDoesntExistOnLstat("/myrootdir2/myrenameddir"); - EXPECT_CALL(fsimpl, rename(StrEq("/myrootdir/mydir"), StrEq("/myrootdir2/myrenameddir"))) + EXPECT_CALL(*fsimpl, rename(StrEq("/myrootdir/mydir"), StrEq("/myrootdir2/myrenameddir"))) .Times(1).WillOnce(Return()); Rename("/myrootdir/mydir", "/myrootdir2/myrenameddir"); diff --git a/test/fspp/fuse/rmdir/FuseRmdirDirnameTest.cpp b/test/fspp/fuse/rmdir/FuseRmdirDirnameTest.cpp index 69615044..b2c6f0a7 100644 --- a/test/fspp/fuse/rmdir/FuseRmdirDirnameTest.cpp +++ b/test/fspp/fuse/rmdir/FuseRmdirDirnameTest.cpp @@ -7,7 +7,7 @@ class FuseRmdirDirnameTest: public FuseRmdirTest { TEST_F(FuseRmdirDirnameTest, Rmdir) { ReturnIsDirOnLstat("/mydir"); - EXPECT_CALL(fsimpl, rmdir(StrEq("/mydir"))) + EXPECT_CALL(*fsimpl, rmdir(StrEq("/mydir"))) // After rmdir was called, lstat should return that it doesn't exist anymore // This is needed to make the ::rmdir() syscall pass. .Times(1).WillOnce(FromNowOnReturnDoesntExistOnLstat()); @@ -18,7 +18,7 @@ TEST_F(FuseRmdirDirnameTest, Rmdir) { TEST_F(FuseRmdirDirnameTest, RmdirNested) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mysubdir"); - EXPECT_CALL(fsimpl, rmdir(StrEq("/mydir/mysubdir"))) + EXPECT_CALL(*fsimpl, rmdir(StrEq("/mydir/mysubdir"))) // After rmdir was called, lstat should return that it doesn't exist anymore // This is needed to make the ::rmdir() syscall pass. .Times(1).WillOnce(FromNowOnReturnDoesntExistOnLstat()); @@ -30,7 +30,7 @@ TEST_F(FuseRmdirDirnameTest, RmdirNested2) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); ReturnIsDirOnLstat("/mydir/mydir2/mydir3"); - EXPECT_CALL(fsimpl, rmdir(StrEq("/mydir/mydir2/mydir3"))) + EXPECT_CALL(*fsimpl, rmdir(StrEq("/mydir/mydir2/mydir3"))) // After rmdir was called, lstat should return that it doesn't exist anymore // This is needed to make the ::rmdir() syscall pass. .Times(1).WillOnce(FromNowOnReturnDoesntExistOnLstat()); diff --git a/test/fspp/fuse/rmdir/FuseRmdirErrorTest.cpp b/test/fspp/fuse/rmdir/FuseRmdirErrorTest.cpp index f46f1e4d..771de2e8 100644 --- a/test/fspp/fuse/rmdir/FuseRmdirErrorTest.cpp +++ b/test/fspp/fuse/rmdir/FuseRmdirErrorTest.cpp @@ -14,7 +14,7 @@ INSTANTIATE_TEST_CASE_P(FuseRmdirErrorTest, FuseRmdirErrorTest, Values(EACCES, E TEST_P(FuseRmdirErrorTest, ReturnedErrorIsCorrect) { ReturnIsDirOnLstat(DIRNAME); - EXPECT_CALL(fsimpl, rmdir(StrEq(DIRNAME))) + EXPECT_CALL(*fsimpl, rmdir(StrEq(DIRNAME))) .Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); int error = RmdirReturnError(DIRNAME); diff --git a/test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp b/test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp index 21cd9004..56bcae7a 100644 --- a/test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp +++ b/test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp @@ -17,14 +17,14 @@ INSTANTIATE_TEST_CASE_P(FuseStatfsErrorTest, FuseStatfsErrorTest, Values(EACCES, TEST_F(FuseStatfsErrorTest, ReturnNoError) { ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, statfs(_)).Times(1).WillOnce(Return()); + EXPECT_CALL(*fsimpl, statfs(_)).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( _)).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 18e548a8..fe00807b 100644 --- a/test/fspp/fuse/statfs/testutils/FuseStatfsTest.cpp +++ b/test/fspp/fuse/statfs/testutils/FuseStatfsTest.cpp @@ -33,7 +33,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(_)).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 9a3753e7..e6a35b6d 100644 --- a/test/fspp/fuse/truncate/FuseTruncateErrorTest.cpp +++ b/test/fspp/fuse/truncate/FuseTruncateErrorTest.cpp @@ -15,7 +15,7 @@ INSTANTIATE_TEST_CASE_P(FuseTruncateErrorTest, FuseTruncateErrorTest, Values(EAC TEST_P(FuseTruncateErrorTest, ReturnedErrorIsCorrect) { ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, truncate(StrEq(FILENAME), _)) + EXPECT_CALL(*fsimpl, truncate(StrEq(FILENAME), _)) .Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); int error = TruncateFileReturnError(FILENAME, fspp::num_bytes_t(0)); diff --git a/test/fspp/fuse/truncate/FuseTruncateFilenameTest.cpp b/test/fspp/fuse/truncate/FuseTruncateFilenameTest.cpp index be1db3fd..a2628e1d 100644 --- a/test/fspp/fuse/truncate/FuseTruncateFilenameTest.cpp +++ b/test/fspp/fuse/truncate/FuseTruncateFilenameTest.cpp @@ -9,7 +9,7 @@ class FuseTruncateFilenameTest: public FuseTruncateTest { TEST_F(FuseTruncateFilenameTest, TruncateFile) { ReturnIsFileOnLstat("/myfile"); - EXPECT_CALL(fsimpl, truncate(StrEq("/myfile"), _)) + EXPECT_CALL(*fsimpl, truncate(StrEq("/myfile"), _)) .Times(1).WillOnce(Return()); TruncateFile("/myfile", fspp::num_bytes_t(0)); @@ -18,7 +18,7 @@ TEST_F(FuseTruncateFilenameTest, TruncateFile) { TEST_F(FuseTruncateFilenameTest, TruncateFileNested) { ReturnIsDirOnLstat("/mydir"); ReturnIsFileOnLstat("/mydir/myfile"); - EXPECT_CALL(fsimpl, truncate(StrEq("/mydir/myfile"), _)) + EXPECT_CALL(*fsimpl, truncate(StrEq("/mydir/myfile"), _)) .Times(1).WillOnce(Return()); TruncateFile("/mydir/myfile", fspp::num_bytes_t(0)); @@ -28,7 +28,7 @@ TEST_F(FuseTruncateFilenameTest, TruncateFileNested2) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); ReturnIsFileOnLstat("/mydir/mydir2/myfile"); - EXPECT_CALL(fsimpl, truncate(StrEq("/mydir/mydir2/myfile"), _)) + EXPECT_CALL(*fsimpl, truncate(StrEq("/mydir/mydir2/myfile"), _)) .Times(1).WillOnce(Return()); TruncateFile("/mydir/mydir2/myfile", fspp::num_bytes_t(0)); diff --git a/test/fspp/fuse/truncate/FuseTruncateSizeTest.cpp b/test/fspp/fuse/truncate/FuseTruncateSizeTest.cpp index d567650c..f716ee75 100644 --- a/test/fspp/fuse/truncate/FuseTruncateSizeTest.cpp +++ b/test/fspp/fuse/truncate/FuseTruncateSizeTest.cpp @@ -18,7 +18,7 @@ INSTANTIATE_TEST_CASE_P(FuseTruncateSizeTest, FuseTruncateSizeTest, Values( TEST_P(FuseTruncateSizeTest, TruncateFile) { ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, truncate(StrEq(FILENAME), Eq(GetParam()))) + EXPECT_CALL(*fsimpl, truncate(StrEq(FILENAME), Eq(GetParam()))) .Times(1).WillOnce(Return()); TruncateFile(FILENAME, GetParam()); diff --git a/test/fspp/fuse/unlink/FuseUnlinkErrorTest.cpp b/test/fspp/fuse/unlink/FuseUnlinkErrorTest.cpp index fdc71dd0..0082c0a4 100644 --- a/test/fspp/fuse/unlink/FuseUnlinkErrorTest.cpp +++ b/test/fspp/fuse/unlink/FuseUnlinkErrorTest.cpp @@ -14,7 +14,7 @@ INSTANTIATE_TEST_CASE_P(FuseUnlinkErrorTest, FuseUnlinkErrorTest, Values(EACCES, TEST_P(FuseUnlinkErrorTest, ReturnedErrorIsCorrect) { ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, unlink(StrEq(FILENAME))) + EXPECT_CALL(*fsimpl, unlink(StrEq(FILENAME))) .Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); int error = UnlinkReturnError(FILENAME); diff --git a/test/fspp/fuse/unlink/FuseUnlinkFilenameTest.cpp b/test/fspp/fuse/unlink/FuseUnlinkFilenameTest.cpp index 0eb29aaf..ba5c2c47 100644 --- a/test/fspp/fuse/unlink/FuseUnlinkFilenameTest.cpp +++ b/test/fspp/fuse/unlink/FuseUnlinkFilenameTest.cpp @@ -7,7 +7,7 @@ class FuseUnlinkFilenameTest: public FuseUnlinkTest { TEST_F(FuseUnlinkFilenameTest, Unlink) { ReturnIsFileOnLstat("/mydir"); - EXPECT_CALL(fsimpl, unlink(StrEq("/mydir"))) + EXPECT_CALL(*fsimpl, unlink(StrEq("/mydir"))) // After rmdir was called, lstat should return that it doesn't exist anymore // This is needed to make the ::rmdir() syscall pass. .Times(1).WillOnce(FromNowOnReturnDoesntExistOnLstat()); @@ -18,7 +18,7 @@ TEST_F(FuseUnlinkFilenameTest, Unlink) { TEST_F(FuseUnlinkFilenameTest, UnlinkNested) { ReturnIsDirOnLstat("/mydir"); ReturnIsFileOnLstat("/mydir/mysubdir"); - EXPECT_CALL(fsimpl, unlink(StrEq("/mydir/mysubdir"))) + EXPECT_CALL(*fsimpl, unlink(StrEq("/mydir/mysubdir"))) // After rmdir was called, lstat should return that it doesn't exist anymore // This is needed to make the ::rmdir() syscall pass. .Times(1).WillOnce(FromNowOnReturnDoesntExistOnLstat()); @@ -30,7 +30,7 @@ TEST_F(FuseUnlinkFilenameTest, UnlinkNested2) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); ReturnIsFileOnLstat("/mydir/mydir2/mydir3"); - EXPECT_CALL(fsimpl, unlink(StrEq("/mydir/mydir2/mydir3"))) + EXPECT_CALL(*fsimpl, unlink(StrEq("/mydir/mydir2/mydir3"))) // After rmdir was called, lstat should return that it doesn't exist anymore // This is needed to make the ::rmdir() syscall pass. .Times(1).WillOnce(FromNowOnReturnDoesntExistOnLstat()); diff --git a/test/fspp/fuse/utimens/FuseUtimensErrorTest.cpp b/test/fspp/fuse/utimens/FuseUtimensErrorTest.cpp index 58233721..bd5b068e 100644 --- a/test/fspp/fuse/utimens/FuseUtimensErrorTest.cpp +++ b/test/fspp/fuse/utimens/FuseUtimensErrorTest.cpp @@ -15,7 +15,7 @@ INSTANTIATE_TEST_CASE_P(FuseUtimensErrorTest, FuseUtimensErrorTest, Values(EACCE TEST_P(FuseUtimensErrorTest, ReturnedErrorIsCorrect) { ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, utimens(StrEq(FILENAME), _, _)) + EXPECT_CALL(*fsimpl, utimens(StrEq(FILENAME), _, _)) .Times(1).WillOnce(Throw(FuseErrnoException(GetParam()))); int error = UtimensReturnError(FILENAME, TIMEVALUE, TIMEVALUE); diff --git a/test/fspp/fuse/utimens/FuseUtimensFilenameTest.cpp b/test/fspp/fuse/utimens/FuseUtimensFilenameTest.cpp index 058f3621..fec46fbb 100644 --- a/test/fspp/fuse/utimens/FuseUtimensFilenameTest.cpp +++ b/test/fspp/fuse/utimens/FuseUtimensFilenameTest.cpp @@ -9,7 +9,7 @@ class FuseUtimensFilenameTest: public FuseUtimensTest { TEST_F(FuseUtimensFilenameTest, UtimensFile) { ReturnIsFileOnLstat("/myfile"); - EXPECT_CALL(fsimpl, utimens(StrEq("/myfile"), _, _)) + EXPECT_CALL(*fsimpl, utimens(StrEq("/myfile"), _, _)) .Times(1).WillOnce(Return()); Utimens("/myfile", TIMEVALUE, TIMEVALUE); @@ -18,7 +18,7 @@ TEST_F(FuseUtimensFilenameTest, UtimensFile) { TEST_F(FuseUtimensFilenameTest, UtimensFileNested) { ReturnIsDirOnLstat("/mydir"); ReturnIsFileOnLstat("/mydir/myfile"); - EXPECT_CALL(fsimpl, utimens(StrEq("/mydir/myfile"), _, _)) + EXPECT_CALL(*fsimpl, utimens(StrEq("/mydir/myfile"), _, _)) .Times(1).WillOnce(Return()); Utimens("/mydir/myfile", TIMEVALUE, TIMEVALUE); @@ -28,7 +28,7 @@ TEST_F(FuseUtimensFilenameTest, UtimensFileNested2) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); ReturnIsFileOnLstat("/mydir/mydir2/myfile"); - EXPECT_CALL(fsimpl, utimens(StrEq("/mydir/mydir2/myfile"), _, _)) + EXPECT_CALL(*fsimpl, utimens(StrEq("/mydir/mydir2/myfile"), _, _)) .Times(1).WillOnce(Return()); Utimens("/mydir/mydir2/myfile", TIMEVALUE, TIMEVALUE); @@ -36,7 +36,7 @@ TEST_F(FuseUtimensFilenameTest, UtimensFileNested2) { TEST_F(FuseUtimensFilenameTest, UtimensDir) { ReturnIsDirOnLstat("/mydir"); - EXPECT_CALL(fsimpl, utimens(StrEq("/mydir"), _, _)) + EXPECT_CALL(*fsimpl, utimens(StrEq("/mydir"), _, _)) .Times(1).WillOnce(Return()); Utimens("/mydir", TIMEVALUE, TIMEVALUE); @@ -45,7 +45,7 @@ TEST_F(FuseUtimensFilenameTest, UtimensDir) { TEST_F(FuseUtimensFilenameTest, UtimensDirNested) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); - EXPECT_CALL(fsimpl, utimens(StrEq("/mydir/mydir2"), _, _)) + EXPECT_CALL(*fsimpl, utimens(StrEq("/mydir/mydir2"), _, _)) .Times(1).WillOnce(Return()); Utimens("/mydir/mydir2", TIMEVALUE, TIMEVALUE); @@ -55,7 +55,7 @@ TEST_F(FuseUtimensFilenameTest, UtimensDirNested2) { ReturnIsDirOnLstat("/mydir"); ReturnIsDirOnLstat("/mydir/mydir2"); ReturnIsDirOnLstat("/mydir/mydir2/mydir3"); - EXPECT_CALL(fsimpl, utimens(StrEq("/mydir/mydir2/mydir3"), _, _)) + EXPECT_CALL(*fsimpl, utimens(StrEq("/mydir/mydir2/mydir3"), _, _)) .Times(1).WillOnce(Return()); Utimens("/mydir/mydir2/mydir3", TIMEVALUE, TIMEVALUE); diff --git a/test/fspp/fuse/utimens/FuseUtimensTimeParameterTest.cpp b/test/fspp/fuse/utimens/FuseUtimensTimeParameterTest.cpp index 89781f4a..631a7249 100644 --- a/test/fspp/fuse/utimens/FuseUtimensTimeParameterTest.cpp +++ b/test/fspp/fuse/utimens/FuseUtimensTimeParameterTest.cpp @@ -23,7 +23,7 @@ INSTANTIATE_TEST_CASE_P(FuseUtimensTimeParameterTest, FuseUtimensTimeParameterTe TEST_P(FuseUtimensTimeParameterTest, Utimens) { ReturnIsFileOnLstat(FILENAME); - EXPECT_CALL(fsimpl, utimens(StrEq(FILENAME), TimeSpecEq(GetParam()[0]), TimeSpecEq(GetParam()[1]))) + EXPECT_CALL(*fsimpl, utimens(StrEq(FILENAME), TimeSpecEq(GetParam()[0]), TimeSpecEq(GetParam()[1]))) .Times(1).WillOnce(Return()); Utimens(FILENAME, GetParam()[0], GetParam()[1]); diff --git a/test/fspp/fuse/write/FuseWriteDataTest.cpp b/test/fspp/fuse/write/FuseWriteDataTest.cpp index d7719dbb..ecd2a981 100644 --- a/test/fspp/fuse/write/FuseWriteDataTest.cpp +++ b/test/fspp/fuse/write/FuseWriteDataTest.cpp @@ -49,7 +49,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, _, _, _)) .WillRepeatedly(WriteToFile); } diff --git a/test/fspp/fuse/write/FuseWriteErrorTest.cpp b/test/fspp/fuse/write/FuseWriteErrorTest.cpp index aa87454d..6886e400 100644 --- a/test/fspp/fuse/write/FuseWriteErrorTest.cpp +++ b/test/fspp/fuse/write/FuseWriteErrorTest.cpp @@ -27,7 +27,7 @@ INSTANTIATE_TEST_CASE_P(FuseWriteErrorTest, FuseWriteErrorTest, Values(EAGAIN, E TEST_P(FuseWriteErrorTest, ReturnErrorOnFirstWriteCall) { - EXPECT_CALL(fsimpl, write(0, _, _, _)) + EXPECT_CALL(*fsimpl, write(0, _, _, _)) .WillRepeatedly(Throw(FuseErrnoException(GetParam()))); char *buf = new char[WRITECOUNT.value()]; @@ -41,13 +41,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, _, _, 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, _, _, 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 40616c61..e586eafd 100644 --- a/test/fspp/fuse/write/FuseWriteFileDescriptorTest.cpp +++ b/test/fspp/fuse/write/FuseWriteFileDescriptorTest.cpp @@ -18,7 +18,7 @@ INSTANTIATE_TEST_CASE_P(FuseWriteFileDescriptorTest, FuseWriteFileDescriptorTest TEST_P(FuseWriteFileDescriptorTest, FileDescriptorIsCorrect) { ReturnIsFileOnLstat(FILENAME); OnOpenReturnFileDescriptor(FILENAME, GetParam()); - EXPECT_CALL(fsimpl, write(Eq(GetParam()), _, _, _)) + EXPECT_CALL(*fsimpl, write(Eq(GetParam()), _, _, _)) .Times(1).WillOnce(Return()); char buf[1]; diff --git a/test/fspp/fuse/write/FuseWriteOverflowTest.cpp b/test/fspp/fuse/write/FuseWriteOverflowTest.cpp index f35e7f68..d81da83f 100644 --- a/test/fspp/fuse/write/FuseWriteOverflowTest.cpp +++ b/test/fspp/fuse/write/FuseWriteOverflowTest.cpp @@ -26,7 +26,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, _, _, _)).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 746c9a0f..d7cade13 100644 --- a/test/fspp/testutils/FuseTest.cpp +++ b/test/fspp/testutils/FuseTest.cpp @@ -6,6 +6,8 @@ using ::testing::Return; using ::testing::Throw; using ::testing::Action; using ::testing::Invoke; +using std::make_shared; +using std::shared_ptr; using cpputils::unique_ref; using cpputils::make_unique_ref; @@ -17,43 +19,46 @@ using namespace fspp::fuse; MockFilesystem::MockFilesystem() {} MockFilesystem::~MockFilesystem() {} -FuseTest::FuseTest(): fsimpl() { +FuseTest::FuseTest(): fsimpl(make_shared()) { auto defaultAction = Throw(FuseErrnoException(EIO)); - ON_CALL(fsimpl, openFile(_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, closeFile(_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, lstat(_,_)).WillByDefault(Throw(FuseErrnoException(ENOENT))); - ON_CALL(fsimpl, fstat(_,_)).WillByDefault(Throw(FuseErrnoException(ENOENT))); - ON_CALL(fsimpl, truncate(_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, ftruncate(_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, read(_,_,_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, write(_,_,_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, fsync(_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, fdatasync(_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, access(_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, createAndOpenFile(_,_,_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, mkdir(_,_,_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, rmdir(_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, unlink(_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, rename(_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, readDir(_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, utimens(_,_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, statfs(_)).WillByDefault(Invoke([](struct statvfs *result) { + ON_CALL(*fsimpl, openFile(_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, closeFile(_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, lstat(_,_)).WillByDefault(Throw(FuseErrnoException(ENOENT))); + ON_CALL(*fsimpl, fstat(_,_)).WillByDefault(Throw(FuseErrnoException(ENOENT))); + ON_CALL(*fsimpl, truncate(_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, ftruncate(_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, read(_,_,_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, write(_,_,_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, fsync(_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, fdatasync(_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, access(_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, createAndOpenFile(_,_,_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, mkdir(_,_,_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, rmdir(_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, unlink(_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, rename(_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, readDir(_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, utimens(_,_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, statfs(_)).WillByDefault(Invoke([](struct statvfs *result) { ::statvfs("/", result); // As dummy value take the values from the root filesystem })); - ON_CALL(fsimpl, chmod(_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, chown(_,_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, createSymlink(_,_,_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, readSymlink(_,_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, chmod(_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, chown(_,_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, createSymlink(_,_,_,_)).WillByDefault(defaultAction); + ON_CALL(*fsimpl, readSymlink(_,_,_)).WillByDefault(defaultAction); - EXPECT_CALL(fsimpl, access(_,_)).WillRepeatedly(Return()); + EXPECT_CALL(*fsimpl, access(_,_)).WillRepeatedly(Return()); ReturnIsDirOnLstat("/"); } unique_ref FuseTest::TestFS() { - return make_unique_ref(&fsimpl); + return make_unique_ref(fsimpl); } -FuseTest::TempTestFS::TempTestFS(MockFilesystem *fsimpl): _mountDir(), _fuse(fsimpl, "fusetest", boost::none), _fuse_thread(&_fuse) { +FuseTest::TempTestFS::TempTestFS(shared_ptr fsimpl) + :_mountDir(), + _fuse([fsimpl] (Fuse*) {return fsimpl;}, "fusetest", boost::none), _fuse_thread(&_fuse) { + _fuse_thread.start(_mountDir.path(), {"-f"}); } @@ -87,7 +92,6 @@ Action FuseTest::ReturnIsFileFstatWithSize(fspp::n result->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH; result->st_nlink = 1; result->st_size = size.value(); - std::cout << "Return size: " << size.value() < FuseTest::ReturnIsDir = Action FuseTest::ReturnDoesntExist = Throw(fspp::fuse::FuseErrnoException(ENOENT)); void FuseTest::OnOpenReturnFileDescriptor(const char *filename, int descriptor) { - EXPECT_CALL(fsimpl, openFile(StrEq(filename), _)).Times(1).WillOnce(Return(descriptor)); + EXPECT_CALL(*fsimpl, openFile(StrEq(filename), _)).Times(1).WillOnce(Return(descriptor)); } void FuseTest::ReturnIsFileOnLstat(const bf::path &path) { - EXPECT_CALL(fsimpl, lstat(::testing::StrEq(path.string().c_str()), ::testing::_)).WillRepeatedly(ReturnIsFile); + EXPECT_CALL(*fsimpl, lstat(::testing::StrEq(path.string().c_str()), ::testing::_)).WillRepeatedly(ReturnIsFile); } void FuseTest::ReturnIsFileOnLstatWithSize(const bf::path &path, const fspp::num_bytes_t size) { - EXPECT_CALL(fsimpl, lstat(::testing::StrEq(path.string().c_str()), ::testing::_)).WillRepeatedly(ReturnIsFileWithSize(size)); + EXPECT_CALL(*fsimpl, lstat(::testing::StrEq(path.string().c_str()), ::testing::_)).WillRepeatedly(ReturnIsFileWithSize(size)); } void FuseTest::ReturnIsDirOnLstat(const bf::path &path) { - EXPECT_CALL(fsimpl, lstat(::testing::StrEq(path.string().c_str()), ::testing::_)).WillRepeatedly(ReturnIsDir); + EXPECT_CALL(*fsimpl, lstat(::testing::StrEq(path.string().c_str()), ::testing::_)).WillRepeatedly(ReturnIsDir); } void FuseTest::ReturnDoesntExistOnLstat(const bf::path &path) { - EXPECT_CALL(fsimpl, lstat(::testing::StrEq(path.string().c_str()), ::testing::_)).WillRepeatedly(ReturnDoesntExist); + EXPECT_CALL(*fsimpl, lstat(::testing::StrEq(path.string().c_str()), ::testing::_)).WillRepeatedly(ReturnDoesntExist); } void FuseTest::ReturnIsFileOnFstat(int descriptor) { - EXPECT_CALL(fsimpl, fstat(descriptor, _)).WillRepeatedly(ReturnIsFileFstat); + EXPECT_CALL(*fsimpl, fstat(descriptor, _)).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, _)).WillRepeatedly(ReturnIsFileFstatWithSize(size)); } \ No newline at end of file diff --git a/test/fspp/testutils/FuseTest.h b/test/fspp/testutils/FuseTest.h index a06856e3..1cd80950 100644 --- a/test/fspp/testutils/FuseTest.h +++ b/test/fspp/testutils/FuseTest.h @@ -90,7 +90,7 @@ public: class TempTestFS { public: - TempTestFS(MockFilesystem *fsimpl); + TempTestFS(std::shared_ptr fsimpl); virtual ~TempTestFS(); public: const boost::filesystem::path &mountDir() const; @@ -102,7 +102,7 @@ public: cpputils::unique_ref TestFS(); - MockFilesystem fsimpl; + std::shared_ptr fsimpl; //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