diff --git a/src/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp b/src/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp index ee511b17..e034ffd2 100644 --- a/src/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp +++ b/src/test/fspp/fuse/openFile/FuseOpenFileDescriptorTest.cpp @@ -36,7 +36,7 @@ TEST_P(FuseOpenFileDescriptorTest, TestReturnedFileDescriptor) { ReturnIsFileOnLstat(FILENAME); EXPECT_CALL(fsimpl, openFile(StrEq(FILENAME), _)) .Times(1).WillOnce(Return(GetParam())); - EXPECT_CALL(fsimpl, read(GetParam(), _, _, _)).Times(1); + EXPECT_CALL(fsimpl, read(GetParam(), _, _, _)).Times(1).WillOnce(Return(0)); OpenAndReadFile(FILENAME); } diff --git a/src/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp b/src/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp index 3ed45e17..82408f77 100644 --- a/src/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp +++ b/src/test/fspp/fuse/openFile/FuseOpenFilenameTest.cpp @@ -5,6 +5,7 @@ using ::testing::_; using ::testing::StrEq; +using ::testing::Return; class FuseOpenFilenameTest: public FuseOpenTest { public: @@ -13,7 +14,7 @@ public: TEST_F(FuseOpenFilenameTest, OpenFile) { ReturnIsFileOnLstat("/myfile"); EXPECT_CALL(fsimpl, openFile(StrEq("/myfile"), _)) - .Times(1); + .Times(1).WillOnce(Return(0)); OpenFile("/myfile", O_RDONLY); } @@ -22,7 +23,7 @@ TEST_F(FuseOpenFilenameTest, OpenFileNested) { ReturnIsDirOnLstat("/mydir"); ReturnIsFileOnLstat("/mydir/myfile"); EXPECT_CALL(fsimpl, openFile(StrEq("/mydir/myfile"), _)) - .Times(1); + .Times(1).WillOnce(Return(0)); OpenFile("/mydir/myfile", O_RDONLY); } @@ -32,7 +33,7 @@ TEST_F(FuseOpenFilenameTest, OpenFileNested2) { ReturnIsDirOnLstat("/mydir/mydir2"); ReturnIsFileOnLstat("/mydir/mydir2/myfile"); EXPECT_CALL(fsimpl, openFile(StrEq("/mydir/mydir2/myfile"), _)) - .Times(1); + .Times(1).WillOnce(Return(0)); OpenFile("/mydir/mydir2/myfile", O_RDONLY); } diff --git a/src/test/fspp/fuse/openFile/FuseOpenFlagsTest.cpp b/src/test/fspp/fuse/openFile/FuseOpenFlagsTest.cpp index 22701bdc..2009cccd 100644 --- a/src/test/fspp/fuse/openFile/FuseOpenFlagsTest.cpp +++ b/src/test/fspp/fuse/openFile/FuseOpenFlagsTest.cpp @@ -4,6 +4,7 @@ using ::testing::_; using ::testing::StrEq; using ::testing::WithParamInterface; using ::testing::Values; +using ::testing::Return; class FuseOpenFlagsTest: public FuseOpenTest, public WithParamInterface { }; @@ -12,7 +13,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()))) - .Times(1); + .Times(1).WillOnce(Return(0)); OpenFile(FILENAME, GetParam()); } diff --git a/src/test/testutils/FuseTest.h b/src/test/testutils/FuseTest.h index aa9c1e3e..537407ba 100644 --- a/src/test/testutils/FuseTest.h +++ b/src/test/testutils/FuseTest.h @@ -68,29 +68,26 @@ public: class FuseTest: public ::testing::Test { public: FuseTest(): fsimpl() { - /*auto defaultAction = Throw(fspp::FuseErrnoException(EIO)); - ON_CALL(fsimpl, openFile(_,_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, closeFile(_)).WillByDefault(defaultAction); - ON_CALL(fsimpl, lstat(_,_)).WillByDefault(Invoke([](const char *path, struct ::stat *) { - printf("LSTAT\n");fflush(stdout); - throw fspp::FuseErrnoException(EIO); - })); - ON_CALL(fsimpl, fstat(_,_)).WillByDefault(defaultAction); - 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(defaultAction);*/ + auto defaultAction = ::testing::Throw(fspp::FuseErrnoException(EIO)); + ON_CALL(fsimpl, openFile(::testing::_,::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, closeFile(::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, lstat(::testing::_,::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, fstat(::testing::_,::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, truncate(::testing::_,::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, ftruncate(::testing::_,::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, read(::testing::_,::testing::_,::testing::_,::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, write(::testing::_,::testing::_,::testing::_,::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, fsync(::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, fdatasync(::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, access(::testing::_,::testing:: _)).WillByDefault(defaultAction); + ON_CALL(fsimpl, createAndOpenFile(::testing::_,::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, mkdir(::testing::_, ::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, rmdir(::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, unlink(::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, rename(::testing::_,::testing:: _)).WillByDefault(defaultAction); + ON_CALL(fsimpl, readDir(::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, utimens(::testing::_, ::testing::_)).WillByDefault(defaultAction); + ON_CALL(fsimpl, statfs(::testing::_, ::testing::_)).WillByDefault(defaultAction); } class TempTestFS { @@ -120,7 +117,7 @@ public: return std::make_unique(&fsimpl); } - ::testing::StrictMock fsimpl; + MockFilesystem fsimpl; ::testing::Action ReturnIsFile = ::testing::Invoke([](const char*, struct ::stat* result) {